filecat 7.13.0 → 7.14.4
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/1142.97da60368424992aa345.js +1 -0
- package/build/dist/{2572.8fdddfebb4da2f29dbd8.js → 2572.7e7a9c31be5b678fae9f.js} +1 -1
- package/build/dist/{2674.2713dbaf7b4dbb6baa4c.js → 2674.57dca88c03c75c01a508.js} +1 -1
- package/build/dist/{3299.b85fad5623f990484bd9.js → 3299.937b009da6be833febd9.js} +1 -1
- package/build/dist/394.c8dd8740abe9c8e966be.js +1 -0
- package/build/dist/5308.7b9f32f5b110b7b30f98.js +1 -0
- package/build/dist/5516.30abe1f0cae2352028c1.js +1 -0
- package/build/dist/5744.236bce5b3b9188b4927f.js +1 -0
- package/build/dist/621.9b9a5312624393359a06.js +1 -0
- package/build/dist/6404.a2bcc23b592dbd6d719b.js +1 -0
- package/build/dist/7181.91fe39c64601170928c9.js +1 -0
- package/build/dist/735.80eacc3ca29a27059b14.js +1 -0
- package/build/dist/{7873.e3098bc6f510e5bea55f.js → 7873.f206780aa5e1d97ee481.js} +1 -1
- package/build/dist/8302.dacd7272ac7837764b5f.js +1 -0
- package/build/dist/8365.e876e79b3f2031b20183.js +1 -0
- package/build/dist/892.7c2341cc1d38845fceb9.js +1 -0
- package/build/dist/{9299.4c39ae6b03d41c516b1f.js → 9299.d5615865bd9ebd376923.js} +1 -1
- package/build/dist/dark.css +21 -28
- package/build/dist/google-dark.css +21 -28
- package/build/dist/google.css +4 -13
- package/build/dist/index.html +1 -1
- package/build/dist/main.393fb0005ec80a2b4828.js +2 -0
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/1142.bc43fae2e5e38d9359df.js +0 -1
- package/build/dist/394.a8337677ef993b923783.js +0 -1
- package/build/dist/4004.ca7e777145c700c5b186.js +0 -1
- package/build/dist/5308.d1e5ccb49396fc1b026d.js +0 -1
- package/build/dist/5516.88521f3a3c7101c46df3.js +0 -1
- package/build/dist/5744.0f8a0432b73b2eb0a7ff.js +0 -1
- package/build/dist/621.28f07b5c059e80331746.js +0 -1
- package/build/dist/6404.bcf224539211a7979990.js +0 -1
- package/build/dist/7181.640be82b27656082091e.js +0 -1
- package/build/dist/735.38718e61fe313f131a3e.js +0 -1
- package/build/dist/8302.c72a3767319d87419737.js +0 -1
- package/build/dist/892.a62727e6df6e80655ca7.js +0 -1
- package/build/dist/main.e03c0b1342da0ac83715.js +0 -2
- package/build/ripgrep/rg.exe +0 -0
- /package/build/dist/{main.e03c0b1342da0ac83715.js.LICENSE.txt → main.393fb0005ec80a2b4828.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[621,4935],{53002(e,t,n){n.r(t),n.d(t,{default:()=>m});var r=n(96540),s=n(34843),c=n(82893),l=n(85997),o=n(45907),a=n(74848);function i(e){const{name:t,dirty:n,loading:s,error:c,saving:i,on_save:u,on_close:d,children:f,extra:h}=e,m=(0,o.y)(),g=(0,r.useRef)(d),x=(0,r.useRef)(u),y=(0,r.useRef)(n);g.current=d,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)(l.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>u()}),(0,a.jsx)(l.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&&c&&(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:c}),!s&&!c&&f]})]})}var u=n(24935),d=n(99018),f=n(93245),h=n(23430);function m(){const[e,t]=(0,s.fp)(c.AG.excel_editor),[n,l]=(0,r.useState)(!1),[o,m]=(0,r.useState)(!1),g=(0,r.useRef)(),x=async()=>{if(!g.current)return!1;m(!0);try{return await g.current()}finally{m(!1)}},y=(0,r.useRef)(n);return y.current=n,(0,f.a)(h.nE.excel,()=>y.current,()=>x()),(0,a.jsx)(i,{name:e.name,dirty:n,loading:!1,error:"",saving:o,on_save:x,on_close:()=>{const n=e.close;t({}),n?.()},children:e.url&&(0,a.jsx)(u.default,{url:e.url,save_path:(0,d.Vi)(e.name??""),on_dirty:l,bind_save:e=>g.current=e})})}},24935(e,t,n){n.r(t),n.d(t,{default:()=>b});var r=n(96540),s=n(47049),c=n(8890);const l=e=>Math.round(7*e+5),o=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 d(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,c=e.getUTCMonth()+1,l=e.getUTCDate(),o="日一二三四五六"[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(c)).replace(/mm/g,n(c)).replace(/d(?!d)/g,String(l)).replace(/dd/g,n(l)).replace(/aaaa/g,`星期${o}`)}const f=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&&f(n)?{text:d(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&f(n)?{text:d(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 c=t.fills?.[s.fillId],l=t.fonts?.[s.fontId],o={};"solid"===c?.patternType&&(o.bg=i(c.fgColor,n)),o.color=i(l?.color,n),l?.bold&&(o.bold=!0),l?.italic&&(o.italic=!0),l?.size&&(o.fontSize=l.size),l?.name&&(o.fontFamily=l.name),l?.underline&&(o.underline=!0),l?.strike&&(o.strike=!0);const a=s.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(o.align=a.horizontal),a?.vertical&&(o.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(o.wrap=!0),a?.indent&&(o.indent=a.indent),Object.keys(o).length?o: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 c={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(c[s])return c[s];const l=t.numFmts;return l instanceof Map?l.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=[],c=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,l=new Map;let o;for(;o=c.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(o[2])?.[1];e&&l.set(o[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=l.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let c=0,a=0;r.rows.forEach((e,t)=>{e.size&&(c=Math.max(c,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=c;e++){const t=[],c=r.rows.get(e);for(let r=1;r<=a;r++){const l=c?.get(r),o=h(l,n,g(l,s));t.push(o.text);const a=m(l,s,n);o.runs&&(a?a.runs=o.runs:u.set(`${e-1}_${r-1}`,{runs:o.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const d=l(r.defaultColumnWidth??8.43),f=new Array(a).fill(d);r.columnDimensions?.forEach(e=>{const t=l(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<f.length&&(f[n-1]=t)});const x=o(r.defaultRowHeight??15),y=new Array(c).fill(x),p=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<y.length&&e.height&&(y[t-1]=o(e.height)),e.hidden&&t-1<c&&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:f,row_heights:y,hidden_rows:p,merges:v}})}var y=n(74848);function p(e){const{bytes:t,on_change:n,bind_save:l}=e,[o,i]=(0,r.useState)([]),[u,d]=(0,r.useState)(0),[,f]=(0,r.useState)(0),[h,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),p=(0,r.useRef)(null),[w,b]=(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 S=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{l(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,c=n+1;let l=s.rows.get(r);l||(l=new Map,s.rows.set(r,l));const o=l.get(c);null!==e&&""!==e?o?o.value=e:l.set(c,{row:r,col:c,value:e}):o&&(o.value=null)})})}),await(0,c.n)(n)}(t,o);return g.current=!1,n(!1),e})},[o,t,l,n]);const E=o[u],{col_x:C,row_y:j,total_w:k,total_h:M}=r.useMemo(()=>{const e=E?.col_widths??[],t=E?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(E?.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}},[E]),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||!C.length)return;const t=Math.max(0,N(C,e.scrollLeft)-1),n=Math.max(0,N(j,e.scrollTop)-1);b({c0:t,c1:Math.min(C.length-1,N(C,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(j.length-1,N(j,e.scrollTop+e.clientHeight)+2)})},[C,j]);(0,r.useEffect)(()=>{$()},[E,$]);if(h)return(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:h});if(!o.length)return(0,y.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const A=E?.values??[],F=(j.length,C.length,new Set);E.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||F.add(`${s}_${n}`)});const R=(e,t)=>{const n=A[e]?.[t];return(null==n||""===n)&&!E.styles.get(`${e}_${t}`)?.bg};return(0,y.jsxs)("div",{className:"xlsx-body",children:[(0,y.jsx)("div",{className:"xlsx-tabs",children:o.map((e,t)=>(0,y.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{d(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+C[n],top:0,width:C[n+1]-C[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+j[n],width:46,height:j[n+1]-j[n]},children:n+1}),Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const r=w.c0+t;if(F.has(`${n}_${r}`))return null;const s=E.merges.find(e=>e[0]===n&&e[1]===r),c=s?C[s[3]+1]-C[s[1]]:C[r+1]-C[r],l=s?j[s[2]+1]-j[s[0]]:j[n+1]-j[n];return(0,y.jsx)(v,{value:A[n]?.[r]??"",cell_style:E.styles.get(`${n}_${r}`),spillable:R(n,r+1),style:{left:46+C[r],top:24+j[n],width:c,height:l,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=o[u];r&&(r.values[e][t]=""===n?null:n,S(),f(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function v(e){const{value:t,cell_style:n,style:s,spillable:c,on_change:l}=e,[o,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),d=(0,r.useRef)(null);(0,r.useEffect)(()=>{o&&d.current&&(d.current.focus(),d.current.select())},[o]);const f=()=>{a(!1),i!==(t??"")&&l(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":""} ${c?"xlsx-cell--spill":""}`,style:{...s,...h,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:o?(0,y.jsx)("textarea",{ref:d,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:f,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),f())}}):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 b(e){const{url:t,save_path:n,on_dirty:s,bind_save:c}=e,[l,o]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,d]=(0,r.useState)(!0),[f,h]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return d(!0),i(""),h(!1),o(void 0),(0,w.PQ)(t).then(t=>e&&o(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&d(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(f)},[f,s]),(0,r.useEffect)(()=>{c?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,w.GB)(n,e);return t&&(o(e),h(!1)),t})},[n,c]),a?(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!l?(0,y.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,y.jsx)(p,{bytes:l,on_change:h,bind_save:e=>m.current=e})}},99018(e,t,n){n.d(t,{GB:()=>a,PQ:()=>o,Vi:()=>l});var r=n(14284),s=n(34289),c=n(62042);function l(e){return`${encodeURIComponent((0,s.GG)("file",(0,s.vX)()))}${e}`}async function o(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,c.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)}},93245(e,t,n){n.d(t,{a:()=>a});var r=n(96540),s=n(34843),c=n(82893),l=n(23430);const o=[{id:l.nE.ace,label:"文本编辑器(ace)"},{id:l.nE.md,label:"md编辑器"},{id:l.nE.mind,label:"思维导图编辑器"},{id:l.nE.draw,label:"draw编辑器"},{id:l.nE.timeline,label:"时间线编辑器"},{id:l.nE.image,label:"图片编辑器"},{id:l.nE.excel,label:"excel编辑器"}];function a(e,t,n,l=!1){const[o]=(0,s.fp)(c.AG.user_base_info),a=o?.user_data?.editor_auto_save,i=(0,r.useRef)(a);i.current=a;const u=(0,r.useRef)(t);u.current=t;const d=(0,r.useRef)(n);d.current=n,(0,r.useEffect)(()=>{if(l)return;const t=i.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const n=setInterval(()=>{u.current()&&d.current(!0)},1e3*t.interval);return()=>clearInterval(n)},[a,e,l])}n.d(t,["d",0,o])}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6404,8277],{35304(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>C});var a=n(96540),r=n(57889),l=(n(14284),n(62042)),o=n(22022),i=n(45602),c=(n(88781),n(86063));const d={classic:{backgroundColor:"#fafafa",lineColor:"#4d8f7f",lineWidth:2,root:{fillColor:"#4d8f7f",color:"#fff",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#fff",color:"#2f4f47",borderRadius:5,borderColor:"#4d8f7f",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#fff",color:"#3c3c3c",borderRadius:5,borderColor:"#a8d5c8",borderWidth:1,paddingX:12,paddingY:5}},dark:{backgroundColor:"#1f2226",lineColor:"#6b7c8c",lineWidth:1,root:{fillColor:"#3a4654",color:"#f2f4f6",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#2b323a",color:"#e6eaef",borderRadius:5,borderColor:"#4c5866",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#242a31",color:"#ccd3da",borderRadius:5,borderColor:"#3c454f",borderWidth:1,paddingX:12,paddingY:5}},simple:{backgroundColor:"#fff",lineColor:"#c8ccd0",lineWidth:1,root:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:10,paddingY:4},second:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3},node:{fillColor:"transparent",color:"#5f6368",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3}},colorful:{backgroundColor:"#fffdf6",lineColor:"#f2a65a",lineWidth:2,root:{fillColor:"#f2854a",color:"#fff",borderRadius:24,paddingX:20,paddingY:9},second:{fillColor:"#ffd66b",color:"#6b4a12",borderRadius:16,borderWidth:0,paddingX:14,paddingY:6},node:{fillColor:"#a8d8ea",color:"#1e3f4d",borderRadius:12,borderWidth:0,paddingX:12,paddingY:5}}};var s=n(34843),u=n(82893),m=n(61443),p=n(74848);function f(e){const[t,n]=(0,a.useState)(e.initValue||""),r=t=>{n(t),e.onChange(t)};return e.multiline?(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Z2,{placeholder:e.placeholder||"",rows:e.rows??5,value:t,handleInputChange:r})}):(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Sm,{placeholder:e.placeholder||"",value:t,handleInputChange:r})})}var E,b=n(75725),_=n(85997);n(30576);E=i.default,Object.entries(d).forEach(([e,t])=>{E.defineTheme?.(e,t)});const h=[{cmd:"INSERT_CHILD_NODE",icon:"account_tree",label:"添加子节点"},{cmd:"INSERT_NODE",icon:"subdirectory_arrow_right",label:"添加同级节点"},{cmd:"INSERT_PARENT_NODE",icon:"arrow_upward",label:"插入父节点"},{cmd:"CUT_NODE",icon:"content_cut",label:"剪切"},{cmd:"PASTE_NODE",icon:"content_paste",label:"粘贴"},{cmd:"REMOVE_NODE",icon:"delete",label:"删除节点"},{cmd:"INSERT_GROUP",icon:"add_circle_outline",label:"插入",children:[{cmd:"SET_NODE_ICON",icon:"emoji_emotions",label:"插入图标"},{cmd:"REMOVE_NODE_ICON",icon:"format_clear",label:"删除图标"},{cmd:"SET_NODE_NOTE",icon:"sticky_note_2",label:"节点备注"},{cmd:"REMOVE_NODE_NOTE",icon:"speaker_notes_off",label:"删除备注"},{cmd:"SET_NODE_TAG",icon:"sell",label:"节点标签"},{cmd:"REMOVE_NODE_TAG",icon:"label_off",label:"删除标签"},{cmd:"SET_NODE_HYPERLINK",icon:"link",label:"插入超链接"},{cmd:"REMOVE_NODE_HYPERLINK",icon:"link_off",label:"删除超链接"}]},{cmd:"ADD_GENERALIZATION",icon:"call_merge",label:"添加概要"},{cmd:"REMOVE_GENERALIZATION",icon:"call_split",label:"删除概要"}],N=[{value:"logicalStructure",label:"逻辑结构图"},{value:"mindMap",label:"思维导图"},{value:"organizationStructure",label:"组织结构图"},{value:"catalogOrganization",label:"目录组织图"},{value:"timeline",label:"时间轴(左)"},{value:"timeline2",label:"时间轴(下)"},{value:"timeline3",label:"时间轴(上)"},{value:"verticalTimeline",label:"时间轴(竖)"},{value:"fishbone",label:"鱼骨图"},{value:"rightFishbone",label:"鱼骨图(右)"}],v=[{value:"curve",label:"曲线"},{value:"straight",label:"直线"},{value:"direct",label:"直连"}],g=[{value:"default",label:"默认主题"},{value:"classic",label:"经典"},{value:"dark",label:"暗色"},{value:"simple",label:"极简"},{value:"colorful",label:"缤纷"}],x=i.default.iconList||[];function C(e){const{t}=(0,o.Bd)(),[n,d]=(0,a.useState)(!0),[m,E]=(0,a.useState)(""),[C,y]=(0,a.useState)(100),[D,T]=(0,a.useState)("default"),[,w]=(0,s.fp)(u.AG.prompt_card),[j,R]=(0,a.useState)("mindMap"),[S,k]=(0,a.useState)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),A=(0,a.useRef)(null),M=(0,a.useRef)(!1),Y=(0,a.useRef)({props:e});Y.current={props:e};const W=()=>{M.current||(M.current=!0,Y.current.props.on_dirty?.(!0))},P=async(e=!1)=>{if(!A.current)return e||(0,l.zN)(t("编辑器尚未就绪")),!1;const n=await Y.current.props.on_save((()=>{const e=A.current;return e?JSON.stringify(e.getData(!0)):""})(),e);return n&&(M.current=!1,Y.current.props.on_dirty?.(!1),Y.current.props.on_saved?.()),n};(0,a.useEffect)(()=>{e.register?.({save:P,is_dirty:()=>M.current})},[e.register]),(0,a.useEffect)(()=>{if(!I.current)return;if(!e.url&&void 0===e.data)return;let n=!1;const a=[];A.current?.destroy?.(),A.current=null,M.current=!1,d(!0),E("");const o=async e=>{if(n||!I.current)return;const r=e&&e.root?e:null,l=r?r.root:e??{data:{text:t("中心主题")}},o=new i.default({el:I.current,data:l,fit:!0,enableDblclickBackToRootNode:!0,enableShortcutOnlyWhenMouseInSvg:!0,autoMoveWhenMouseInEdgeOnDrag:!0,...c.k$});A.current=o,r&&o.setFullData(r),d(!1),T(o.getTheme?.()||"default"),R(o.getLayout?.()||"mindMap");window.requestAnimationFrame(()=>{n||(()=>{let e=!1;const t=window.setTimeout(()=>{n||(e=!0)},400);a.push(t),o.on("data_change",()=>{e&&(W(),y(O(o)))}),o.on("view_data_change",()=>{y(O(o))}),o.on("error",(e,t)=>{console.error("[mind]",e,t)}),y(O(o))})()})};return(async()=>{try{let t=null;if(void 0!==e.data)t=e.data;else{const a=await r.l.get(e.url);if(n)return;t=a}let a=null;if("string"==typeof t&&t.trim())try{a=JSON.parse(t)}catch{a=null}else t&&"object"==typeof t&&(a=t);a=(0,c.tW)(a),await o(a)}catch(e){n||(d(!1),E(t("加载思维导图失败")),(0,l.zN)(t("加载思维导图失败")))}})(),()=>{n=!0,a.forEach(e=>window.clearTimeout(e)),A.current?.destroy?.(),A.current=null}},[e.url,e.data]),(0,a.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),P())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]);const V=e=>{const t=A.current;if(!t)return;const n=Math.min(4,Math.max(.25,e));t.view.setScale(n),y(Math.round(100*n))},G={SET_NODE_NOTE:{title:"节点备注",placeholder:"请输入节点备注",get:e=>e.getData("note")||""},SET_NODE_TAG:{title:"节点标签",placeholder:"请输入节点标签,多个用逗号分隔",get:e=>(e.getData("tag")||[]).join(",")},SET_NODE_HYPERLINK:{title:"插入超链接",placeholder:"请输入链接地址",get:e=>e.getData("hyperlink")||""}};(0,a.useEffect)(()=>{if(!S)return;const e=()=>k(null),t=window.setTimeout(()=>{window.addEventListener("click",e),window.addEventListener("blur",e)},0);return()=>{window.clearTimeout(t),window.removeEventListener("click",e),window.removeEventListener("blur",e)}},[S]),(0,a.useEffect)(()=>{const e=L.current;if(!e)return;const t=e=>{const t=A.current?.renderer?.activeNodeList?.[0];t&&(e.preventDefault(),e.stopPropagation(),k({x:e.clientX,y:e.clientY,node:t}))};return e.addEventListener("contextmenu",t,!0),()=>e.removeEventListener("contextmenu",t,!0)},[]);const X=e=>e.map(e=>({v:e.cmd,r:(0,p.jsxs)("div",{className:"common-tag-center mind-menu-row",children:[(0,p.jsx)(_.In,{icon:e.icon,not_use_icon_style:!0}),(0,p.jsx)("span",{children:t(e.label)})]}),items:e.children?X(e.children):void 0})),H=e=>{const n=A.current,a=S;if(n&&a){if(k(null),"ADD_GENERALIZATION"===e||"REMOVE_GENERALIZATION"===e)return n.execCommand(e),void W();"SET_NODE_NOTE"!==e&&"SET_NODE_TAG"!==e&&"SET_NODE_HYPERLINK"!==e?"SET_NODE_ICON"!==e?e.startsWith("REMOVE_NODE_")?((e,t)=>{e&&("REMOVE_NODE_ICON"===t?A.current.execCommand("SET_NODE_ICON",e,[]):"REMOVE_NODE_NOTE"===t?A.current.execCommand("SET_NODE_NOTE",e,""):"REMOVE_NODE_TAG"===t?A.current.execCommand("SET_NODE_TAG",e,[]):"REMOVE_NODE_HYPERLINK"===t&&A.current.execCommand("SET_NODE_HYPERLINK",e,"",""),W())})(a.node,e):(n.execCommand(e,a.node),W()):(e=>{if(!e)return;const n=Array.isArray(e.getData("icon"))?e.getData("icon"):[];w({open:!0,title:t("插入图标"),context_div:(0,p.jsx)("div",{className:"prompt-icon-list",children:x.flatMap(t=>(t.list||[]).map((a,r)=>(0,p.jsx)("button",{type:"button",className:"prompt-icon-list__item",title:a.name,dangerouslySetInnerHTML:{__html:a.icon},onClick:()=>{A.current.execCommand("SET_NODE_ICON",e,[...n,`${t.type}_${a.name}`]),w({open:!1}),W()}},t.type+r)))}),cancel:()=>w({open:!1})})})(a.node):((e,n)=>{if(!e)return;const a=G[n],r=a.get(e);let l=r;w({open:!0,title:t(a.title),context_div:(0,p.jsx)(f,{initValue:r,placeholder:t(a.placeholder),multiline:!0,onChange:e=>l=e}),confirm:()=>{const t=l.trim();"SET_NODE_TAG"===n?A.current.execCommand(n,e,t.split(/[,,]/).map(e=>e.trim()).filter(Boolean)):"SET_NODE_HYPERLINK"===n?A.current.execCommand(n,e,t,t):A.current.execCommand(n,e,t),w({open:!1}),W()},cancel:()=>w({open:!1})})})(a.node,e)}};return(0,p.jsxs)("div",{className:"mind-wrap"+(e.fullscreen?" mind-wrap--full":""),children:[e.header,(0,p.jsxs)("div",{className:"mind-toolbar",children:[(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加子节点")+" (Tab)",onClick:()=>A.current?.execCommand?.("INSERT_CHILD_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"account_tree"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加同级节点")+" (Enter)",onClick:()=>A.current?.execCommand?.("INSERT_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"subdirectory_arrow_right"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("删除节点")+" (Delete)",onClick:()=>A.current?.execCommand?.("REMOVE_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"delete"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("撤销")+" (Ctrl+Z)",onClick:()=>A.current?.execCommand?.("BACK"),children:(0,p.jsx)("span",{className:"material-icons",children:"undo"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("重做")+" (Ctrl+Y)",onClick:()=>A.current?.execCommand?.("FORWARD"),children:(0,p.jsx)("span",{className:"material-icons",children:"redo"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsxs)("span",{className:"mind-toolbar__zoom",children:[C,"%"]}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("缩小"),onClick:()=>V(O(A.current)/100-.2),children:(0,p.jsx)("span",{className:"material-icons",children:"remove"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("放大"),onClick:()=>V(O(A.current)/100+.2),children:(0,p.jsx)("span",{className:"material-icons",children:"add"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("适应窗口"),onClick:()=>{A.current?.view?.fit?.(),y(O(A.current))},children:(0,p.jsx)("span",{className:"material-icons",children:"fit_screen"})})]}),(0,p.jsxs)("div",{className:"mind-toolbar mind-toolbar--sub",children:[(0,p.jsx)("select",{className:"mind-select",title:t("结构"),value:j,onChange:e=>{const t=e.target.value;A.current?.setLayout?.(t),R(t),W()},children:N.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsxs)("select",{className:"mind-select",title:t("连线风格"),defaultValue:"",onChange:e=>{const t=e.target.value;if(t){const e=A.current?.getCustomThemeConfig?.()||{};A.current?.setThemeConfig?.({...e,lineStyle:t}),W()}e.target.value=""},children:[(0,p.jsx)("option",{value:"",children:t("连线风格")}),v.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))]}),(0,p.jsx)("select",{className:"mind-select",title:t("主题"),value:D,onChange:e=>{const t=e.target.value;T(t),A.current?.setTheme?.(t),W()},children:g.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsx)("span",{className:"mind-toolbar__gap"})]}),(0,p.jsxs)("div",{className:"mind-canvas",ref:L,children:[(0,p.jsx)("div",{className:"mind-mount",ref:I}),n&&(0,p.jsx)("div",{className:"mind-mask",children:"Loading..."}),m&&(0,p.jsx)("div",{className:"mind-mask",children:m}),S&&(0,p.jsx)(b.rY,{click:()=>k(null),children:(0,p.jsx)(b.Pu,{x:S.x,y:S.y,items:X(h),click:e=>H(e)})})]})]})}function O(e){const t=e?.view?.getTransformData?.()?.state?.scale;return"number"==typeof t&&t>0?Math.round(100*t):100}},86063(e,t,n){"use strict";function a(e){return"smm-mind"===e}n.d(t,{Hn:()=>s,hj:()=>a,tW:()=>o});const r={mousewheelMoveStep:35,scaleRatio:.08};let l=null;function o(e){return e&&"object"==typeof e?e.data?.nodeData?i(e.data.nodeData):e.root&&"object"==typeof e.root?e.root.data?e:{...e,root:c(e.root)}:e.data&&"object"==typeof e.data?e:c(e):null}function i(e){return{data:{text:"string"==typeof e?.topic?e.topic:"string"==typeof e?.data?.text?e.data.text:""},children:Array.isArray(e?.children)?e.children.map(i):[]}}function c(e){return{data:{text:"string"==typeof e?.text?e.text:"",...e?.note?{note:e.note}:{}},children:Array.isArray(e?.children)?e.children.map(c):[]}}function d(e){e.stopPropagation()}async function s(e){const t=function(e){const t=e.trim();if(!t)return null;let n=null;try{n=JSON.parse(t)}catch{return null}return o(n)}(e),a=await(l||(l=Promise.all([Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8277)]).then(n.bind(n,45602)),n.e(8781).then(n.bind(n,88781))]).then(([e])=>e.default)),l);return{data:t,async mount(e,n){let l=!1;const o=await function(e,t){return new Promise(n=>{const a=()=>{t()?n(!1):e.isConnected&&e.clientWidth&&e.clientHeight?n(!0):window.setTimeout(a,16)};a()})}(e,()=>l);if(!o)return{destroy:()=>{},get_data:()=>null};const i=document.createElement("div");i.className="md-graph__mind-host",!1!==n?.release_wheel&&e.addEventListener("wheel",d,{capture:!0,passive:!0}),e.append(i);const c=new a({el:i,data:t?.root??t??{data:{text:""}},readonly:!n?.editable,fit:!0,...r});return t?.root&&c.setFullData(t),{destroy:()=>{l=!0,e.removeEventListener("wheel",d,{capture:!0}),c?.destroy?.()},get_data:()=>c?.getData?.(!1)}}}}n.d(t,["k$",0,r])},28277(){}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4091,7181],{48890(e,t,n){n.d(t,{Kw:()=>i,Tt:()=>r});var i=n(80952),r=(n(82327),n(1766),n(24854),n(90008),n(90846),n(40975),n(44286),n(30766),n(14973),n(69687),n(1234),n(47507),n(87268),n(34678),n(24522));const o=`https://gcore.jsdelivr.net/npm/ace-builds@${i.version}/src-min-noconflict/`;i.config.set("basePath",o),i.config.set("modePath",o),i.config.set("themePath",o),i.config.set("workerPath",o)},84091(e,t,n){n.r(t),n.d(t,{default:()=>l});var i=n(96540),r=(n(80952),n(48890)),o=n(34843),a=n(82893),s=n(78247),c=n(74848);function l(e){const t=(0,i.useRef)(null),[n,l]=(0,o.fp)(a.AG.user_base_info),d=n.user_data.theme?.includes("dark")?"cloud_editor_dark":"cloud9_day";return(0,i.useEffect)(()=>{const n=r.Kw.edit(t.current,{value:s.xK.get_value_temp(e.editor_id),showPrintMargin:!1,theme:`ace/theme/${d}`,mode:e.model??r.Tt.getModeForPath(e.name??"").mode,wrap:!1,highlightActiveLine:!1,fontSize:14,...e.options});return n.setOptions({}),n.container.addEventListener("wheel",function(e){e.preventDefault()}),n.focus(),n.on("change",function(t){e.on_change&&e.on_change()}),t.current=n,n.formatCode=()=>{const e=r.Kw.require("ace/ext/beautify"),n=t.current;n&&e.beautify(n.session)},s.xK.set_editor_temp(n,e.editor_id),()=>{s.xK.delete_editor_temp(e.editor_id),n.destroy()}},[]),(0,c.jsx)("div",{ref:t,style:{height:"100%",width:"100%"}})}},57181(e,t,n){n.r(t),n.d(t,{default:()=>_});var i=n(96540),r=n(85997),o=n(57952),a=n(34843),s=n(82893),c=n(78247),l=(n(62042),n(84091)),d=n(34289),u=n(34251),f=n(93245),m=n(23430),h=n(74848);function _(){const[e,t]=(0,a.fp)(s.AG.editorSetting),[n,_]=(0,i.useState)(!1),v=(0,i.useRef)(n);v.current=n;const[p,g]=(0,a.fp)(s.AG.fileShellShow),[x,w]=(0,a.fp)(s.AG.file_shell_hidden);async function b(){e.save&&n&&(await e.save(c.xK.get_editor_value()),c.xK.set_value_temp(""),_(!1))}const E=t=>{(t.ctrlKey||t.metaKey)&&"s"===t.key&&(t.preventDefault(),e.save&&n&&b())};return(0,i.useEffect)(()=>()=>{_(!1)},[e]),(0,i.useEffect)(()=>(document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}),[n,e]),(0,f.a)(m.nE.ace,()=>!!e.save&&v.current,()=>b()),e.open&&(0,h.jsxs)("div",{id:"editor-container",children:[(0,h.jsxs)(o.A,{ignore_tags:!0,left_children:[(0,h.jsx)(r.rA,{title:"取消",icon:"close",onClick:function(){c.xK.set_value_temp(""),t({open:!1,model:"",fileName:"",save:null}),e?.close?.()}},1),(0,h.jsx)("div",{children:e.fileName},2)],children:[e.menu_list&&e.menu_list,(e.can_format||(0,u.zr)(e.fileName))&&(0,h.jsx)(r.rA,{title:"格式化",icon:"data_object",onClick:function(){c.xK.get_editor()?.formatCode()}}),e.opt_shell&&(0,h.jsx)(r.rA,{icon:"terminal",title:"shell",onClick:function(){p.show?w(!x):g({show:!0,path:(0,d.GG)("file",(0,d.vX)())})}}),n&&(0,h.jsx)(r.rA,{title:"保存",icon:"save",onClick:b}),(0,h.jsx)("title",{children:e.fileName})]}),(0,h.jsx)(l.default,{name:e.fileName,model:e.model,on_change:function(){n||_(!0)}})]})}},93245(e,t,n){n.d(t,{a:()=>c});var i=n(96540),r=n(34843),o=n(82893),a=n(23430);const s=[{id:a.nE.ace,label:"文本编辑器(ace)"},{id:a.nE.md,label:"md编辑器"},{id:a.nE.mind,label:"思维导图编辑器"},{id:a.nE.draw,label:"draw编辑器"},{id:a.nE.timeline,label:"时间线编辑器"},{id:a.nE.image,label:"图片编辑器"},{id:a.nE.excel,label:"excel编辑器"}];function c(e,t,n,a=!1){const[s]=(0,r.fp)(o.AG.user_base_info),c=s?.user_data?.editor_auto_save,l=(0,i.useRef)(c);l.current=c;const d=(0,i.useRef)(t);d.current=t;const u=(0,i.useRef)(n);u.current=n,(0,i.useEffect)(()=>{if(a)return;const t=l.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const n=setInterval(()=>{d.current()&&u.current(!0)},1e3*t.interval);return()=>clearInterval(n)},[c,e,a])}n.d(t,["d",0,s])}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[735,6404,8277],{87943(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>b});var a=n(96540),r=n(34843),l=n(82893),o=n(14284),i=n(62042),c=n(53459),d=n(34289),s=n(22022),u=n(35304),m=n(93245),f=n(23430),p=n(74848);function b(){const[e,t]=(0,r.fp)(l.AG.mind_editor),[n,b]=(0,a.useState)(!1),{t:_}=(0,s.Bd)(),E=(0,a.useRef)(null),h=void 0!==e.code_source,N=()=>{n&&!window.confirm(_("有未保存的修改,确定要关闭吗?"))||(t({}),e?.close?.())},v=async(e=!1)=>{await(E.current?.save(e))},g=(0,a.useRef)(n);return g.current=n,(0,m.a)(f.nE.mind,()=>!h&&g.current,e=>v(e),h),(0,a.useEffect)(()=>{if(void 0===e.url&&void 0===e.code_source)return;const t=e=>{"Escape"===e.key&&(e.stopPropagation(),N())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e.url,e.code_source,n]),void 0!==e.url||h?(0,p.jsx)("div",{id:"mind-container",className:h?"mind-container--over":void 0,children:(0,p.jsx)("div",{className:"mind-context",children:(0,p.jsx)(u.default,{fullscreen:!0,reset_key:e.url??e.name,url:h?void 0:e.url,data:h?e.code_source:void 0,on_dirty:b,register:e=>{E.current=e},header:(0,p.jsxs)("div",{className:"mind-topbar",children:[(0,p.jsx)("span",{className:"material-icons mind-topbar__icon",children:"account_tree"}),(0,p.jsx)("span",{className:"mind-topbar__name",children:e.name}),(0,p.jsx)("span",{style:{flex:1}}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:_("保存")+" (Ctrl+S)",onClick:v,children:(0,p.jsx)("span",{className:"material-icons",children:"save"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:_("关闭"),onClick:N,children:(0,p.jsx)("span",{className:"material-icons",children:"close"})})]}),on_save:async(n,a)=>{if(h)return e.on_save_code?.(n),a||(0,i.SK)(_("保存成功")),t({}),!0;return(await o.$M.post(`save/${encodeURIComponent((0,d.GG)("file",(0,d.vX)()))}${e.name}`,{context:n})).code===c.m.Success&&(a||(0,i.SK)(_("保存成功")),!0)}})})}):null}},35304(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>C});var a=n(96540),r=n(57889),l=(n(14284),n(62042)),o=n(22022),i=n(45602),c=(n(88781),n(86063));const d={classic:{backgroundColor:"#fafafa",lineColor:"#4d8f7f",lineWidth:2,root:{fillColor:"#4d8f7f",color:"#fff",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#fff",color:"#2f4f47",borderRadius:5,borderColor:"#4d8f7f",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#fff",color:"#3c3c3c",borderRadius:5,borderColor:"#a8d5c8",borderWidth:1,paddingX:12,paddingY:5}},dark:{backgroundColor:"#1f2226",lineColor:"#6b7c8c",lineWidth:1,root:{fillColor:"#3a4654",color:"#f2f4f6",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#2b323a",color:"#e6eaef",borderRadius:5,borderColor:"#4c5866",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#242a31",color:"#ccd3da",borderRadius:5,borderColor:"#3c454f",borderWidth:1,paddingX:12,paddingY:5}},simple:{backgroundColor:"#fff",lineColor:"#c8ccd0",lineWidth:1,root:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:10,paddingY:4},second:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3},node:{fillColor:"transparent",color:"#5f6368",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3}},colorful:{backgroundColor:"#fffdf6",lineColor:"#f2a65a",lineWidth:2,root:{fillColor:"#f2854a",color:"#fff",borderRadius:24,paddingX:20,paddingY:9},second:{fillColor:"#ffd66b",color:"#6b4a12",borderRadius:16,borderWidth:0,paddingX:14,paddingY:6},node:{fillColor:"#a8d8ea",color:"#1e3f4d",borderRadius:12,borderWidth:0,paddingX:12,paddingY:5}}};var s=n(34843),u=n(82893),m=n(61443),f=n(74848);function p(e){const[t,n]=(0,a.useState)(e.initValue||""),r=t=>{n(t),e.onChange(t)};return e.multiline?(0,f.jsx)("div",{className:"prompt-input",children:(0,f.jsx)(m.Z2,{placeholder:e.placeholder||"",rows:e.rows??5,value:t,handleInputChange:r})}):(0,f.jsx)("div",{className:"prompt-input",children:(0,f.jsx)(m.Sm,{placeholder:e.placeholder||"",value:t,handleInputChange:r})})}var b,_=n(75725),E=n(85997);n(30576);b=i.default,Object.entries(d).forEach(([e,t])=>{b.defineTheme?.(e,t)});const h=[{cmd:"INSERT_CHILD_NODE",icon:"account_tree",label:"添加子节点"},{cmd:"INSERT_NODE",icon:"subdirectory_arrow_right",label:"添加同级节点"},{cmd:"INSERT_PARENT_NODE",icon:"arrow_upward",label:"插入父节点"},{cmd:"CUT_NODE",icon:"content_cut",label:"剪切"},{cmd:"PASTE_NODE",icon:"content_paste",label:"粘贴"},{cmd:"REMOVE_NODE",icon:"delete",label:"删除节点"},{cmd:"INSERT_GROUP",icon:"add_circle_outline",label:"插入",children:[{cmd:"SET_NODE_ICON",icon:"emoji_emotions",label:"插入图标"},{cmd:"REMOVE_NODE_ICON",icon:"format_clear",label:"删除图标"},{cmd:"SET_NODE_NOTE",icon:"sticky_note_2",label:"节点备注"},{cmd:"REMOVE_NODE_NOTE",icon:"speaker_notes_off",label:"删除备注"},{cmd:"SET_NODE_TAG",icon:"sell",label:"节点标签"},{cmd:"REMOVE_NODE_TAG",icon:"label_off",label:"删除标签"},{cmd:"SET_NODE_HYPERLINK",icon:"link",label:"插入超链接"},{cmd:"REMOVE_NODE_HYPERLINK",icon:"link_off",label:"删除超链接"}]},{cmd:"ADD_GENERALIZATION",icon:"call_merge",label:"添加概要"},{cmd:"REMOVE_GENERALIZATION",icon:"call_split",label:"删除概要"}],N=[{value:"logicalStructure",label:"逻辑结构图"},{value:"mindMap",label:"思维导图"},{value:"organizationStructure",label:"组织结构图"},{value:"catalogOrganization",label:"目录组织图"},{value:"timeline",label:"时间轴(左)"},{value:"timeline2",label:"时间轴(下)"},{value:"timeline3",label:"时间轴(上)"},{value:"verticalTimeline",label:"时间轴(竖)"},{value:"fishbone",label:"鱼骨图"},{value:"rightFishbone",label:"鱼骨图(右)"}],v=[{value:"curve",label:"曲线"},{value:"straight",label:"直线"},{value:"direct",label:"直连"}],g=[{value:"default",label:"默认主题"},{value:"classic",label:"经典"},{value:"dark",label:"暗色"},{value:"simple",label:"极简"},{value:"colorful",label:"缤纷"}],x=i.default.iconList||[];function C(e){const{t}=(0,o.Bd)(),[n,d]=(0,a.useState)(!0),[m,b]=(0,a.useState)(""),[C,O]=(0,a.useState)(100),[j,w]=(0,a.useState)("default"),[,D]=(0,s.fp)(u.AG.prompt_card),[R,T]=(0,a.useState)("mindMap"),[S,k]=(0,a.useState)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),A=(0,a.useRef)(null),M=(0,a.useRef)(!1),Y=(0,a.useRef)({props:e});Y.current={props:e};const W=()=>{M.current||(M.current=!0,Y.current.props.on_dirty?.(!0))},P=async(e=!1)=>{if(!A.current)return e||(0,l.zN)(t("编辑器尚未就绪")),!1;const n=await Y.current.props.on_save((()=>{const e=A.current;return e?JSON.stringify(e.getData(!0)):""})(),e);return n&&(M.current=!1,Y.current.props.on_dirty?.(!1),Y.current.props.on_saved?.()),n};(0,a.useEffect)(()=>{e.register?.({save:P,is_dirty:()=>M.current})},[e.register]),(0,a.useEffect)(()=>{if(!I.current)return;if(!e.url&&void 0===e.data)return;let n=!1;const a=[];A.current?.destroy?.(),A.current=null,M.current=!1,d(!0),b("");const o=async e=>{if(n||!I.current)return;const r=e&&e.root?e:null,l=r?r.root:e??{data:{text:t("中心主题")}},o=new i.default({el:I.current,data:l,fit:!0,enableDblclickBackToRootNode:!0,enableShortcutOnlyWhenMouseInSvg:!0,autoMoveWhenMouseInEdgeOnDrag:!0,...c.k$});A.current=o,r&&o.setFullData(r),d(!1),w(o.getTheme?.()||"default"),T(o.getLayout?.()||"mindMap");window.requestAnimationFrame(()=>{n||(()=>{let e=!1;const t=window.setTimeout(()=>{n||(e=!0)},400);a.push(t),o.on("data_change",()=>{e&&(W(),O(y(o)))}),o.on("view_data_change",()=>{O(y(o))}),o.on("error",(e,t)=>{console.error("[mind]",e,t)}),O(y(o))})()})};return(async()=>{try{let t=null;if(void 0!==e.data)t=e.data;else{const a=await r.l.get(e.url);if(n)return;t=a}let a=null;if("string"==typeof t&&t.trim())try{a=JSON.parse(t)}catch{a=null}else t&&"object"==typeof t&&(a=t);a=(0,c.tW)(a),await o(a)}catch(e){n||(d(!1),b(t("加载思维导图失败")),(0,l.zN)(t("加载思维导图失败")))}})(),()=>{n=!0,a.forEach(e=>window.clearTimeout(e)),A.current?.destroy?.(),A.current=null}},[e.url,e.data]),(0,a.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),P())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]);const G=e=>{const t=A.current;if(!t)return;const n=Math.min(4,Math.max(.25,e));t.view.setScale(n),O(Math.round(100*n))},V={SET_NODE_NOTE:{title:"节点备注",placeholder:"请输入节点备注",get:e=>e.getData("note")||""},SET_NODE_TAG:{title:"节点标签",placeholder:"请输入节点标签,多个用逗号分隔",get:e=>(e.getData("tag")||[]).join(",")},SET_NODE_HYPERLINK:{title:"插入超链接",placeholder:"请输入链接地址",get:e=>e.getData("hyperlink")||""}};(0,a.useEffect)(()=>{if(!S)return;const e=()=>k(null),t=window.setTimeout(()=>{window.addEventListener("click",e),window.addEventListener("blur",e)},0);return()=>{window.clearTimeout(t),window.removeEventListener("click",e),window.removeEventListener("blur",e)}},[S]),(0,a.useEffect)(()=>{const e=L.current;if(!e)return;const t=e=>{const t=A.current?.renderer?.activeNodeList?.[0];t&&(e.preventDefault(),e.stopPropagation(),k({x:e.clientX,y:e.clientY,node:t}))};return e.addEventListener("contextmenu",t,!0),()=>e.removeEventListener("contextmenu",t,!0)},[]);const X=e=>e.map(e=>({v:e.cmd,r:(0,f.jsxs)("div",{className:"common-tag-center mind-menu-row",children:[(0,f.jsx)(E.In,{icon:e.icon,not_use_icon_style:!0}),(0,f.jsx)("span",{children:t(e.label)})]}),items:e.children?X(e.children):void 0})),H=e=>{const n=A.current,a=S;if(n&&a){if(k(null),"ADD_GENERALIZATION"===e||"REMOVE_GENERALIZATION"===e)return n.execCommand(e),void W();"SET_NODE_NOTE"!==e&&"SET_NODE_TAG"!==e&&"SET_NODE_HYPERLINK"!==e?"SET_NODE_ICON"!==e?e.startsWith("REMOVE_NODE_")?((e,t)=>{e&&("REMOVE_NODE_ICON"===t?A.current.execCommand("SET_NODE_ICON",e,[]):"REMOVE_NODE_NOTE"===t?A.current.execCommand("SET_NODE_NOTE",e,""):"REMOVE_NODE_TAG"===t?A.current.execCommand("SET_NODE_TAG",e,[]):"REMOVE_NODE_HYPERLINK"===t&&A.current.execCommand("SET_NODE_HYPERLINK",e,"",""),W())})(a.node,e):(n.execCommand(e,a.node),W()):(e=>{if(!e)return;const n=Array.isArray(e.getData("icon"))?e.getData("icon"):[];D({open:!0,title:t("插入图标"),context_div:(0,f.jsx)("div",{className:"prompt-icon-list",children:x.flatMap(t=>(t.list||[]).map((a,r)=>(0,f.jsx)("button",{type:"button",className:"prompt-icon-list__item",title:a.name,dangerouslySetInnerHTML:{__html:a.icon},onClick:()=>{A.current.execCommand("SET_NODE_ICON",e,[...n,`${t.type}_${a.name}`]),D({open:!1}),W()}},t.type+r)))}),cancel:()=>D({open:!1})})})(a.node):((e,n)=>{if(!e)return;const a=V[n],r=a.get(e);let l=r;D({open:!0,title:t(a.title),context_div:(0,f.jsx)(p,{initValue:r,placeholder:t(a.placeholder),multiline:!0,onChange:e=>l=e}),confirm:()=>{const t=l.trim();"SET_NODE_TAG"===n?A.current.execCommand(n,e,t.split(/[,,]/).map(e=>e.trim()).filter(Boolean)):"SET_NODE_HYPERLINK"===n?A.current.execCommand(n,e,t,t):A.current.execCommand(n,e,t),D({open:!1}),W()},cancel:()=>D({open:!1})})})(a.node,e)}};return(0,f.jsxs)("div",{className:"mind-wrap"+(e.fullscreen?" mind-wrap--full":""),children:[e.header,(0,f.jsxs)("div",{className:"mind-toolbar",children:[(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("添加子节点")+" (Tab)",onClick:()=>A.current?.execCommand?.("INSERT_CHILD_NODE"),children:(0,f.jsx)("span",{className:"material-icons",children:"account_tree"})}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("添加同级节点")+" (Enter)",onClick:()=>A.current?.execCommand?.("INSERT_NODE"),children:(0,f.jsx)("span",{className:"material-icons",children:"subdirectory_arrow_right"})}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("删除节点")+" (Delete)",onClick:()=>A.current?.execCommand?.("REMOVE_NODE"),children:(0,f.jsx)("span",{className:"material-icons",children:"delete"})}),(0,f.jsx)("span",{className:"mind-toolbar__sep"}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("撤销")+" (Ctrl+Z)",onClick:()=>A.current?.execCommand?.("BACK"),children:(0,f.jsx)("span",{className:"material-icons",children:"undo"})}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("重做")+" (Ctrl+Y)",onClick:()=>A.current?.execCommand?.("FORWARD"),children:(0,f.jsx)("span",{className:"material-icons",children:"redo"})}),(0,f.jsx)("span",{className:"mind-toolbar__sep"}),(0,f.jsxs)("span",{className:"mind-toolbar__zoom",children:[C,"%"]}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("缩小"),onClick:()=>G(y(A.current)/100-.2),children:(0,f.jsx)("span",{className:"material-icons",children:"remove"})}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("放大"),onClick:()=>G(y(A.current)/100+.2),children:(0,f.jsx)("span",{className:"material-icons",children:"add"})}),(0,f.jsx)("button",{type:"button",className:"mind-btn",title:t("适应窗口"),onClick:()=>{A.current?.view?.fit?.(),O(y(A.current))},children:(0,f.jsx)("span",{className:"material-icons",children:"fit_screen"})})]}),(0,f.jsxs)("div",{className:"mind-toolbar mind-toolbar--sub",children:[(0,f.jsx)("select",{className:"mind-select",title:t("结构"),value:R,onChange:e=>{const t=e.target.value;A.current?.setLayout?.(t),T(t),W()},children:N.map(e=>(0,f.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,f.jsxs)("select",{className:"mind-select",title:t("连线风格"),defaultValue:"",onChange:e=>{const t=e.target.value;if(t){const e=A.current?.getCustomThemeConfig?.()||{};A.current?.setThemeConfig?.({...e,lineStyle:t}),W()}e.target.value=""},children:[(0,f.jsx)("option",{value:"",children:t("连线风格")}),v.map(e=>(0,f.jsx)("option",{value:e.value,children:t(e.label)},e.value))]}),(0,f.jsx)("select",{className:"mind-select",title:t("主题"),value:j,onChange:e=>{const t=e.target.value;w(t),A.current?.setTheme?.(t),W()},children:g.map(e=>(0,f.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,f.jsx)("span",{className:"mind-toolbar__gap"})]}),(0,f.jsxs)("div",{className:"mind-canvas",ref:L,children:[(0,f.jsx)("div",{className:"mind-mount",ref:I}),n&&(0,f.jsx)("div",{className:"mind-mask",children:"Loading..."}),m&&(0,f.jsx)("div",{className:"mind-mask",children:m}),S&&(0,f.jsx)(_.rY,{click:()=>k(null),children:(0,f.jsx)(_.Pu,{x:S.x,y:S.y,items:X(h),click:e=>H(e)})})]})]})}function y(e){const t=e?.view?.getTransformData?.()?.state?.scale;return"number"==typeof t&&t>0?Math.round(100*t):100}},86063(e,t,n){"use strict";function a(e){return"smm-mind"===e}n.d(t,{Hn:()=>s,hj:()=>a,tW:()=>o});const r={mousewheelMoveStep:35,scaleRatio:.08};let l=null;function o(e){return e&&"object"==typeof e?e.data?.nodeData?i(e.data.nodeData):e.root&&"object"==typeof e.root?e.root.data?e:{...e,root:c(e.root)}:e.data&&"object"==typeof e.data?e:c(e):null}function i(e){return{data:{text:"string"==typeof e?.topic?e.topic:"string"==typeof e?.data?.text?e.data.text:""},children:Array.isArray(e?.children)?e.children.map(i):[]}}function c(e){return{data:{text:"string"==typeof e?.text?e.text:"",...e?.note?{note:e.note}:{}},children:Array.isArray(e?.children)?e.children.map(c):[]}}function d(e){e.stopPropagation()}async function s(e){const t=function(e){const t=e.trim();if(!t)return null;let n=null;try{n=JSON.parse(t)}catch{return null}return o(n)}(e),a=await(l||(l=Promise.all([Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8277)]).then(n.bind(n,45602)),n.e(8781).then(n.bind(n,88781))]).then(([e])=>e.default)),l);return{data:t,async mount(e,n){let l=!1;const o=await function(e,t){return new Promise(n=>{const a=()=>{t()?n(!1):e.isConnected&&e.clientWidth&&e.clientHeight?n(!0):window.setTimeout(a,16)};a()})}(e,()=>l);if(!o)return{destroy:()=>{},get_data:()=>null};const i=document.createElement("div");i.className="md-graph__mind-host",!1!==n?.release_wheel&&e.addEventListener("wheel",d,{capture:!0,passive:!0}),e.append(i);const c=new a({el:i,data:t?.root??t??{data:{text:""}},readonly:!n?.editable,fit:!0,...r});return t?.root&&c.setFullData(t),{destroy:()=>{l=!0,e.removeEventListener("wheel",d,{capture:!0}),c?.destroy?.()},get_data:()=>c?.getData?.(!1)}}}}n.d(t,["k$",0,r])},93245(e,t,n){"use strict";n.d(t,{a:()=>c});var a=n(96540),r=n(34843),l=n(82893),o=n(23430);const i=[{id:o.nE.ace,label:"文本编辑器(ace)"},{id:o.nE.md,label:"md编辑器"},{id:o.nE.mind,label:"思维导图编辑器"},{id:o.nE.draw,label:"draw编辑器"},{id:o.nE.timeline,label:"时间线编辑器"},{id:o.nE.image,label:"图片编辑器"},{id:o.nE.excel,label:"excel编辑器"}];function c(e,t,n,o=!1){const[i]=(0,r.fp)(l.AG.user_base_info),c=i?.user_data?.editor_auto_save,d=(0,a.useRef)(c);d.current=c;const s=(0,a.useRef)(t);s.current=t;const u=(0,a.useRef)(n);u.current=n,(0,a.useEffect)(()=>{if(o)return;const t=d.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const n=setInterval(()=>{s.current()&&u.current(!0)},1e3*t.interval);return()=>clearInterval(n)},[c,e,o])}n.d(t,["d",0,i])},28277(){}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7873],{26559(e,n,t){var i=t(96540),o=t(34843),d=t(82893),r=t(76118),s=t(69918),a=t(8332),m=t(74848);const l=i.memo(function(e){const[n]=(0,o.fp)(d.AG.md_editor_last_context),[t]=(0,i.useState)(n?.trim()?n:a.$);return(0,m.jsx)("div",{className:e.className,ref:n=>e.setting&&(0,s.Ce)(n,e.setting),children:(0,m.jsx)("div",{className:"md-editor-scroll",children:(0,m.jsx)("div",{className:"md-editor-sheet",children:(0,m.jsx)(r.A,{value:t})})})})});t.d(n,["A",0,l])},8332(e,n,t){t.d(n,["$",0,'# 一级标题 Heading 1\n\n## 二级标题 Heading 2\n\n### 三级标题 Heading 3\n\n#### 四级标题 Heading 4\n\n##### 五级标题 Heading 5\n\n###### 六级标题 Heading 6\n\n这是一段普通正文,用来观察字体、字号、行高和文字颜色。中间可以包含 **加粗文字**、*斜体文字*、~~删除线~~、`行内代码` 以及 [一个链接](https://github.com/xiaobaidadada/filecat)。\n\n> 这是一段引用文字。\n> 引用通常用来强调摘录的内容,左侧一般会有一条竖线。\n\n- 无序列表第一项\n- 无序列表第二项\n - 嵌套的子项\n- 无序列表第三项\n\n1. 有序列表第一项\n2. 有序列表第二项\n3. 有序列表第三项\n\n```javascript\n// 代码块\nfunction greet(name) {\n console.log(`Hello, ${name}!`);\n}\ngreet("filecat");\n```\n\n| 列一 | 列二 | 列三 |\n| --- | --- | --- |\n| 内容 A | 内容 B | 内容 C |\n| 内容 D | 内容 E | 内容 F |\n\n---\n\n最后一段正文,用于观察段落之间的间距。\n',"V",0,'/* ===== md 主题 =====\n 选择器请从 .md-editor-sheet 开始写 —— 它是正文容器的类名,\n 编辑器与右侧预览用的是同一个类名,一处书写、两处生效。\n\n 注意:css 原样注入页面,不做任何改写。\n 写成 body、h1 这种全局选择器会真的作用到整个后台界面,不要这么写。\n\n 下面每一组都可以直接改,不需要的整段删掉即可。\n ============================================ */\n\n/* ---------- 正文 ---------- */\n.md-editor-sheet {\n font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; /* 字体 */\n font-size: 16px; /* 字号 */\n line-height: 1.7; /* 行高:1.7 约为字号的 1.7 倍 */\n color: #333333; /* 文字颜色 */\n}\n\n/* ---------- 整页底色 ----------\n 底色必须写在 .md-editor-scroll(滚动容器)上,不要写在 .md-editor-sheet。\n 纸张高度只有一屏,写在纸张上的底色长文档一滚就露底(上半截有色、下半截变回灰)。\n 深色主题尤其要注意:这一条不写,滚动时就会白一半黑一半。 */\n.md-editor-scroll {\n background: #ffffff;\n}\n\n/* ---------- 标题 h1 ~ h6 ---------- */\n.md-editor-sheet h1 {\n font-size: 2em; /* 相对正文字号的倍数 */\n font-weight: 600; /* 字重:400 常规 / 600 半粗 / 700 粗 */\n color: #1a1a1a;\n margin-top: 1.4em;\n margin-bottom: 0.6em;\n padding-bottom: 0.3em;\n border-bottom: 1px solid #eaecef; /* 标题下划线,不需要就删掉这行 */\n}\n.md-editor-sheet h2 { font-size: 1.5em; font-weight: 600; margin-top: 1.3em; margin-bottom: 0.6em; }\n.md-editor-sheet h3 { font-size: 1.25em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.5em; }\n.md-editor-sheet h4 { font-size: 1em; font-weight: 600; margin-top: 1.1em; margin-bottom: 0.5em; }\n.md-editor-sheet h5 { font-size: 0.9em; font-weight: 600; margin-top: 1em; margin-bottom: 0.5em; }\n.md-editor-sheet h6 { font-size: 0.85em; font-weight: 600; color: #6a737d; margin-top: 1em; margin-bottom: 0.5em; }\n\n/* ---------- 段落与行内元素 ---------- */\n.md-editor-sheet p {\n margin: 0 0 1em; /* 段落间距:上 右 下 左,下边距控制段与段的距离 */\n}\n.md-editor-sheet strong { font-weight: 600; } /* 加粗文字 */\n.md-editor-sheet em { font-style: italic; } /* 斜体文字 */\n.md-editor-sheet a { color: #0366d6; text-decoration: none; } /* 链接颜色;加下划线写 underline */\n.md-editor-sheet a:hover { text-decoration: underline; } /* 鼠标悬停时的链接样式 */\n.md-editor-sheet del { color: #999999; } /* 删除线文字 */\n\n/* ---------- 引用 ---------- */\n.md-editor-sheet blockquote {\n margin: 0 0 1em;\n padding: 0.4em 1em;\n color: #6a737d; /* 引用文字颜色 */\n border-left: 4px solid #dfe2e5; /* 左侧竖线,这是引用最明显的特征 */\n background: #f6f8fa; /* 引用底色,不需要就删掉 */\n}\n\n/* ---------- 代码 ---------- */\n.md-editor-sheet code {\n font-family: Consolas, Monaco, "Courier New", monospace; /* 等宽字体 */\n font-size: 0.88em;\n color: #476582; /* 行内代码文字色 */\n background: rgba(27, 31, 35, 0.05); /* 行内代码底色 */\n padding: 0.2em 0.4em;\n border-radius: 3px; /* 圆角 */\n}\n.md-editor-sheet pre {\n padding: 1em;\n overflow: auto; /* 内容太宽时出现横向滚动条 */\n background: #f6f8fa; /* 代码块底色 */\n border-radius: 6px;\n margin: 0 0 1em;\n}\n.md-editor-sheet pre code {\n background: transparent; /* 代码块里的 code 不要再叠一层底色 */\n padding: 0;\n}\n\n/* ---------- 列表 ---------- */\n.md-editor-sheet ul, .md-editor-sheet ol {\n padding-left: 2em; /* 缩进 */\n margin: 0 0 1em;\n}\n.md-editor-sheet li { margin: 0.25em 0; } /* 列表项之间的间距 */\n\n/* ---------- 表格 ---------- */\n.md-editor-sheet table {\n width: 100%;\n border-collapse: collapse; /* 相邻边框合并成一条线 */\n margin: 0 0 1em;\n}\n.md-editor-sheet table th, .md-editor-sheet table td {\n padding: 6px 13px;\n border: 1px solid #dfe2e5; /* 单元格边框 */\n}\n.md-editor-sheet table th {\n font-weight: 600;\n background: #f6f8fa; /* 表头底色 */\n}\n\n/* ---------- 分割线 ---------- */\n.md-editor-sheet hr {\n height: 1px; /* 线的粗细 */\n border: 0;\n background: #e1e4e8; /* 线的颜色 */\n margin: 1.6em 0;\n}\n\n/* ---------- 图片 ---------- */\n.md-editor-sheet img {\n max-width: 100%; /* 防止大图撑破版面 */\n border-radius: 4px;\n}\n'])},57873(e,n,t){t.r(n),t.d(n,{default:()=>F});var i=t(96540),o=t(22022),d=t(61973),r=t(85997),s=t(4412),a=t(75725),m=t(70447),l=t(61443),c=t(62042),h=t(78247),g=t(23430);const f=/^(\d+(?:\.\d+)?)(px|%|rem|em|vw|vh|ch)$/,u=/^\d+(\.\d+)?$/,p=/^\d+$/,x=/[\\/:*?"<>|\u0000-\u001f]/,
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7873],{26559(e,n,t){var i=t(96540),o=t(34843),d=t(82893),r=t(76118),s=t(69918),a=t(8332),m=t(74848);const l=i.memo(function(e){const[n]=(0,o.fp)(d.AG.md_editor_last_context),[t]=(0,i.useState)(n?.trim()?n:a.$);return(0,m.jsx)("div",{className:e.className,ref:n=>e.setting&&(0,s.Ce)(n,e.setting),children:(0,m.jsx)("div",{className:"md-editor-scroll",children:(0,m.jsx)("div",{className:"md-editor-sheet",children:(0,m.jsx)(r.A,{value:t})})})})});t.d(n,["A",0,l])},8332(e,n,t){t.d(n,["$",0,'# 一级标题 Heading 1\n\n## 二级标题 Heading 2\n\n### 三级标题 Heading 3\n\n#### 四级标题 Heading 4\n\n##### 五级标题 Heading 5\n\n###### 六级标题 Heading 6\n\n这是一段普通正文,用来观察字体、字号、行高和文字颜色。中间可以包含 **加粗文字**、*斜体文字*、~~删除线~~、`行内代码` 以及 [一个链接](https://github.com/xiaobaidadada/filecat)。\n\n> 这是一段引用文字。\n> 引用通常用来强调摘录的内容,左侧一般会有一条竖线。\n\n- 无序列表第一项\n- 无序列表第二项\n - 嵌套的子项\n- 无序列表第三项\n\n1. 有序列表第一项\n2. 有序列表第二项\n3. 有序列表第三项\n\n```javascript\n// 代码块\nfunction greet(name) {\n console.log(`Hello, ${name}!`);\n}\ngreet("filecat");\n```\n\n| 列一 | 列二 | 列三 |\n| --- | --- | --- |\n| 内容 A | 内容 B | 内容 C |\n| 内容 D | 内容 E | 内容 F |\n\n---\n\n最后一段正文,用于观察段落之间的间距。\n',"V",0,'/* ===== md 主题 =====\n 选择器请从 .md-editor-sheet 开始写 —— 它是正文容器的类名,\n 编辑器与右侧预览用的是同一个类名,一处书写、两处生效。\n\n 注意:css 原样注入页面,不做任何改写。\n 写成 body、h1 这种全局选择器会真的作用到整个后台界面,不要这么写。\n\n 下面每一组都可以直接改,不需要的整段删掉即可。\n ============================================ */\n\n/* ---------- 正文 ---------- */\n.md-editor-sheet {\n font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; /* 字体 */\n font-size: 16px; /* 字号 */\n line-height: 1.7; /* 行高:1.7 约为字号的 1.7 倍 */\n color: #333333; /* 文字颜色 */\n}\n\n/* ---------- 整页底色 ----------\n 底色必须写在 .md-editor-scroll(滚动容器)上,不要写在 .md-editor-sheet。\n 纸张高度只有一屏,写在纸张上的底色长文档一滚就露底(上半截有色、下半截变回灰)。\n 深色主题尤其要注意:这一条不写,滚动时就会白一半黑一半。 */\n.md-editor-scroll {\n background: #ffffff;\n}\n\n/* ---------- 标题 h1 ~ h6 ---------- */\n.md-editor-sheet h1 {\n font-size: 2em; /* 相对正文字号的倍数 */\n font-weight: 600; /* 字重:400 常规 / 600 半粗 / 700 粗 */\n color: #1a1a1a;\n margin-top: 1.4em;\n margin-bottom: 0.6em;\n padding-bottom: 0.3em;\n border-bottom: 1px solid #eaecef; /* 标题下划线,不需要就删掉这行 */\n}\n.md-editor-sheet h2 { font-size: 1.5em; font-weight: 600; margin-top: 1.3em; margin-bottom: 0.6em; }\n.md-editor-sheet h3 { font-size: 1.25em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.5em; }\n.md-editor-sheet h4 { font-size: 1em; font-weight: 600; margin-top: 1.1em; margin-bottom: 0.5em; }\n.md-editor-sheet h5 { font-size: 0.9em; font-weight: 600; margin-top: 1em; margin-bottom: 0.5em; }\n.md-editor-sheet h6 { font-size: 0.85em; font-weight: 600; color: #6a737d; margin-top: 1em; margin-bottom: 0.5em; }\n\n/* ---------- 段落与行内元素 ---------- */\n.md-editor-sheet p {\n margin: 0 0 1em; /* 段落间距:上 右 下 左,下边距控制段与段的距离 */\n}\n.md-editor-sheet strong { font-weight: 600; } /* 加粗文字 */\n.md-editor-sheet em { font-style: italic; } /* 斜体文字 */\n.md-editor-sheet a { color: #0366d6; text-decoration: none; } /* 链接颜色;加下划线写 underline */\n.md-editor-sheet a:hover { text-decoration: underline; } /* 鼠标悬停时的链接样式 */\n.md-editor-sheet del { color: #999999; } /* 删除线文字 */\n\n/* ---------- 引用 ---------- */\n.md-editor-sheet blockquote {\n margin: 0 0 1em;\n padding: 0.4em 1em;\n color: #6a737d; /* 引用文字颜色 */\n border-left: 4px solid #dfe2e5; /* 左侧竖线,这是引用最明显的特征 */\n background: #f6f8fa; /* 引用底色,不需要就删掉 */\n}\n\n/* ---------- 代码 ---------- */\n.md-editor-sheet code {\n font-family: Consolas, Monaco, "Courier New", monospace; /* 等宽字体 */\n font-size: 0.88em;\n color: #476582; /* 行内代码文字色 */\n background: rgba(27, 31, 35, 0.05); /* 行内代码底色 */\n padding: 0.2em 0.4em;\n border-radius: 3px; /* 圆角 */\n}\n.md-editor-sheet pre {\n padding: 1em;\n overflow: auto; /* 内容太宽时出现横向滚动条 */\n background: #f6f8fa; /* 代码块底色 */\n border-radius: 6px;\n margin: 0 0 1em;\n}\n.md-editor-sheet pre code {\n background: transparent; /* 代码块里的 code 不要再叠一层底色 */\n padding: 0;\n}\n\n/* ---------- 列表 ---------- */\n.md-editor-sheet ul, .md-editor-sheet ol {\n padding-left: 2em; /* 缩进 */\n margin: 0 0 1em;\n}\n.md-editor-sheet li { margin: 0.25em 0; } /* 列表项之间的间距 */\n\n/* ---------- 表格 ---------- */\n.md-editor-sheet table {\n width: 100%;\n border-collapse: collapse; /* 相邻边框合并成一条线 */\n margin: 0 0 1em;\n}\n.md-editor-sheet table th, .md-editor-sheet table td {\n padding: 6px 13px;\n border: 1px solid #dfe2e5; /* 单元格边框 */\n}\n.md-editor-sheet table th {\n font-weight: 600;\n background: #f6f8fa; /* 表头底色 */\n}\n\n/* ---------- 分割线 ---------- */\n.md-editor-sheet hr {\n height: 1px; /* 线的粗细 */\n border: 0;\n background: #e1e4e8; /* 线的颜色 */\n margin: 1.6em 0;\n}\n\n/* ---------- 图片 ---------- */\n.md-editor-sheet img {\n max-width: 100%; /* 防止大图撑破版面 */\n border-radius: 4px;\n}\n'])},57873(e,n,t){t.r(n),t.d(n,{default:()=>F});var i=t(96540),o=t(22022),d=t(61973),r=t(85997),s=t(4412),a=t(75725),m=t(70447),l=t(61443),c=t(62042),h=t(78247),g=t(23430);const f=/^(\d+(?:\.\d+)?)(px|%|rem|em|vw|vh|ch)$/,u=/^\d+(\.\d+)?$/,p=/^\d+$/,x=/[\\/:*?"<>|\u0000-\u001f]/,b={size(e,n=!1){const t=String(e??"").trim();if(!t)return null;let i;if(n&&u.test(t))i=t;else{const e=f.exec(t);if(!e)return null;i=e[1]}const o=Number(i);return Number.isFinite(o)&&o>0&&o<=1e4?t:null},uint(e){const n=String(e??"").trim();return p.test(n)?Number(n):null},filename(e,n=!0){const t=String(e??"").trim();return""===t?n?"":null:"."===t||".."===t||x.test(t)||t.length>64?null:t}},_={content_max_width:b.size,content_padding:b.size,font_size:b.size,line_height:e=>b.size(e,!0),theme:b.filename};var k=t(87361),j=t(69918),y=t(26559),v=t(96763),w=t(45907),z=t(34843),C=t(82893),S=t(74848);const N=[{key:"content_max_width",label:"正文最大宽度"},{key:"content_padding",label:"正文左右边距"},{key:"font_size",label:"正文字号"},{key:"line_height",label:"行高"}];function F(){const{t:e}=(0,o.Bd)(),n=(0,d.Zp)(),{check_user_auth:t}=(0,h.MH)(),f=(0,w.y)(),u=t(g.oV.md_editor_setting),[,p]=(0,z.fp)(C.AG.md_editor_setting),[,x]=(0,z.fp)(C.AG.md_theme_css),[b,F]=(0,i.useState)({}),[A,$]=(0,i.useState)(!0),[G,H]=(0,i.useState)(!1),[P,E]=(0,i.useState)([]),[B,I]=(0,i.useState)(j.FG.theme);(0,i.useEffect)(()=>{Promise.all([(0,j.gC)(),(0,v.Kz)()]).then(([e,n])=>{const t={};N.forEach(n=>t[n.key]=String(e[n.key]??"")),F(t),I(e.theme??j.FG.theme),E(n)}).finally(()=>$(!1))},[]);const K=P.find(e=>e.id===B),V=e=>{const n=_[e]((b[e]??"").trim());return null===n?j.FG[e]:n};return(0,S.jsxs)("div",{children:[(0,S.jsx)(s.aZ,{position:"right",children:(0,S.jsx)(r.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>n(-1)})}),(0,S.jsx)(a.jW,{isFull:!0,more:!0,children:(0,S.jsx)(a.NN,{children:(0,S.jsx)(a.xh,{children:(0,S.jsxs)(a.fI,{children:[(0,S.jsx)(a.VP,{widthPer:33,maxWidth:"30rem",children:(0,S.jsx)(m.Zp,{title:e("编辑器设置"),titleCom:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.C3,{text:e("恢复默认"),clickFun:()=>{const e={};N.forEach(n=>e[n.key]=String(j.FG[n.key])),F(e)}}),u&&(0,S.jsx)(r.$n,{text:e(G?"保存中":"保存"),clickFun:()=>{G||(async()=>{const n={theme:B};for(const t of N){const i=(b[t.key]??"").trim(),o=_[t.key](i);if(null===o)return void(0,c.zN)(`${e(t.label)}: ${e("请输入合法的 CSS 值,例如 10px、3rem、80%")}`);n[t.key]=o}H(!0);try{const t=await(0,j.fy)(n);if(t){(0,c.SK)(e("保存成功"));const n={};N.forEach(e=>n[e.key]=String(t[e.key]??"")),F(n),I(t.theme??j.FG.theme),p({...t}),(0,v.sO)().then(x)}else(0,c.zN)(e("保存失败"))}finally{H(!1)}})()}})]}),children:A?(0,S.jsxs)("div",{className:"common-box common-box-center",children:[e("加载中"),"..."]}):(0,S.jsxs)("div",{className:"md-setting-form",children:[(0,S.jsx)(l.BC,{vertical:!0,label:e("主题"),children:(0,S.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem"},children:[(0,S.jsx)(l.l6,{value:B,onChange:e=>I(e),disabled:!u,options:[{title:e("不使用主题"),value:""},...P.map(e=>({title:e.id,value:e.id}))]}),(0,S.jsx)(r.rA,{icon:"add",title:e("新建主题"),onClick:()=>n(k.o.md_theme_editor_page)}),(0,S.jsx)(r.rA,{icon:"edit",title:e("编辑主题"),onClick:()=>n(`${k.o.md_theme_editor_page}?id=${encodeURIComponent(B)}`)}),K&&(0,S.jsx)(r.rA,{icon:"delete",title:e("删除主题"),onClick:()=>{return n=K,void f({sub_title:e("确认删除这个主题吗?"),confirm_fun:async()=>{await(0,v._8)(n.id)?((0,c.SK)(e("删除成功")),E(await(0,v.Kz)()),B===n.id&&I(j.FG.theme)):(0,c.zN)(e("删除失败"))}});var n}})]})}),N.map(n=>(0,S.jsx)(l.BC,{vertical:!0,label:e(n.label),children:(0,S.jsx)(l.Sm,{disabled:!u,placeholder:String(j.FG[n.key]),value:b[n.key]??"",handleInputChange:e=>F(t=>({...t,[n.key]:e}))})},n.key)),!u&&(0,S.jsx)("p",{className:"md-editor-setting-page__desc",children:e("nprmtp")})]})})}),(0,S.jsx)(a.VP,{widthPer:50,maxWidth:"60rem",children:(0,S.jsx)(m.Zp,{title:e("预览"),children:(0,S.jsx)(y.A,{className:"md-editor-setting-page__preview",setting:{content_max_width:V("content_max_width"),content_padding:V("content_padding"),font_size:V("font_size"),line_height:V("line_height")}})})})]})})})})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8302],{83277(e,t,n){n.d(t,{$j:()=>a,Lv:()=>s});class s{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,t){if(!e||!t?.length)return e;for(const n of t)if(n.value===e)return n.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const n of t)if(n.value===e)return!0;return!1}}const o=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function a(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}n.d(t,["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,o])},77481(e,t,n){n.d(t,{S:()=>r,X:()=>i});var s=n(96540),o=n(61443),a=n(74848);function i(e){const[t,n]=s.useState([]),i=(0,s.useRef)(-1),[r,l]=(0,s.useState)(-1),[c,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 m=()=>{i.current=-1,l(-1),d(-1)};return(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:e.headers?.map((t,n)=>{const s=!!e.filter&&(e.filter.column??0)===n;let i=t;if(s){const n=e.filter,s=n.options.find(e=>e.value===n.value);null!=n.value&&s&&(i=`${t} (${s.label})`)}return(0,a.jsx)("th",{className:s?"table-filter-col":"",children:s?(0,a.jsx)(o.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:i}):t},n)})})}),(0,a.jsx)("tbody",{children:t.map((t,n)=>{const s=!!e.onRowDrag;return(0,a.jsx)("tr",{className:s?(r===n?"row-dragging":"")+(c===n?" row-drop-target":""):"",draggable:s,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{s&&(i.current=n,l(n),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!s||i.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(n))},onDrop:t=>{s&&(t.preventDefault(),(()=>{const t=i.current,n=c;m(),t<0||n<0||t===n||e.onRowDrag?.(t,n)})())},onDragEnd:m,children:t.map((n,s)=>{const o=s===t.length-1?"small":"";return(0,a.jsx)("td",{className:o,style:{width:e.width??"auto"},children:n},s)})},n)})})]})}function r(e){return(0,a.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,a.jsx)("div",{children:e},t))})}},29591(e,t,n){n.r(t),n.d(t,{default:()=>N});var s=n(22022),o=n(96540),a=n(85997),i=n(4412),r=n(34843),l=n(82893),c=n(75725),d=n(77481),m=n(61443),p=n(70447),u=n(34299),_=n(74848);var h=n(14284),x=n(53459),g=n(62042),v=n(7523),j=n(78247),f=n(23430),y=n(61973),w=n(14944),C=n(92275),b=n(88815),A=n(64694),k=n(45907),S=n(12721),I=n(24659),K=n(83277);function N(){const{t:e}=(0,s.Bd)(),{initUserInfo:t}=(0,o.useContext)(v.F),n=[e("编号"),e("url"),e("是否开启"),e("key"),e("默认model"),e("更多属性"),e("备注")],N=[e("编号"),e("本地目录"),e("自动加载"),e("备注")],[$,O]=(0,o.useState)([]),[L,M]=(0,o.useState)({}),[P,X]=(0,o.useState)([]),[D,T]=(0,o.useState)([]),[H,R]=(0,o.useState)(null),q=(0,o.useRef)(),F=(0,o.useRef)(!1),V=(0,o.useRef)(!1),[E,W]=(0,o.useState)([]),[Y,B]=(0,o.useState)(!1),[G,J]=(0,o.useState)({}),[z,U]=(0,r.fp)(l.AG.prompt_card),[Z,Q]=(0,r.fp)(l.AG.user_base_info),[ee,te]=(0,o.useState)(!1),ne=D.filter(e=>"http"!==(e.transport??"stdio")),se=D.filter(e=>"http"===e.transport),oe=[e("编号"),e("名称"),e("是否开启"),e("状态"),"command","args","cwd",e("tools|env"),e("备注")],ae=[e("编号"),e("名称"),e("是否开启"),e("状态"),e("endpoint"),e("tools|headers"),e("备注")],ie=[e("编号"),e("提示词"),e("LLM编辑开关"),e("llm_pmt"),e("编辑规则"),e("备注")],[re,le]=(0,o.useState)([]),[ce,de]=(0,o.useState)(!1),me=function(){const[e,t]=(0,r.fp)(l.AG.prompt_card);return e=>{t({open:!0,title:"信息",context_div:(0,_.jsx)("div",{children:(0,_.jsx)(u.default,{context:e})})})}}(),{check_user_auth:pe}=(0,j.MH)(),[ue,_e]=(0,r.fp)(l.AG.editorSetting),he=(0,y.Zp)(),xe=(0,k.y)(),ge=(0,I.K)(),ve=async()=>{const e=await h.jV.get("docs_on_get");e.code===x.m.Success&&te(e.data)};(0,o.useEffect)(()=>{(async()=>{const e=await h.XO.get("ai_agent_setting");e.code===x.m.Success&&O(e.data.models);const t=await h.XO.get("ai_agent_global_setting");t.code===x.m.Success&&M(t.data??{}),await w.ws.addMsg(C.HK.ai_load_info,e=>{R(e.context)});const n=await w.ws.sendData(C.HK.ai_load_info,{});n?.context&&R(n.context);const s=await h.XO.get("ai_docs_setting");s.code===x.m.Success&&(q.current=s.data.param,s.data.list?.length&&X(s.data.list));const o=await h.XO.get("ai_mcp_setting");o.code===x.m.Success&&T(o.data.list??[]),await Ae(),ve();const a=await h.XO.get("ai_system_prompts");a.code===x.m.Success&&le(a.data??[]);const i=await h.XO.get("ai_long_term_memory_setting");i.code===x.m.Success&&de(i.data?.open??!1)})()},[]),(0,o.useEffect)(()=>{w.ws.addMsg(C.HK.mcp_status,e=>{const t=e.context??{},n={};for(const e of t.status??[])n[e.index]={state:e.state,error:e.error,tool_count:e.tool_count};J(n),t.done&&Ae()})},[]);const je=(e="stdio")=>{const t="http"===e?{name:"",open:!1,note:"",transport:"http",endpoint:"",headers:"",stream:!1,timeout_ms:1e4}:{name:"",open:!1,command:"",args:"",cwd:"",env:"",note:"",transport:"stdio",timeout_ms:1e4};T([...D,t]),F.current=!0},fe=e=>{const t=D.indexOf(e);t<0||(D.splice(t,1),T([...D]),F.current=!0)},ye=e=>{T([...D,{...e,open:!1}]),F.current=!0},we=async e=>{for(let e=0;e<$.length;e++)$[e].index=e;(await h.XO.post("ai_agent_setting/save",{models:e??$})).code===x.m.Success&&(0,g.SK)("保存成功")},Ce=async e=>{(await h.XO.post("ai_agent_global_setting/save",e??L)).code===x.m.Success&&(0,g.SK)("保存成功")},be=async e=>{for(let e=0;e<D.length;e++)D[e].index=e;(await h.XO.post("ai_mcp_setting/save",{list:e??D})).code===x.m.Success&&((0,g.SK)("保存成功"),F.current=!1,w.ws.sendData(C.HK.mcp_reload,{}))},Ae=async()=>{const e=await h.XO.get("ai_mcp_tools");return e.code===x.m.Success?(W(e.data??[]),e.data??[]):[]},ke=async e=>{B(!0);try{const t=await h.XO.post("ai_mcp_tools/reload",{index:e});if(t.code===x.m.Success)return await Ae(),(0,g.SK)("MCP工具加载成功"),t.data??null}finally{B(!1)}return null},Se=async(t,n,s,o)=>{const a=o??E.find(e=>e.index===n)??{index:n,key:`${n}`,name:t.name??"",note:t.note,transport:t.transport??"stdio",open:!!t.open,loaded:!1,tool_count:0,tools:[]},i=(a.tools??[]).map(t=>({id:t.runtime_name,title:t.tool_name,subtitle:t.description||e("无描述"),detail:t.display_name,meta:t.runtime_name}));U({open:!0,title:`${t.name||t.note||n} MCP工具`,context_div:(0,_.jsx)(S.O,{title:`${t.name||t.note||n} MCP工具`,subtitle:`${a.transport??"stdio"} | ${a.open?e("是"):e("否")} | ${a.loaded?"loaded":"idle"} | ${a.tool_count} tools`,pages:i,initialPageId:s,onRefresh:async()=>{const e=await ke(n);e&&await Se(t,n,s,e)},renderPage:t=>{if(!t)return(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")});const n=a.tools?.find(e=>e.runtime_name===t.id);return n?(0,_.jsxs)("div",{className:"prompt-switch-page__detail",children:[(0,_.jsx)("div",{className:"prompt-switch-page__detail-title",children:n.display_name}),(0,_.jsx)("div",{className:"prompt-switch-page__detail-desc",children:n.description||e("无描述")}),(0,_.jsxs)("div",{className:"prompt-switch-page__detail-row",children:[(0,_.jsx)("strong",{children:"runtime:"})," ",n.runtime_name]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("strong",{children:"schema:"}),(0,_.jsx)("pre",{className:"prompt-switch-page__schema",children:JSON.stringify(n.input_schema??{},null,2)})]})]}):(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")})}}),cancel:()=>U({open:!1})})},Ie=t=>{const n=G[t];let s=n?.state,o=n?.error,a=n?.tool_count;if(!s){const e=E.find(e=>e.index===t);s=e?.state,o=e?.error,a=e?.tool_count}switch(s){case"loading":return(0,_.jsx)(p.fq,{loading:!0,text:e("加载中")});case"success":return(0,_.jsx)(p.fq,{success:!0,text:`${a??0} ${e("个工具")}`});case"failed":return(0,_.jsx)("span",{title:o??e("加载失败"),children:(0,_.jsx)(p.fq,{success:!1,text:e("加载失败")})});default:return(0,_.jsx)(p.fq,{text:e("未加载")})}},Ke=async e=>{for(let e=0;e<$.length;e++)$[e].index=e;let t={list:P,docs_update_tag:V.current};null!=e&&(t={param:e}),V.current=!1;(await h.XO.post("ai_docs_setting_save",t)).code===x.m.Success&&(0,g.SK)("保存成功")},Ne=async()=>{for(let e=0;e<re.length;e++)re[e].index=e;(await h.XO.post("ai_system_prompts/save",{list:re})).code===x.m.Success&&(0,g.SK)("保存成功")};return(0,_.jsxs)("div",{children:[(0,_.jsx)(i.aZ,{position:"right",children:pe(f.oV.ai_agent_setting)&&(0,_.jsx)(a.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{he(-1)}})}),(0,_.jsx)(c.jW,{isFull:!0,more:!0,children:(0,_.jsx)(c.NN,{children:(0,_.jsxs)(c.xh,{children:[(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:100,maxWidth:"130rem",children:(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("供应商设置")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{me('\n1. Only OpenAI-style AI APIs are supported. Fill in the FULL endpoint path (not just the domain), e.g. https://ark.cn-beijing.volces.com/api/v3/chat/completions\n2. The longer the conversation history, the more expensive the LLM token cost. Currently, there is no long-term memory simplification capability. You can set the system prompt to make the AI answer more concisely to save tokens\n3. When writing the model request parameter JSON, you can only write JSON in it, to configure the attributes supported by OpenAI-style AI, such as temperature, thinking (Doubao\'s deep thinking toggle), etc.\n4. You can enable "stream": true in the model request parameters to improve response speed.\n5. Deep thinking currently affects output speed. It is recommended to set { "thinking" : { "type":"disabled" } } to disable it (Doubao example).\n6. To use the AI feature to query server information, the AI needs to be able to know some commands. You need to first set command permissions for the user in user settings. It is recommended to set * to allow all commands, and then set the dangerous commands that are not allowed to be executed in the settings\n7. The model type and Become Tool are now both configured in "More Attributes → Extra Parameter Settings" using request_type / tool_mode (comments are already provided in the editor).\n8. After becoming a tool, the model will be loaded as a tool, enabling different models to serve as different roles; please do not set both it and "Enabled" to true at the same time.\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"short_text",title:e("全局prompt"),onClick:()=>{_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{L.sys_prompt=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,sys_prompt:e})}}),j.xK.set_value_temp(L.sys_prompt??"")}}),(0,_.jsx)(a.rA,{icon:"edit_attributes",title:e("全局")+" "+e("model请求参数json编写"),onClick:()=>{_e({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{L.json_params=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,json_params:e})},can_format:!0}),j.xK.set_value_temp(L.json_params??"")}}),(0,_.jsx)(a.rA,{icon:"settings",title:e("全局")+" "+e("额外参数设置"),onClick:()=>{_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{L.dotenv=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,dotenv:e})}}),j.xK.set_value_temp(L.dotenv??"")}}),(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{O([...$,{note:"",open:!1,path:"",dotenv:K.CP,json_params:K.cL}])}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:async()=>{await we()}})]}),children:(0,_.jsx)(d.X,{headers:n,onRowDrag:(e,t)=>{O((0,A.TI)($,e,t))},rows:$.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(m.Sm,{value:K.Lv.get_label_by_v(t.url,t.show_options?.options_agent_url_list),options:t.show_options?.options_agent_url_list,handleInputChange:e=>{t.url=e},no_border:!0}),(0,_.jsx)(m.l6,{value:t.open,onChange:e=>{((e,t,n)=>{const s=[];for(let e=0;e<$.length;e++)$[e].open=e===n&&t,s.push($[e]);O(s)})(0,e,n)},options:ge,no_border:!0}),(0,_.jsx)(m.Sm,{type:K.Lv.have_label_by_v(t.token,t.show_options?.options_agent_key_list)?null:"password",value:K.Lv.get_label_by_v(t.token,t.show_options?.options_agent_key_list),options:t.show_options?.options_agent_key_list,handleInputChange:e=>{t.token=e},no_border:!0}),(0,_.jsx)(m.Sm,{value:K.Lv.get_label_by_v(t.model,t.show_options?.options_agent_model_list),options:t.show_options?.options_agent_model_list,handleInputChange:e=>{t.model=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"short_text",title:"prompt",onClick:()=>{j.xK.set_value_temp($[n].sys_prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{$[n].sys_prompt=e,O($),j.xK.set_value_temp(""),we($)}})}}),(0,_.jsx)(a.rA,{icon:"edit_attributes",title:"model请求参数json编写",onClick:()=>{j.xK.set_value_temp($[n].json_params),_e({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{$[n].json_params=e,O($),j.xK.set_value_temp(""),we($)},can_format:!0})}}),(0,_.jsx)(a.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{j.xK.set_value_temp($[n].dotenv),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{$[n].dotenv=e,O($),j.xK.set_value_temp(""),we($)}})}})]}),(0,_.jsx)(m.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{$.splice(e,1),O([...$])})(n)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>(e=>{O([...$,{...$[e],open:!1}])})(n)})]})];return s}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:70,maxWidth:"100rem",children:(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - stdio"]})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{me("\n1. 这里配置的是 MCP Client 启动参数,当前实现的是 stdio 模式,也就是通过 command + args 启动本地 MCP Server\n2. 例如可以填 npx / uvx / python 等命令,再配合对应的 MCP server 包参数\n3. 保存后会自动重新加载 MCP 工具,agent 聊天时会把这些工具一起带给模型\n4. 建议把 cwd 配到具体项目目录,避免 server 在错误目录里运行\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>je("stdio")}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{be()}})]}),children:(0,_.jsx)(d.X,{headers:oe,onRowDrag:(e,t)=>{T((0,A.TI)(D,D.indexOf(ne[e]),D.indexOf(ne[t]))),F.current=!0},rows:ne.map((t,n)=>{const s=D.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(m.Sm,{value:t.name,handleInputChange:e=>{t.name=e,F.current=!0},no_border:!0}),(0,_.jsx)(m.l6,{value:t.open,onChange:e=>{t.open=e,T([...D]),F.current=!0},options:ge,no_border:!0}),Ie(D.indexOf(t)),(0,_.jsx)(m.Sm,{value:t.command,handleInputChange:e=>{t.command=e,F.current=!0},no_border:!0}),(0,_.jsx)(m.Sm,{value:t.args,handleInputChange:e=>{t.args=e,F.current=!0},no_border:!0}),(0,_.jsx)(m.Sm,{value:t.cwd,handleInputChange:e=>{t.cwd=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"visibility",title:"查看工具",onClick:()=>{Se(t,s)}}),(0,_.jsx)(a.rA,{icon:"settings",title:"env",onClick:()=>{j.xK.set_value_temp(t.env??""),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.env=e,T([...D]),j.xK.set_value_temp(""),F.current=!0,be()}})}})]}),(0,_.jsx)(m.Sm,{value:t.note,handleInputChange:e=>{t.note=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>fe(t)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>ye(t)})]})]}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsxs)(c.VP,{widthPer:70,maxWidth:"100rem",children:[(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - HTTP"]})," "]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>je("http")}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{be()}})]}),children:(0,_.jsx)(d.X,{headers:ae,onRowDrag:(e,t)=>{T((0,A.TI)(D,D.indexOf(se[e]),D.indexOf(se[t]))),F.current=!0},rows:se.map((t,n)=>{const s=D.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(m.Sm,{value:t.name,handleInputChange:e=>{t.name=e,F.current=!0},no_border:!0}),(0,_.jsx)(m.l6,{value:t.open,onChange:e=>{t.open=e,T([...D]),F.current=!0},options:ge,no_border:!0}),Ie(D.indexOf(t)),(0,_.jsx)(m.Sm,{value:t.endpoint,handleInputChange:e=>{t.endpoint=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"visibility",title:"查看工具",onClick:()=>{Se(t,s)}}),(0,_.jsx)(a.rA,{icon:"settings",title:"headers",onClick:()=>{j.xK.set_value_temp(t.headers??""),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.headers=e,T([...D]),j.xK.set_value_temp(""),F.current=!0,be()}})}})]}),(0,_.jsx)(m.Sm,{value:t.note,handleInputChange:e=>{t.note=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>fe(t)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>ye(t)})]})]}),width:"10rem"})}),(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("系统会话提示词")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{me('\n1. 系统会话提示词,在 AI 聊天页创建会话时可以选择,选中的提示词会自动填入聊天框作为第一条系统消息\n2. 适用于预先设定常用的会话场景模板,如"代码审查"、"翻译助手"、"运维诊断"等\n3. "LLM编辑开关":开启后,当用户选择了该系统提示词发起对话时,AI 将会获得一个"更新会话提示词"工具,允许 AI 在对话中对当前会话进行总结,并写入到本提示词的"LLM编辑提示词"字段(全局保存,供之后的新会话沿用),使 AI 能自我维护长期上下文。\n4. "LLM编辑提示词":可选。AI 编辑后写回的内容(可预填初始方向)。仅在"LLM编辑开关"开启时生效。\n5. "编辑规则":可选。给 LLM 的编辑要求,例如"总结时不要超过 300 token"、"用简洁的项目要点记录"等。仅在"LLM编辑开关"开启时生效。\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{le([...re,{prompt:"",note:"",llm_prompt_enable:!1}])}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{Ne()}})]}),children:(0,_.jsx)(d.X,{headers:ie,onRowDrag:(e,t)=>{le((0,A.TI)(re,e,t))},rows:re.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"short_text",title:e("提示词"),onClick:()=>{j.xK.set_value_temp(t.prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.prompt=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)(a.Ay,{checked:!!t.llm_prompt_enable,onChange:e=>{t.llm_prompt_enable=e,le([...re])},title:e("LLM编辑开关")}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"edit_note",title:e("llm_pmt"),onClick:()=>{j.xK.set_value_temp(t.llm_prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.llm_prompt=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"rule",title:e("编辑规则"),onClick:()=>{j.xK.set_value_temp(t.llm_prompt_tip??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.llm_prompt_tip=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)(m.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{re.splice(e,1),le([...re])})(n)})})];return s}),width:"10rem"})}),(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("长期记忆")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{me(e("开启后跨会话保存记忆。四个固定文件:周/月/年/永久。每周结束自动压缩周→月,每月结束自动压缩月→年,每年结束自动压缩年→永久。编辑按钮可手动查看和修改。"))},title:"信息"})]}),titleCom:(0,_.jsx)("div",{children:(0,_.jsx)(a.Ay,{checked:ce,onChange:async t=>{de(t),await h.XO.post("ai_long_term_memory_setting/save",{open:t}),(0,g.SK)(e("长期记忆设置已保存"))},title:e("开关")})}),children:(0,_.jsx)("div",{style:{display:"flex",gap:"0.5rem",padding:"0.5rem 0",flexWrap:"wrap"},children:[{type:"week",label:e("周记忆"),tip:e("上限3000字")},{type:"month",label:e("月记忆"),tip:e("上限6000字")},{type:"year",label:e("年记忆"),tip:e("上限9000字")},{type:"forever",label:e("永久记忆"),tip:e("上限12000字")}].map(({type:t,label:n,tip:s})=>(0,_.jsx)(a.rA,{icon:"edit",title:`${e("编辑")} ${n} (${s})`,onClick:async()=>{const s=await h.XO.get(`ai_long_term_memory_bucket/${t}`),o=s.code===x.m.Success?s.data??"":"";j.xK.set_value_temp(o),_e({model:"ace/mode/text",open:!0,fileName:`long_term_memory_${t}.txt`,save:async s=>{await h.XO.post(`ai_long_term_memory_bucket/${t}/save`,{data:s}),j.xK.set_value_temp(""),(0,g.SK)(`${n} ${e("已保存")}`)}})}},t))})})]})}),(0,_.jsxs)(c.fI,{children:[(0,_.jsx)(c.VP,{widthPer:50,maxWidth:"80rem",children:(0,_.jsx)(p.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("本地知识库")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{me("\n1. 本地知识库用于为AI增强理解能力,或者分析本地文件,原理读取本地的文件,对文件在内存中建立全文索引,为AI提供额外数据(需要有模型开启才能使用)\n2. 该功能只能用于小型知识库,作为本地小型或者公司内部资料使用还是没有问题的\n3. 每次保存都会重新加载知识库中的文件,不会全部重新加载,而是检测哪些文件有变更\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.Ay,{checked:ee,onChange:async e=>{await h.jV.post("docs_on_set",{status:e}),ve(),t()},title:e("知识库开关")}),(0,_.jsx)(a.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{j.xK.set_value_temp(q.current),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{q.current=e,j.xK.set_value_temp(""),Ke(q.current)}})}}),(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...P,{note:"",auto_load:!1,dir:""}]),V.current=!0}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{Ke()}})]}),children:(0,_.jsx)(d.X,{headers:N,onRowDrag:(e,t)=>{X((0,A.TI)(P,e,t)),V.current=!0},rows:P.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(m.Sm,{value:t.dir,handleInputChange:e=>{t.dir=e,V.current=!0},no_border:!0}),(0,_.jsx)(m.l6,{value:t.auto_load,onChange:e=>{t.auto_load=e,X([...P]),V.current=!0},options:ge,no_border:!0}),(0,_.jsx)(m.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除记录"),onClick:()=>(e=>{P.splice(e,1),X([...P]),V.current=!0})(n)}),(0,_.jsx)(a.rA,{icon:"restore",title:e("手动加载"),onClick:()=>{xe({sub_title:"手动加载",confirm_fun:()=>{h.jV.post("docs_load_file",{param_path:t.dir}),(0,g.SK)("ok")}})}}),(0,_.jsx)(a.rA,{icon:"delete_forever",title:e("从索引删除"),onClick:()=>{xe({sub_title:"从索引删除",confirm_fun:()=>{h.jV.post("docs_del",{param_path:t.dir}),(0,g.SK)("ok")}})}})]})];return s}),width:"10rem"})})}),H&&(0,_.jsx)(c.VP,{widthPer:50,maxWidth:"80rem",children:(0,_.jsxs)(p.Zp,{title:e("知识库加载信息"),children:[(0,_.jsx)(c.Yh,{left:e("最近一次加载")+","+e("加载进度"),right:H?.progress}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件数量")}`,right:H?.num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件字符数量")}`,right:H?.char_num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件大小")}`,right:(0,b.v7)(H?.size)}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总耗时")}`,right:(0,b.a3)(H?.consume_time_ms_len)}),(0,_.jsx)(c.Yh,{left:`${e("总文件数量")}`,right:H?.total_num})]})})]})]})})})]})}},34299(e,t,n){n.r(t),n.d(t,{default:()=>C});var s=n(96540),o=n(23802),a=n(53995),i=n(18569),r=n(77979),l=n(8263),c=n(69428),d=n.n(c),m=(n(3775),n(21499)),p=n(99214),u=n(89117),_=n(86063),h=n(89334),x=n(41105),g=n(52388),v=n(19878),j=(n(72411),n(74848));const f=new o.A({html:!0,highlight:function(e,t){if(t&&v.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${v.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${v.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${f.utils.escapeHtml(e)}</code></pre>`}});async function y(e,t){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=g.A.t("rendering");const n=await(0,_.Hn)(t);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await n.mount(e))}function w(e){const t=e.className.match(/language-([\w-]+)/);return t?t[1]:""}function C(e){const t=(0,s.useRef)(null);return(0,p.VD)(),(0,s.useEffect)(()=>{t.current&&(t.current.innerHTML=f.render(e.context??""),async function(e){const t=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(t)){const t=w(e),n=(0,u.Hm)(t),s=(0,_.hj)(t);if(!n&&!s)continue;const o=e.closest(".code-block-with-copy")??e.parentElement;if(!o)continue;const a=e.textContent??"",i=document.createElement("div");if(o.replaceWith(i),s){try{await y(i,a)}catch(e){console.error("[mind] render failed",e),i.className="md-graph md-graph--mind",i.textContent=String(e)}continue}i.className="md-graph md-graph--loading",i.textContent=g.A.t("rendering");const r=await(0,u.U6)(t,a);i.isConnected&&(r.error?(i.className="md-graph md-graph--error",i.textContent=r.error):(i.className="md-graph",i.innerHTML=r.svg))}}(t.current),(0,h.rg)(t.current))},[e.context]),(0,j.jsx)("div",{ref:t})}f.use(a.A).use(i.A).use(r.A).use(l.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,n,s,o,a)=>{const i=t[n],r=i.content.trim(),l=i.info.trim();let c="";if(l&&v.A.getLanguage(l))try{c=v.A.highlight(r,{language:l}).value}catch(t){c=e.utils.escapeHtml(r)}else try{c=v.A.highlightAuto(r).value}catch(t){c=e.utils.escapeHtml(r)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(r)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${c}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,n,s,o){return o.renderToken(e,t,n)};e.renderer.rules.link_open=(e,n,s,o,a)=>{const i=e[n],r=i.attrIndex("href");if(r>=0){const e=i.attrs[r][1];i.attrs[r][1]=(0,m.bi)(window.location.href,e)}return t(e,n,s,o,a)}}),(0,h.Rh)(f,x.pC)},24659(e,t,n){var s=n(22022);n.d(t,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])},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([[6010,8365],{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])},16514(e,s,t){t.r(s),t.d(s,{default:()=>ce});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(14284),r=t(7463),l=t(78247),d=t(53459),u=t(72693),m=t(82893),g=t(61443),h=t(83277);function _(e){return null==e||e<0?"0":e.toLocaleString()}var p=t(14944),f=t(92275),x=t(62042);function j(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,h.$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 v(e){const s=(0,h.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,h.$j)(e.content)).filter(Boolean).join("\n\n"):""}let b=0;function w(){return-++b}function y(e=[]){let s=0;return e.filter(e=>"user"===e.role||"assistant"===e.role).map(e=>({id:++s,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list??(e.tool_call_ends?.length?[{tool_call_ends:e.tool_call_ends,content:v(e),role:"assistant"}]:void 0),images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const S=/\.(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 N(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||S.test(e.name)?"text":"binary"}function k(e){return e.text()}function C(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function A(e){const s=[];for(const t of e){const e=N(t);let n="";if("text"===e)try{const e=await k(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 C(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}function I(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var M=t(21499),$=t(64694),R=t(45907),B=t(74848);var D=t(40505);function T(e){const{active_session_id_ref:s,local_owner_ref:t,subscribed_ref:a,set_messages:i,scroll_to_bottom:o,auto_scroll_ref:c,mark_session_running:r,refresh_sessions:l,reload_session:d,set_active_session_running:u}=e,m=(0,n.useRef)(new Map);return(0,n.useEffect)(()=>{const e=()=>s.current,n=(s,n)=>{if(r(s,!1),m.current.clear(),e()&&e()===s){if(u(!1),a.current===s&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:s,subscribe:!1}),a.current=null),t.current===s)return void(t.current=null);n?.length?i(e=>{let s=e.length;for(;s>0&&"bot"===e[s-1].sender;)s--;return[...e.slice(0,s),...y(n)].map((e,s)=>({...e,id:s+1}))}):d(s).catch(()=>{})}l()},g=s=>{const n=s?.context||{};n.session_id&&(((s,n,a,r,l=0)=>{e()&&e()===s&&t.current!==s&&i(e=>{const s=m.current,t=r?-(l+1):l;let i=e;if(!r){const e=-(l+1),t=s.get(e);void 0!==t&&(i=i.filter(e=>e.id!==t),s.delete(e))}const d=s.get(t),u=void 0===d?-1:i.findIndex(e=>e.id===d),g=-1===u?{id:w(),sender:"bot",text:""}:{...i[u]};if(-1===u&&s.set(t,g.id),r?(g.text=n,g.is_loading=!0):n&&(g.text=g.text+n,g.is_loading=!1),a&&(g.content_list=[{tool_call_ends:a,content:g.text,role:"assistant"}],g.is_loading=!1),c.current&&requestAnimationFrame(()=>o()),-1===u)return[...i,g];const h=i.slice();return h[u]=g,h})})(n.session_id,n.text||"",n.tool_call_ends,n.notice,n.chunk_index),r(n.session_id,!0))},h=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)},_=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)};return p.ws.addMsg(f.HK.ai_chat_msg,g),p.ws.addMsg(f.HK.ai_chat_end,h),p.ws.addMsg(f.HK.ai_chat_error,_),()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,g),p.ws.off_message(`message_${f.HK.ai_chat_end}`,h),p.ws.off_message(`message_${f.HK.ai_chat_error}`,_),a.current&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:a.current,subscribe:!1}),a.current=null)}},[]),{chunkBubbleRef:m,bind_live_bubbles:(e,s)=>{m.current.clear();for(let t=0;t<s;t++){const n=e[e.length-s+t];n&&m.current.set(t,n.id)}},clear_bubbles:()=>m.current.clear()}}var V=t(85997),H=t(34299);function E(e){const s=e.attachments&&e.attachments.length>0?(0,B.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,B.jsxs)("div",{className:"chat-message-attachment",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{children:e.name}),(0,B.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(K,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(z,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(F,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,B.jsx)(H.default,{context:e.text}):null;return(0,B.jsxs)(B.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,h.$j)(e.content);return a&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(H.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(P,{callList:e.tool_call_ends})},`tool-${s}`)),(0,B.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,B.jsx)(H.default,{context:e.text}):null]})}(e);return 0===t.length?(0,B.jsxs)(B.Fragment,{children:[s,a]}):(0,B.jsxs)(B.Fragment,{children:[t,s,a]})}function P({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,B.jsxs)("div",{className:"chat-message-call-list",children:[(0,B.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,B.jsx)(V.In,{icon:s?"expand_less":"expand_more"}),(0,B.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,B.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,B.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,B.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,B.jsxs)("div",{className:"call-list-item-header",children:[(0,B.jsx)(V.In,{icon:e.success?"check_circle":"error"}),(0,B.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,B.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"参数"}),(0,B.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"错误"}),(0,B.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"结果"}),(0,B.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function K({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,B.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,B.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,B.jsx)("p",{className:"image-generation-prompt",children:(0,B.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,B.jsx)(H.default,{context:s})]}):(0,B.jsx)(H.default,{context:s||""})}function z({audio:e,text:s}){if(e){if(e.url)return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,B.jsx)("div",{className:"audio-result",children:(0,B.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,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,B.jsx)(H.default,{context:t})}function L({content:e,label:s}){const[t,a]=n.useState(!1);return(0,B.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,D.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,B.jsx)(V.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function F({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,B.jsx)(H.default,{context:s})}if(!t)return(0,B.jsx)(H.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,B.jsxs)("div",{className:"embeddings-result",children:[(0,B.jsxs)("div",{className:"embeddings-summary",children:[(0,B.jsx)("strong",{children:"向量嵌入结果"}),(0,B.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,B.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,B.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,B.jsxs)("div",{className:"embeddings-toolbar",children:[(0,B.jsx)(L,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,B.jsx)(L,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,B.jsx)(L,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,B.jsx)("div",{className:"embeddings-preview",children:(0,B.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,B.jsxs)("details",{children:[(0,B.jsx)("summary",{children:"查看详细数据"}),(0,B.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function O(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 c.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 c.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 q=t(4412),U=t(23430),G=t(87361),J=t(80389),W=t(7523),Q=t(23496);const X=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:r,sysPromptList:u,batchMode:h,selectedMsgCount:_,sessionVisible:p,onToggleSessionPanel:f,onCreateSession:j,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),I=(0,o.Zp)(),{check_user_auth:M}=(0,l.MH)(),[,$]=(0,a.fp)(m.AG.ai_session_collapsed),{open:R}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(m.AG.prompt_card),[t,o]=(0,a.fp)(m.AG.ai_chat_zoom),{initUserInfo:r}=(0,n.useContext)(W.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,B.jsx)(J.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 c.wm.post(Q.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,x.SK)(e("缩放调整成功")),r(),a()}})}}}(),D=M(U.oV.ai_model_switch)||M(U.oV.ai_agent_setting),T=[];for(const e of t)for(const s of e.models)T.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const H=t.find(e=>e.active),E=H?`${H.index}::${e}`:"",P=(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(V.rA,{icon:"menu",title:A("会话"),onClick:f,selected:p}),(0,B.jsx)(V.rA,{icon:"add",title:A("新会话"),onClick:()=>j()}),u.length>0&&(0,B.jsx)(g.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...u.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),D&&T.length>0&&(0,B.jsx)(g.l6,{value:E,options:[{title:A("选择模型"),value:""},...T],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),c.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===d.m.Success?((0,x.SK)("success"),r()):(0,x.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),h&&(0,B.jsx)(V.rA,{icon:"done",title:A("完成"),onClick:v}),h&&_>0&&(0,B.jsx)(V.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,B.jsx)(V.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:R}),(0,B.jsx)(V.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),M(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{I(G.o.ai_rebot_setting_page)}}),M(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"settings",title:"ai setting",onClick:()=>{I(G.o.ai_agent_setting_page)}})]});return C?(0,B.jsx)("div",{className:"chat-inline-header",children:P}):(0,B.jsx)(q.aZ,{position:"right",children:P})};var Z=t(89824);function Y({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:g,onToggleBatchMode:h,onBatchDeleteSessions:_,onClearAllSessions:p,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,B.jsxs)("aside",{className:"chat-session-list",children:[(0,B.jsx)("div",{className:"chat-session-search",children:(0,B.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,B.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,B.jsx)("div",{children:(0,B.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&&g?g(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,B.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>g?.(e.id),onClick:e=>e.stopPropagation()}),(0,B.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,B.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,B.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,B.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,B.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,B.jsx)(Z.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,B.jsx)(V.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,B.jsxs)("div",{className:"chat-session-actions",children:[(0,B.jsx)(V.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:h}),j&&!u&&(0,B.jsx)(V.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,B.jsx)(V.rA,{icon:"delete",title:v("删除选中会话"),onClick:_}),!u&&p&&(0,B.jsx)(V.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:p})]})]})}function ee(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const se=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:d,onToggleBatchMode:u,onBatchCopy:m,onBatchDelete:g,showBatchBar:h,t:_})=>{const[p,f]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),j=e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},v=()=>{f(e=>e.size>0&&x.every(s=>e.has(s))?new Set:new Set(x))};return(0,B.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[h&&(0,B.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,B.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,B.jsx)("button",{onClick:m,children:_("复制所选")}),(0,B.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,B.jsx)("button",{onClick:u,children:_("取消")})]}),e.map(e=>{const n=p.has(e.id);return(0,B.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,B.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,B.jsxs)("div",{className:"ai-loading-bubble",children:[(0,B.jsxs)("div",{className:"ai-loading-dots",children:[(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"})]}),(0,B.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,B.jsxs)(B.Fragment,{children:[n?(0,B.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>j(e.id),children:[(0,B.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,B.jsx)("span",{className:"chat-message-summary-text",children:ee(e)||_("(无内容)")})]}):(0,B.jsx)("div",{className:"chat-message-body",children:E(e)}),(0,B.jsxs)("div",{className:"message-actions",children:[(0,B.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,B.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,B.jsx)("button",{onClick:d,children:_("全部复制")}),(0,B.jsx)("button",{onClick:u,children:_("多选")})]}),(0,B.jsxs)("div",{className:"message-collapse-bar",children:[(0,B.jsx)("button",{onClick:()=>j(e.id),children:_(n?"展开":"折叠")}),(0,B.jsx)("button",{onClick:v,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,B.jsx)("span",{className:"message-elapsed",children:(0,M.kf)(e.elapsed_ms)})]})]})]},e.id)}),(0,B.jsx)("div",{ref:o})]})},te=(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,g]=(0,n.useState)(!1),h=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>h(),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,B.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?.(h()),onCompositionStart:()=>g(!0),onCompositionEnd:()=>g(!1),"data-placeholder":d?e:void 0})});var ne=t(84369);function ae({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,B.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,B.jsxs)("div",{className:"chat-attachment-chip",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{title:e.name,children:e.name}),(0,B.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,B.jsx)(V.In,{icon:"close"})})]},`${e.name}_${t}`))})}const ie=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:g,readonly:h=!1},_)=>{const{t:p}=(0,i.Bd)(),f=(0,n.useRef)(null),x=(0,n.useRef)(null),[j,v]=(0,a.fp)(m.AG.ai_chat_input_height);(0,n.useImperativeHandle)(_,()=>({getValue:()=>f.current?.getValue()??"",setValue:e=>f.current?.setValue(e),clear:()=>f.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,ne.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=x.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,B.jsxs)("div",{ref:x,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,B.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,B.jsx)("input",{ref:g,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,B.jsxs)("div",{className:"chat-input-shell",children:[(0,B.jsx)(ae,{pendingAttachments:o,onRemove:c}),(0,B.jsx)(te,{ref:f,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,B.jsx)(V.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,B.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,B.jsx)(V.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,B.jsx)(V.Vi,{text:p("发送"),clickFun:e}),b&&(0,B.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),oe=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[c,r]=(0,n.useState)(!1),[l,d]=(0,n.useState)(null),[u,g]=(0,n.useState)(null),[h,_]=(0,n.useState)(!1),[j,v]=(0,a.fp)(m.AG.ai_bg_expanded),[,b]=(0,a.fp)(m.AG.ai_session_collapsed),w=()=>{v(!1)},y=(0,n.useCallback)(async()=>{r(!0);try{const s=new f.hf(f.HK.ai_bg_process_list_req);s.context={};const t=await p.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{r(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=y);const S=(0,n.useCallback)(async e=>{_(!0),d(e);try{const s=new f.hf(f.HK.ai_bg_process_output_req);s.context={pid:e};const t=await p.ws.send(s);g(t.context)}catch(e){console.error("获取进程输出失败",e),(0,x.zN)("获取进程输出失败")}finally{_(!1)}},[]),N=(0,n.useCallback)(async e=>{try{const s=new f.hf(f.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await p.ws.send(s);t?.context?.success?((0,x.SK)("进程已终止"),y(),l===e&&(d(null),g(null))):(0,x.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,x.zN)("终止进程失败")}},[y,l]);(0,n.useEffect)(()=>{y();const e=setInterval(y,5e3);return()=>clearInterval(e)},[y]);const k=t.filter(e=>e.running),C=t.filter(e=>!e.running);return(0,B.jsxs)(B.Fragment,{children:[j&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:w}),(0,B.jsxs)("aside",{className:"chat-bg-process-panel "+(j?"expanded":""),children:[(0,B.jsxs)("div",{className:"chat-bg-process-header",children:[(0,B.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:w})]}),(0,B.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,B.jsx)(V.rA,{icon:"refresh",title:s("刷新"),onClick:y}),(0,B.jsxs)("span",{className:"chat-bg-process-count",children:[k.length," ",s("个运行中"),C.length>0&&` / ${C.length} ${s("个已退出")}`]})]}),(0,B.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),k.map(e=>(0,B.jsxs)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} running`,children:[(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>S(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,B.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,B.jsx)(V.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>S(e.pid)}),(0,B.jsx)(V.rA,{icon:"stop",title:s("终止进程"),onClick:()=>N(e.pid)})]})]},e.pid)),C.map(e=>(0,B.jsx)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} finished`,children:(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>S(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==l&&(0,B.jsxs)("div",{className:"chat-bg-process-output",children:[(0,B.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,B.jsxs)("span",{children:["PID: ",l," ",s("输出")]}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:()=>{d(null),g(null)}})]}),(0,B.jsx)("div",{className:"chat-bg-process-output-content",children:h?(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):u?(0,B.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||s("(无输出)")}):null})]})]})]})};function ce(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:h,sync_url:v=!0,on_session_change:b}=e,{t:S}=(0,i.Bd)(),[N,k]=(0,o.ok)(),C=v&&N.get("session")||"",{check_user_auth:V}=(0,l.MH)();(0,u.w)();const[H]=(0,a.fp)(m.AG.user_base_info),E=!!H?.user_data?.is_root,[P,K]=(0,a.fp)(m.AG.ai_session_collapsed),[z,L]=(0,a.fp)(m.AG.ai_bg_expanded),[F,q]=(0,a.fp)(m.AG.prompt_card),[U]=(0,a.fp)(m.AG.ai_chat_zoom),[G,J]=(0,n.useState)(null),[W,Q]=(0,n.useState)([]),[Z,ee]=(0,n.useState)(new Set),[te,ne]=(0,n.useState)([]),[ae,ce]=(0,n.useState)(""),[re,le]=(0,n.useState)([]),[de,ue]=(0,n.useState)(0),me=(0,n.useRef)(null),ge=(0,n.useRef)(null),he=(0,n.useRef)(null),_e=(0,n.useRef)({}),pe=(0,n.useRef)({}),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current=G},[G]);const xe=(0,n.useRef)(null),je=(0,n.useRef)([]),ve=(0,n.useRef)(""),be=(0,n.useRef)(!1),we=(0,n.useRef)(null),ye=(0,n.useRef)(()=>{}),Se=function(e){const{admin_call:s,owner_of_session:t,get_sessions:a,activeSessionId:o,admin_mode_ref:r}=e,{t:l}=(0,i.Bd)(),u=(0,R.y)(),[m,g]=(0,n.useState)([]),[h,_]=(0,n.useState)(!1),[p,f]=(0,n.useState)(new Set),v=(0,n.useRef)(null),b=(0,n.useRef)(!0),w=(0,n.useRef)(!1),S=(e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s},N=(e=!1)=>{const s=v.current;if(!s)return;s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"});let t=0;const n=()=>{const s=v.current;s&&(s.scrollTo({top:s.scrollHeight,behavior:e&&0===t?"smooth":"auto"}),++t<6&&requestAnimationFrame(n))};requestAnimationFrame(n)},k=()=>{w.current=!0};return(0,n.useLayoutEffect)(()=>{w.current&&(w.current=!1,b.current=!0),b.current&&N(!1)},[m]),(0,n.useEffect)(()=>{const e=v.current;if(!e)return;const s=()=>{b.current=S(e)};e.addEventListener("scroll",s);const t=()=>{b.current&&(e.scrollTop=e.scrollHeight)},n=new ResizeObserver(t),a=()=>[...e.children].forEach(e=>n.observe(e));a();const i=new MutationObserver(()=>{a(),t()});return i.observe(e,{childList:!0}),()=>{e.removeEventListener("scroll",s),n.disconnect(),i.disconnect()}},[]),{messages:m,setMessages:g,batchMode:h,setBatchMode:_,selectedMsgIds:p,setSelectedMsgIds:f,chatContainerRef:v,autoScrollRef:b,isNearBottom:S,scrollToBottom:N,request_scroll_bottom:k,apply_session:e=>{if(!e)return g([]),void k();let s=e.messages??[];e.live_messages?.length&&(s=[...s,...e.live_messages]),g(y(s)),k()},handleDelete:e=>{u({sub_title:l("cf_one"),confirm_fun:async()=>{const n=m.findIndex(s=>s.id===e);if(n<0)return;if(g(m.filter(s=>s.id!==e)),!o)return;const a=t(o);a?s("message_delete",{session_id:o,user_id:a,indices:[n]}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:[n]}).catch(console.error)}})},handleCopy:async e=>{(0,D.lW)(j(e)),(0,x.SK)("复制成功")},handleCopyAll:async()=>{const e=a();if(!e.length)return void(0,x.SK)("暂无聊天记录");const t=[];for(const n of e){const e=n.user_id?await s("get",{session_id:n.id,user_id:n.user_id}):await c.jV.post("session/get",{session_id:n.id});if(e.code!==d.m.Success||!e.data)continue;const a=e.data,i=y([...a.messages??[],...a.live_messages??[]]).map(j).filter(Boolean).join("\n\n\n");i&&t.push(i)}t.length?((0,D.lW)(t.join("\n\n\n")),(0,x.SK)("复制成功")):(0,x.SK)("暂无聊天记录")},handleBatchCopy:()=>{const e=m.filter(e=>p.has(e.id)).map(j).filter(Boolean).join("\n\n\n");e?((0,D.lW)(e),(0,x.SK)("复制成功")):(0,x.SK)("暂无内容")},toggleBatchMode:()=>{h&&f(new Set),_(e=>!e)},toggleMsgSelect:e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},batchDeleteMessages:()=>{0!==p.size&&u({sub_title:l("cf_msgs"),confirm_fun:async()=>{const e=[];if(m.forEach((s,t)=>{p.has(s.id)&&e.push(t)}),g(m.filter(e=>!p.has(e.id))),f(new Set),_(!1),!o||0===e.length)return;const n=t(o);n?s("message_delete",{session_id:o,user_id:n,indices:e}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:e}).catch(console.error)}})}}}({admin_call:(e,s)=>c.jV.post("admin/session",{action:e,...s||{}}),owner_of_session:e=>be.current?je.current.find(s=>s.id===e)?.user_id:void 0,get_sessions:()=>je.current,activeSessionId:ve.current,admin_mode_ref:be});ye.current=Se.apply_session;const Ne=function(e){const{on_session_loaded:s,set_session_panel_open:t,on_session_change:a,init_cwd:o,write_url_session:r,url_session_id:l,init_session_id:u}=e,{t:m}=(0,i.Bd)(),h=(0,R.y)(),[_,p]=(0,n.useState)([]),[f,j]=(0,n.useState)(""),[v,b]=(0,n.useState)(""),[w,y]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(!1),A=(0,n.useRef)(!1),I=(0,n.useRef)([]);(0,n.useEffect)(()=>{A.current=w},[w]),(0,n.useEffect)(()=>{I.current=_},[_]);const D=(e,s={})=>c.jV.post("admin/session",{action:e,...s}),T=e=>{if(A.current)return I.current.find(s=>s.id===e)?.user_id},V=async(e,n=!1,i)=>{const o=i??I.current.find(s=>s.id===e)?.user_id,u=A.current&&o?await D("get",{session_id:e,user_id:o}):await c.jV.post("session/get",{session_id:e});if(u.code!==d.m.Success||!u.data)return!1;const m=u.data;return j(m.id),l!==m.id&&r(m.id),a?.(m.id),N(!!m.running),b(m.sys_prompt_id??""),n&&t(!0),s(m),!0},H=async e=>{const t=A.current?await D("list_all_sessions"):await c.jV.get("sessions");if(t.code!==d.m.Success)return!1;const n=t.data??[];p(n);const a=null===e?n[0]?.id??"":e||f||n[0]?.id||"";if(!a)return j(""),r(null),s(null),!1;const i=n.find(e=>e.id===a)?.user_id;return await V(a,!1,i)},E=async e=>{if(!e)return null;const s=await c.jV.get("sessions");if(s.code!==d.m.Success)return null;const t=s.data??[],n=(0,M.ed)(e),a=t.find(e=>(0,M.ed)(e.file_cwd_path)===n);if(a)return a.id;const i=await c.jV.post("session",{file_cwd_path:n});return i.code!==d.m.Success?null:i.data.id};return{sessions:_,setSessions:p,sessions_ref:I,activeSessionId:f,setActiveSessionId:j,selectedSysPromptId:v,setSelectedSysPromptId:b,admin_all_mode:w,admin_mode_ref:A,readonly:k,activeSessionRunning:S,setActiveSessionRunning:N,admin_call:D,call:(e,s,t)=>A.current?D(e,s):t(),owner_of_session:T,refreshSessions:async()=>{const e=A.current?await D("list_all_sessions"):await c.jV.get("sessions");e.code===d.m.Success&&p(e.data??[])},markSessionRunning:(e,s)=>{p(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})},loadSession:V,loadSessions:H,createSession:async e=>{const n=await c.jV.post("session",{sys_prompt_id:e||void 0,file_cwd_path:o||void 0});if(n.code!==d.m.Success)return;const a=n.data;j(a.id),b(a.sys_prompt_id??""),t(!0),s(null),await H(a.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},locate_session_by_cwd:E,init_active_session:async()=>{if(o){const e=await E(o);e&&await H(e)||await H()}else u?await H(u)||await H():l&&await H(l)||await H()},reorderSessions:(e,s)=>{if(A.current)return;const t=I.current.findIndex(s=>s.id===e),n=I.current.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,$.TI)(I.current,t,n);p(a),c.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},deleteSession:e=>{h({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=T(e);s?await D("delete",{session_id:e,user_id:s}):await c.jV.post("session/delete",{session_id:e}),f===e?(j(""),await H(null)):await H(f)}})},renameSession:(e,s)=>{let t=s;h({confirm_fun:async()=>{const s=T(e);s?await D("rename",{session_id:e,user_id:s,title:t}):await c.jV.post("sessions/update/meta",{id:e,title:t}),await H(f)},context_div:(0,B.jsx)("div",{className:"card-content",children:(0,B.jsx)(g.Sm,{value:t,handleInputChange:e=>{t=e}})})})},toggleCmdAuto:async(e,s)=>{const t=T(e);t?await D("cmd_auto",{session_id:e,user_id:t,allow:s}):await c.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,x.SK)(m(s?"命令检测已开启":"命令检测已关闭")),await H(f)},batchDeleteSessions:(e,s)=>{0!==e.size&&h({sub_title:m("cf_ses"),confirm_fun:async()=>{if(A.current)await D("batch_delete",{session_ids:Array.from(e)});else for(const s of e)await c.jV.post("session/delete",{session_id:s});s(),e.has(f)?(j(""),await H(null)):await H(f)}})},clearAllSessions:()=>{h({sub_title:m("cf_all"),confirm_fun:async()=>{await c.jV.post("sessions/clear",{}),j(""),s(null),await H(null)}})},toggleAllUsersMode:async()=>{const e=!w;y(e),A.current=e,C(e),j(""),s(null);const t=e?await D("list_all_sessions"):await c.jV.get("sessions"),n=t.code===d.m.Success?t.data??[]:[];p(n),n[0]?.id&&await V(n[0].id,!1,n[0].user_id)},changeSystemPrompt:e=>{if(b(e),!f)return;const s=T(f);s?D("sys_prompt",{session_id:f,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):c.jV.post("session/sys_prompt",{session_id:f,sys_prompt_id:e||void 0}).catch(console.error)}}}({on_session_loaded:e=>ye.current(e),set_session_panel_open:e=>K(!e),on_session_change:b,init_cwd:h,write_url_session:e=>{v&&k(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},url_session_id:C,init_session_id:t});(0,n.useEffect)(()=>{ve.current=Ne.activeSessionId,be.current=Ne.admin_all_mode,je.current=Ne.sessions},[Ne.activeSessionId,Ne.admin_all_mode,Ne.sessions]);T({active_session_id_ref:ve,local_owner_ref:xe,subscribed_ref:we,set_messages:Se.setMessages,scroll_to_bottom:()=>Se.scrollToBottom(!1),auto_scroll_ref:Se.autoScrollRef,mark_session_running:Ne.markSessionRunning,refresh_sessions:Ne.refreshSessions,reload_session:e=>Ne.loadSession(e),set_active_session_running:Ne.setActiveSessionRunning});const ke=(0,n.useRef)((0,r.sg)(e=>{Se.setMessages(e),Se.autoScrollRef.current&&Se.scrollToBottom(!1)},50)).current,Ce=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:c,refreshSessions:r,scrollToBottom:l,buildRequestMessages:d,getSelectedSysPromptId:u,setLocalOwner:m}=e,g=(0,n.useRef)([]),h=(0,n.useRef)(null),_=(e,n,c)=>{const g=s(),_=g.length+1,x={...n,id:_},j=[...g,x];t(j),i(e),m(e),h.current={abort:()=>{}};const v={id:-1,sender:"bot",text:"AI thinking ...",is_loading:!0};j.push(v),t([...j]);const b=new Map,w=()=>{o()===e&&a([...j])},S=()=>{const e=j.indexOf(v);-1!==e&&j.splice(e,1)},N=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",a=t.tool_call_ends,i=t.chunk_index??0;if(t.notice)return v.id=-1,v.text=n,v.is_loading=!0,j.includes(v)||j.push(v),void w();if("[DONE]"===n)return;if(!n&&!a)return;S();let o=b.get(i);o||(o={id:_+1+i,sender:"bot",text:"",is_loading:!0},j.push(o),b.set(i,o)),n&&(o.text=o.text+n,o.is_loading=!1),a&&(o.content_list=[{tool_call_ends:a,content:o.text,role:"assistant"}],o.is_loading=!1),w()},k=s=>{const n=s.context||{};n.session_id===e&&(A(),h.current=null,m(null),i(s=>s===e?null:s),o()===e&&t(e=>{const s=e.filter(I);let t=s;if(n.once_messages_list?.length){let e=-1;for(let t=s.length-1;t>=0;t--)if("user"===s[t].sender){e=t;break}const a=e>=0?e+1:s.length;t=[...s.slice(0,a),...y(n.once_messages_list)]}return t.map((e,s)=>({...e,id:s+1}))}),r(),l(!0),c())},C=s=>{const n=s.context||{};if(n.session_id!==e)return;A(),h.current=null,i(s=>s===e?null:s);const a="AI request error: "+(n.message||"未知错误");S();const r=[...j].reverse().find(e=>"bot"===e.sender);r?(r.text=r.text?`${r.text}\n\n${a}`:a,r.is_loading=!1):j.push({id:_+1,sender:"bot",text:a}),o()===e&&t([...j].map((e,s)=>({...e,id:s+1}))),c()},A=()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,N),p.ws.off_message(`message_${f.HK.ai_chat_end}`,k),p.ws.off_message(`message_${f.HK.ai_chat_error}`,C)};p.ws.addMsg(f.HK.ai_chat_msg,N),p.ws.addMsg(f.HK.ai_chat_end,k),p.ws.addMsg(f.HK.ai_chat_error,C),p.ws.sendData(f.HK.ai_chat_req,{messages:d(n),session_id:e,sys_prompt_id:u()})},x=()=>{const e=g.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:w(),sender:"user",text:s.text,attachments:s.attachments};_(o(),n,x)};return{startChatStream:_,processPendingQueue:x,enqueueMessage:(e,s)=>{g.current.push({text:e,attachments:s})},getQueueLength:()=>g.current.length,abort:()=>{const e=o();e&&(p.ws.sendData(f.HK.ai_chat_abort,{session_id:e}),h.current&&(h.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>Se.messages,setMessages:Se.setMessages,setMessagesDebounced:ke,setSending:J,getActiveSessionId:()=>ve.current,setActiveSessionId:Ne.setActiveSessionId,refreshSessions:Ne.refreshSessions,scrollToBottom:Se.scrollToBottom,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:()=>Ne.selectedSysPromptId,setLocalOwner:e=>{xe.current=e}}),Ae=e=>{ce(e?.ai_config?.model??"")},Ie=async()=>{try{const e=await c.jV.get("public_models");e.code===d.m.Success&&le(e.data?.groups??[])}catch{le([])}},Me=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&Q(e=>[...e,...s])},$e=e=>Ne.owner_of_session(e),Re=()=>{Se.batchMode&&(Se.setSelectedMsgIds(new Set),ee(new Set)),Se.setBatchMode(e=>!e)};(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Ae(e.data)),await Ie(),await Ne.init_active_session();const s=await c.jV.get("system_prompts");s.code===d.m.Success&&ne(s.data??[])})(),requestAnimationFrame(()=>Se.scrollToBottom(!1)),_e.current.onCountChange=ue,_e.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ue(s)};return p.ws.addMsg(f.HK.ai_bg_process_count_notify,e),()=>{p.ws.off_message(`message_${f.HK.ai_bg_process_count_notify}`,e)}},[]);const Be=G===Ne.activeSessionId||Ne.activeSessionRunning;return(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(X,{inline:s,currentModelName:ae,setCurrentModelName:ce,modelGroups:re,onModelChanged:async()=>{await Ie();const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Ae(e.data))},sysPromptList:te,batchMode:Se.batchMode,selectedMsgCount:Se.selectedMsgIds.size,sessionVisible:!P,onToggleSessionPanel:()=>K(e=>!e),onCreateSession:Ne.createSession,onBatchDeleteMessages:Se.batchDeleteMessages,onToggleBatchMode:Re,bgProcessVisible:z,bgProcessCount:de,onToggleBgProcess:()=>L(e=>!e),selectedSysPromptId:Ne.selectedSysPromptId,setSelectedSysPromptId:Ne.changeSystemPrompt}),(0,B.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":U},children:[!P&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:()=>K(!0)}),!P&&(0,B.jsx)(Y,{sessions:Ne.sessions,activeSessionId:Ne.activeSessionId,onSelectSession:e=>Ne.loadSession(e,!1),onReorderSessions:Ne.reorderSessions,onRenameSession:Ne.renameSession,onDeleteSession:Ne.deleteSession,onToggleCmdAuto:Ne.toggleCmdAuto,onShowUsageStats:async e=>{q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-loading",children:S("加载中...")}),cancel:()=>q({open:!1})});try{const s=$e(e),t=s?await Ne.admin_call("usage_stats",{session_id:e,user_id:s}):await c.jV.post("session/usage_stats",{session_id:e});if(t.code===d.m.Success&&t.data){const e=t.data;q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsxs)("div",{className:"usage-stats-panel",children:[[{l:S("对话轮次"),v:(e.turns??0).toString()},{l:S("AI输入Token"),v:_(e.input_tokens)},{l:S("AI输出Token"),v:_(e.output_tokens)},{l:S("AI输入Token(最近一轮)"),v:_(e.recent_input_tokens)},{l:S("AI输出Token(最近一轮)"),v:_(e.recent_output_tokens)}].map((e,s)=>(0,B.jsxs)("div",{className:"usage-stats-row",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,B.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,B.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:S("AI Token总计消耗")}),(0,B.jsx)("span",{className:"usage-stats-value",children:_((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>q({open:!1})})}else q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:S("暂无统计数据")}),cancel:()=>q({open:!1})})}catch{q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:S("暂无统计数据")}),cancel:()=>q({open:!1})})}},onShowSessionSetting:e=>{let s=Ne.sessions.find(s=>s.id===e)?.file_cwd_path??"";q({open:!0,title:S("会话设置"),context_div:(0,B.jsxs)("div",{className:"session-setting",children:[(0,B.jsx)("div",{className:"session-setting__label",children:S("服务器工作目录")}),(0,B.jsx)(g.Sm,{value:s,placeholder:S("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=$e(e);(t?await Ne.admin_call("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await c.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===d.m.Success&&(0,x.SK)(S("保存成功"))}catch{}q({open:!1}),await Ne.loadSessions(Ne.activeSessionId)},cancel:()=>q({open:!1})})},batchMode:Se.batchMode,selectedSessionIds:Z,onToggleSessionSelect:e=>{ee(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Re,onBatchDeleteSessions:()=>Ne.batchDeleteSessions(Z,()=>{ee(new Set),Se.setBatchMode(!1)}),onClearAllSessions:Ne.admin_all_mode?void 0:Ne.clearAllSessions,allUsersMode:Ne.admin_all_mode,onToggleAllUsersMode:Ne.toggleAllUsersMode,showAllUsersEntry:E}),(0,B.jsx)(oe,{panelRef:_e}),(0,B.jsxs)("section",{className:"chat-main",children:[0===Se.messages?.length&&(0,B.jsx)("div",{className:"chat-header",children:(0,B.jsx)("div",{children:S("ai_ask")})}),(0,B.jsx)(se,{messages:Se.messages,batchMode:Se.batchMode,selectedMsgIds:Se.selectedMsgIds,sending:Be,chatContainerRef:Se.chatContainerRef,messagesEndRef:he,onToggleMsgSelect:Se.toggleMsgSelect,onDelete:Se.handleDelete,onCopy:Se.handleCopy,onCopyAll:Se.handleCopyAll,onToggleBatchMode:Re,onBatchCopy:Se.handleBatchCopy,onBatchDelete:Se.batchDeleteMessages,showBatchBar:Se.batchMode&&Se.selectedMsgIds.size>0&&0===Z.size,t:S}),(0,B.jsx)(ie,{ref:me,onSend:async()=>{if(Ne.admin_all_mode)return;const e=(me.current?.getValue()??"").trim();if(!e&&0===W.length)return;if(G===Ne.activeSessionId){const s=await A(W);Ce.enqueueMessage(e,s),me.current?.clear(),Q([]);const t={id:w(),sender:"user",text:e+(Ce.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void Se.setMessages(e=>[...e,t])}let s=Ne.activeSessionId;if(!s){const t=await c.jV.post("session",{title:(e||W[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:h||void 0});if(t.code!==d.m.Success)return;s=t.data.id,Ne.setActiveSessionId(s),b?.(s),await Ne.loadSessions(s)}const t=await A(W),n={id:w(),sender:"user",text:e,attachments:t};me.current?.clear(),Q([]);const a=pe.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:Se.messages.length+2,sender:"bot",text:"处理中...",is_loading:!0},i={...n,id:Se.messages.length+1},o=[...Se.messages,i,t];Se.setMessages(o),J(s);return void(await O(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),Se.setMessages([...o]),J(null),Ne.refreshSessions(),Se.scrollToBottom(!0),Ce.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,Se.setMessages([...o]),J(null),Ce.processPendingQueue()))}Ce.startChatStream(s,n,()=>Ce.processPendingQueue())},readonly:Ne.admin_all_mode,sending:Be,onAbort:Ce.abort,pendingAttachments:W,onRemoveAttachment:e=>{Q(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ge.current?.click()},onAddFiles:Me,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Me(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ge})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>g});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 g(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),g=(0,n.useRef)(!1),h=(0,n.useRef)(null),_=(0,n.useRef)(void 0),p=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),g.current=!1,h.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:h.current,approved:e}),h.current=null),p.current()},[s]),x=(0,n.useCallback)(()=>{if(g.current)return;if(0===l.current.length)return g.current=!1,void s({open:!1});g.current=!0;const e=l.current.shift();e?(h.current=e.askId,_.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(_.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:_.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):g.current=!1},[t,f,s]);p.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(g.current&&h.current===t.askId&&(h.current=null,g.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=[],g.current=!1,h.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),g=t(89117),h=t(86063),_=t(89334),p=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,h.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,g.Hm)(s),n=(0,h.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,g.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,_.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,_.Rh)(v,p.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,[g,h]=(0,n.useState)(!1),_=(0,n.useRef)(null),p=(0,n.useRef)(u);p.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=_.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)),p.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{_.current=null,h(!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;_.current={pos:t(e),size:s()},h(!0)},[]);return(0,n.useEffect)(()=>{if(!g)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[g,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:g,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([[892],{20892(e,t,n){n.r(t),n.d(t,{default:()=>h});var s=n(96540),i=n(57889),l=n(62042),a=n(22022),r=n(93392),c=n(61443),o=n(74848);const d=36,u=4.8;function m(e){return`timeline-node--${e}`}function h(e){const{t}=(0,a.Bd)(),[n,u]=(0,s.useState)(()=>(0,r.bw)()),[m,h]=(0,s.useState)(!0),[_,v]=(0,s.useState)(""),[x,b]=(0,s.useState)(1),[g,f]=(0,s.useState)({}),j=(0,s.useCallback)((e,t)=>{f(n=>n[e]===t?n:{...n,[e]:t})},[]),[y,N]=(0,s.useState)({}),w=(0,s.useCallback)((e,t)=>{N(n=>n[e]===t?n:{...n,[e]:t})},[]),[k,C]=(0,s.useState)(!1),[E,L]=(0,s.useState)(null),[R,$]=(0,s.useState)("event"),S=(0,s.useRef)(null),T=(0,s.useRef)(null),z=(0,s.useRef)(!1),P=(0,s.useRef)({props:e});P.current={props:e};const U=(0,s.useRef)([]),D=(0,s.useRef)([]),[O,I]=(0,s.useState)(0),M=(0,s.useRef)(null),[B,Y]=(0,s.useState)(null),[X,F]=(0,s.useState)(null),A=(0,s.useRef)(n);A.current=n;const K=(0,s.useRef)(x);K.current=x;const Z="vertical"===n.layout.direction,q=(0,s.useRef)(k);q.current=k;const G=e=>{e&&!q.current||z.current!==e&&(z.current=e,P.current.props.on_dirty?.(e))},J=(0,s.useCallback)(e=>{U.current[U.current.length-1]!==e&&(U.current.push(e),U.current.length>100&&U.current.shift()),D.current=[],I(e=>e+1)},[]),W=(0,s.useCallback)(e=>{q.current&&(J((0,r.vE)(A.current)),A.current=e,u(e),G(!0))},[J,G]),H=e=>{q.current?W(e):(A.current=e,u(e))},V=(0,s.useCallback)(()=>{if(!q.current)return;const e=U.current.pop();null!=e&&(D.current.push((0,r.vE)(A.current)),u((0,r.Tz)(JSON.parse(e))),L(null),G(!0),I(e=>e+1))},[]),Q=(0,s.useCallback)(()=>{if(!q.current)return;const e=D.current.pop();null!=e&&(U.current.push((0,r.vE)(A.current)),u((0,r.Tz)(JSON.parse(e))),L(null),G(!0),I(e=>e+1))},[]),ee=async(e=!1)=>{if(!q.current)return!1;const t=await P.current.props.on_save((0,r.vE)(A.current),e);return t&&G(!1),t};(0,s.useEffect)(()=>{e.register?.({save:ee,is_dirty:()=>z.current,is_edit_mode:()=>k})},[e.register,k]),(0,s.useEffect)(()=>{P.current.props.on_edit_mode_change?.(k)},[k]),(0,s.useEffect)(()=>{if(e.doc)return u(e.doc),b(1),h(!1),void v("");if(!e.url)return;let n=!1;return h(!0),v(""),U.current=[],D.current=[],I(e=>e+1),L(null),G(!1),(async()=>{try{const t=await i.l.get(e.url);if(n)return;const s=(0,r.dO)(t)??(0,r.bw)();u(s),b((0,r.$4)(s.layout.zoom??1,.3,3,1)),window.setTimeout(()=>{const e=T.current;e&&(e.scrollLeft=(s.layout.scroll_x??0)*(s.layout.zoom??1),e.scrollTop=(s.layout.scroll_y??0)*(s.layout.zoom??1))},60)}catch{if(n)return;v(t("加载时间线失败")),(0,l.zN)(t("加载时间线失败"))}finally{n||h(!1)}})(),()=>{n=!0}},[e.url,e.doc]);const te=e=>{return Math.max(d,(t=e.id,g[t]??d))+10;var t},ne=e=>e.collapsed?te(e):d+(e=>{const t="vertical"===n.layout.direction?96:240,s={left:0,right:0};return e.events.forEach((e,i)=>{const l=n.layout.alternate?i%2==0?"left":"right":e.side;s[l]+=(y[e.id]??t)+12}),Math.max(s.left,s.right)})(e),se=(0,s.useMemo)(()=>{const e=[];let t=0;for(const s of n.phases)e.push(t),t+=s.collapsed?Math.max(d,g[s.id]??d)+10:ne(s);return e},[n.phases,g,y]);(0,s.useEffect)(()=>{const e=e=>{const t=M.current,n=S.current;if(!t||!n)return;const s=n.getBoundingClientRect(),i=K.current,l=("vertical"===A.current.layout.direction?e.clientY-s.top:e.clientX-s.left)/i,a=A.current.phases;let r=a.length-1;for(let e=0;e<a.length;e++){if(l<=se[e]+ne(a[e])){r=e;break}}const c=r<=t.from?se[r]:se[r]+ne(a[r]);F(c),r!==t.from&&(((e,t)=>{const n=[...A.current.phases];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;const[s]=n.splice(e,1);n.splice(t,0,s);const i={...A.current,phases:n};A.current=i,u(i)})(t.from,r),t.from=r)},t=()=>{const e=M.current;e&&(M.current=null,document.body.classList.remove("timeline-phase-dragging"),Y(null),F(null),null!=e.snapshot&&e.snapshot!==(0,r.vE)(A.current)&&(J(e.snapshot),G(!0)))};return document.addEventListener("pointermove",e),document.addEventListener("pointerup",t),document.addEventListener("pointercancel",t),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",t),document.removeEventListener("pointercancel",t)}},[se,J]);const ie=(e,t,s)=>{if(!q.current)return;if(0!==e.button)return;e.target.closest("input, textarea, button, select, [data-event-width], [data-event-link]")||(e.stopPropagation(),$("event"),L(n.phases[t].events[s].id))},le=(e,t)=>{if(!q.current)return;const n=A.current.phases[t];if(!n)return;const s="vertical"===A.current.layout.direction,i=K.current;let l=n.head_width??0;if(!l){const t=e.currentTarget.closest(".timeline-phase__head");t&&(l=t.getBoundingClientRect().width/i)}const a=s?e.clientX:e.clientY,c=n.id,o=(0,r.vE)(A.current),d=e=>{let t=((s?e.clientX:e.clientY)-a)/i;s&&(t=-t);const n=Math.round((0,r.$4)(l+t,80,1200,l)),o={...A.current,phases:A.current.phases.map(e=>e.id===c?{...e,head_width:n}:e)};A.current=o,u(o)},m=()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",m),o!==(0,r.vE)(A.current)&&(J(o),G(!0))};document.addEventListener("pointermove",d),document.addEventListener("pointerup",m)},ae=(e,t,n,s)=>{if(!q.current)return;const i=A.current.phases[t]?.events[n];if(!i)return;const l="vertical"===A.current.layout.direction,a=K.current;let c=i.width??0;if(!c){const t=e.currentTarget.closest(".timeline-event");t&&(c=t.getBoundingClientRect().width/a)}const o=l?e.clientX:e.clientY,d=i.id,m=(0,r.vE)(A.current),h=e=>{let t=((l?e.clientX:e.clientY)-o)/a;"left"===s&&(t=-t);const n=Math.round((0,r.$4)(c+t,80,1200,c)),i={...A.current,phases:A.current.phases.map(e=>({...e,events:e.events.map(e=>e.id===d?{...e,width:n}:e)}))};A.current=i,u(i)},p=()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",p),m!==(0,r.vE)(A.current)&&(J(m),G(!0))};document.addEventListener("pointermove",h),document.addEventListener("pointerup",p)},re=(e,t,n,s)=>{if(!q.current)return;const i=A.current.phases[t]?.events[n];if(!i)return;const l="vertical"===A.current.layout.direction,a=K.current,c=i.link_length??42,o=l?e.clientX:e.clientY,d=i.id,m=(0,r.vE)(A.current),h=e=>{let t=((l?e.clientX:e.clientY)-o)/a;"left"===s&&(t=-t);const n=(0,r.$4)(c+t,8,800,c),i={...A.current,phases:A.current.phases.map(e=>({...e,events:e.events.map(e=>e.id===d?{...e,link_length:n}:e)}))};A.current=i,u(i)},p=()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",p),m!==(0,r.vE)(A.current)&&(J(m),G(!0))};document.addEventListener("pointermove",h),document.addEventListener("pointerup",p)};(0,s.useEffect)(()=>{const e=T.current;if(!e)return;const t=e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=e.deltaY>0?-.1:.1;b(e=>(0,r.$4)(Number((e+t).toFixed(2)),.3,3,1))};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[]);const ce=e=>{W({...A.current,layout:{...A.current.layout,...e}})},oe=e=>{const t=(0,r.$4)(Number(e.toFixed(2)),.3,3,1);b(t),q.current&&ce({zoom:t})},de=(e,t)=>{W({...A.current,phases:A.current.phases.map(n=>({...n,events:n.events.map(n=>n.id===e?{...n,...t}:n)}))})},ue=(e,t)=>{H({...A.current,phases:A.current.phases.map(n=>n.id===e?{...n,...t}:n)})},me=(e,t)=>{const n=A.current.phases,s=n.findIndex(t=>t.id===e);if(s<0)return;const i="before"===t?s:s+1,l=[...n];l.splice(i,0,(0,r.vT)(i)),H({...A.current,phases:l})},he=(e,t)=>{const n=[...A.current.phases],s=n.findIndex(t=>t.id===e),i=s+t;s<0||i<0||i>=n.length||([n[s],n[i]]=[n[i],n[s]],W({...A.current,phases:n}))},pe=(e,t)=>{W({...A.current,phases:A.current.phases.map(n=>{const s=n.events.findIndex(t=>t.id===e),i=s+t;if(s<0||i<0||i>=n.events.length)return n;const l=[...n.events];return[l[s],l[i]]=[l[i],l[s]],{...n,events:l}})})},_e=e=>{q.current&&(M.current={from:e,snapshot:(0,r.vE)(A.current)},Y(A.current.phases[e]?.id??null),document.body.classList.add("timeline-phase-dragging"))},ve=e=>{const t=A.current.phases.find(t=>t.id===e);if(!t)return;const n=t.events.filter(e=>"left"===e.side).length,s=n<=t.events.length-n?"left":"right",i=(0,r.IG)(s,.5),l=A.current.phases.map(t=>t.id===e?{...t,events:[...t.events,i]}:t);W({...A.current,phases:l}),$("event"),L(i.id)},xe=e=>{W({...A.current,phases:A.current.phases.map(t=>({...t,events:t.events.filter(t=>t.id!==e)}))}),L(t=>t===e?null:t)},be=e=>{$("phase"),L(e)},ge=e=>{W({...A.current,phases:A.current.phases.filter(t=>t.id!==e)}),L(t=>t===e?null:t)},fe=()=>{const e=P.current.props.url??"";let t=e;const n=e.indexOf("?");if(n>=0){t=new URLSearchParams(e.slice(n+1)).get("file")||""}t||(t=e.split("?")[0]);let s=t.split("/").filter(Boolean).pop()??"";for(let e=0;e<2;e++)try{const e=decodeURIComponent(s);if(e===s)break;s=e}catch{break}return s.replace(/\.timeline$/,"")||"timeline"};(0,s.useEffect)(()=>{const e=S.current,t=T.current;if(!e||!t||"vertical"!==n.layout.direction)return;e.style.setProperty("--side-scroll","0px");const s=t.clientWidth/2,i=t.getBoundingClientRect().left+s;let l=0;e.querySelectorAll(".timeline-event").forEach(e=>{const t=e.getBoundingClientRect();l=Math.max(l,i-t.left,t.right-i)}),e.style.setProperty("--side-scroll",`${Math.max(120,Math.ceil(l)+40)}px`)},[n.phases,n.layout.direction,n.layout.card_style,n.layout.node_style,x]);const je=(0,s.useRef)(0);(0,s.useEffect)(()=>{const e=e=>{const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=e.ctrlKey||e.metaKey;return!n||"s"!==e.key&&"S"!==e.key?!n||"z"!==e.key&&"Z"!==e.key?!n||"y"!==e.key&&"Y"!==e.key?void(("Delete"===e.key||"Backspace"===e.key)&&E&&"event"===R&&q.current&&(e.preventDefault(),xe(E))):(e.preventDefault(),e.stopPropagation(),void Q()):(e.preventDefault(),e.stopPropagation(),void(e.shiftKey?Q():V())):(e.preventDefault(),e.stopPropagation(),void ee())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E,R]);const ye="event"===R&&E?(e=>{for(const t of n.phases){const n=t.events.find(t=>t.id===e);if(n)return{event:n,phase:t}}return null})(E):null,Ne="phase"===R&&E?n.phases.find(e=>e.id===E)??null:null,we=n.layout,ke=n.phases.length>0&&n.phases.every(e=>e.collapsed);return(0,o.jsxs)("div",{className:`timeline-wrap${e.fullscreen?" timeline-wrap--full":""}${e.readonly?" timeline-wrap--readonly":""}`,children:[e.header,!e.readonly&&(0,o.jsxs)("div",{className:"timeline-toolbar",children:[(0,o.jsx)("button",{type:"button",className:"timeline-btn"+(k?" timeline-btn--on":""),title:t(k?"退出编辑模式":"进入编辑模式"),onClick:()=>C(e=>!e),children:(0,o.jsx)("span",{className:"material-icons",children:k?"edit":"visibility"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t(ke?"展开全部阶段":"折叠全部阶段"),onClick:()=>{const e=A.current.phases.some(e=>!e.collapsed);H({...A.current,phases:A.current.phases.map(t=>({...t,collapsed:e}))})},children:(0,o.jsx)("span",{className:"material-icons",children:ke?"unfold_more":"unfold_less"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("阶段倒置"),onClick:()=>{const e=[...A.current.phases].reverse();H({...A.current,phases:e})},children:(0,o.jsx)("span",{className:"material-icons",children:"swap_vert"})}),k&&(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("添加阶段"),onClick:()=>{const e=A.current.phases.length;W({...A.current,phases:[...A.current.phases,(0,r.vT)(e)]})},children:(0,o.jsx)("span",{className:"material-icons",children:"add_box"})})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("导出 SVG"),onClick:()=>{const e=(0,r.Ao)(A.current),t=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=fe()+".svg",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)},children:(0,o.jsx)("span",{className:"material-icons",children:"download"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("导出图片"),onClick:()=>{const e=(0,r.Ao)(A.current),n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),s=URL.createObjectURL(n),i=new Image;i.onload=()=>{const e=document.createElement("canvas");e.width=2*i.width||1200,e.height=2*i.height||800;const t=e.getContext("2d");t&&(t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.drawImage(i,0,0,e.width,e.height),e.toBlob(e=>{if(!e)return;const t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=fe()+".png",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},"image/png")),URL.revokeObjectURL(s)},i.onerror=()=>{(0,l.zN)(t("导出图片失败")),URL.revokeObjectURL(s)},i.src=s},children:(0,o.jsx)("span",{className:"material-icons",children:"image"})}),k&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"timeline-toolbar__divider"}),(0,o.jsxs)("div",{className:"timeline-seg",children:[(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+(Z?" timeline-seg__btn--on":""),title:t("纵向"),onClick:()=>{Z||ce({direction:"vertical"})},children:(0,o.jsx)("span",{className:"material-icons",children:"swap_vert"})}),(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+(Z?"":" timeline-seg__btn--on"),title:t("横向"),onClick:()=>{Z&&ce({direction:"horizontal"})},children:(0,o.jsx)("span",{className:"material-icons",children:"swap_horiz"})})]}),(0,o.jsxs)("label",{className:"timeline-toolbar__select",title:t("节点样式"),children:[(0,o.jsx)("span",{className:"material-icons",children:"radio_button_checked"}),(0,o.jsxs)("select",{value:we.node_style,onChange:e=>ce({node_style:e.target.value}),children:[(0,o.jsx)("option",{value:"dot",children:t("圆点")}),(0,o.jsx)("option",{value:"circle",children:t("圆形")}),(0,o.jsx)("option",{value:"square",children:t("方形")}),(0,o.jsx)("option",{value:"image",children:t("图片")})]})]}),(0,o.jsxs)("label",{className:"timeline-toolbar__select",title:t("卡片样式"),children:[(0,o.jsx)("span",{className:"material-icons",children:"crop_square"}),(0,o.jsxs)("select",{value:we.card_style,onChange:e=>ce({card_style:e.target.value}),children:[(0,o.jsx)("option",{value:"card",children:t("卡片")}),(0,o.jsx)("option",{value:"plain",children:t("朴素")}),(0,o.jsx)("option",{value:"bubble",children:t("气泡")})]})]}),(0,o.jsxs)("label",{className:"timeline-toolbar__select",title:t("连线风格"),children:[(0,o.jsx)("span",{className:"material-icons",children:"linear_scale"}),(0,o.jsxs)("select",{value:we.line_style,onChange:e=>ce({line_style:e.target.value}),children:[(0,o.jsx)("option",{value:"solid",children:t("实线")}),(0,o.jsx)("option",{value:"dashed",children:t("虚线")}),(0,o.jsx)("option",{value:"dotted",children:t("点线")})]})]}),(0,o.jsx)("button",{type:"button",className:"timeline-btn"+(we.show_connector?" timeline-btn--on":""),title:t("显示连线"),onClick:()=>ce({show_connector:!we.show_connector}),children:(0,o.jsx)("span",{className:"material-icons",children:"timeline"})})]}),(0,o.jsx)("span",{className:"timeline-toolbar__gap"}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("撤销")+" (Ctrl+Z)","data-tick":O,disabled:0===U.current.length,onClick:V,children:(0,o.jsx)("span",{className:"material-icons",children:"undo"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("重做")+" (Ctrl+Y)",disabled:0===D.current.length,onClick:Q,children:(0,o.jsx)("span",{className:"material-icons",children:"redo"})}),(0,o.jsxs)("span",{className:"timeline-toolbar__zoom",children:[Math.round(100*x),"%"]}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("缩小"),onClick:()=>oe(x-.1),children:(0,o.jsx)("span",{className:"material-icons",children:"remove"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("放大"),onClick:()=>oe(x+.1),children:(0,o.jsx)("span",{className:"material-icons",children:"add"})}),(0,o.jsx)("button",{type:"button",className:"timeline-btn",title:t("重置缩放"),onClick:()=>oe(1),children:(0,o.jsx)("span",{className:"material-icons",children:"restart_alt"})})]}),(0,o.jsxs)("div",{className:"timeline-body",children:[(0,o.jsx)("div",{className:`timeline-canvas timeline-canvas--${we.direction}`,ref:T,onScroll:()=>{q.current&&(window.clearTimeout(je.current),je.current=window.setTimeout(()=>{const e=T.current;if(!e)return;const t=Math.round(e.scrollLeft/K.current),n=Math.round(e.scrollTop/K.current),s=A.current.layout;if(s.scroll_x===t&&s.scroll_y===n)return;const i={...A.current,layout:{...s,scroll_x:t,scroll_y:n}};A.current=i,u(i),G(!0)},250))},children:(0,o.jsxs)("div",{className:"timeline-inner",ref:S,style:{"--zoom":x},children:[null!==X&&(0,o.jsx)("div",{className:"timeline-drop",style:Z?{top:`${X}px`}:{left:`${X}px`}}),n.phases.map((e,n)=>(0,o.jsx)(p,{phase:e,phase_index:n,layout:we,zoom:x,vertical:Z,selected_id:E,on_event_down:ie,on_width_down:ae,on_link_down:re,on_add_event:ve,on_delete_event:xe,on_update_phase:ue,on_delete_phase:ge,on_select_phase:be,head_height:g[e.id],on_head_height:j,on_phase_width_down:le,event_heights:y,on_event_height:w,edit_mode:k,on_phase_drag_start:_e,drag_phase_id:B,t},e.id))]})}),k&&!e.readonly&&Ne&&(0,o.jsxs)("div",{className:"timeline-panel",children:[(0,o.jsxs)("div",{className:"timeline-panel__title",children:[(0,o.jsx)("span",{className:"material-icons",children:"layers"}),(0,o.jsx)("span",{children:t("阶段")}),(0,o.jsx)("span",{className:"material-icons timeline-panel__close",title:t("关闭"),onClick:()=>L(null),children:"close"})]}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("名称")}),(0,o.jsx)(c.Z2,{width:"100%",readOnly:!k,value:Ne.name,handleInputChange:e=>ue(Ne.id,{name:e})}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("描述")}),(0,o.jsx)(c.Z2,{width:"100%",readOnly:!k,value:Ne.desc??"",handleInputChange:e=>ue(Ne.id,{desc:e})}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("颜色")}),(0,o.jsxs)("div",{className:"timeline-panel__colors",children:[r.Tw.map(e=>(0,o.jsx)("span",{className:"timeline-swatch",style:{background:e},onClick:()=>ue(Ne.id,{color:e})},e)),(0,o.jsx)("label",{className:"timeline-swatch timeline-swatch--pick",title:t("自定义颜色"),children:(0,o.jsx)("input",{type:"color",value:Ne.color||we.axis_color,onChange:e=>ue(Ne.id,{color:e.target.value})})})]}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("阶段头")}),(0,o.jsxs)("div",{className:"timeline-panel__seg",children:[(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+(!1!==Ne.head_visible?" timeline-seg__btn--on":""),onClick:()=>ue(Ne.id,{head_visible:!0}),children:t("显示")}),(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+(!1===Ne.head_visible?" timeline-seg__btn--on":""),onClick:()=>ue(Ne.id,{head_visible:!1}),children:t("隐藏")})]}),(0,o.jsx)("div",{className:"timeline-panel__hint",children:t("拖动阶段头可调整顺序")}),(0,o.jsxs)("div",{className:"timeline-panel__insert",children:[(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>me(Ne.id,"before"),children:[(0,o.jsx)("span",{className:"material-icons",children:"vertical_align_top"}),t("在阶段前插入")]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>me(Ne.id,"after"),children:[(0,o.jsx)("span",{className:"material-icons",children:"vertical_align_bottom"}),t("在阶段后插入")]})]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>ve(Ne.id),children:[(0,o.jsx)("span",{className:"material-icons",children:"add_circle"}),t("添加事件")]}),(0,o.jsxs)("div",{className:"timeline-panel__insert",children:[(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>he(Ne.id,-1),children:[(0,o.jsx)("span",{className:"material-icons",children:"arrow_upward"}),t("上移")]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>he(Ne.id,1),children:[(0,o.jsx)("span",{className:"material-icons",children:"arrow_downward"}),t("下移")]})]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__del",onClick:()=>ge(Ne.id),children:[(0,o.jsx)("span",{className:"material-icons",children:"delete"}),t("删除阶段")]})]}),k&&!e.readonly&&ye&&(0,o.jsxs)("div",{className:"timeline-panel",children:[(0,o.jsxs)("div",{className:"timeline-panel__title",children:[(0,o.jsx)("span",{className:"material-icons",children:"edit"}),(0,o.jsx)("span",{children:t("事件")}),(0,o.jsx)("span",{className:"material-icons timeline-panel__close",title:t("关闭"),onClick:()=>L(null),children:"close"})]}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("标题")}),(0,o.jsx)(c.Sm,{width:"100%",value:ye.event.title,handleInputChange:e=>de(ye.event.id,{title:e})}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("描述")}),(0,o.jsx)(c.Z2,{width:"100%",readOnly:!k,value:ye.event.desc??"",handleInputChange:e=>de(ye.event.id,{desc:e})}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("时间")}),(0,o.jsxs)("div",{className:"timeline-panel__times",children:[(0,o.jsx)(c.Sm,{width:"100%",value:ye.event.startTime??"",placeholder:t("起始时间"),handleInputChange:e=>de(ye.event.id,{startTime:e})}),(0,o.jsx)(c.Sm,{width:"100%",value:ye.event.endTime??"",placeholder:t("结束时间"),handleInputChange:e=>de(ye.event.id,{endTime:e})})]}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("图片地址")}),(0,o.jsx)(c.Sm,{width:"100%",value:ye.event.image??"",placeholder:"https://...",handleInputChange:e=>de(ye.event.id,{image:e})}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("方向")}),(0,o.jsxs)("div",{className:"timeline-panel__seg",children:[(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+("left"===ye.event.side?" timeline-seg__btn--on":""),onClick:()=>de(ye.event.id,{side:"left"}),children:t(Z?"左侧":"上侧")}),(0,o.jsx)("button",{type:"button",className:"timeline-seg__btn"+("right"===ye.event.side?" timeline-seg__btn--on":""),onClick:()=>de(ye.event.id,{side:"right"}),children:t(Z?"右侧":"下侧")})]}),(0,o.jsx)("label",{className:"timeline-panel__label",children:t("颜色")}),(0,o.jsxs)("div",{className:"timeline-panel__colors",children:[(0,o.jsx)("span",{className:"timeline-swatch timeline-swatch--auto",title:t("跟随阶段"),onClick:()=>de(ye.event.id,{color:""})}),r.Tw.map(e=>(0,o.jsx)("span",{className:"timeline-swatch",style:{background:e},onClick:()=>de(ye.event.id,{color:e})},e)),(0,o.jsx)("label",{className:"timeline-swatch timeline-swatch--pick",title:t("自定义颜色"),children:(0,o.jsx)("input",{type:"color",value:ye.event.color||Ne?.color||we.axis_color,onChange:e=>de(ye.event.id,{color:e.target.value})})})]}),(0,o.jsx)("div",{className:"timeline-panel__hint",children:t("用上移下移调整事件顺序,用左右切换事件所在侧")}),(0,o.jsxs)("div",{className:"timeline-panel__insert",children:[(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>pe(ye.event.id,-1),children:[(0,o.jsx)("span",{className:"material-icons",children:"arrow_upward"}),t("上移")]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>pe(ye.event.id,1),children:[(0,o.jsx)("span",{className:"material-icons",children:"arrow_downward"}),t("下移")]})]}),(0,o.jsxs)("button",{type:"button",className:"timeline-panel__del",onClick:()=>xe(ye.event.id),children:[(0,o.jsx)("span",{className:"material-icons",children:"delete"}),t("删除事件")]})]})]}),m&&(0,o.jsx)("div",{className:"timeline-mask",children:"Loading..."}),_&&(0,o.jsx)("div",{className:"timeline-mask",children:_})]})}function p(e){const{phase:t,layout:n,zoom:i,vertical:l,selected_id:a,t:r}=e,c=t.color||n.axis_color,m=!!t.collapsed,h=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{const n=h.current;if(!n||!1===t.head_visible)return;const s=()=>e.on_head_height(t.id,n.offsetHeight);s();const i=new ResizeObserver(s);return i.observe(n),()=>i.disconnect()},[t.id,t.name,t.desc,t.head_visible]);const p=e.head_height??d,v=(()=>{const s=l?96:240,i={left:0,right:0};return t.events.forEach((t,l)=>{const a=n.alternate?l%2==0?"left":"right":t.side;i[a]+=(e.event_heights[t.id]??s)+12}),u+p+6+Math.max(i.left,i.right)})(),x=m?Math.max(d,u+p+6)+10:v,b="solid"===n.line_style?{background:c}:{borderColor:c,borderStyle:(g=n.line_style,"dashed"===g?"dashed":"dotted"===g?"dotted":"solid")};var g;return(0,o.jsxs)("div",{className:`timeline-phase${m?" timeline-phase--collapsed":""}${e.drag_phase_id===t.id?" timeline-phase--dragging":""}`,style:l?{height:`${x}px`}:{width:`${x}px`},children:[(0,o.jsx)("div",{className:"timeline-phase__band",style:b}),!1!==t.head_visible&&(0,o.jsxs)("div",{className:"timeline-phase__head",ref:h,style:{borderColor:c,...t.head_width?{width:t.head_width,maxWidth:"none"}:{}},onPointerDown:n=>{const s=n.target;s.closest(".timeline-phase__op")||s.closest(".timeline-phase__drag")||s.closest(".timeline-phase__toggle")||e.on_select_phase(t.id)},children:[(0,o.jsx)("span",{className:"material-icons timeline-phase__drag",title:r("拖动排序"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_phase_drag_start(e.phase_index)},children:"drag_indicator"}),(0,o.jsx)("span",{className:"material-icons timeline-phase__toggle",title:r(m?"展开":"折叠"),onClick:()=>e.on_update_phase(t.id,{collapsed:!m}),children:m?"expand_more":"expand_less"}),(0,o.jsx)("div",{className:"timeline-phase__name",style:{color:c},title:t.name,children:t.name}),t.desc&&(0,o.jsx)("div",{className:"timeline-phase__desc",title:t.desc,children:t.desc}),(0,o.jsx)("div",{className:"timeline-phase__width","data-phase-width":t.id,title:r("拖动调整宽度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_phase_width_down(t,e.phase_index)}})]}),!m&&(0,o.jsxs)(o.Fragment,{children:[!1===t.head_visible&&(0,o.jsx)("span",{className:"material-icons timeline-phase__show-head",title:r("显示阶段头"),onClick:()=>e.on_update_phase(t.id,{head_visible:!0}),children:"visibility"}),(()=>{const c=e=>n.alternate?e%2==0?"left":"right":t.events[e].side,d=l?96:240,m=t=>e.event_heights[t]??d,h={left:0,right:0},v=t.events.map((e,t)=>{const n=c(t),s=h[n];return h[n]=s+m(e.id)+12,s});return t.events.map((d,h)=>{const x=c(h),b=u+p+6+v[h]+m(d.id)/2,g=n.node_style;return(0,o.jsxs)(s.Fragment,{children:[d.startTime&&(0,o.jsx)("div",{className:`timeline-event__time timeline-event__time--start timeline-event--node-${g}`,style:l?{top:b}:{left:b},children:d.startTime}),d.endTime&&(0,o.jsx)("div",{className:`timeline-event__time timeline-event__time--end timeline-event--node-${g}`,style:l?{top:b}:{left:b},children:d.endTime}),(0,o.jsx)(_,{event:d,phase:t,layout:n,vertical:l,zoom:i,side:x,along:v[h],head_size:p,on_height:t=>e.on_event_height(d.id,t),event_index:h,phase_index:e.phase_index,selected:a===d.id,on_down:e.on_event_down,on_width_down:e.on_width_down,on_link_down:e.on_link_down,on_delete:e.on_delete_event,t:r})]},d.id)})})()]})]})}function _(e){const{event:t,phase:n,layout:i,vertical:l,zoom:a,side:r,selected:c,t:h}=e,p=t.color||n.color||i.axis_color,_=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{const t=_.current;if(!t||!e.on_height)return;const n="vertical"===i.direction,s=()=>{const s=t.getBoundingClientRect(),i=Math.round((n?s.height:s.width)/a);i>0&&e.on_height(i)};s();const l=new ResizeObserver(s);l.observe(t);const r=window.setTimeout(s,300);return()=>{l.disconnect(),window.clearTimeout(r)}},[t.title,t.desc,t.image,t.width,a,i.direction,e.on_height]);const v=`${u+(e.head_size??d)+6+e.along}px`,x={"--ev-color":p};null!=t.link_length&&(x["--side-gap"]=`${t.link_length}px`);const b=l?{top:v}:{left:v};return t.width&&(b.width=`${t.width}px`),(0,o.jsxs)("div",{className:`timeline-event timeline-event--${i.card_style} timeline-event--side-${r} timeline-event--node-${i.node_style}`+(c?" timeline-event--on":"")+(i.show_connector?" timeline-event--linked":""),ref:_,style:{...b,...x,borderColor:p},onPointerDown:t=>e.on_down(t,e.phase_index,e.event_index),children:[i.show_connector&&(0,o.jsx)("div",{className:"timeline-event__link",style:{borderColor:p,borderStyle:i.line_style}}),(0,o.jsx)("div",{className:`timeline-node ${m(i.node_style)}`,style:{background:"image"===i.node_style&&t.image?"transparent":p},children:"image"===i.node_style&&t.image?(0,o.jsx)("img",{src:t.image,alt:""}):null}),(0,o.jsxs)("div",{className:"timeline-event__body",children:[(0,o.jsx)("div",{className:"timeline-event__title",style:{color:p},children:t.title||h("未命名")}),t.desc&&(0,o.jsx)("div",{className:"timeline-event__desc",children:t.desc})]}),(0,o.jsx)("div",{className:"timeline-event__width","data-event-width":t.id,title:h("拖动调整卡片宽度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_width_down(t,e.phase_index,e.event_index,r)}}),i.show_connector&&(0,o.jsx)("div",{className:"timeline-event__link-handle","data-event-link":t.id,title:h("拖动调整连线长度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_link_down(t,e.phase_index,e.event_index,r)}}),(0,o.jsx)("span",{className:"material-icons timeline-event__del",title:h("删除事件"),onClick:n=>{n.stopPropagation(),e.on_delete(t.id)},children:"close"})]})}}}]);
|