filecat 7.10.2 → 7.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/1075.68438aa42e20e5b2d39b.js +1 -0
- package/build/dist/1922.77cdb5e5f50b344fcf32.js +2 -0
- package/build/dist/1922.77cdb5e5f50b344fcf32.js.LICENSE.txt +23 -0
- package/build/dist/259.1c05c3135a8291823002.js +1 -0
- package/build/dist/2674.46c009a7ec426b7d8828.js +1 -0
- package/build/dist/{3299.de79d172b41af93a8716.js → 3299.5c01eebc0f62cdc7bb39.js} +1 -1
- package/build/dist/394.a8337677ef993b923783.js +1 -0
- package/build/dist/{4004.f4c06b50348214eb2962.js → 4004.916c0413a6db61a54e11.js} +1 -1
- package/build/dist/4903.cac82807407e7342b5ad.js +1 -0
- package/build/dist/4935.fe24d47c4075780c9c11.js +1 -0
- package/build/dist/5877.e2316c84a95490f77439.js +1 -0
- package/build/dist/621.28f07b5c059e80331746.js +1 -0
- package/build/dist/{6247.525b0b68872036ac2fa6.js → 6247.6ce123e9fc8b8be16c10.js} +1 -1
- package/build/dist/{8302.ce97557b7cf7c8387942.js → 8302.894efa465f6037f9f5a8.js} +1 -1
- package/build/dist/892.a62727e6df6e80655ca7.js +1 -0
- package/build/dist/9299.4c39ae6b03d41c516b1f.js +1 -0
- package/build/dist/9334.f04716a7e41f783abc47.js +1 -0
- package/build/dist/index.html +1 -1
- package/build/dist/main.65dcea654963fc771a86.js +2 -0
- package/build/main.js +1 -1
- package/package.json +23 -31
- package/build/dist/1075.05eed88707339ca32044.js +0 -1
- package/build/dist/259.3c0eb22e9b43ffb63c9c.js +0 -1
- package/build/dist/2674.d1bf937289c51ddeceac.js +0 -1
- package/build/dist/4903.070aaa53a243baf05133.js +0 -1
- package/build/dist/5877.98d0475aaf4058b9a715.js +0 -1
- package/build/dist/9299.76095cb6629c36ca3343.js +0 -1
- package/build/dist/9334.a25983aafdcbde63ae5e.js +0 -1
- package/build/dist/main.26c2c54f6ab534513ebd.js +0 -2
- /package/build/dist/{main.26c2c54f6ab534513ebd.js.LICENSE.txt → main.65dcea654963fc771a86.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4004,6010],{83277(e,s,t){t.d(s,{$j:()=>i,Lv:()=>n});class n{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}const a=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function i(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n\n\n# 聊天循环最大次数\ntool_call_max=500\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n\n# ===== 模型类型(request_type)=====\n# 必填项,不同类型的 model 接口格式不同,默认 completions。\n# 可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n#request_type=completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,可实现不同模型担任不同角色/能力,供 AI agent 在对话中动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n#tool_mode=false\n\n# ===== 是否支持图片(support_image)=====\n# 开启后:1) 注册 read_image 工具,让 AI 能读取本地图片;\n# 2) 工具读到的图片会以 OpenAI 多模态格式 image_url 随消息发给模型,模型就能真正"看图"。\n# 关闭后:AI 看不到图片,read_image 只会返回一句文字说明。\n# 主流模型(gpt-4o、豆包、qwen-vl、deepseek-vl 等)都支持,默认开启。\nsupport_image=true\n',"cL",0,a])},95733(e,s,t){t.r(s),t.d(s,{default:()=>ne});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(92275),r=t(14284),l=t(7463),d=t(21499),u=t(64694),m=t(78247),h=t(40505),g=t(62042),p=t(45907),_=t(53459),f=t(72693),x=t(82893),j=t(61443),v=t(83277);function b(e){return null==e||e<0?"0":e.toLocaleString()}function w(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,v.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function y(e){const s=(0,v.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,v.$j)(e.content)).filter(Boolean).join("\n\n"):""}function S(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:y(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const N=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function k(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||N.test(e.name)?"text":"binary"}function C(e){return e.text()}function A(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function $(e){const s=[];for(const t of e){const e=k(t);let n="";if("text"===e)try{const e=await C(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await A(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var I=t(14944);var M=t(85997),R=t(34299),D=t(74848);function H(e){const s=e.attachments&&e.attachments.length>0?(0,D.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,D.jsxs)("div",{className:"chat-message-attachment",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{children:e.name}),(0,D.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(E,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(T,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(B,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,D.jsx)(R.default,{context:e.text}):null;return(0,D.jsxs)(D.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,v.$j)(e.content);return a&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(R.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(V,{callList:e.tool_call_ends})},`tool-${s}`)),(0,D.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,D.jsx)(R.default,{context:e.text}):null]})}(e);return 0===t.length?(0,D.jsxs)(D.Fragment,{children:[s,a]}):(0,D.jsxs)(D.Fragment,{children:[t,s,a]})}function V({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,D.jsxs)("div",{className:"chat-message-call-list",children:[(0,D.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,D.jsx)(M.In,{icon:s?"expand_less":"expand_more"}),(0,D.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,D.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,D.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,D.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,D.jsxs)("div",{className:"call-list-item-header",children:[(0,D.jsx)(M.In,{icon:e.success?"check_circle":"error"}),(0,D.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,D.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"参数"}),(0,D.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"错误"}),(0,D.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"结果"}),(0,D.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function E({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,D.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,D.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,D.jsx)("p",{className:"image-generation-prompt",children:(0,D.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,D.jsx)(R.default,{context:s})]}):(0,D.jsx)(R.default,{context:s||""})}function T({audio:e,text:s}){if(e){if(e.url)return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,D.jsx)(R.default,{context:t})}function K({content:e,label:s}){const[t,a]=n.useState(!1);return(0,D.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,h.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,D.jsx)(M.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function B({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,D.jsx)(R.default,{context:s})}if(!t)return(0,D.jsx)(R.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,D.jsxs)("div",{className:"embeddings-result",children:[(0,D.jsxs)("div",{className:"embeddings-summary",children:[(0,D.jsx)("strong",{children:"向量嵌入结果"}),(0,D.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,D.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,D.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,D.jsxs)("div",{className:"embeddings-toolbar",children:[(0,D.jsx)(K,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,D.jsx)(K,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,D.jsx)(K,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,D.jsx)("div",{className:"embeddings-preview",children:(0,D.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,D.jsxs)("details",{children:[(0,D.jsx)("summary",{children:"查看详细数据"}),(0,D.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function z(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await r.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const a=n.data||{},i=(a.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=i.map((e,s)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:a.session_id||s,images:i,text:o||`生成了 ${i.length} 张图片`}}(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||s,o=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await r.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var P=t(4412),L=t(23430),F=t(87361),O=t(80389),q=t(7523),G=t(23496);const U=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:c,sysPromptList:l,batchMode:d,selectedMsgCount:u,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),$=(0,o.Zp)(),{check_user_auth:I}=(0,m.MH)(),[,R]=(0,a.fp)(x.AG.ai_session_collapsed),{open:H}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(x.AG.prompt_card),[t,o]=(0,a.fp)(x.AG.ai_chat_zoom),{initUserInfo:c}=(0,n.useContext)(q.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,D.jsx)(O.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),a()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await r.wm.post(G.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,g.SK)(e("缩放调整成功")),c(),a()}})}}}(),V=I(L.oV.ai_model_switch)||I(L.oV.ai_agent_setting),E=[];for(const e of t)for(const s of e.models)E.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const T=t.find(e=>e.active),K=T?`${T.index}::${e}`:"",B=(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(M.rA,{icon:"menu",title:A("会话"),onClick:p,selected:h}),(0,D.jsx)(M.rA,{icon:"add",title:A("新会话"),onClick:()=>f()}),l.length>0&&(0,D.jsx)(j.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...l.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),V&&E.length>0&&(0,D.jsx)(j.l6,{value:K,options:[{title:A("选择模型"),value:""},...E],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...a]=t.split("::"),i=a.join("::");i&&(s(i),r.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===_.m.Success?((0,g.SK)("success"),c()):(0,g.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),d&&u>0&&(0,D.jsx)(M.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,D.jsx)(M.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:H}),(0,D.jsx)(M.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{$(F.o.ai_rebot_setting_page)}}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"settings",title:"ai setting",onClick:()=>{$(F.o.ai_agent_setting_page)}})]});return C?(0,D.jsx)("div",{className:"chat-inline-header",children:B}):(0,D.jsx)(P.aZ,{position:"right",children:B})};var J=t(89824);function W({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:h,onToggleBatchMode:g,onBatchDeleteSessions:p,onClearAllSessions:_,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j}){const{t:v}=(0,i.Bd)(),[b,w]=(0,n.useState)(""),[y,S]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=!!a&&!f,A=b.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(b.toLowerCase())||(e.summary||"").toLowerCase().includes(b.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(b.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(b.toLowerCase())):e;return(0,D.jsxs)("aside",{className:"chat-session-list",children:[(0,D.jsx)("div",{className:"chat-session-search",children:(0,D.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,D.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,D.jsx)("div",{children:(0,D.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${y===n?"row-dragging":""} ${N===n&&null!==y&&y!==n?"row-drop-target":""}`,draggable:C,onDragStart:()=>S(n),onDragOver:e=>{null!==y&&(e.preventDefault(),N!==n&&k(n))},onDragEnd:()=>{S(null),k(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=y;if(S(null),k(null),null===s||s===e||!a)return;const t=A[s]?.id,n=A[e]?.id;t&&n&&a(t,n)})(n)},onClick:()=>{u&&h?h(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,D.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>h?.(e.id),onClick:e=>e.stopPropagation()}),(0,D.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,D.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,D.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,D.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,D.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,D.jsx)(J.MenuSelect,{list:[{name:v("重命名"),click:()=>o(e.id,e.title)},...f?[]:[{name:v("移动到最上"),click:()=>{const s=A[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{name:v("移动到最下"),click:()=>{const s=A[A.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{name:e.cmd_auto_allow?v("命令检测关闭"):v("命令检测开启"),click:()=>r?.(e.id,!e.cmd_auto_allow)},{name:v("字符消耗统计"),click:()=>l(e.id)},{name:v("设置"),click:()=>d?.(e.id)},{name:v("删除"),click:()=>c(e.id)}],children:(0,D.jsx)(M.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,D.jsxs)("div",{className:"chat-session-actions",children:[(0,D.jsx)(M.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:g}),j&&!u&&(0,D.jsx)(M.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,D.jsx)(M.rA,{icon:"delete",title:v("删除选中会话"),onClick:p}),!u&&_&&(0,D.jsx)(M.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:_})]})]})}function Q(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const X=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:u,onToggleBatchMode:m,onBatchCopy:h,onBatchDelete:g,showBatchBar:p,t:_})=>{const[f,x]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),v=e=>{x(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},b=()=>{x(e=>e.size>0&&j.every(s=>e.has(s))?new Set:new Set(j))};return(0,D.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[p&&(0,D.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,D.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,D.jsx)("button",{onClick:h,children:_("复制所选")}),(0,D.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,D.jsx)("button",{onClick:m,children:_("取消")})]}),e.map(e=>{const n=f.has(e.id);return(0,D.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,D.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,D.jsxs)("div",{className:"ai-loading-bubble",children:[(0,D.jsxs)("div",{className:"ai-loading-dots",children:[(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"})]}),(0,D.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>v(e.id),children:[(0,D.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,D.jsx)("span",{className:"chat-message-summary-text",children:Q(e)||_("(无内容)")})]}):(0,D.jsx)("div",{className:"chat-message-body",children:H(e)}),(0,D.jsxs)("div",{className:"message-collapse-bar",children:[(0,D.jsx)("button",{onClick:()=>v(e.id),children:_(n?"展开":"折叠")}),(0,D.jsx)("button",{onClick:b,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,D.jsx)("span",{className:"message-elapsed",children:(0,d.kf)(e.elapsed_ms)})]}),(0,D.jsx)("div",{className:"message-actions",children:s?(0,D.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?_("取消选择"):_("选择")}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,D.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,D.jsx)("button",{onClick:u,children:_("全部复制")}),(0,D.jsx)("button",{onClick:m,children:_("多选")})]})})]})]},e.id)}),(0,D.jsx)("div",{ref:o})]})},Z=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>g(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,D.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:o,onInput:()=>c?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});var Y=t(84369);function ee({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,D.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,D.jsxs)("div",{className:"chat-attachment-chip",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{title:e.name,children:e.name}),(0,D.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,D.jsx)(M.In,{icon:"close"})})]},`${e.name}_${t}`))})}const se=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:m,readonly:h=!1},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),f=(0,n.useRef)(null),[j,v]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,Y.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=f.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,D.jsxs)("div",{ref:f,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,D.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,D.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,D.jsxs)("div",{className:"chat-input-shell",children:[(0,D.jsx)(ee,{pendingAttachments:o,onRemove:c}),(0,D.jsx)(Z,{ref:_,placeholder:p(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input",style:S})]}),!h&&(0,D.jsx)(M.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,D.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,D.jsx)(M.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,D.jsx)(M.Vi,{text:p("发送"),clickFun:e}),b&&(0,D.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),te=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[p,_]=(0,n.useState)(!1),[f,j]=(0,a.fp)(x.AG.ai_bg_expanded),[,v]=(0,a.fp)(x.AG.ai_session_collapsed),b=()=>{j(!1)},w=(0,n.useCallback)(async()=>{l(!0);try{const s=new c.hf(c.HK.ai_bg_process_list_req);s.context={};const t=await I.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=w);const y=(0,n.useCallback)(async e=>{_(!0),u(e);try{const s=new c.hf(c.HK.ai_bg_process_output_req);s.context={pid:e};const t=await I.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,g.zN)("获取进程输出失败")}finally{_(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new c.hf(c.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await I.ws.send(s);t?.context?.success?((0,g.SK)("进程已终止"),w(),d===e&&(u(null),h(null))):(0,g.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,g.zN)("终止进程失败")}},[w,d]);(0,n.useEffect)(()=>{w();const e=setInterval(w,5e3);return()=>clearInterval(e)},[w]);const N=t.filter(e=>e.running),k=t.filter(e=>!e.running);return(0,D.jsxs)(D.Fragment,{children:[f&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:b}),(0,D.jsxs)("aside",{className:"chat-bg-process-panel "+(f?"expanded":""),children:[(0,D.jsxs)("div",{className:"chat-bg-process-header",children:[(0,D.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:b})]}),(0,D.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,D.jsx)(M.rA,{icon:"refresh",title:s("刷新"),onClick:w}),(0,D.jsxs)("span",{className:"chat-bg-process-count",children:[N.length," ",s("个运行中"),k.length>0&&` / ${k.length} ${s("个已退出")}`]})]}),(0,D.jsxs)("div",{className:"chat-bg-process-list",children:[r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),N.map(e=>(0,D.jsxs)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} running`,children:[(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,D.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,D.jsx)(M.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,D.jsx)(M.rA,{icon:"stop",title:s("终止进程"),onClick:()=>S(e.pid)})]})]},e.pid)),k.map(e=>(0,D.jsx)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} finished`,children:(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==d&&(0,D.jsxs)("div",{className:"chat-bg-process-output",children:[(0,D.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,D.jsxs)("span",{children:["PID: ",d," ",s("输出")]}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:()=>{u(null),h(null)}})]}),(0,D.jsx)("div",{className:"chat-bg-process-output-content",children:p?(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):m?(0,D.jsx)("pre",{className:"chat-bg-process-output-pre",children:m.output||s("(无输出)")}):null})]})]})]})};t(99214);function ne(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:v,sync_url:y=!0,on_session_change:N}=e,{t:k}=(0,i.Bd)(),[C,A]=(0,o.ok)(),M=y&&C.get("session")||"",R=e=>{y&&A(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},H=(0,p.y)(),{check_user_auth:V}=(0,m.MH)();(0,f.w)();const[E,T]=(0,n.useState)([]),[K,B]=(0,n.useState)([]),[P,L]=(0,n.useState)(!1),[F,O]=(0,n.useState)(""),[q,G]=(0,n.useState)(null),[J,Q]=(0,n.useState)(!1),Z=(0,n.useRef)(null),[Y,ee]=(0,n.useState)([]),[ne]=(0,a.fp)(x.AG.user_base_info),ae=!!ne?.user_data?.is_root,[ie,oe]=(0,a.fp)(x.AG.ai_session_collapsed),[ce,re]=(0,a.fp)(x.AG.ai_bg_expanded),[le,de]=(0,a.fp)(x.AG.prompt_card),[ue]=(0,a.fp)(x.AG.ai_chat_zoom),[me,he]=(0,n.useState)(!1),[ge,pe]=(0,n.useState)(new Set),[_e,fe]=(0,n.useState)(new Set),[xe,je]=(0,n.useState)(""),ve=(0,n.useRef)(null),be=(0,n.useRef)(null),we=(0,n.useRef)(null),ye=(0,n.useRef)(!0),Se=(0,n.useRef)(null),Ne=(0,n.useRef)(0),ke=(0,n.useRef)(null),Ce=(0,n.useRef)({}),Ae=(0,n.useRef)(F),$e=(0,n.useRef)(q);(0,n.useEffect)(()=>{Ae.current=F},[F]),(0,n.useEffect)(()=>{$e.current=q},[q]);const Ie=(0,n.useRef)({}),[Me,Re]=(0,n.useState)([]),[De,He]=(0,n.useState)(""),[Ve,Ee]=(0,n.useState)([]),Te=async()=>{try{const e=await r.jV.get("public_models");e.code===_.m.Success&&Ee(e.data?.groups??[])}catch{Ee([])}},Ke=e=>{He(e?.ai_config?.model??"")},[Be,ze]=(0,n.useState)(0),Pe=(0,n.useRef)((0,l.sg)(e=>{T(e),ye.current&&Le(!1)},50)).current,Le=(e=!1)=>{const s=we.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},Fe=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Fe.current=P},[P]);const Oe=(e,s={})=>r.jV.post("admin/session",{action:e,...s}),qe=async()=>{const e=Fe.current?await Oe("list_all_sessions"):await r.jV.get("sessions");e.code===_.m.Success&&B(e.data??[])},Ge=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:r,refreshSessions:l,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,r)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};h.push(p),t([...h]);const _=new Map;let f=!0,x=p;const j=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",i=t.tool_call_ends,c=t.chunk_index??0;if("[DONE]"!==n)if(f)f=!1,x.text=n,i&&(x.content_list=[{tool_call_ends:i,content:x.text,role:"assistant"}]),x.is_loading=!1,x.chunk_index=c,_.set(c,x),o()===e&&a([...h]);else{const s=_.get(c);if(s)s.text+=n,i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),o()===e&&a([...h]);else{const s={id:Date.now()+Math.random(),sender:"bot",text:n,chunk_index:c};i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),h.push(s),_.set(c,s),o()===e&&a([...h])}}},v=s=>{const n=s.context||{};if(n.session_id===e){if(w(),g.current=null,i(s=>s===e?null:s),x.is_loading=!1,o()===e)if(n.once_messages_list?.length){const e=S(n.once_messages_list);t(s=>{const t=s[s.length-1];return"bot"===t?.sender?[...s.slice(0,-1),...e]:[...s,...e]})}else t([...h]);l(),d(!0),r()}},b=s=>{const n=s.context||{};n.session_id===e&&(w(),g.current=null,i(s=>s===e?null:s),x.text="AI请求出错: "+(n.message||"未知错误"),x.is_loading=!1,o()===e&&t([...h]),r())},w=()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,j),I.ws.off_message(`message_${c.HK.ai_chat_end}`,v),I.ws.off_message(`message_${c.HK.ai_chat_error}`,b)};I.ws.addMsg(c.HK.ai_chat_msg,j),I.ws.addMsg(c.HK.ai_chat_end,v),I.ws.addMsg(c.HK.ai_chat_error,b),I.ws.sendData(c.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(o(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(I.ws.sendData(c.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>E,setMessages:T,setMessagesDebounced:Pe,setSending:G,getActiveSessionId:()=>Ae.current,setActiveSessionId:O,refreshSessions:qe,scrollToBottom:Le,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>xe}),Ue=async e=>{const s=Fe.current?await Oe("list_all_sessions"):await r.jV.get("sessions");if(s.code!==_.m.Success)return!1;const t=s.data??[];B(t);const n=null===e?t[0]?.id??"":e||F||t[0]?.id||"";if(n){const e=t.find(e=>e.id===n)?.user_id;return await Je(n,!1,e)}return T([]),O(""),R(null),!1},Je=async(e,s=!1,t)=>{const n=t??K.find(s=>s.id===e)?.user_id,a=Fe.current&&n?await Oe("get",{session_id:e,user_id:n}):await r.jV.post("session/get",{session_id:e});if(a.code!==_.m.Success||!a.data)return!1;const i=a.data;O(i.id),y&&M!==i.id&&R(i.id),N?.(i.id),Q(!!i.running),ke.current&&ke.current!==i.id&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=i.running?i.id:null,ke.current&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!0});const o=S(i.messages);return i.running&&i.live_messages?.length?T([...o,...S(i.live_messages)]):T(o),je(i.sys_prompt_id??""),s&&oe(!1),Ce.current.refresh?.(),requestAnimationFrame(()=>Le(!1)),!0},We=e=>{if(Fe.current)return K.find(s=>s.id===e)?.user_id},Qe=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&ee(e=>[...e,...s])},Xe=()=>{me&&(pe(new Set),fe(new Set)),he(e=>!e)},Ze=()=>{0!==ge.size&&H({sub_title:k("cf_msgs"),confirm_fun:async()=>{const e=[];if(E.forEach((s,t)=>{ge.has(s.id)&&e.push(t)}),T(E.filter(e=>!ge.has(e.id))),pe(new Set),he(!1),F&&e.length>0){const s=We(F);s?Oe("message_delete",{session_id:F,user_id:s,indices:e}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:e}).catch(console.error)}}})},Ye=async()=>{const e=await r.XO.get("ai_agent_setting/env");if(e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data)),await Te(),v){const e=await(async e=>{if(!e)return null;const s=await r.jV.get("sessions");if(s.code!==_.m.Success)return null;const t=s.data??[];e=(0,d.ed)(e);const n=t.find(s=>(0,d.ed)(s.file_cwd_path)===e);if(n)return n.id;const a=await r.jV.post("session",{file_cwd_path:e});return a.code!==_.m.Success?null:a.data.id})(v);!!e&&await Ue(e)||await Ue()}else if(t){await Ue(t)||await Ue()}else if(M){await Ue(M)||await Ue()}else await Ue();const s=await r.jV.get("system_prompts");s.code===_.m.Success&&Re(s.data??[])};(0,n.useEffect)(()=>{Ye(),requestAnimationFrame(()=>Le(!1)),Ce.current.onCountChange=ze,Ce.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ze(s)};return I.ws.addMsg(c.HK.ai_bg_process_count_notify,e),()=>{I.ws.off_message(`message_${c.HK.ai_bg_process_count_notify}`,e)}},[]),(0,n.useEffect)(()=>{const e=we.current;if(!e)return;const s=()=>{ye.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useEffect)(()=>{const e=()=>Ae.current,s=()=>$e.current,t=(t,n)=>{if(e()&&e()===t){if(Se.current=null,Q(!1),ke.current===t&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),ke.current=null),s()===t)return;n?.length?T(e=>{const s=S(n),t=e[e.length-1];return"bot"===t?.sender?[...e.slice(0,-1),...s]:[...e,...s]}):Je(t).catch(()=>{}),qe()}},n=t=>{const n=t?.context||{};if(!n.session_id)return;var a,i,o;a=n.session_id,i=n.text||"",o=n.tool_call_ends,e()&&e()===a&&s()!==a&&T(e=>{const s=e[e.length-1];if(s&&"bot"===s.sender){const t=[...e],n={...s};return n.text+=i,o&&(n.content_list=[{tool_call_ends:o,content:n.text,role:"assistant"}]),t[t.length-1]=n,Se.current=n.id,ye.current&&requestAnimationFrame(()=>Le(!1)),t}const t={id:Date.now()+Math.random(),sender:"bot",text:i};return o&&(t.content_list=[{tool_call_ends:o,content:i,role:"assistant"}]),Se.current=t.id,ye.current&&requestAnimationFrame(()=>Le(!1)),[...e,t]});const c=Date.now();c-Ne.current>1500&&(Ne.current=c,qe())},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return I.ws.addMsg(c.HK.ai_chat_msg,n),I.ws.addMsg(c.HK.ai_chat_end,a),I.ws.addMsg(c.HK.ai_chat_error,i),()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,n),I.ws.off_message(`message_${c.HK.ai_chat_end}`,a),I.ws.off_message(`message_${c.HK.ai_chat_error}`,i),ke.current&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=null)}},[]),(0,n.useLayoutEffect)(()=>{ye.current&&Le(!1)},[E]);return(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(U,{inline:s,currentModelName:De,setCurrentModelName:He,modelGroups:Ve,onModelChanged:async()=>{await Te();const e=await r.XO.get("ai_agent_setting/env");e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data))},sysPromptList:Me,batchMode:me,selectedMsgCount:ge.size,sessionVisible:!ie,onToggleSessionPanel:()=>{oe(e=>!e)},onCreateSession:async e=>{const s=e??"",t=await r.jV.post("session",{sys_prompt_id:s||void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;const n=t.data;O(n.id),T([]),je(n.sys_prompt_id??""),oe(!1),await Ue(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:Ze,bgProcessVisible:ce,bgProcessCount:Be,onToggleBgProcess:()=>re(e=>!e),selectedSysPromptId:xe,setSelectedSysPromptId:e=>{if(je(e),F){const s=We(F);s?Oe("sys_prompt",{session_id:F,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):r.jV.post("session/sys_prompt",{session_id:F,sys_prompt_id:e||void 0}).catch(console.error)}}}),(0,D.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":ue},children:[!ie&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:()=>oe(!0)}),!ie&&(0,D.jsx)(W,{sessions:K,activeSessionId:F,onSelectSession:e=>Je(e,!1),onReorderSessions:(e,s)=>{if(Fe.current)return;const t=K.findIndex(s=>s.id===e),n=K.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,u.TI)(K,t,n);B(a),r.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},onRenameSession:(e,s)=>{let t=s;H({confirm_fun:async()=>{const s=We(e);s?await Oe("rename",{session_id:e,user_id:s,title:t}):await r.jV.post("sessions/update/meta",{id:e,title:t}),await Ue(F)},context_div:(0,D.jsx)("div",{className:"card-content",children:(0,D.jsx)(j.Sm,{value:t,handleInputChange:e=>{t=e}})})})},onDeleteSession:e=>{H({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=We(e);s?await Oe("delete",{session_id:e,user_id:s}):await r.jV.post("session/delete",{session_id:e}),F===e?(O(""),await Ue(null)):await Ue(F)}})},onToggleCmdAuto:async(e,s)=>{const t=We(e);t?await Oe("cmd_auto",{session_id:e,user_id:t,allow:s}):await r.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,g.SK)(k(s?"命令检测已开启":"命令检测已关闭")),await Ue(F)},onShowUsageStats:async e=>{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-loading",children:k("加载中...")}),cancel:()=>de({open:!1})});try{const s=We(e),t=s?await Oe("usage_stats",{session_id:e,user_id:s}):await r.jV.post("session/usage_stats",{session_id:e});if(t.code===_.m.Success&&t.data){const e=t.data;de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsxs)("div",{className:"usage-stats-panel",children:[[{l:k("对话轮次"),v:(e.turns??0).toString()},{l:k("AI输入Token"),v:b(e.input_tokens)},{l:k("AI输出Token"),v:b(e.output_tokens)},{l:k("AI输入Token(最近一轮)"),v:b(e.recent_input_tokens)},{l:k("AI输出Token(最近一轮)"),v:b(e.recent_output_tokens)}].map((e,s)=>(0,D.jsxs)("div",{className:"usage-stats-row",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,D.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,D.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:k("AI Token总计消耗")}),(0,D.jsx)("span",{className:"usage-stats-value",children:b((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>de({open:!1})})}else de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}catch{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}},onShowSessionSetting:e=>{let s=K.find(s=>s.id===e)?.file_cwd_path??"";de({open:!0,title:k("会话设置"),context_div:(0,D.jsxs)("div",{className:"session-setting",children:[(0,D.jsx)("div",{className:"session-setting__label",children:k("服务器工作目录")}),(0,D.jsx)(j.Sm,{value:s,placeholder:k("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=We(e);(t?await Oe("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await r.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===_.m.Success&&(0,g.SK)(k("保存成功"))}catch{}de({open:!1}),await Ue(F)},cancel:()=>de({open:!1})})},batchMode:me,selectedSessionIds:_e,onToggleSessionSelect:e=>{fe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Xe,onBatchDeleteSessions:()=>{0!==_e.size&&H({sub_title:k("cf_ses"),confirm_fun:async()=>{if(Fe.current)await Oe("batch_delete",{session_ids:Array.from(_e)});else for(const e of _e)await r.jV.post("session/delete",{session_id:e});fe(new Set),he(!1),_e.has(F)?(O(""),await Ue(null)):await Ue(F)}})},onClearAllSessions:P?void 0:()=>{H({sub_title:k("cf_all"),confirm_fun:async()=>{await r.jV.post("sessions/clear",{}),O(""),T([]),await Ue(null)}})},allUsersMode:P,onToggleAllUsersMode:async()=>{const e=!P;L(e),Fe.current=e,O(""),T([]);const s=e?await Oe("list_all_sessions"):await r.jV.get("sessions"),t=s.code===_.m.Success?s.data??[]:[];B(t),t[0]?.id&&await Je(t[0].id,!1,t[0].user_id)},showAllUsersEntry:ae}),(0,D.jsx)(te,{panelRef:Ce}),(0,D.jsxs)("section",{className:"chat-main",children:[0===E?.length&&(0,D.jsx)("div",{className:"chat-header",children:(0,D.jsx)("div",{children:k("ai_ask")})}),(0,D.jsx)(X,{messages:E,batchMode:me,selectedMsgIds:ge,sending:q===F||J,chatContainerRef:we,messagesEndRef:be,onToggleMsgSelect:e=>{pe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:e=>{H({sub_title:k("cf_one"),confirm_fun:async()=>{const s=E.findIndex(s=>s.id===e);if(s<0)return;const t=E.filter(s=>s.id!==e);if(T(t),F){const e=We(F);e?Oe("message_delete",{session_id:F,user_id:e,indices:[s]}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:[s]}).catch(console.error)}}})},onCopy:async e=>{(0,h.lW)(w(e)),(0,g.SK)("复制成功")},onCopyAll:async()=>{if(!K.length)return void(0,g.SK)("暂无聊天记录");const e=[];for(const s of K){const t=s.user_id?await Oe("get",{session_id:s.id,user_id:s.user_id}):await r.jV.post("session/get",{session_id:s.id});if(t.code!==_.m.Success||!t.data)continue;const n=t.data,a=S([...n.messages??[],...n.live_messages??[]]).map(w).filter(Boolean).join("\n\n\n");a&&e.push(a)}e.length?((0,h.lW)(e.join("\n\n\n")),(0,g.SK)("复制成功")):(0,g.SK)("暂无聊天记录")},onToggleBatchMode:Xe,onBatchCopy:()=>{const e=E.filter(e=>ge.has(e.id)).map(w).filter(Boolean).join("\n\n\n");e?((0,h.lW)(e),(0,g.SK)("复制成功")):(0,g.SK)("暂无内容")},onBatchDelete:Ze,showBatchBar:me&&ge.size>0&&0===_e.size,t:k}),(0,D.jsx)(se,{ref:Z,onSend:async()=>{if(Fe.current)return;const e=(Z.current?.getValue()??"").trim();if(!e&&0===Y.length)return;if(q===F){const s=await $(Y);Ge.enqueueMessage(e,s),Z.current?.clear(),ee([]);const t={id:Date.now(),sender:"user",text:e+(Ge.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void T(e=>[...e,t])}let s=F;if(!s){const t=await r.jV.post("session",{title:(e||Y[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;s=t.data.id,O(s),N?.(s),await Ue(s)}const t=await $(Y),n={id:Date.now(),sender:"user",text:e,attachments:t};Z.current?.clear(),ee([]);const a=Ie?.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...E,n,t];T(i),G(s);return void(await z(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),T([...i]),G(null),qe(),Le(!0),Ge.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,T([...i]),G(null),Ge.processPendingQueue()))}Ge.startChatStream(s,n,()=>Ge.processPendingQueue())},readonly:P,sending:q===F||J,onAbort:Ge.abort,pendingAttachments:Y,onRemoveAttachment:e=>{ee(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ve.current?.click()},onAddFiles:Qe,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Qe(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ve})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(22022),i=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.Bd)(),[t,i]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{i(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),x=(0,n.useCallback)(()=>{if(h.current)return;if(0===l.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=l.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):h.current=!1},[t,f,s]);_.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return i.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{i.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>y});var n=t(96540),a=t(23802),i=t(53995),o=t(18569),c=t(77979),r=t(8263),l=t(69428),d=t.n(l),u=(t(3775),t(21499)),m=t(99214),h=t(89117),g=t(86063),p=t(89334),_=t(41105),f=t(52388),x=t(19878),j=(t(72411),t(74848));const v=new a.A({html:!0,highlight:function(e,s){if(s&&x.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${x.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${x.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${v.utils.escapeHtml(e)}</code></pre>`}});async function b(e,s){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=f.A.t("rendering");const t=await(0,g.Hn)(s);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await t.mount(e))}function w(e){const s=e.className.match(/language-([\w-]+)/);return s?s[1]:""}function y(e){const s=(0,n.useRef)(null);return(0,m.VD)(),(0,n.useEffect)(()=>{s.current&&(s.current.innerHTML=v.render(e.context??""),async function(e){const s=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(s)){const s=w(e),t=(0,h.Hm)(s),n=(0,g.hj)(s);if(!t&&!n)continue;const a=e.closest(".code-block-with-copy")??e.parentElement;if(!a)continue;const i=e.textContent??"",o=document.createElement("div");if(a.replaceWith(o),n){try{await b(o,i)}catch(e){console.error("[mind] render failed",e),o.className="md-graph md-graph--mind",o.textContent=String(e)}continue}o.className="md-graph md-graph--loading",o.textContent=f.A.t("rendering");const c=await(0,h.U6)(s,i);o.isConnected&&(c.error?(o.className="md-graph md-graph--error",o.textContent=c.error):(o.className="md-graph",o.innerHTML=c.svg))}}(s.current),(0,p.rg)(s.current))},[e.context]),(0,j.jsx)("div",{ref:s})}v.use(i.A).use(o.A).use(c.A).use(r.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const o=s[t],c=o.content.trim(),r=o.info.trim();let l="";if(r&&x.A.getLanguage(r))try{l=x.A.highlight(c,{language:r}).value}catch(s){l=e.utils.escapeHtml(c)}else try{l=x.A.highlightAuto(c).value}catch(s){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const o=e[t],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][1]=(0,u.bi)(window.location.href,e)}return s(e,t,n,a,i)}}),(0,p.Rh)(v,_.pC)},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),a=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[h,g]=(0,n.useState)(!1),p=(0,n.useRef)(null),_=(0,n.useRef)(u);_.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=p.current;if(!s)return;const{px_to_unit:t,min:n,max:a,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=i(n),d=i(a);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),_.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{p.current=null,g(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;p.current={pos:t(e),size:s()},g(!0)},[]);return(0,n.useEffect)(()=>{if(!h)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[h,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:h,on_pointer_down:w,on_pointer_up:b}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4004,6010],{83277(e,s,t){t.d(s,{$j:()=>i,Lv:()=>n});class n{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}const a=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function i(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n\n\n# 聊天循环最大次数\ntool_call_max=500\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n\n# ===== 模型类型(request_type)=====\n# 必填项,不同类型的 model 接口格式不同,默认 completions。\n# 可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n#request_type=completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,可实现不同模型担任不同角色/能力,供 AI agent 在对话中动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n#tool_mode=false\n\n# ===== 是否支持图片(support_image)=====\n# 开启后:1) 注册 read_image 工具,让 AI 能读取本地图片;\n# 2) 工具读到的图片会以 OpenAI 多模态格式 image_url 随消息发给模型,模型就能真正"看图"。\n# 关闭后:AI 看不到图片,read_image 只会返回一句文字说明。\n# 主流模型(gpt-4o、豆包、qwen-vl、deepseek-vl 等)都支持,默认开启。\nsupport_image=true\n',"cL",0,a])},95733(e,s,t){t.r(s),t.d(s,{default:()=>ne});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(92275),r=t(14284),l=t(7463),d=t(21499),u=t(64694),m=t(78247),h=t(40505),g=t(62042),p=t(45907),_=t(53459),f=t(72693),x=t(82893),j=t(61443),v=t(83277);function b(e){return null==e||e<0?"0":e.toLocaleString()}function w(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,v.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function y(e){const s=(0,v.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,v.$j)(e.content)).filter(Boolean).join("\n\n"):""}function S(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:y(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const N=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function k(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||N.test(e.name)?"text":"binary"}function C(e){return e.text()}function A(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function $(e){const s=[];for(const t of e){const e=k(t);let n="";if("text"===e)try{const e=await C(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await A(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var I=t(14944);var M=t(85997),R=t(34299),D=t(74848);function H(e){const s=e.attachments&&e.attachments.length>0?(0,D.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,D.jsxs)("div",{className:"chat-message-attachment",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{children:e.name}),(0,D.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(E,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(T,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(B,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,D.jsx)(R.default,{context:e.text}):null;return(0,D.jsxs)(D.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,v.$j)(e.content);return a&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(R.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(V,{callList:e.tool_call_ends})},`tool-${s}`)),(0,D.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,D.jsx)(R.default,{context:e.text}):null]})}(e);return 0===t.length?(0,D.jsxs)(D.Fragment,{children:[s,a]}):(0,D.jsxs)(D.Fragment,{children:[t,s,a]})}function V({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,D.jsxs)("div",{className:"chat-message-call-list",children:[(0,D.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,D.jsx)(M.In,{icon:s?"expand_less":"expand_more"}),(0,D.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,D.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,D.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,D.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,D.jsxs)("div",{className:"call-list-item-header",children:[(0,D.jsx)(M.In,{icon:e.success?"check_circle":"error"}),(0,D.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,D.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"参数"}),(0,D.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"错误"}),(0,D.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"结果"}),(0,D.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function E({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,D.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,D.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,D.jsx)("p",{className:"image-generation-prompt",children:(0,D.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,D.jsx)(R.default,{context:s})]}):(0,D.jsx)(R.default,{context:s||""})}function T({audio:e,text:s}){if(e){if(e.url)return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,D.jsx)(R.default,{context:t})}function K({content:e,label:s}){const[t,a]=n.useState(!1);return(0,D.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,h.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,D.jsx)(M.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function B({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,D.jsx)(R.default,{context:s})}if(!t)return(0,D.jsx)(R.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,D.jsxs)("div",{className:"embeddings-result",children:[(0,D.jsxs)("div",{className:"embeddings-summary",children:[(0,D.jsx)("strong",{children:"向量嵌入结果"}),(0,D.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,D.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,D.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,D.jsxs)("div",{className:"embeddings-toolbar",children:[(0,D.jsx)(K,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,D.jsx)(K,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,D.jsx)(K,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,D.jsx)("div",{className:"embeddings-preview",children:(0,D.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,D.jsxs)("details",{children:[(0,D.jsx)("summary",{children:"查看详细数据"}),(0,D.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function z(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await r.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const a=n.data||{},i=(a.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=i.map((e,s)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:a.session_id||s,images:i,text:o||`生成了 ${i.length} 张图片`}}(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||s,o=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await r.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var P=t(4412),L=t(23430),F=t(87361),O=t(80389),q=t(7523),G=t(23496);const U=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:c,sysPromptList:l,batchMode:d,selectedMsgCount:u,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),$=(0,o.Zp)(),{check_user_auth:I}=(0,m.MH)(),[,R]=(0,a.fp)(x.AG.ai_session_collapsed),{open:H}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(x.AG.prompt_card),[t,o]=(0,a.fp)(x.AG.ai_chat_zoom),{initUserInfo:c}=(0,n.useContext)(q.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,D.jsx)(O.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),a()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await r.wm.post(G.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,g.SK)(e("缩放调整成功")),c(),a()}})}}}(),V=I(L.oV.ai_model_switch)||I(L.oV.ai_agent_setting),E=[];for(const e of t)for(const s of e.models)E.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const T=t.find(e=>e.active),K=T?`${T.index}::${e}`:"",B=(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(M.rA,{icon:"menu",title:A("会话"),onClick:p,selected:h}),(0,D.jsx)(M.rA,{icon:"add",title:A("新会话"),onClick:()=>f()}),l.length>0&&(0,D.jsx)(j.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...l.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),V&&E.length>0&&(0,D.jsx)(j.l6,{value:K,options:[{title:A("选择模型"),value:""},...E],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...a]=t.split("::"),i=a.join("::");i&&(s(i),r.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===_.m.Success?((0,g.SK)("success"),c()):(0,g.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),d&&u>0&&(0,D.jsx)(M.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,D.jsx)(M.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:H}),(0,D.jsx)(M.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{$(F.o.ai_rebot_setting_page)}}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"settings",title:"ai setting",onClick:()=>{$(F.o.ai_agent_setting_page)}})]});return C?(0,D.jsx)("div",{className:"chat-inline-header",children:B}):(0,D.jsx)(P.aZ,{position:"right",children:B})};var J=t(89824);function W({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:h,onToggleBatchMode:g,onBatchDeleteSessions:p,onClearAllSessions:_,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j}){const{t:v}=(0,i.Bd)(),[b,w]=(0,n.useState)(""),[y,S]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=!!a&&!f,A=b.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(b.toLowerCase())||(e.summary||"").toLowerCase().includes(b.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(b.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(b.toLowerCase())):e;return(0,D.jsxs)("aside",{className:"chat-session-list",children:[(0,D.jsx)("div",{className:"chat-session-search",children:(0,D.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,D.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,D.jsx)("div",{children:(0,D.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${y===n?"row-dragging":""} ${N===n&&null!==y&&y!==n?"row-drop-target":""}`,draggable:C,onDragStart:()=>S(n),onDragOver:e=>{null!==y&&(e.preventDefault(),N!==n&&k(n))},onDragEnd:()=>{S(null),k(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=y;if(S(null),k(null),null===s||s===e||!a)return;const t=A[s]?.id,n=A[e]?.id;t&&n&&a(t,n)})(n)},onClick:()=>{u&&h?h(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,D.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>h?.(e.id),onClick:e=>e.stopPropagation()}),(0,D.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,D.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,D.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,D.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,D.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,D.jsx)(J.MenuSelect,{list:[{name:v("重命名"),click:()=>o(e.id,e.title)},...f?[]:[{name:v("移动到最上"),click:()=>{const s=A[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{name:v("移动到最下"),click:()=>{const s=A[A.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{name:e.cmd_auto_allow?v("命令检测关闭"):v("命令检测开启"),click:()=>r?.(e.id,!e.cmd_auto_allow)},{name:v("字符消耗统计"),click:()=>l(e.id)},{name:v("设置"),click:()=>d?.(e.id)},{name:v("删除"),click:()=>c(e.id)}],children:(0,D.jsx)(M.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,D.jsxs)("div",{className:"chat-session-actions",children:[(0,D.jsx)(M.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:g}),j&&!u&&(0,D.jsx)(M.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,D.jsx)(M.rA,{icon:"delete",title:v("删除选中会话"),onClick:p}),!u&&_&&(0,D.jsx)(M.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:_})]})]})}function Q(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const X=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:u,onToggleBatchMode:m,onBatchCopy:h,onBatchDelete:g,showBatchBar:p,t:_})=>{const[f,x]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),v=e=>{x(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},b=()=>{x(e=>e.size>0&&j.every(s=>e.has(s))?new Set:new Set(j))};return(0,D.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[p&&(0,D.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,D.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,D.jsx)("button",{onClick:h,children:_("复制所选")}),(0,D.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,D.jsx)("button",{onClick:m,children:_("取消")})]}),e.map(e=>{const n=f.has(e.id);return(0,D.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,D.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,D.jsxs)("div",{className:"ai-loading-bubble",children:[(0,D.jsxs)("div",{className:"ai-loading-dots",children:[(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"})]}),(0,D.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>v(e.id),children:[(0,D.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,D.jsx)("span",{className:"chat-message-summary-text",children:Q(e)||_("(无内容)")})]}):(0,D.jsx)("div",{className:"chat-message-body",children:H(e)}),(0,D.jsxs)("div",{className:"message-collapse-bar",children:[(0,D.jsx)("button",{onClick:()=>v(e.id),children:_(n?"展开":"折叠")}),(0,D.jsx)("button",{onClick:b,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,D.jsx)("span",{className:"message-elapsed",children:(0,d.kf)(e.elapsed_ms)})]}),(0,D.jsx)("div",{className:"message-actions",children:s?(0,D.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?_("取消选择"):_("选择")}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,D.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,D.jsx)("button",{onClick:u,children:_("全部复制")}),(0,D.jsx)("button",{onClick:m,children:_("多选")})]})})]})]},e.id)}),(0,D.jsx)("div",{ref:o})]})},Z=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>g(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,D.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:o,onInput:()=>c?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});var Y=t(84369);function ee({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,D.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,D.jsxs)("div",{className:"chat-attachment-chip",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{title:e.name,children:e.name}),(0,D.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,D.jsx)(M.In,{icon:"close"})})]},`${e.name}_${t}`))})}const se=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:m,readonly:h=!1},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),f=(0,n.useRef)(null),[j,v]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,Y.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=f.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,D.jsxs)("div",{ref:f,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,D.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,D.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,D.jsxs)("div",{className:"chat-input-shell",children:[(0,D.jsx)(ee,{pendingAttachments:o,onRemove:c}),(0,D.jsx)(Z,{ref:_,placeholder:p(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input",style:S})]}),!h&&(0,D.jsx)(M.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,D.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,D.jsx)(M.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,D.jsx)(M.Vi,{text:p("发送"),clickFun:e}),b&&(0,D.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),te=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[p,_]=(0,n.useState)(!1),[f,j]=(0,a.fp)(x.AG.ai_bg_expanded),[,v]=(0,a.fp)(x.AG.ai_session_collapsed),b=()=>{j(!1)},w=(0,n.useCallback)(async()=>{l(!0);try{const s=new c.hf(c.HK.ai_bg_process_list_req);s.context={};const t=await I.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=w);const y=(0,n.useCallback)(async e=>{_(!0),u(e);try{const s=new c.hf(c.HK.ai_bg_process_output_req);s.context={pid:e};const t=await I.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,g.zN)("获取进程输出失败")}finally{_(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new c.hf(c.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await I.ws.send(s);t?.context?.success?((0,g.SK)("进程已终止"),w(),d===e&&(u(null),h(null))):(0,g.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,g.zN)("终止进程失败")}},[w,d]);(0,n.useEffect)(()=>{w();const e=setInterval(w,5e3);return()=>clearInterval(e)},[w]);const N=t.filter(e=>e.running),k=t.filter(e=>!e.running);return(0,D.jsxs)(D.Fragment,{children:[f&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:b}),(0,D.jsxs)("aside",{className:"chat-bg-process-panel "+(f?"expanded":""),children:[(0,D.jsxs)("div",{className:"chat-bg-process-header",children:[(0,D.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:b})]}),(0,D.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,D.jsx)(M.rA,{icon:"refresh",title:s("刷新"),onClick:w}),(0,D.jsxs)("span",{className:"chat-bg-process-count",children:[N.length," ",s("个运行中"),k.length>0&&` / ${k.length} ${s("个已退出")}`]})]}),(0,D.jsxs)("div",{className:"chat-bg-process-list",children:[r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),N.map(e=>(0,D.jsxs)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} running`,children:[(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,D.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,D.jsx)(M.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,D.jsx)(M.rA,{icon:"stop",title:s("终止进程"),onClick:()=>S(e.pid)})]})]},e.pid)),k.map(e=>(0,D.jsx)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} finished`,children:(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==d&&(0,D.jsxs)("div",{className:"chat-bg-process-output",children:[(0,D.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,D.jsxs)("span",{children:["PID: ",d," ",s("输出")]}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:()=>{u(null),h(null)}})]}),(0,D.jsx)("div",{className:"chat-bg-process-output-content",children:p?(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):m?(0,D.jsx)("pre",{className:"chat-bg-process-output-pre",children:m.output||s("(无输出)")}):null})]})]})]})};t(99214);function ne(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:v,sync_url:y=!0,on_session_change:N}=e,{t:k}=(0,i.Bd)(),[C,A]=(0,o.ok)(),M=y&&C.get("session")||"",R=e=>{y&&A(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},H=(0,p.y)(),{check_user_auth:V}=(0,m.MH)();(0,f.w)();const[E,T]=(0,n.useState)([]),[K,B]=(0,n.useState)([]),[P,L]=(0,n.useState)(!1),[F,O]=(0,n.useState)(""),[q,G]=(0,n.useState)(null),[J,Q]=(0,n.useState)(!1),Z=(0,n.useRef)(null),[Y,ee]=(0,n.useState)([]),[ne]=(0,a.fp)(x.AG.user_base_info),ae=!!ne?.user_data?.is_root,[ie,oe]=(0,a.fp)(x.AG.ai_session_collapsed),[ce,re]=(0,a.fp)(x.AG.ai_bg_expanded),[le,de]=(0,a.fp)(x.AG.prompt_card),[ue]=(0,a.fp)(x.AG.ai_chat_zoom),[me,he]=(0,n.useState)(!1),[ge,pe]=(0,n.useState)(new Set),[_e,fe]=(0,n.useState)(new Set),[xe,je]=(0,n.useState)(""),ve=(0,n.useRef)(null),be=(0,n.useRef)(null),we=(0,n.useRef)(null),ye=(0,n.useRef)(!0),Se=(0,n.useRef)(null),Ne=(0,n.useRef)(null),ke=(0,n.useRef)({}),Ce=(0,n.useRef)(F),Ae=(0,n.useRef)(q);(0,n.useEffect)(()=>{Ce.current=F},[F]),(0,n.useEffect)(()=>{Ae.current=q},[q]);const $e=(0,n.useRef)({}),[Ie,Me]=(0,n.useState)([]),[Re,De]=(0,n.useState)(""),[He,Ve]=(0,n.useState)([]),Ee=async()=>{try{const e=await r.jV.get("public_models");e.code===_.m.Success&&Ve(e.data?.groups??[])}catch{Ve([])}},Te=e=>{De(e?.ai_config?.model??"")},[Ke,Be]=(0,n.useState)(0),ze=(0,n.useRef)((0,l.sg)(e=>{T(e),ye.current&&Pe(!1)},50)).current,Pe=(e=!1)=>{const s=we.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},Le=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Le.current=P},[P]);const Fe=(e,s={})=>r.jV.post("admin/session",{action:e,...s}),Oe=async()=>{const e=Le.current?await Fe("list_all_sessions"):await r.jV.get("sessions");e.code===_.m.Success&&B(e.data??[])},qe=(e,s)=>{B(t=>{const n=t.find(s=>s.id===e);return n&&!!n.running!==s?t.map(t=>t.id===e?{...t,running:s}:t):t})},Ge=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:r,refreshSessions:l,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,r)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};h.push(p),t([...h]);const _=new Map;let f=!0,x=p;const j=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",i=t.tool_call_ends,c=t.chunk_index??0;if("[DONE]"!==n)if(f)f=!1,x.text=n,i&&(x.content_list=[{tool_call_ends:i,content:x.text,role:"assistant"}]),x.is_loading=!1,x.chunk_index=c,_.set(c,x),o()===e&&a([...h]);else{const s=_.get(c);if(s)s.text+=n,i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),o()===e&&a([...h]);else{const s={id:Date.now()+Math.random(),sender:"bot",text:n,chunk_index:c};i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),h.push(s),_.set(c,s),o()===e&&a([...h])}}},v=s=>{const n=s.context||{};if(n.session_id===e){if(w(),g.current=null,i(s=>s===e?null:s),x.is_loading=!1,o()===e)if(n.once_messages_list?.length){const e=S(n.once_messages_list);t(s=>{const t=s[s.length-1];return"bot"===t?.sender?[...s.slice(0,-1),...e]:[...s,...e]})}else t([...h]);l(),d(!0),r()}},b=s=>{const n=s.context||{};n.session_id===e&&(w(),g.current=null,i(s=>s===e?null:s),x.text="AI请求出错: "+(n.message||"未知错误"),x.is_loading=!1,o()===e&&t([...h]),r())},w=()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,j),I.ws.off_message(`message_${c.HK.ai_chat_end}`,v),I.ws.off_message(`message_${c.HK.ai_chat_error}`,b)};I.ws.addMsg(c.HK.ai_chat_msg,j),I.ws.addMsg(c.HK.ai_chat_end,v),I.ws.addMsg(c.HK.ai_chat_error,b),I.ws.sendData(c.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(o(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(I.ws.sendData(c.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>E,setMessages:T,setMessagesDebounced:ze,setSending:G,getActiveSessionId:()=>Ce.current,setActiveSessionId:O,refreshSessions:Oe,scrollToBottom:Pe,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>xe}),Ue=async e=>{const s=Le.current?await Fe("list_all_sessions"):await r.jV.get("sessions");if(s.code!==_.m.Success)return!1;const t=s.data??[];B(t);const n=null===e?t[0]?.id??"":e||F||t[0]?.id||"";if(n){const e=t.find(e=>e.id===n)?.user_id;return await Je(n,!1,e)}return T([]),O(""),R(null),!1},Je=async(e,s=!1,t)=>{const n=t??K.find(s=>s.id===e)?.user_id,a=Le.current&&n?await Fe("get",{session_id:e,user_id:n}):await r.jV.post("session/get",{session_id:e});if(a.code!==_.m.Success||!a.data)return!1;const i=a.data;O(i.id),y&&M!==i.id&&R(i.id),N?.(i.id),Q(!!i.running),Ne.current&&Ne.current!==i.id&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:Ne.current,subscribe:!1}),Ne.current=i.running?i.id:null,Ne.current&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:Ne.current,subscribe:!0});const o=S(i.messages);return i.running&&i.live_messages?.length?T([...o,...S(i.live_messages)]):T(o),je(i.sys_prompt_id??""),s&&oe(!1),ke.current.refresh?.(),requestAnimationFrame(()=>Pe(!1)),!0},We=e=>{if(Le.current)return K.find(s=>s.id===e)?.user_id},Qe=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&ee(e=>[...e,...s])},Xe=()=>{me&&(pe(new Set),fe(new Set)),he(e=>!e)},Ze=()=>{0!==ge.size&&H({sub_title:k("cf_msgs"),confirm_fun:async()=>{const e=[];if(E.forEach((s,t)=>{ge.has(s.id)&&e.push(t)}),T(E.filter(e=>!ge.has(e.id))),pe(new Set),he(!1),F&&e.length>0){const s=We(F);s?Fe("message_delete",{session_id:F,user_id:s,indices:e}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:e}).catch(console.error)}}})},Ye=async()=>{const e=await r.XO.get("ai_agent_setting/env");if(e.code===_.m.Success&&($e.current=e.data,Te(e.data)),await Ee(),v){const e=await(async e=>{if(!e)return null;const s=await r.jV.get("sessions");if(s.code!==_.m.Success)return null;const t=s.data??[];e=(0,d.ed)(e);const n=t.find(s=>(0,d.ed)(s.file_cwd_path)===e);if(n)return n.id;const a=await r.jV.post("session",{file_cwd_path:e});return a.code!==_.m.Success?null:a.data.id})(v);!!e&&await Ue(e)||await Ue()}else if(t){await Ue(t)||await Ue()}else if(M){await Ue(M)||await Ue()}else await Ue();const s=await r.jV.get("system_prompts");s.code===_.m.Success&&Me(s.data??[])};(0,n.useEffect)(()=>{Ye(),requestAnimationFrame(()=>Pe(!1)),ke.current.onCountChange=Be,ke.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&Be(s)};return I.ws.addMsg(c.HK.ai_bg_process_count_notify,e),()=>{I.ws.off_message(`message_${c.HK.ai_bg_process_count_notify}`,e)}},[]),(0,n.useEffect)(()=>{const e=we.current;if(!e)return;const s=()=>{ye.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useEffect)(()=>{const e=()=>Ce.current,s=()=>Ae.current,t=(t,n)=>{if(qe(t,!1),e()&&e()===t){if(Se.current=null,Q(!1),Ne.current===t&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),Ne.current=null),s()===t)return;n?.length?T(e=>{const s=S(n),t=e[e.length-1];return"bot"===t?.sender?[...e.slice(0,-1),...s]:[...e,...s]}):Je(t).catch(()=>{})}Oe()},n=t=>{const n=t?.context||{};var a,i,o;n.session_id&&(a=n.session_id,i=n.text||"",o=n.tool_call_ends,e()&&e()===a&&s()!==a&&T(e=>{const s=e[e.length-1];if(s&&"bot"===s.sender){const t=[...e],n={...s};return n.text+=i,o&&(n.content_list=[{tool_call_ends:o,content:n.text,role:"assistant"}]),t[t.length-1]=n,Se.current=n.id,ye.current&&requestAnimationFrame(()=>Pe(!1)),t}const t={id:Date.now()+Math.random(),sender:"bot",text:i};return o&&(t.content_list=[{tool_call_ends:o,content:i,role:"assistant"}]),Se.current=t.id,ye.current&&requestAnimationFrame(()=>Pe(!1)),[...e,t]}),qe(n.session_id,!0))},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return I.ws.addMsg(c.HK.ai_chat_msg,n),I.ws.addMsg(c.HK.ai_chat_end,a),I.ws.addMsg(c.HK.ai_chat_error,i),()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,n),I.ws.off_message(`message_${c.HK.ai_chat_end}`,a),I.ws.off_message(`message_${c.HK.ai_chat_error}`,i),Ne.current&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:Ne.current,subscribe:!1}),Ne.current=null)}},[]),(0,n.useLayoutEffect)(()=>{ye.current&&Pe(!1)},[E]);return(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(U,{inline:s,currentModelName:Re,setCurrentModelName:De,modelGroups:He,onModelChanged:async()=>{await Ee();const e=await r.XO.get("ai_agent_setting/env");e.code===_.m.Success&&($e.current=e.data,Te(e.data))},sysPromptList:Ie,batchMode:me,selectedMsgCount:ge.size,sessionVisible:!ie,onToggleSessionPanel:()=>{oe(e=>!e)},onCreateSession:async e=>{const s=e??"",t=await r.jV.post("session",{sys_prompt_id:s||void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;const n=t.data;O(n.id),T([]),je(n.sys_prompt_id??""),oe(!1),await Ue(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:Ze,bgProcessVisible:ce,bgProcessCount:Ke,onToggleBgProcess:()=>re(e=>!e),selectedSysPromptId:xe,setSelectedSysPromptId:e=>{if(je(e),F){const s=We(F);s?Fe("sys_prompt",{session_id:F,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):r.jV.post("session/sys_prompt",{session_id:F,sys_prompt_id:e||void 0}).catch(console.error)}}}),(0,D.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":ue},children:[!ie&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:()=>oe(!0)}),!ie&&(0,D.jsx)(W,{sessions:K,activeSessionId:F,onSelectSession:e=>Je(e,!1),onReorderSessions:(e,s)=>{if(Le.current)return;const t=K.findIndex(s=>s.id===e),n=K.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,u.TI)(K,t,n);B(a),r.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},onRenameSession:(e,s)=>{let t=s;H({confirm_fun:async()=>{const s=We(e);s?await Fe("rename",{session_id:e,user_id:s,title:t}):await r.jV.post("sessions/update/meta",{id:e,title:t}),await Ue(F)},context_div:(0,D.jsx)("div",{className:"card-content",children:(0,D.jsx)(j.Sm,{value:t,handleInputChange:e=>{t=e}})})})},onDeleteSession:e=>{H({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=We(e);s?await Fe("delete",{session_id:e,user_id:s}):await r.jV.post("session/delete",{session_id:e}),F===e?(O(""),await Ue(null)):await Ue(F)}})},onToggleCmdAuto:async(e,s)=>{const t=We(e);t?await Fe("cmd_auto",{session_id:e,user_id:t,allow:s}):await r.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,g.SK)(k(s?"命令检测已开启":"命令检测已关闭")),await Ue(F)},onShowUsageStats:async e=>{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-loading",children:k("加载中...")}),cancel:()=>de({open:!1})});try{const s=We(e),t=s?await Fe("usage_stats",{session_id:e,user_id:s}):await r.jV.post("session/usage_stats",{session_id:e});if(t.code===_.m.Success&&t.data){const e=t.data;de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsxs)("div",{className:"usage-stats-panel",children:[[{l:k("对话轮次"),v:(e.turns??0).toString()},{l:k("AI输入Token"),v:b(e.input_tokens)},{l:k("AI输出Token"),v:b(e.output_tokens)},{l:k("AI输入Token(最近一轮)"),v:b(e.recent_input_tokens)},{l:k("AI输出Token(最近一轮)"),v:b(e.recent_output_tokens)}].map((e,s)=>(0,D.jsxs)("div",{className:"usage-stats-row",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,D.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,D.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:k("AI Token总计消耗")}),(0,D.jsx)("span",{className:"usage-stats-value",children:b((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>de({open:!1})})}else de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}catch{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}},onShowSessionSetting:e=>{let s=K.find(s=>s.id===e)?.file_cwd_path??"";de({open:!0,title:k("会话设置"),context_div:(0,D.jsxs)("div",{className:"session-setting",children:[(0,D.jsx)("div",{className:"session-setting__label",children:k("服务器工作目录")}),(0,D.jsx)(j.Sm,{value:s,placeholder:k("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=We(e);(t?await Fe("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await r.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===_.m.Success&&(0,g.SK)(k("保存成功"))}catch{}de({open:!1}),await Ue(F)},cancel:()=>de({open:!1})})},batchMode:me,selectedSessionIds:_e,onToggleSessionSelect:e=>{fe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Xe,onBatchDeleteSessions:()=>{0!==_e.size&&H({sub_title:k("cf_ses"),confirm_fun:async()=>{if(Le.current)await Fe("batch_delete",{session_ids:Array.from(_e)});else for(const e of _e)await r.jV.post("session/delete",{session_id:e});fe(new Set),he(!1),_e.has(F)?(O(""),await Ue(null)):await Ue(F)}})},onClearAllSessions:P?void 0:()=>{H({sub_title:k("cf_all"),confirm_fun:async()=>{await r.jV.post("sessions/clear",{}),O(""),T([]),await Ue(null)}})},allUsersMode:P,onToggleAllUsersMode:async()=>{const e=!P;L(e),Le.current=e,O(""),T([]);const s=e?await Fe("list_all_sessions"):await r.jV.get("sessions"),t=s.code===_.m.Success?s.data??[]:[];B(t),t[0]?.id&&await Je(t[0].id,!1,t[0].user_id)},showAllUsersEntry:ae}),(0,D.jsx)(te,{panelRef:ke}),(0,D.jsxs)("section",{className:"chat-main",children:[0===E?.length&&(0,D.jsx)("div",{className:"chat-header",children:(0,D.jsx)("div",{children:k("ai_ask")})}),(0,D.jsx)(X,{messages:E,batchMode:me,selectedMsgIds:ge,sending:q===F||J,chatContainerRef:we,messagesEndRef:be,onToggleMsgSelect:e=>{pe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:e=>{H({sub_title:k("cf_one"),confirm_fun:async()=>{const s=E.findIndex(s=>s.id===e);if(s<0)return;const t=E.filter(s=>s.id!==e);if(T(t),F){const e=We(F);e?Fe("message_delete",{session_id:F,user_id:e,indices:[s]}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:[s]}).catch(console.error)}}})},onCopy:async e=>{(0,h.lW)(w(e)),(0,g.SK)("复制成功")},onCopyAll:async()=>{if(!K.length)return void(0,g.SK)("暂无聊天记录");const e=[];for(const s of K){const t=s.user_id?await Fe("get",{session_id:s.id,user_id:s.user_id}):await r.jV.post("session/get",{session_id:s.id});if(t.code!==_.m.Success||!t.data)continue;const n=t.data,a=S([...n.messages??[],...n.live_messages??[]]).map(w).filter(Boolean).join("\n\n\n");a&&e.push(a)}e.length?((0,h.lW)(e.join("\n\n\n")),(0,g.SK)("复制成功")):(0,g.SK)("暂无聊天记录")},onToggleBatchMode:Xe,onBatchCopy:()=>{const e=E.filter(e=>ge.has(e.id)).map(w).filter(Boolean).join("\n\n\n");e?((0,h.lW)(e),(0,g.SK)("复制成功")):(0,g.SK)("暂无内容")},onBatchDelete:Ze,showBatchBar:me&&ge.size>0&&0===_e.size,t:k}),(0,D.jsx)(se,{ref:Z,onSend:async()=>{if(Le.current)return;const e=(Z.current?.getValue()??"").trim();if(!e&&0===Y.length)return;if(q===F){const s=await $(Y);Ge.enqueueMessage(e,s),Z.current?.clear(),ee([]);const t={id:Date.now(),sender:"user",text:e+(Ge.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void T(e=>[...e,t])}let s=F;if(!s){const t=await r.jV.post("session",{title:(e||Y[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;s=t.data.id,O(s),N?.(s),await Ue(s)}const t=await $(Y),n={id:Date.now(),sender:"user",text:e,attachments:t};Z.current?.clear(),ee([]);const a=$e?.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...E,n,t];T(i),G(s);return void(await z(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),T([...i]),G(null),Oe(),Pe(!0),Ge.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,T([...i]),G(null),Ge.processPendingQueue()))}Ge.startChatStream(s,n,()=>Ge.processPendingQueue())},readonly:P,sending:q===F||J,onAbort:Ge.abort,pendingAttachments:Y,onRemoveAttachment:e=>{ee(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ve.current?.click()},onAddFiles:Qe,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Qe(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ve})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(22022),i=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.Bd)(),[t,i]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{i(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),x=(0,n.useCallback)(()=>{if(h.current)return;if(0===l.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=l.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):h.current=!1},[t,f,s]);_.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return i.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{i.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>y});var n=t(96540),a=t(23802),i=t(53995),o=t(18569),c=t(77979),r=t(8263),l=t(69428),d=t.n(l),u=(t(3775),t(21499)),m=t(99214),h=t(89117),g=t(86063),p=t(89334),_=t(41105),f=t(52388),x=t(19878),j=(t(72411),t(74848));const v=new a.A({html:!0,highlight:function(e,s){if(s&&x.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${x.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${x.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${v.utils.escapeHtml(e)}</code></pre>`}});async function b(e,s){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=f.A.t("rendering");const t=await(0,g.Hn)(s);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await t.mount(e))}function w(e){const s=e.className.match(/language-([\w-]+)/);return s?s[1]:""}function y(e){const s=(0,n.useRef)(null);return(0,m.VD)(),(0,n.useEffect)(()=>{s.current&&(s.current.innerHTML=v.render(e.context??""),async function(e){const s=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(s)){const s=w(e),t=(0,h.Hm)(s),n=(0,g.hj)(s);if(!t&&!n)continue;const a=e.closest(".code-block-with-copy")??e.parentElement;if(!a)continue;const i=e.textContent??"",o=document.createElement("div");if(a.replaceWith(o),n){try{await b(o,i)}catch(e){console.error("[mind] render failed",e),o.className="md-graph md-graph--mind",o.textContent=String(e)}continue}o.className="md-graph md-graph--loading",o.textContent=f.A.t("rendering");const c=await(0,h.U6)(s,i);o.isConnected&&(c.error?(o.className="md-graph md-graph--error",o.textContent=c.error):(o.className="md-graph",o.innerHTML=c.svg))}}(s.current),(0,p.rg)(s.current))},[e.context]),(0,j.jsx)("div",{ref:s})}v.use(i.A).use(o.A).use(c.A).use(r.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const o=s[t],c=o.content.trim(),r=o.info.trim();let l="";if(r&&x.A.getLanguage(r))try{l=x.A.highlight(c,{language:r}).value}catch(s){l=e.utils.escapeHtml(c)}else try{l=x.A.highlightAuto(c).value}catch(s){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const o=e[t],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][1]=(0,u.bi)(window.location.href,e)}return s(e,t,n,a,i)}}),(0,p.Rh)(v,_.pC)},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),a=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[h,g]=(0,n.useState)(!1),p=(0,n.useRef)(null),_=(0,n.useRef)(u);_.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=p.current;if(!s)return;const{px_to_unit:t,min:n,max:a,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=i(n),d=i(a);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),_.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{p.current=null,g(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;p.current={pos:t(e),size:s()},g(!0)},[]);return(0,n.useEffect)(()=>{if(!h)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[h,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:h,on_pointer_down:w,on_pointer_up:b}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4903],{64903(e,t,n){n.r(t),n.d(t,{default:()=>f});var c=n(96540),i=n(34843),l=n(82893),s=n(85997),o=n(57952),a=(n(62042),n(21499),n(40505),n(22022)),d=(n(99214),n(74848));const r=c.lazy(()=>Promise.all([n.e(4946),n.e(2626),n.e(892),n.e(9334),n.e(6010)]).then(n.bind(n,34299)));function f(e){const{t}=(0,a.Bd)(),[n,c]=(0,i.fp)(l.AG.markdown);if(n.context)return(0,d.jsxs)("div",{id:"md-container",children:[(0,d.jsx)(o.A,{ignore_tags:!0,left_children:[(0,d.jsx)(s.rA,{title:t("取消"),icon:"close",onClick:function(){c({context:"",filename:""}),n?.close?.()}},1),(0,d.jsx)("title",{children:n.filename},2)]}),(0,d.jsx)("div",{className:"md-context ",children:(0,d.jsx)(r,{context:n.context})})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4935],{24935(e,t,n){n.r(t),n.d(t,{default:()=>S});var r=n(96540),s=n(47049),l=n(8890);const o=e=>Math.round(7*e+5),a=e=>Math.round(4*e/3);function c(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,l=e.getUTCMonth()+1,o=e.getUTCDate(),a="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(s)).replace(/(?<!m)m(?!m)/g,String(l)).replace(/mm/g,n(l)).replace(/d(?!d)/g,String(o)).replace(/dd/g,n(o)).replace(/aaaa/g,`星期${a}`)}const h=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function d(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&h(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&h(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const s=t.cellXfs?.[r];if(!s)return;const l=t.fills?.[s.fillId],o=t.fonts?.[s.fontId],a={};"solid"===l?.patternType&&(a.bg=i(l.fgColor,n)),a.color=i(o?.color,n),o?.bold&&(a.bold=!0),o?.italic&&(a.italic=!0),o?.size&&(a.fontSize=o.size),o?.name&&(a.fontFamily=o.name),o?.underline&&(a.underline=!0),o?.strike&&(a.strike=!0);const c=s.alignment;return c?.horizontal&&["left","center","right"].includes(c.horizontal)&&(a.align=c.horizontal),c?.vertical&&(a.valign="center"===c.vertical?"middle":c.vertical),c?.wrapText&&(a.wrap=!0),c?.indent&&(a.indent=c.indent),Object.keys(a).length?a:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const s=r.numFmtId;if(void 0===s||0===s)return;const l={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(l[s])return l[s];const o=t.numFmts;return o instanceof Map?o.get(s):void 0}async function x(e){const t=await(0,s.a)(c(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const s=[],l=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,o=new Map;let a;for(;a=l.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(a[2])?.[1];e&&o.set(a[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=o.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let l=0,c=0;r.rows.forEach((e,t)=>{e.size&&(l=Math.max(l,t),e.forEach((e,t)=>{c=Math.max(c,t)}))});const i=[],u=new Map;for(let e=1;e<=l;e++){const t=[],l=r.rows.get(e);for(let r=1;r<=c;r++){const o=l?.get(r),a=d(o,n,g(o,s));t.push(a.text);const c=m(o,s,n);a.runs&&(c?c.runs=a.runs:u.set(`${e-1}_${r-1}`,{runs:a.runs})),c&&u.set(`${e-1}_${r-1}`,c)}i.push(t)}const f=o(r.defaultColumnWidth??8.43),h=new Array(c).fill(f);r.columnDimensions?.forEach(e=>{const t=o(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<h.length&&(h[n-1]=t)});const x=a(r.defaultRowHeight??15),y=new Array(l).fill(x),p=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<y.length&&e.height&&(y[t-1]=a(e.height)),e.hidden&&t-1<l&&p.add(t-1)});const w=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:h,row_heights:y,hidden_rows:p,merges:w}})}var y=n(74848);function p(e){const{bytes:t,on_change:n,bind_save:o}=e,[a,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,h]=(0,r.useState)(0),[d,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),p=(0,r.useRef)(null),[_,S]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),x(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const b=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{o(async()=>{const e=await async function(e,t){const n=await(0,s.a)(c(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const s=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,l=n+1;let o=s.rows.get(r);o||(o=new Map,s.rows.set(r,o));const a=o.get(l);null!==e&&""!==e?a?a.value=e:o.set(l,{row:r,col:l,value:e}):a&&(a.value=null)})})}),await(0,l.n)(n)}(t,a);return g.current=!1,n(!1),e})},[a,t,o,n]);const C=a[u],{col_x:M,row_y:E,total_w:j,total_h:k}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),$=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n},F=(0,r.useCallback)(()=>{const e=p.current;if(!e||!M.length)return;const t=Math.max(0,$(M,e.scrollLeft)-1),n=Math.max(0,$(E,e.scrollTop)-1);S({c0:t,c1:Math.min(M.length-1,$(M,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,$(E,e.scrollTop+e.clientHeight)+2)})},[M,E]);(0,r.useEffect)(()=>{F()},[C,F]);if(d)return(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:d});if(!a.length)return(0,y.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const D=C?.values??[],A=(E.length,M.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||A.add(`${s}_${n}`)});const N=(e,t)=>{const n=D[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,y.jsxs)("div",{className:"xlsx-body",children:[(0,y.jsx)("div",{className:"xlsx-tabs",children:a.map((e,t)=>(0,y.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),p.current&&(p.current.scrollTop=0,p.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,y.jsx)("div",{className:"xlsx-scroll",ref:p,onScroll:F,children:(0,y.jsxs)("div",{className:"xlsx-grid",style:{width:46+j,height:24+k},children:[Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const n=_.c0+t;return(0,y.jsx)("div",{className:"xlsx-head",style:{left:46+M[n],top:0,width:M[n+1]-M[n],height:24},children:v(n)},"ch"+n)}),Array.from({length:Math.max(0,_.r1-_.r0)}).map((e,t)=>{const n=_.r0+t;return(0,y.jsxs)(r.Fragment,{children:[(0,y.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const r=_.c0+t;if(A.has(`${n}_${r}`))return null;const s=C.merges.find(e=>e[0]===n&&e[1]===r),l=s?M[s[3]+1]-M[s[1]]:M[r+1]-M[r],o=s?E[s[2]+1]-E[s[0]]:E[n+1]-E[n];return(0,y.jsx)(w,{value:D[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:N(n,r+1),style:{left:46+M[r],top:24+E[n],width:l,height:o,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=a[u];r&&(r.values[e][t]=""===n?null:n,b(),h(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function w(e){const{value:t,cell_style:n,style:s,spillable:l,on_change:o}=e,[a,c]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{a&&f.current&&(f.current.focus(),f.current.select())},[a]);const h=()=>{c(!1),i!==(t??"")&&o(i)},d={};return n?.bg&&(d.backgroundColor=n.bg),n?.color&&(d.color=n.color),n?.bold&&(d.fontWeight=600),n?.italic&&(d.fontStyle="italic"),n?.fontSize&&(d.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(d.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(d.textDecoration="underline"),n?.strike&&(d.textDecoration=d.textDecoration?`${d.textDecoration} line-through`:"line-through"),n?.align&&(d.textAlign=n.align,d.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(d.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(d.whiteSpace="pre-wrap"),n?.indent&&(d.paddingLeft=.35+1.4*n.indent+"em"),(0,y.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${l?"xlsx-cell--spill":""}`,style:{...s,...d,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),c(!0)},children:a?(0,y.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:h,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&c(!1):(e.preventDefault(),h())}}):n?.runs?(0,y.jsx)("span",{children:n.runs.map((e,t)=>(0,y.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function v(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var _=n(99018);function S(e){const{url:t,save_path:n,on_dirty:s,bind_save:l}=e,[o,a]=(0,r.useState)(),[c,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[h,d]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),d(!1),a(void 0),(0,_.PQ)(t).then(t=>e&&a(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(h)},[h,s]),(0,r.useEffect)(()=>{l?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,_.GB)(n,e);return t&&(a(e),d(!1)),t})},[n,l]),c?(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:c}):u||!o?(0,y.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,y.jsx)(p,{bytes:o,on_change:d,bind_save:e=>m.current=e})}},99018(e,t,n){n.d(t,{GB:()=>c,PQ:()=>a,Vi:()=>o});var r=n(14284),s=n(34289),l=n(62042);function o(e){return`${encodeURIComponent((0,s.GG)("file",(0,s.vX)()))}${e}`}async function a(e){const t=await fetch(e,{headers:{Authorization:localStorage.getItem("token")}});if(!t.ok)throw new Error(`读取文件失败: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}function c(e,t){return async function(e,t){const n=await r.$M.post(`save_bin/${e}`,{base64:i(t)});return 0===n.code||((0,l.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function i(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5877],{77481(e,t,n){n.d(t,{S:()=>c,X:()=>l});var s=n(96540),a=n(61443),r=n(74848);function l(e){const[t,n]=s.useState([]),l=(0,s.useRef)(-1),[c,o]=(0,s.useState)(-1),[i,d]=(0,s.useState)(-1);(0,s.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]);const u=()=>{l.current=-1,o(-1),d(-1)};return(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsx)("tr",{children:e.headers?.map((t,n)=>{const s=!!e.filter&&(e.filter.column??0)===n;let l=t;if(s){const n=e.filter,s=n.options.find(e=>e.value===n.value);null!=n.value&&s&&(l=`${t} (${s.label})`)}return(0,r.jsx)("th",{className:s?"table-filter-col":"",children:s?(0,r.jsx)(a.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:l}):t},n)})})}),(0,r.jsx)("tbody",{children:t.map((t,n)=>{const s=!!e.onRowDrag;return(0,r.jsx)("tr",{className:s?(c===n?"row-dragging":"")+(i===n?" row-drop-target":""):"",draggable:s,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{s&&(l.current=n,o(n),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!s||l.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(n))},onDrop:t=>{s&&(t.preventDefault(),(()=>{const t=l.current,n=i;u(),t<0||n<0||t===n||e.onRowDrag?.(t,n)})())},onDragEnd:u,children:t.map((n,s)=>{const a=s===t.length-1?"small":"";return(0,r.jsx)("td",{className:a,style:{width:e.width??"auto"},children:n},s)})},n)})})]})}function c(e){return(0,r.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,r.jsx)("div",{children:e},t))})}},83029(e,t,n){n.d(t,{N:()=>v});var s=n(96540),a=n(34843),r=n(82893),l=n(74848);function c(e){const[t,n]=(0,a.fp)(r.AG.user_base_info);return(0,l.jsx)("div",{children:e.div?(0,l.jsx)("div",{className:"nav_list_a",style:{background:e.color},children:e.name}):e.clickItem||"dir"===e._type?(0,l.jsx)("div",{className:"nav_list_a",style:{background:e.color},onClick:()=>{"dir"!==e._type?e.clickItem&&e.clickItem(e):e.click_dir(e.item)},children:e.name}):(0,l.jsx)("a",{href:e.url,target:e.target,className:"nav_list_a",style:{background:e.color},children:e.name})})}var o=n(64694),i=n(61443),d=n(85997),u=n(61973),h=n(22022);const p=["#ffffff","#fefff8","#fcfdf1","#d3d2dc","#f8f9fd","#ebf4fe","#ebebeb","#e8f7eb","#eaf2f9"];let m,x,_=[];const f=[];function v(e){const[t,n]=(0,s.useState)([]),[v,j]=(0,s.useState)(-1),g=(0,u.zy)(),[S,y]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!1),{t:k}=(0,h.Bd)(),[b,I]=(0,s.useState)([]),[N,D]=(0,a.fp)(r.AG.nav_index_add_item_by_now_list),A=e=>{-1!==v?f[v]._children=e:_=e};(0,s.useEffect)(()=>{(async()=>{if(!e.getItems)return;const t=await e.getItems();_=t,n(_)})()},[g]);(0,s.useEffect)(()=>{if(N){const e=[...t,{name:"",color:(0,o.Lr)(p),...N}];A(e),n(e),y(!0),D(void 0)}},[N]);const K=e=>{j(v+1),n(e._children),f.push(e)};return(0,l.jsxs)("div",{className:"nav_list_div scroll-div-y",children:[-1!==v&&(0,l.jsx)(d.rA,{title:"返回",icon:"arrow_back",onClick:()=>{n(0===v?_:f[v-1]._children),j(v-1),f.pop()}}),t.map((a,r)=>(0,l.jsxs)("div",{draggable:!0,onDragOver:e=>{e.preventDefault()},onDragStart:e=>((e,t)=>{m=t})(0,r),onDrop:e=>((e,s)=>{e.preventDefault();const a=t[m],r=t[s];if(r&&"dir"===r._type){const e=[...t];return e.splice(m,1),r._children||(r._children=[]),r._children.push(a),A(e),void n(e)}const l=[...t],c=l[m];l.splice(m,1),l.splice(s,0,c),A(l),n(l)})(e,r),style:{cursor:S?"move":"pointer"},children:[(0,l.jsx)(c,{name:a.name,item:a,...a,div:S,target:"_blank",click_dir:K,clickItem:e.clickItem}),S&&(void 0!==b.find(e=>e===r)||C)&&(0,l.jsxs)("div",{className:C?"":" site_edit ",children:["dir"===a._type?(0,l.jsxs)(s.Fragment,{children:[(0,l.jsx)(i.Sm,{value:a.name,handleInputChange:e=>{a.name=e},placeholder:k("输入类目名"),no_border:!0}),(0,l.jsx)(i.Sm,{value:a.color,type:"color",handleInputChange:e=>{a.color=e},placeholder:"color",no_border:!0})]}):e.items.map((e,t)=>(0,l.jsx)("div",{children:(0,l.jsx)(i.Sm,{value:a[e.key],type:"color"===e.key?"color":void 0,handleInputChange:t=>{a[e.key]=t},placeholder:e.preName,no_border:!0})},t)),!C&&(0,l.jsx)(d.C3,{text:k("折叠"),clickFun:()=>{I((0,o.P1)(b,r))}})]}),S&&(0,l.jsx)("div",{style:{display:"block"},children:(0,l.jsxs)("span",{className:"div-row ",children:[(0,l.jsx)(d.C3,{text:k("删除"),clickFun:()=>{(e=>{const s=[...t];s.splice(e,1),A(s),n(s)})(r)}}),(0,l.jsx)(d.C3,{text:k("编辑"),clickFun:()=>{void 0===b.find(e=>e===r)&&I([...b,r])}})]})})]},r)),S&&(0,l.jsxs)("div",{style:{display:"block"},children:[(0,l.jsx)(d.rA,{title:k("取消"),icon:"cancel",onClick:()=>{I([]),y(!1),x&&(n(x),A(x)),w(!1)}}),(0,l.jsx)(d.rA,{title:k("添加"),icon:"add",onClick:async()=>{const s=[...t,{name:"",color:(0,o.Lr)(p),...e.get_pre_add_item&&await e.get_pre_add_item()}];A(s),n(s)}}),(0,l.jsx)(d.rA,{title:k("添加类目"),icon:"add_box",onClick:()=>{const e=[...t,{name:"",_type:"dir",_children:[],color:"#c1edfb"}];A(e),n(e)}}),(0,l.jsx)(d.rA,{title:k("全部编辑"),icon:C?"unfold_less":"unfold_more",onClick:()=>{w(!C)}})]}),(void 0===e.have_auth_edit||!0===e.have_auth_edit)&&(0,l.jsx)(d.rA,{icon:S?"save":"edit",title:k(S?"保存":"编辑"),onClick:async()=>{S?e.save&&await e.save(_):x=t,y(!S)}})]})}},65877(e,t,n){n.r(t),n.d(t,{default:()=>A});var s=n(96540),a=n(75725),r=n(61443),l=n(70447),c=n(85997),o=n(34289),i=n(22022),d=n(62042),u=n(14284),h=n(53459),p=n(74848);function m(e){const{t}=(0,i.Bd)(),[n,m]=(0,s.useState)(t("毫秒")),[x,_]=(0,s.useState)(""),[f,v]=(0,s.useState)(""),[j,g]=(0,s.useState)(null),[S,y]=(0,s.useState)(null),[C,w]=(0,s.useState)(Date.now());return(0,s.useEffect)(()=>{(async()=>{const e=await u.Yu.get("sys_time/get");if(e.code===h.m.Success){const t=await e.data;g(t.timestamp),y(t.timezone),w(t.timestamp)}})();const e=setInterval(()=>{w(e=>e+1e3)},1e3);return()=>clearInterval(e)},[]),(0,p.jsxs)(a.fI,{children:[(0,p.jsx)(a.VP,{widthPer:33,children:(0,p.jsxs)(l.Zp,{title:t("时间转换器"),rightBottomCom:(0,p.jsx)(c.C3,{text:t("确定"),clickFun:function(){if(!x&&!f)return void(0,d.zN)("不能都为空");let e=0;const t=""!==x&&0!==x;if(t){if(!(0,o.kf)(x))return void(0,d.zN)("must be number !");e=parseInt(x),"分秒"===n&&(e*=1e3)}const s=new Date(t?e:f),a=new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(s);if(v(a),!x){const e=s.getTime();_("毫秒"===n?e:e/1e3)}}}),children:[(0,p.jsx)(r.l6,{value:n,options:[{title:t("毫秒"),value:"毫秒"},{title:t("分秒"),value:"分秒"}],onChange:function(e){m(e)}}),(0,p.jsx)(r.Sm,{placeholder:n,value:x,handleInputChange:e=>{_(e)}}),(0,p.jsx)(r.Sm,{placeholder:t("格式化时间"),value:f,handleInputChange:e=>{v(e)}})]})}),(0,p.jsx)(a.VP,{children:null!==j&&null!==S&&(0,p.jsxs)(l.Zp,{title:t("服务器时间"),children:[(0,p.jsxs)("h1",{children:[t("时区"),": ",S]}),(0,p.jsxs)("h1",{children:[t("时间"),": ",new Date(C).toLocaleString(navigator.language,{timeZone:S})]})]})})]})}var x=n(4412),_=n(83029),f=n(78247),v=n(23430);function j(e){const{t}=(0,i.Bd)(),{check_user_auth:n}=(0,f.MH)(),[a,l]=(0,s.useState)(""),o=async e=>{const t=e||a;if(!t)return void(0,d.zN)("mac地址不能为空");(await u._U.post("wol/exec",{mac:t})).code===h.m.Success&&(0,d.SK)("发送唤醒命令成功")};return(0,p.jsxs)("div",{children:[(0,p.jsxs)(x.aZ,{position:"right",children:[(0,p.jsx)(c.rA,{icon:"play_arrow",title:t("发送"),onClick:()=>{o()}}),(0,p.jsx)(r.$Z,{placeholder:t("mac_dst"),icon:"laptop_mac",value:a,handleInputChange:e=>l(e)})]}),(0,p.jsx)(_.N,{have_auth_edit:n(v.oV.wol_proxy_tag_update),getItems:async()=>{const e=await u._U.get("wol/tag");return e.code===h.m.Success?e.data:[]},save:async e=>{(await u._U.post("wol/tag/save",e)).code!==h.m.Success&&(0,d.zN)("网络错误")},clickItem:async e=>{l(e.mac),o(e.mac)},items:[{key:"name",preName:t("名字")},{key:"mac",preName:"mac"+t("地址")},{key:"color",preName:"color"}]})]})}var g=n(77481),S=n(34843),y=n(82893),C=n(40505);let w;function k(){const[e,t]=(0,s.useState)("rsa"),[n,o]=(0,s.useState)("pem"),{t:m,i18n:_}=(0,i.Bd)(),[f,v]=(0,S.fp)(y.AG.confirm),[j,k]=(0,s.useState)(""),[b,I]=(0,s.useState)(""),N=async t=>{if(!b||!j)return void(0,d.zN)("密钥不能为空");let n="id_"+e;"pub"===t&&(n+=".pub"),v({open:!0,title:m("将覆盖密钥文件"),sub_title:`之前的密钥将作废。 将会作为 ${n} 文件保存到系统上的"${w}"目录下,此目录会作为openssh(git)所使用的默认目录。`,handle:async()=>{(await u.cD.post("save_openssh",{name:n,context:"pub"===t?j:b})).code===h.m.Success&&((0,d.SK)("完成"),v({open:!1,handle:null}))}})};return(0,p.jsxs)(s.Fragment,{children:[(0,p.jsx)(x.aZ,{position:"right",children:(0,p.jsx)(g.S,{isFlex:!0,columns:[(0,p.jsx)(r.l6,{tip:m("加密算法"),value:e,width:"auto",onChange:e=>{t(e)},options:[{title:m("RSA"),value:"rsa"},{title:m("DSA"),value:"dsa"},{title:m("ECDSA"),value:"ecdsa"}]}),(0,p.jsx)(r.l6,{tip:m("输出格式"),value:n,width:"auto",onChange:e=>{o(e)},options:[{title:m("普通PEM"),value:"pem"},{title:m("opensshPEM"),value:"openssh_pem"}]}),(0,p.jsx)(c.rA,{icon:"play_arrow",title:m("生成"),onClick:()=>{(async()=>{const t=await u.cD.post("generate",{type:e,form:n});t.code===h.m.Success&&(k(t.data.public_key),I(t.data.private_key),w=t.data.home_path)})()}})]})}),(0,p.jsx)(a.xh,{children:(0,p.jsxs)(a.fI,{children:[(0,p.jsx)(a.VP,{children:(0,p.jsx)(l.Zp,{title:m("公钥"),titleCom:(0,p.jsx)(c.rA,{title:m("复制"),icon:"copy_all",onClick:()=>{j&&((0,C.lW)(j),(0,d.SK)("完成"))}}),rightBottomCom:"openssh_pem"===n&&(0,p.jsx)(c.C3,{text:m("ssh_dir"),clickFun:()=>{N("pub")}}),children:(0,p.jsx)("textarea",{className:"input--textarea input--no_border",style:{width:"100%",height:"270px"},onChange:e=>{k(e.target.value)},value:j})})}),(0,p.jsx)(a.VP,{children:(0,p.jsx)(l.Zp,{title:m("私钥"),titleCom:(0,p.jsx)(c.rA,{title:m("复制"),icon:"copy_all",onClick:()=>{b&&((0,C.lW)(b),(0,d.SK)("成功"))}}),rightBottomCom:"openssh_pem"===n&&(0,p.jsx)(c.C3,{text:m("ssh_dir"),clickFun:()=>{N("pri")}}),children:(0,p.jsx)("textarea",{className:"input--textarea input--no_border",style:{width:"100%",height:"270px"},value:b,onChange:e=>{I(e.target.value)}})})})]})})]})}var b=n(14944),I=n(92275);function N(){const{t:e}=(0,i.Bd)(),[t,n]=(0,s.useState)(""),[o,u]=(0,s.useState)("1"),[h,m]=(0,s.useState)("65535"),[x,_]=(0,s.useState)("100"),[f,v]=(0,s.useState)("2000"),[j,S]=(0,s.useState)(!1),[y,C]=(0,s.useState)(null),[w,k]=(0,s.useState)([]),[N,D]=(0,s.useState)(null),A=(0,s.useRef)([]),K=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!K.current)return K.current=!0,b.ws.addMsg(I.HK.port_scan_progress,e=>{C(e.context)}),b.ws.addMsg(I.HK.port_scan_result,e=>{const t=e.context,n=[...A.current,t];A.current=n,k(n)}),b.ws.addMsg(I.HK.port_scan_end,t=>{D(t.context),S(!1),t.context.cancelled?(0,d.zN)(e("扫描已取消")):(0,d.SK)(e("扫描完成"))}),()=>{b.ws.sendData(I.HK.port_scan_cancel,{}),b.ws.removeMsg(I.HK.port_scan_progress),b.ws.removeMsg(I.HK.port_scan_result),b.ws.removeMsg(I.HK.port_scan_end),K.current=!1}},[]);return(0,p.jsx)(a.xh,{children:(0,p.jsx)(a.fI,{children:(0,p.jsx)(a.VP,{children:(0,p.jsxs)(l.Zp,{title:e("TCP ")+e("端口扫描"),titleCom:(0,p.jsxs)("span",{children:[y&&(0,p.jsxs)("span",{children:[e("已发现"),": ",y.openCount]}),N&&(0,p.jsxs)("span",{children:[e("总计扫描"),": ",N.totalScanned," | ",e("开放"),": ",N.totalOpen]})]}),rightBottomCom:j?(0,p.jsx)(c.C3,{text:e("取消"),clickFun:()=>{b.ws.sendData(I.HK.port_scan_cancel,{}).catch(()=>{})}}):(0,p.jsx)(c.C3,{text:e("扫描"),clickFun:()=>(()=>{if(!t)return void(0,d.zN)(e("hostreq"));const n=parseInt(o),s=parseInt(h);isNaN(n)||isNaN(s)||n<1||s<1||n>65535||s>65535?(0,d.zN)(e("端口范围无效")):n>s?(0,d.zN)(e("portrng")):(S(!0),C(null),k([]),A.current=[],D(null),b.ws.sendData(I.HK.port_scan_req,{host:t,startPort:n,endPort:s,concurrency:parseInt(x)||100,timeout:parseInt(f)||2e3}).catch(()=>{}))})()}),children:[(0,p.jsx)(r.Sm,{placeholder:e("目标主机"),value:t,handleInputChange:e=>n(e)}),(0,p.jsx)(r.Sm,{placeholder:e("起始端口"),value:o,handleInputChange:e=>u(e)}),(0,p.jsx)(r.Sm,{placeholder:e("结束端口"),value:h,handleInputChange:e=>m(e)}),(0,p.jsx)(r.Sm,{placeholder:e("并发数"),value:x,handleInputChange:e=>_(e)}),(0,p.jsx)(r.Sm,{placeholder:e("超时(ms)"),value:f,handleInputChange:e=>v(e)}),j&&y&&(0,p.jsxs)("div",{children:[(0,p.jsxs)("p",{children:[e("已扫描"),": ",y.scanned," / ",y.total]}),(0,p.jsx)(l.gz,{progress:y.percent})]}),w.length>0&&(0,p.jsx)(g.X,{headers:[e("端口"),e("状态")],rows:w.map(t=>[t.port,(0,p.jsx)("span",{children:e("开放")})])}),j&&0===w.length&&(0,p.jsx)("p",{children:e("正在扫描...")}),!j&&N&&0===w.length&&(0,p.jsx)("p",{children:e("未发现开放端口")}),!j&&!N&&0===w.length&&(0,p.jsx)("p",{children:e("scan_in")})]})})})})}var D=n(87361);function A(e){const{t}=(0,i.Bd)(),{check_user_auth:n}=(0,f.MH)(),s=[];return s.push({index:1,name:t("时间工具"),rto:"timeutil/",component:(0,p.jsx)(m,{})},{index:1,name:t("非对称密钥"),rto:"crypto/",component:(0,p.jsx)(k,{})}),n(v.oV.port_scan)&&s.push({index:1,name:t("端口扫描"),rto:"portscan/",component:(0,p.jsx)(N,{})}),n(v.oV.wol_proxy)&&s.push({index:1,name:t("网络唤醒"),rto:"netwol/",component:(0,p.jsx)(j,{})}),(0,p.jsx)(a.W1,{optionList:s,father_route:D.o.toolbox})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[621,4935],{53002(e,t,n){n.r(t),n.d(t,{default:()=>d});var r=n(96540),s=n(34843),o=n(82893),c=n(85997),l=n(45907),a=n(74848);function i(e){const{name:t,dirty:n,loading:s,error:o,saving:i,on_save:u,on_close:f,children:d,extra:h}=e,m=(0,l.y)(),g=(0,r.useRef)(f),x=(0,r.useRef)(u),y=(0,r.useRef)(n);g.current=f,x.current=u,y.current=n;const p=()=>{y.current?m({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>g.current?.()}):g.current?.()};return(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),x.current?.()):"Escape"===e.key&&p()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,a.jsxs)("div",{className:"office-editor",children:[(0,a.jsxs)("div",{className:"office-editor__topbar",children:[(0,a.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,a.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,a.jsxs)("div",{className:"office-editor__ops",children:[h,i&&(0,a.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),u&&(0,a.jsx)(c.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>u()}),(0,a.jsx)(c.rA,{icon:"close",title:"关闭 (Esc)",onClick:p})]})]}),(0,a.jsxs)("div",{className:"office-editor__body",children:[s&&(0,a.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!s&&o&&(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:o}),!s&&!o&&d]})]})}var u=n(24935),f=n(99018);function d(){const[e,t]=(0,s.fp)(o.AG.excel_editor),[n,c]=(0,r.useState)(!1),[l,d]=(0,r.useState)(!1),h=(0,r.useRef)();return(0,a.jsx)(i,{name:e.name,dirty:n,loading:!1,error:"",saving:l,on_save:async()=>{if(!h.current)return!1;d(!0);try{return await h.current()}finally{d(!1)}},on_close:()=>{const n=e.close;t({}),n?.()},children:e.url&&(0,a.jsx)(u.default,{url:e.url,save_path:(0,f.Vi)(e.name??""),on_dirty:c,bind_save:e=>h.current=e})})}},24935(e,t,n){n.r(t),n.d(t,{default:()=>S});var r=n(96540),s=n(47049),o=n(8890);const c=e=>Math.round(7*e+5),l=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,o=e.getUTCMonth()+1,c=e.getUTCDate(),l="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(s)).replace(/(?<!m)m(?!m)/g,String(o)).replace(/mm/g,n(o)).replace(/d(?!d)/g,String(c)).replace(/dd/g,n(c)).replace(/aaaa/g,`星期${l}`)}const d=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function h(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&d(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&d(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const s=t.cellXfs?.[r];if(!s)return;const o=t.fills?.[s.fillId],c=t.fonts?.[s.fontId],l={};"solid"===o?.patternType&&(l.bg=i(o.fgColor,n)),l.color=i(c?.color,n),c?.bold&&(l.bold=!0),c?.italic&&(l.italic=!0),c?.size&&(l.fontSize=c.size),c?.name&&(l.fontFamily=c.name),c?.underline&&(l.underline=!0),c?.strike&&(l.strike=!0);const a=s.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(l.align=a.horizontal),a?.vertical&&(l.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(l.wrap=!0),a?.indent&&(l.indent=a.indent),Object.keys(l).length?l:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const s=r.numFmtId;if(void 0===s||0===s)return;const o={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(o[s])return o[s];const c=t.numFmts;return c instanceof Map?c.get(s):void 0}async function x(e){const t=await(0,s.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const s=[],o=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,c=new Map;let l;for(;l=o.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(l[2])?.[1];e&&c.set(l[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=c.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let o=0,a=0;r.rows.forEach((e,t)=>{e.size&&(o=Math.max(o,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=o;e++){const t=[],o=r.rows.get(e);for(let r=1;r<=a;r++){const c=o?.get(r),l=h(c,n,g(c,s));t.push(l.text);const a=m(c,s,n);l.runs&&(a?a.runs=l.runs:u.set(`${e-1}_${r-1}`,{runs:l.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=c(r.defaultColumnWidth??8.43),d=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=c(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<d.length&&(d[n-1]=t)});const x=l(r.defaultRowHeight??15),y=new Array(o).fill(x),p=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<y.length&&e.height&&(y[t-1]=l(e.height)),e.hidden&&t-1<o&&p.add(t-1)});const v=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:d,row_heights:y,hidden_rows:p,merges:v}})}var y=n(74848);function p(e){const{bytes:t,on_change:n,bind_save:c}=e,[l,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,d]=(0,r.useState)(0),[h,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),p=(0,r.useRef)(null),[w,S]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),x(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const b=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{c(async()=>{const e=await async function(e,t){const n=await(0,s.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const s=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,o=n+1;let c=s.rows.get(r);c||(c=new Map,s.rows.set(r,c));const l=c.get(o);null!==e&&""!==e?l?l.value=e:c.set(o,{row:r,col:o,value:e}):l&&(l.value=null)})})}),await(0,o.n)(n)}(t,l);return g.current=!1,n(!1),e})},[l,t,c,n]);const C=l[u],{col_x:j,row_y:E,total_w:k,total_h:M}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),N=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n},$=(0,r.useCallback)(()=>{const e=p.current;if(!e||!j.length)return;const t=Math.max(0,N(j,e.scrollLeft)-1),n=Math.max(0,N(E,e.scrollTop)-1);S({c0:t,c1:Math.min(j.length-1,N(j,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,N(E,e.scrollTop+e.clientHeight)+2)})},[j,E]);(0,r.useEffect)(()=>{$()},[C,$]);if(h)return(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:h});if(!l.length)return(0,y.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const F=C?.values??[],A=(E.length,j.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||A.add(`${s}_${n}`)});const D=(e,t)=>{const n=F[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,y.jsxs)("div",{className:"xlsx-body",children:[(0,y.jsx)("div",{className:"xlsx-tabs",children:l.map((e,t)=>(0,y.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),p.current&&(p.current.scrollTop=0,p.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,y.jsx)("div",{className:"xlsx-scroll",ref:p,onScroll:$,children:(0,y.jsxs)("div",{className:"xlsx-grid",style:{width:46+k,height:24+M},children:[Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const n=w.c0+t;return(0,y.jsx)("div",{className:"xlsx-head",style:{left:46+j[n],top:0,width:j[n+1]-j[n],height:24},children:_(n)},"ch"+n)}),Array.from({length:Math.max(0,w.r1-w.r0)}).map((e,t)=>{const n=w.r0+t;return(0,y.jsxs)(r.Fragment,{children:[(0,y.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const r=w.c0+t;if(A.has(`${n}_${r}`))return null;const s=C.merges.find(e=>e[0]===n&&e[1]===r),o=s?j[s[3]+1]-j[s[1]]:j[r+1]-j[r],c=s?E[s[2]+1]-E[s[0]]:E[n+1]-E[n];return(0,y.jsx)(v,{value:F[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:D(n,r+1),style:{left:46+j[r],top:24+E[n],width:o,height:c,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=l[u];r&&(r.values[e][t]=""===n?null:n,b(),d(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function v(e){const{value:t,cell_style:n,style:s,spillable:o,on_change:c}=e,[l,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&f.current&&(f.current.focus(),f.current.select())},[l]);const d=()=>{a(!1),i!==(t??"")&&c(i)},h={};return n?.bg&&(h.backgroundColor=n.bg),n?.color&&(h.color=n.color),n?.bold&&(h.fontWeight=600),n?.italic&&(h.fontStyle="italic"),n?.fontSize&&(h.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(h.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(h.textDecoration="underline"),n?.strike&&(h.textDecoration=h.textDecoration?`${h.textDecoration} line-through`:"line-through"),n?.align&&(h.textAlign=n.align,h.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(h.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(h.whiteSpace="pre-wrap"),n?.indent&&(h.paddingLeft=.35+1.4*n.indent+"em"),(0,y.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${o?"xlsx-cell--spill":""}`,style:{...s,...h,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:l?(0,y.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:d,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),d())}}):n?.runs?(0,y.jsx)("span",{children:n.runs.map((e,t)=>(0,y.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function _(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var w=n(99018);function S(e){const{url:t,save_path:n,on_dirty:s,bind_save:o}=e,[c,l]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[d,h]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),h(!1),l(void 0),(0,w.PQ)(t).then(t=>e&&l(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(d)},[d,s]),(0,r.useEffect)(()=>{o?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,w.GB)(n,e);return t&&(l(e),h(!1)),t})},[n,o]),a?(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!c?(0,y.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,y.jsx)(p,{bytes:c,on_change:h,bind_save:e=>m.current=e})}},99018(e,t,n){n.d(t,{GB:()=>a,PQ:()=>l,Vi:()=>c});var r=n(14284),s=n(34289),o=n(62042);function c(e){return`${encodeURIComponent((0,s.GG)("file",(0,s.vX)()))}${e}`}async function l(e){const t=await fetch(e,{headers:{Authorization:localStorage.getItem("token")}});if(!t.ok)throw new Error(`读取文件失败: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}function a(e,t){return async function(e,t){const n=await r.$M.post(`save_bin/${e}`,{base64:i(t)});return 0===n.code||((0,o.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function i(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6247],{77481(e,t,n){n.d(t,{S:()=>i,X:()=>s});var r=n(96540),o=n(61443),l=n(74848);function s(e){const[t,n]=r.useState([]),s=(0,r.useRef)(-1),[i,a]=(0,r.useState)(-1),[c,d]=(0,r.useState)(-1);(0,r.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]);const h=()=>{s.current=-1,a(-1),d(-1)};return(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsx)("tr",{children:e.headers?.map((t,n)=>{const r=!!e.filter&&(e.filter.column??0)===n;let s=t;if(r){const n=e.filter,r=n.options.find(e=>e.value===n.value);null!=n.value&&r&&(s=`${t} (${r.label})`)}return(0,l.jsx)("th",{className:r?"table-filter-col":"",children:r?(0,l.jsx)(o.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:s}):t},n)})})}),(0,l.jsx)("tbody",{children:t.map((t,n)=>{const r=!!e.onRowDrag;return(0,l.jsx)("tr",{className:r?(i===n?"row-dragging":"")+(c===n?" row-drop-target":""):"",draggable:r,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{r&&(s.current=n,a(n),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!r||s.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(n))},onDrop:t=>{r&&(t.preventDefault(),(()=>{const t=s.current,n=c;h(),t<0||n<0||t===n||e.onRowDrag?.(t,n)})())},onDragEnd:h,children:t.map((n,r)=>{const o=r===t.length-1?"small":"";return(0,l.jsx)("td",{className:o,style:{width:e.width??"auto"},children:n},r)})},n)})})]})}function i(e){return(0,l.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,l.jsx)("div",{children:e},t))})}},66247(e,t,n){n.r(t),n.d(t,{default:()=>C});var r=n(96540),o=n(75725),l=n(70447),s=n(85997),i=n(77481),a=n(61443),c=n(22022),d=n(14284),h=n(53459),u=n(62042),f=n(87361),x=n(40505),p=n(4412),j=n(61973),
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6247],{77481(e,t,n){n.d(t,{S:()=>i,X:()=>s});var r=n(96540),o=n(61443),l=n(74848);function s(e){const[t,n]=r.useState([]),s=(0,r.useRef)(-1),[i,a]=(0,r.useState)(-1),[c,d]=(0,r.useState)(-1);(0,r.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]);const h=()=>{s.current=-1,a(-1),d(-1)};return(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsx)("tr",{children:e.headers?.map((t,n)=>{const r=!!e.filter&&(e.filter.column??0)===n;let s=t;if(r){const n=e.filter,r=n.options.find(e=>e.value===n.value);null!=n.value&&r&&(s=`${t} (${r.label})`)}return(0,l.jsx)("th",{className:r?"table-filter-col":"",children:r?(0,l.jsx)(o.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:s}):t},n)})})}),(0,l.jsx)("tbody",{children:t.map((t,n)=>{const r=!!e.onRowDrag;return(0,l.jsx)("tr",{className:r?(i===n?"row-dragging":"")+(c===n?" row-drop-target":""):"",draggable:r,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{r&&(s.current=n,a(n),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!r||s.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(n))},onDrop:t=>{r&&(t.preventDefault(),(()=>{const t=s.current,n=c;h(),t<0||n<0||t===n||e.onRowDrag?.(t,n)})())},onDragEnd:h,children:t.map((n,r)=>{const o=r===t.length-1?"small":"";return(0,l.jsx)("td",{className:o,style:{width:e.width??"auto"},children:n},r)})},n)})})]})}function i(e){return(0,l.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,l.jsx)("div",{children:e},t))})}},66247(e,t,n){n.r(t),n.d(t,{default:()=>C});var r=n(96540),o=n(75725),l=n(70447),s=n(85997),i=n(77481),a=n(61443),c=n(22022),d=n(14284),h=n(53459),u=n(62042),f=n(87361),x=n(40505),p=n(4412),j=n(61973),m=n(34843),_=n(82893),w=n(21469),v=n(21499),g=n(64694),b=n(74848);function C(){const{t:e,i18n:t}=(0,c.Bd)(),n=(0,j.Zp)(),C=[e("编号"),e("路径"),e("过期小时"),e("token"),e("备注"),e("剩余时间(h)"),e("下载次数")],[k,S]=(0,r.useState)([]),[y,A]=(0,m.fp)(_.AG.prompt_card),D=async()=>{const e=await d.XO.get("get_share_file_list");if(e.code===h.m.Success){const t=e.data??[],n=Date.now();for(const e of t)try{if(null!=e.left_hour&&e.left_hour>0){const t=n-e.time_stamp,r=36e5*e.left_hour-t;e.show_left_hour=parseFloat((r/36e5).toFixed(2))}else e.show_left_hour=e.left_hour}catch(e){}S(t)}};(0,r.useEffect)(()=>{D()},[]);return(0,b.jsxs)("div",{className:"common-box ",style:{overflowY:"auto"},children:[(0,b.jsx)(p.aZ,{position:"right",children:(0,b.jsx)(s.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{n(-1)}})}),(0,b.jsx)(o.J,{widthPer:100,maxWidth:"60rem",children:(0,b.jsx)(l.uF,{self_title:(0,b.jsxs)("span",{className:" div-row ",children:[(0,b.jsx)("h2",{children:e("文件分享列表")}),(0,b.jsx)(s.rA,{icon:"info",title:e("提示"),onClick:()=>{let e=(0,b.jsx)("div",{children:"小时设置为-1或者不设置就没有过期时间"});A({open:!0,title:"信息",context_div:(0,b.jsx)("div",{children:e})})}})]}),titleCom:(0,b.jsxs)("div",{children:[(0,b.jsx)(s.rA,{icon:"add",title:e("添加"),onClick:()=>{S([...k,{note:"",path:""}])}}),(0,b.jsx)(s.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("set_share_file_list",k)).code===h.m.Success&&((0,u.SK)("保存成功"),D())}})]}),children:(0,b.jsx)(i.X,{headers:C,onRowDrag:(e,t)=>{S((0,g.TI)(k,e,t))},rows:k.map((t,n)=>{const r=[(0,b.jsx)("div",{children:n}),(0,b.jsx)(a.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,b.jsx)(a.Sm,{value:t.left_hour,handleInputChange:e=>{t.left_hour=parseFloat(e),t.time_stamp=Date.now()},no_border:!0}),(0,b.jsx)(a.Sm,{value:t.token,handleInputChange:e=>{t.token=e},no_border:!0}),(0,b.jsx)(a.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,b.jsx)("p",{children:t.show_left_hour}),(0,b.jsx)("p",{children:t.download_num}),(0,b.jsxs)("div",{children:[(0,b.jsx)(s.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{k.splice(e,1),S([...k])})(n)}),t.id&&(0,b.jsx)(s.rA,{icon:"content_copy",title:e("复制地址"),onClick:()=>{const e=(0,v.bi)(`${window.location.origin}${w.m.base_url}`,`${f.o.share}/${t.id}`);(0,x.lW)(e),(0,u.SK)(e)}}),t.id&&(0,b.jsx)(s.rA,{icon:"open_in_new",title:e("打开新页面"),onClick:()=>{const e=(0,v.bi)(`${window.location.origin}${w.m.base_url}`,`${f.o.share}/${t.id}`);window.open(e)}})]})];return r}),width:"10rem"})})})]})}}}]);
|