filecat 7.14.4 → 7.15.0

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.
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1142],{71142(e,t,n){n.r(t),n.d(t,{default:()=>ue});var r=n(96540),s=n(7523),o=n(34843),c=n(82893),i=n(78247),a=n(23430),u=n(85997),l=n(57952),d=n(62042),m=n(53459),f=n(14284),v=n(57889),_=n(23496),h=n(22022),p=n(76118),g=n(67951),w=n(74848);function x(e){const{t}=(0,h.Bd)(),n=(0,r.useRef)(null),[s,o]=(0,r.useState)({marks:[],block:{name:"paragraph"}}),[c,i]=(0,r.useState)(null),a=(0,r.useCallback)(()=>{const t=e.get_view();if(!t)return;const n=t.state.selection,r=t.state.storedMarks??n.$from.marks();if(o({marks:r.map(e=>e.type.name),block:b(n.$from)}),n.empty)return void i(null);const s=t.coordsAtPos(n.from),c=t.coordsAtPos(n.to),a=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,u=Math.min(s.top,c.top),l=Math.max(s.bottom,c.bottom);i({top:u,bottom:l,left:a})},[e.get_view]);(0,r.useEffect)(()=>{a();const t=e.get_view();if(!t)return;const n=()=>a();t.dom.addEventListener("keyup",n),t.dom.addEventListener("mouseup",n),document.addEventListener("selectionchange",n);const r=t.dom.closest(".md-editor-context");return r?.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n),()=>{t.dom.removeEventListener("keyup",n),t.dom.removeEventListener("mouseup",n),document.removeEventListener("selectionchange",n),r?.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[a,e.get_view,e.refresh_key]);const u=t=>{const n=e.get_view();n&&(t(n.state,n.dispatch),n.focus(),a())},l=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,f]=(0,r.useState)({w:0,h:36});if((0,r.useLayoutEffect)(()=>{if(!c||!n.current)return;const e=n.current.offsetWidth,t=n.current.offsetHeight;f(n=>n.w===e&&n.h===t?n:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const v=(e,n,r,s,o=!1)=>(0,w.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(r),onMouseDown:e=>e.preventDefault(),onClick:s,children:n},e),_=m.w/2,p=_+4,x=Math.max(p,window.innerWidth-_-4),k=document.querySelector(".header")?.getBoundingClientRect().bottom??0,y=c.top-m.h-8,E=y<k+4,j={top:E?Math.min(c.bottom+8,window.innerHeight-m.h-4):y,left:Math.min(x,Math.max(p,c.left))};return(0,w.jsxs)("div",{className:"mdtb mdtb--floating"+(E?" mdtb--below":""),ref:n,style:j,children:[v("h1","H1","一级标题",()=>u((0,g.uf)("heading",{level:1})),d(1)),v("h2","H2","二级标题",()=>u((0,g.uf)("heading",{level:2})),d(2)),v("h3","H3","三级标题",()=>u((0,g.uf)("heading",{level:3})),d(3)),(0,w.jsx)("span",{className:"mdtb__sep"}),v("b","B","加粗",()=>u((0,g.NH)("strong")),l("strong")),v("i","I","斜体",()=>u((0,g.NH)("em")),l("em")),v("s","S","删除线",()=>u((0,g.NH)("strike")),l("strike")),v("code","</>","行内代码",()=>u((0,g.NH)("code")),l("code")),(0,w.jsx)("span",{className:"mdtb__sep"}),v("ul","≔","无序列表",()=>u(g.fK)),v("ol","1.","有序列表",()=>u(g.oB)),v("quote","❝","引用",()=>u(g.Vu))]})}function b(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.name;if("heading"===n)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===n)return{name:"paragraph"}}return{name:"paragraph"}}var k=n(75725),y=n(86059);const E="cut",j="copy",S="paste",C="strong",N="em",R="strike",L="code",A="h1",H="h2",M="h3",G="paragraph",z="bullet",B="ordered",P="quote",$="code_block",F="clean",D="row_before",K="row_after",I="row_delete",T="col_before",U="col_after",W="col_delete",Y="header_toggle",X="cell_merge",q="cell_split",V="table_delete",J="table_insert",O="select_all";function Z(e){const{t}=(0,h.Bd)(),[n,s]=(0,r.useState)(null),o=(0,r.useRef)(e.get_view);o.current=e.get_view,(0,r.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const n=e.target;if(!n||!n.closest(".md-filecat-content"))return;e.preventDefault();const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(r){const e=t.state.selection;if(r.pos<e.from||r.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(r.pos))))}catch{}}}const c=!!n.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,y.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),i=(0,r.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),a=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!n)return null;const u=n.in_table?[{r:t("上方插入行"),v:D},{r:t("下方插入行"),v:K},{r:t("左侧插入列"),v:T},{r:t("右侧插入列"),v:U},{r:t("删除行"),v:I},{r:t("删除列"),v:W},{r:t("切换表头行"),v:Y},{r:t("合并单元格"),v:X},{r:t("拆分单元格"),v:q},{r:t("删除表格"),v:V}]:[],l=[{r:t("剪切"),v:E},{r:t("复制"),v:j},{r:t("粘贴"),v:S},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:C},{r:t("斜体"),v:N},{r:t("删除线"),v:R},{r:t("行内代码"),v:L}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:A},{r:t("二级标题"),v:H},{r:t("三级标题"),v:M},{r:t("正文"),v:G}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:z},{r:t("有序列表"),v:B},{r:t("引用"),v:P},{r:t("代码块"),v:$},{r:t("插入表格"),v:J}]},...u.length?[{r:t("表格"),v:"table",items:u}]:[],{r:t("清除格式"),v:F},{r:t("全选"),v:O}];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k.rY,{click:c}),(0,w.jsx)(k.Pu,{x:n.x,y:n.y,items:l,click:t=>{switch(t){case E:return a("cut");case j:return a("copy");case S:return a("paste");case C:return i((0,g.NH)("strong"));case N:return i((0,g.NH)("em"));case R:return i((0,g.NH)("strike"));case L:return i((0,g.NH)("code"));case A:return i((0,g.uf)("heading",{level:1}));case H:return i((0,g.uf)("heading",{level:2}));case M:return i((0,g.uf)("heading",{level:3}));case G:return i((0,g.uf)("paragraph"));case z:return i(g.fK);case B:return i(g.oB);case P:return i(g.Vu);case $:return i((0,g.uf)("code_block"));case J:return c(),void e.on_insert_table?.();case D:return i(y.JD);case K:return i(y.gC);case T:return i(y.RC);case U:return i(y.GU);case I:return i(y.aR);case W:return i(y.gR);case Y:return i(y.uC);case X:return i(y.w7);case q:return i(y.L0);case V:return i(y.kG);case F:return i((e,t)=>{const{from:n,to:r}=e.selection;let s=e.tr;return e.doc.nodesBetween(n,r,(e,t)=>{if(e.isText)for(const n of e.marks)s=s.removeMark(t,t+e.nodeSize,n.type)}),t?.(s),!0});case O:return i((e,t)=>{const{TextSelection:n}=e.selection.constructor;return t?.(e.tr.setSelection(n.create(e.doc,0,e.doc.content.size))),!0})}}})]})}var Q=n(64877);function ee(e){const t=[];if(!e)return t;const n=e.split(/(\n)/);let r=null,s=0;for(let e=0;e<n.length;e+=2){const o=n[e],c=s;s+=o.length+(n[e+1]?.length??0);const i=o.endsWith("\r")?o.slice(0,-1):o,a=i.trimStart(),u=/^(`{3,}|~{3,})/.exec(a);if(u){const e=u[1][0];null===r?r=e:r===e&&(r=null);continue}if(null!==r)continue;const l=/^ {0,3}(#{1,6})\s+(.*)$/.exec(i);if(!l)continue;const d=l[1].length,m=l[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var te=n(69918),ne=n(96763),re=n(40505);function se(e){const{t}=(0,h.Bd)(),[n,s]=(0,r.useState)(!1),[i,a]=(0,r.useState)({x:0,y:0}),[l,d]=(0,r.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,r.useEffect)(()=>{if(!n)return;let e=!1;return(0,ne.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[n]);const f=(e,t)=>(0,w.jsx)("div",{style:{...(0,re.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,w.jsxs)(r.Fragment,{children:[(0,w.jsx)(u.rA,{icon:"palette",title:t("主题"),onClick:e=>{a({x:e.clientX,y:e.clientY}),s(!0)}}),n&&(0,w.jsx)(k.rY,{click:()=>s(!1),children:(0,w.jsx)(k.Pu,{x:i.x,y:i.y,items:[{r:f(t("follow_sys"),""),v:""},...l.map(e=>({r:f(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var oe=n(2543),ce=n(61973),ie=n(87361),ae=n(93245);function ue(e){const t=e.pane,{t:n}=(0,h.Bd)(),g=(0,ce.Zp)(),{check_user_auth:b}=(0,i.MH)(),k=b(a.oV.md_editor_setting),[y,E]=(0,o.fp)(c.AG.md_editor),j=t??y,S=(0,o.fp)(c.AG.md_editor_last_context)[1],C=(0,r.useRef)(null),[N,R]=(0,r.useState)(null),[L,A]=(0,r.useState)(!1),[H,M]=(0,r.useState)(!1),[G,z]=(0,r.useState)(0),B=(0,r.useRef)(null),[P,$]=(0,r.useState)([]),[F,D]=(0,r.useState)(-1),[K,I]=(0,r.useState)(15),[T,U]=(0,r.useState)(!1),W=(0,r.useRef)(null),Y=(0,r.useRef)(null),[X,q]=(0,o.fp)(c.AG.md_editor_show_outline),[V,J]=(0,o.fp)(c.AG.md_editor_mode),O=(0,r.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=B.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),J(e))},[V]),[re]=(0,o.fp)(c.AG.md_editor_setting),[ue,le]=(0,o.fp)(c.AG.md_theme_css),[de]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:me}=(0,r.useContext)(s.F),fe=(0,r.useRef)(null),ve=(0,r.useRef)(null);(0,r.useEffect)(()=>{ve.current},[de]),(0,r.useEffect)(()=>{(0,te.Ce)(W.current,re)},[re]);(0,r.useEffect)(()=>{(0,ne.bN)("editor",ue)},[ue]),(0,r.useEffect)(()=>{const e=()=>{(0,ne.sO)().then(le)};return window.addEventListener(ne.o3,e),()=>window.removeEventListener(ne.o3,e)},[]);const _e=(0,r.useRef)([]),he=(0,r.useCallback)(()=>{const e=B.current;if(!e)return;const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();_e.current=t,$(t)},[]);(0,r.useEffect)(()=>{t?.on_outline?.(P,F)},[P,F]);const pe=(0,r.useCallback)(()=>{const e=B.current,t=e?.get_view();if(!e||!t)return;const n=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let r=-1;for(const e of _e.current){if(!(e.pos<=n))break;r=e.pos}D(r)},[]);(0,r.useEffect)(()=>{let e=!1;if(j?.url)return M(!1),A(!0),v.l.get(j.url).then(t=>{if(e)return;R(t??"")}).catch(()=>{e||((0,d.zN)(n("打开失败")),R(""))}).finally(()=>{e||A(!1)}),()=>{e=!0};R(null)},[j?.url]),(0,r.useEffect)(()=>{const e=()=>z(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const ge=(0,r.useRef)(O);ge.current=O,(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),ge.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,r.useEffect)(()=>{he(),pe()},[G,V,he,pe]);const we=(0,r.useCallback)(oe.throttle(e=>{if(!W.current||!Y.current)return;const t=parseFloat(getComputedStyle(W.current).fontSize),n=e.clientX/t,r=window.innerWidth/t-4,s=2.25+Y.current.offsetWidth/t;n<=r&&n>=s&&I(parseFloat(n.toFixed(2)))},32),[]),xe=()=>{U(!1),W.current?.removeEventListener("pointermove",we)},be=e=>{const t=B.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),D(e.pos))},ke=async(e=!1)=>{if(!j?.name||!j?.path)return;const t=B.current?.get_markdown();if(void 0===t)return;const r=j.path.slice(0,j.path.length-j.name.length),s=`${encodeURIComponent(r)}${j.name}`;(await f.$M.post(`save/${s}`,{context:t})).code===m.m.Success?(M(!1),e||(0,d.SK)(n("保存成功"))):(0,d.zN)(n("保存失败"))},ye=(0,r.useRef)(ke);ye.current=ke;const Ee=(0,r.useRef)(H);Ee.current=H,(0,ae.a)(a.nE.md,()=>Ee.current,e=>ke(e),j.readonly);const je=()=>{window.print()},Se=(0,r.useRef)(V);Se.current=V;const Ce=(0,r.useRef)(be);Ce.current=be;const Ne=(0,r.useRef)(je);Ne.current=je,(0,r.useEffect)(()=>{t?.on_dirty?.(H)},[H]),(0,r.useEffect)(()=>{t?.register?.({save:e=>ye.current(e),export_pdf:()=>Ne.current(),toggle_mode:()=>ge.current(),mode:()=>Se.current,goto_heading:e=>Ce.current(e),dirty:()=>Ee.current})},[]);const Re=()=>{E({}),M(!1),R(null),B.current=null,y?.close?.()},Le=(0,r.useMemo)(()=>j?.url??"md_editor",[j?.url]);if(!j?.name)return null;const Ae=!!t,He=(0,w.jsxs)("div",{className:"md-editor-context",ref:W,children:[L&&(0,w.jsxs)("div",{className:"common-box common-box-center",children:[n("加载中"),"..."]}),!L&&null!==N&&(0,w.jsxs)(r.Fragment,{children:[!Ae&&X&&(0,w.jsx)("div",{className:"md-outline-panel",style:{width:`${K}em`},children:(0,w.jsx)(Q.default,{items:P,active_pos:F,on_click:be})}),!Ae&&X&&(0,w.jsx)("div",{className:"md-editor-divider",ref:Y,onPointerDown:()=>{U(!0),W.current?.addEventListener("pointermove",we)},onPointerUp:xe}),!Ae&&T&&(0,w.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:xe}),(0,w.jsx)("div",{className:"md-editor-scroll",children:(0,w.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,w.jsx)(x,{get_view:()=>B.current?.get_view()??null,refresh_key:G}),(0,w.jsx)(p.A,{value:N,ref:B,initial_source_mode:"source"===V,doc_path:j?.path,on_ready:e=>{const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();_e.current=t,$(t),D(-1)},on_change:()=>{H||M(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{const e=B.current?.get_markdown()??"";e&&S(e)},800)},on_save:()=>ye.current(),on_selection_change:()=>z(e=>e+1),on_source_mode_change:e=>{J(e?"source":"wysiwyg"),z(e=>e+1)}},Le),"wysiwyg"===V&&(0,w.jsx)(Z,{get_view:()=>B.current?.get_view()??null,on_insert_table:()=>{B.current?.insert_table(3,3),M(!0)}})]})})]})]});return Ae?He:(0,w.jsxs)("div",{id:"md-editor-container",ref:fe,children:[(0,w.jsx)(l.A,{ignore_tags:!0,left_children:[(0,w.jsx)(u.rA,{title:n("关闭"),icon:"close",onClick:Re},1),(0,w.jsx)("div",{className:"md-editor-title",children:j.name},3),...H&&!j.readonly?[(0,w.jsx)(u.rA,{title:n("保存"),icon:"save",onClick:ke},2)]:[],(0,w.jsx)(u.rA,{title:n("大纲"),icon:"list",onClick:()=>q(e=>!e),selected:X},4),...j.readonly?[]:[(0,w.jsx)(u.rA,{title:n("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:O},5)],...j.readonly?[]:[(0,w.jsx)(se,{on_change:async e=>{const t=await f.wm.post(_.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:e});t?.code===m.m.Success?(ve.current=e,await me(),(0,d.SK)(n("保存成功"))):(0,d.zN)(n("保存失败"))}},8)],(0,w.jsx)(u.rA,{title:n("导出PDF"),icon:"print",onClick:je},7),...k&&!j.readonly?[(0,w.jsx)(u.rA,{title:n("编辑器设置"),icon:"settings",onClick:()=>{Re(),g(ie.o.md_editor_setting_page)}},6)]:[]]}),He]})}},93245(e,t,n){n.d(t,{a:()=>a});var r=n(96540),s=n(34843),o=n(82893),c=n(23430);const i=[{id:c.nE.ace,label:"文本编辑器(ace)"},{id:c.nE.md,label:"md编辑器"},{id:c.nE.mind,label:"思维导图编辑器"},{id:c.nE.draw,label:"draw编辑器"},{id:c.nE.timeline,label:"时间线编辑器"},{id:c.nE.image,label:"图片编辑器"},{id:c.nE.excel,label:"excel编辑器"}];function a(e,t,n,c=!1){const[i]=(0,s.fp)(o.AG.user_base_info),a=i?.user_data?.editor_auto_save,u=(0,r.useRef)(a);u.current=a;const l=(0,r.useRef)(t);l.current=t;const d=(0,r.useRef)(n);d.current=n,(0,r.useEffect)(()=>{if(c)return;const t=u.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const n=setInterval(()=>{l.current()&&d.current(!0)},1e3*t.interval);return()=>clearInterval(n)},[a,e,c])}n.d(t,["d",0,i])}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1142],{71142(e,t,n){n.r(t),n.d(t,{default:()=>le});var r=n(96540),s=n(7523),o=n(34843),c=n(82893),i=n(78247),a=n(23430),l=n(85997),u=n(57952),d=n(62042),m=n(53459),f=n(14284),v=n(57889),_=n(23496),h=n(22022),p=n(76118),g=n(67951),w=n(74848);function x(e){const{t}=(0,h.Bd)(),n=(0,r.useRef)(null),[s,o]=(0,r.useState)({marks:[],block:{name:"paragraph"}}),[c,i]=(0,r.useState)(null),a=(0,r.useCallback)(()=>{const t=e.get_view();if(!t)return;const n=t.state.selection,r=t.state.storedMarks??n.$from.marks();if(o({marks:r.map(e=>e.type.name),block:b(n.$from)}),n.empty)return void i(null);const s=t.coordsAtPos(n.from),c=t.coordsAtPos(n.to),a=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,l=Math.min(s.top,c.top),u=Math.max(s.bottom,c.bottom);i({top:l,bottom:u,left:a})},[e.get_view]);(0,r.useEffect)(()=>{a();const t=e.get_view();if(!t)return;const n=()=>a();t.dom.addEventListener("keyup",n),t.dom.addEventListener("mouseup",n),document.addEventListener("selectionchange",n);const r=t.dom.closest(".md-editor-context");return r?.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n),()=>{t.dom.removeEventListener("keyup",n),t.dom.removeEventListener("mouseup",n),document.removeEventListener("selectionchange",n),r?.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[a,e.get_view,e.refresh_key]);const l=t=>{const n=e.get_view();n&&(t(n.state,n.dispatch),n.focus(),a())},u=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,f]=(0,r.useState)({w:0,h:36});if((0,r.useLayoutEffect)(()=>{if(!c||!n.current)return;const e=n.current.offsetWidth,t=n.current.offsetHeight;f(n=>n.w===e&&n.h===t?n:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const v=(e,n,r,s,o=!1)=>(0,w.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(r),onMouseDown:e=>e.preventDefault(),onClick:s,children:n},e),_=m.w/2,p=_+4,x=Math.max(p,window.innerWidth-_-4),k=document.querySelector(".header")?.getBoundingClientRect().bottom??0,y=c.top-m.h-8,E=y<k+4,j={top:E?Math.min(c.bottom+8,window.innerHeight-m.h-4):y,left:Math.min(x,Math.max(p,c.left))};return(0,w.jsxs)("div",{className:"mdtb mdtb--floating"+(E?" mdtb--below":""),ref:n,style:j,children:[v("h1","H1","一级标题",()=>l((0,g.uf)("heading",{level:1})),d(1)),v("h2","H2","二级标题",()=>l((0,g.uf)("heading",{level:2})),d(2)),v("h3","H3","三级标题",()=>l((0,g.uf)("heading",{level:3})),d(3)),(0,w.jsx)("span",{className:"mdtb__sep"}),v("b","B","加粗",()=>l((0,g.NH)("strong")),u("strong")),v("i","I","斜体",()=>l((0,g.NH)("em")),u("em")),v("s","S","删除线",()=>l((0,g.NH)("strike")),u("strike")),v("code","</>","行内代码",()=>l((0,g.NH)("code")),u("code")),(0,w.jsx)("span",{className:"mdtb__sep"}),v("ul","≔","无序列表",()=>l(g.fK)),v("ol","1.","有序列表",()=>l(g.oB)),v("quote","❝","引用",()=>l(g.Vu))]})}function b(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.name;if("heading"===n)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===n)return{name:"paragraph"}}return{name:"paragraph"}}var k=n(75725),y=n(86059);const E="cut",j="copy",S="paste",C="strong",N="em",R="strike",L="code",A="h1",H="h2",M="h3",G="paragraph",z="bullet",B="ordered",$="quote",F="code_block",D="clean",K="row_before",P="row_after",I="row_delete",T="col_before",U="col_after",W="col_delete",Y="header_toggle",X="cell_merge",q="cell_split",V="table_delete",J="table_insert",O="select_all";function Z(e){const{t}=(0,h.Bd)(),[n,s]=(0,r.useState)(null),o=(0,r.useRef)(e.get_view);o.current=e.get_view,(0,r.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const n=e.target;if(!n||!n.closest(".md-filecat-content"))return;e.preventDefault();const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(r){const e=t.state.selection;if(r.pos<e.from||r.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(r.pos))))}catch{}}}const c=!!n.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,y.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),i=(0,r.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),a=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!n)return null;const l=n.in_table?[{r:t("上方插入行"),v:K},{r:t("下方插入行"),v:P},{r:t("左侧插入列"),v:T},{r:t("右侧插入列"),v:U},{r:t("删除行"),v:I},{r:t("删除列"),v:W},{r:t("切换表头行"),v:Y},{r:t("合并单元格"),v:X},{r:t("拆分单元格"),v:q},{r:t("删除表格"),v:V}]:[],u=[{r:t("剪切"),v:E},{r:t("复制"),v:j},{r:t("粘贴"),v:S},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:C},{r:t("斜体"),v:N},{r:t("删除线"),v:R},{r:t("行内代码"),v:L}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:A},{r:t("二级标题"),v:H},{r:t("三级标题"),v:M},{r:t("正文"),v:G}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:z},{r:t("有序列表"),v:B},{r:t("引用"),v:$},{r:t("代码块"),v:F},{r:t("插入表格"),v:J}]},...l.length?[{r:t("表格"),v:"table",items:l}]:[],{r:t("清除格式"),v:D},{r:t("全选"),v:O}];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k.rY,{click:c}),(0,w.jsx)(k.sw,{x:n.x,y:n.y,items:u,click:t=>{switch(t){case E:return a("cut");case j:return a("copy");case S:return a("paste");case C:return i((0,g.NH)("strong"));case N:return i((0,g.NH)("em"));case R:return i((0,g.NH)("strike"));case L:return i((0,g.NH)("code"));case A:return i((0,g.uf)("heading",{level:1}));case H:return i((0,g.uf)("heading",{level:2}));case M:return i((0,g.uf)("heading",{level:3}));case G:return i((0,g.uf)("paragraph"));case z:return i(g.fK);case B:return i(g.oB);case $:return i(g.Vu);case F:return i((0,g.uf)("code_block"));case J:return c(),void e.on_insert_table?.();case K:return i(y.JD);case P:return i(y.gC);case T:return i(y.RC);case U:return i(y.GU);case I:return i(y.aR);case W:return i(y.gR);case Y:return i(y.uC);case X:return i(y.w7);case q:return i(y.L0);case V:return i(y.kG);case D:return i((e,t)=>{const{from:n,to:r}=e.selection;let s=e.tr;return e.doc.nodesBetween(n,r,(e,t)=>{if(e.isText)for(const n of e.marks)s=s.removeMark(t,t+e.nodeSize,n.type)}),t?.(s),!0});case O:return i((e,t)=>{const{TextSelection:n}=e.selection.constructor;return t?.(e.tr.setSelection(n.create(e.doc,0,e.doc.content.size))),!0})}}})]})}var Q=n(64877);function ee(e){const t=[];if(!e)return t;const n=e.split(/(\n)/);let r=null,s=0;for(let e=0;e<n.length;e+=2){const o=n[e],c=s;s+=o.length+(n[e+1]?.length??0);const i=o.endsWith("\r")?o.slice(0,-1):o,a=i.trimStart(),l=/^(`{3,}|~{3,})/.exec(a);if(l){const e=l[1][0];null===r?r=e:r===e&&(r=null);continue}if(null!==r)continue;const u=/^ {0,3}(#{1,6})\s+(.*)$/.exec(i);if(!u)continue;const d=u[1].length,m=u[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var te=n(69918),ne=n(96763),re=n(40505);function se(e){const{t}=(0,h.Bd)(),[n,s]=(0,r.useState)(!1),[i,a]=(0,r.useState)({x:0,y:0}),[u,d]=(0,r.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,r.useEffect)(()=>{if(!n)return;let e=!1;return(0,ne.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[n]);const f=(e,t)=>(0,w.jsx)("div",{style:{...(0,re.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,w.jsxs)(r.Fragment,{children:[(0,w.jsx)(l.rA,{icon:"palette",title:t("主题"),onClick:e=>{a({x:e.clientX,y:e.clientY}),s(!0)}}),n&&(0,w.jsx)(k.rY,{click:()=>s(!1),children:(0,w.jsx)(k.sw,{x:i.x,y:i.y,items:[{r:f(t("follow_sys"),""),v:""},...u.map(e=>({r:f(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var oe=n(2543),ce=n(61973),ie=n(87361),ae=n(93245);function le(e){const t=e.pane,{t:n}=(0,h.Bd)(),g=(0,ce.Zp)(),{check_user_auth:b}=(0,i.MH)(),k=b(a.oV.md_editor_setting),[y,E]=(0,o.fp)(c.AG.md_editor),j=t??y,S=(0,o.fp)(c.AG.md_editor_last_context)[1],C=(0,r.useRef)(null),[N,R]=(0,r.useState)(null),[L,A]=(0,r.useState)(!1),[H,M]=(0,r.useState)(!1),[G,z]=(0,r.useState)(0),B=(0,r.useRef)(null),[$,F]=(0,r.useState)([]),[D,K]=(0,r.useState)(-1),[P,I]=(0,r.useState)(15),[T,U]=(0,r.useState)(!1),W=(0,r.useRef)(null),Y=(0,r.useRef)(null),[X,q]=(0,o.fp)(c.AG.md_editor_show_outline),[V,J]=(0,o.fp)(c.AG.md_editor_mode),O=(0,r.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=B.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),J(e))},[V]),[re]=(0,o.fp)(c.AG.md_editor_setting),[le,ue]=(0,o.fp)(c.AG.md_theme_css),[de]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:me}=(0,r.useContext)(s.F),fe=(0,r.useRef)(null),ve=(0,r.useRef)(null);(0,r.useEffect)(()=>{ve.current},[de]),(0,r.useEffect)(()=>{(0,te.Ce)(W.current,re)},[re]);(0,r.useEffect)(()=>{(0,ne.bN)("editor",le)},[le]),(0,r.useEffect)(()=>{const e=()=>{(0,ne.sO)().then(ue)};return window.addEventListener(ne.o3,e),()=>window.removeEventListener(ne.o3,e)},[]);const _e=(0,r.useRef)([]),he=(0,r.useCallback)(()=>{const e=B.current;if(!e)return;const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();_e.current=t,F(t)},[]);(0,r.useEffect)(()=>{t?.on_outline?.($,D)},[$,D]);const pe=(0,r.useCallback)(()=>{const e=B.current,t=e?.get_view();if(!e||!t)return;const n=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let r=-1;for(const e of _e.current){if(!(e.pos<=n))break;r=e.pos}K(r)},[]);(0,r.useEffect)(()=>{let e=!1;if(j?.url)return M(!1),A(!0),v.l.get(j.url).then(t=>{if(e)return;R(t??"")}).catch(()=>{e||((0,d.zN)(n("打开失败")),R(""))}).finally(()=>{e||A(!1)}),()=>{e=!0};R(null)},[j?.url]),(0,r.useEffect)(()=>{const e=()=>z(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const ge=(0,r.useRef)(O);ge.current=O,(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),ge.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,r.useEffect)(()=>{he(),pe()},[G,V,he,pe]);const we=(0,r.useCallback)(oe.throttle(e=>{if(!W.current||!Y.current)return;const t=parseFloat(getComputedStyle(W.current).fontSize),n=e.clientX/t,r=window.innerWidth/t-4,s=2.25+Y.current.offsetWidth/t;n<=r&&n>=s&&I(parseFloat(n.toFixed(2)))},32),[]),xe=()=>{U(!1),W.current?.removeEventListener("pointermove",we)},be=e=>{const t=B.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),K(e.pos))},ke=async(e=!1)=>{if(!j?.name||!j?.path)return;const t=B.current?.get_markdown();if(void 0===t)return;const r=j.path.slice(0,j.path.length-j.name.length),s=`${encodeURIComponent(r)}${j.name}`;(await f.$M.post(`save/${s}`,{context:t})).code===m.m.Success?(M(!1),e||(0,d.SK)(n("保存成功"))):(0,d.zN)(n("保存失败"))},ye=(0,r.useRef)(ke);ye.current=ke;const Ee=(0,r.useRef)(H);Ee.current=H,(0,ae.a)(a.nE.md,()=>Ee.current,e=>ke(e),j.readonly);const je=()=>{window.print()},Se=(0,r.useRef)(V);Se.current=V;const Ce=(0,r.useRef)(be);Ce.current=be;const Ne=(0,r.useRef)(je);Ne.current=je,(0,r.useEffect)(()=>{t?.on_dirty?.(H)},[H]),(0,r.useEffect)(()=>{t?.register?.({save:e=>ye.current(e),export_pdf:()=>Ne.current(),toggle_mode:()=>ge.current(),mode:()=>Se.current,goto_heading:e=>Ce.current(e),dirty:()=>Ee.current})},[]);const Re=()=>{E({}),M(!1),R(null),B.current=null,y?.close?.()},Le=(0,r.useMemo)(()=>j?.url??"md_editor",[j?.url]);if(!j?.name)return null;const Ae=!!t,He=(0,w.jsxs)("div",{className:"md-editor-context",ref:W,children:[L&&(0,w.jsxs)("div",{className:"common-box common-box-center",children:[n("加载中"),"..."]}),!L&&null!==N&&(0,w.jsxs)(r.Fragment,{children:[!Ae&&X&&(0,w.jsx)("div",{className:"md-outline-panel",style:{width:`${P}em`},children:(0,w.jsx)(Q.default,{items:$,active_pos:D,on_click:be})}),!Ae&&X&&(0,w.jsx)("div",{className:"md-editor-divider",ref:Y,onPointerDown:()=>{U(!0),W.current?.addEventListener("pointermove",we)},onPointerUp:xe}),!Ae&&T&&(0,w.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:xe}),(0,w.jsx)("div",{className:"md-editor-scroll",children:(0,w.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,w.jsx)(x,{get_view:()=>B.current?.get_view()??null,refresh_key:G}),(0,w.jsx)(p.A,{value:N,ref:B,initial_source_mode:"source"===V,doc_path:j?.path,on_ready:e=>{const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();_e.current=t,F(t),K(-1)},on_change:()=>{H||M(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{const e=B.current?.get_markdown()??"";e&&S(e)},800)},on_save:()=>ye.current(),on_selection_change:()=>z(e=>e+1),on_source_mode_change:e=>{J(e?"source":"wysiwyg"),z(e=>e+1)}},Le),"wysiwyg"===V&&(0,w.jsx)(Z,{get_view:()=>B.current?.get_view()??null,on_insert_table:()=>{B.current?.insert_table(3,3),M(!0)}})]})})]})]});return Ae?He:(0,w.jsxs)("div",{id:"md-editor-container",ref:fe,children:[(0,w.jsx)(u.A,{ignore_tags:!0,left_children:[(0,w.jsx)(l.rA,{title:n("关闭"),icon:"close",onClick:Re},1),(0,w.jsx)("div",{className:"md-editor-title",children:j.name},3),...H&&!j.readonly?[(0,w.jsx)(l.rA,{title:n("保存"),icon:"save",onClick:ke},2)]:[],(0,w.jsx)(l.rA,{title:n("大纲"),icon:"list",onClick:()=>q(e=>!e),selected:X},4),...j.readonly?[]:[(0,w.jsx)(l.rA,{title:n("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:O},5)],...j.readonly?[]:[(0,w.jsx)(se,{on_change:async e=>{const t=await f.wm.post(_.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:e});t?.code===m.m.Success?(ve.current=e,await me(),(0,d.SK)(n("保存成功"))):(0,d.zN)(n("保存失败"))}},8)],(0,w.jsx)(l.rA,{title:n("导出PDF"),icon:"print",onClick:je},7),...k&&!j.readonly?[(0,w.jsx)(l.rA,{title:n("编辑器设置"),icon:"settings",onClick:()=>{Re(),g(ie.o.md_editor_setting_page)}},6)]:[]]}),He]})}},93245(e,t,n){n.d(t,{a:()=>a});var r=n(96540),s=n(34843),o=n(82893),c=n(23430);const i=[{id:c.nE.ace,label:"文本编辑器(ace)"},{id:c.nE.md,label:"md编辑器"},{id:c.nE.mind,label:"思维导图编辑器"},{id:c.nE.draw,label:"draw编辑器"},{id:c.nE.timeline,label:"时间线编辑器"},{id:c.nE.image,label:"图片编辑器"},{id:c.nE.excel,label:"excel编辑器"}];function a(e,t,n,c=!1){const[i]=(0,s.fp)(o.AG.user_base_info),a=i?.user_data?.editor_auto_save,l=(0,r.useRef)(a);l.current=a;const u=(0,r.useRef)(t);u.current=t;const d=(0,r.useRef)(n);d.current=n,(0,r.useEffect)(()=>{if(c)return;const t=l.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,c])}n.d(t,["d",0,i])}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2572],{2572(e,t,u){u.r(t),u.d(t,{default:()=>c});u(96540);var a=u(16514),f=u(74848);function c(){return(0,f.jsx)(a.default,{})}}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2572],{2572(e,t,u){u.r(t),u.d(t,{default:()=>c});u(96540);var a=u(69857),f=u(74848);function c(){return(0,f.jsx)(a.default,{})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2674],{92674(e,t,n){n.r(t),n.d(t,{default:()=>R});var a=n(96540),i=n(82893),s=n(34843),o=n(85997),l=n(57952),r=n(47022),c=n(34251),d=n(74848);function u(e){{const[t,n]=(0,a.useState)(!1),[i,s]=(0,a.useState)([]),l=e=>{s(e)},p=async()=>{"folder"===e.type?(t||!e.click||i||await e.click(e,l,e.pre_path),n(!t)):e.click&&await e.click(e,l,e.pre_path)},h=async(t=!1)=>{"folder"!==e.type||t?e.fatherNowToggleExpansion&&e.fatherNowToggleExpansion():await e.click(e,l,e.pre_path)};return(0,a.useEffect)(()=>{s(e.children)},[e.children]),(0,d.jsxs)("div",{className:"studio-item",children:[(0,d.jsxs)("div",{onClick:p,onContextMenu:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),e.handleContextMenu&&e.handleContextMenu(t,e.name,e.pre_path,e.type===r.Iw.folder,h)},className:"studio-item-title"+(e.active_path===e.pre_path?" studio-item-title--active":""),children:[(0,d.jsx)("i",{className:"material-icons studio-item-title-tag","data-icon":t?"arrow_drop_down":"arrow_right",children:"file"==e.type?"":t?"arrow_drop_down":"arrow_right"}),(0,d.jsx)("span",{className:"file-icons",children:(0,d.jsx)("span",{"data-type":(0,c.uL)(e.name),"data-dir":"folder"===e.type,"aria-label":e.name,children:(0,d.jsx)(o.In,{icon:"",aria_label:e.name})})}),(0,d.jsx)("span",{className:"studio-item-name",children:e.name})]}),t&&i&&(0,d.jsx)("div",{style:{marginLeft:20},children:i.map((t,n)=>(0,d.jsx)(a.Fragment,{children:(0,d.jsx)(u,{type:t.type,size:t.size,click:e.click,name:t.name,children:t.children,pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,handleContextMenu:e.handleContextMenu,active_path:e.active_path,fatherNowToggleExpansion:h},n)},n))})]})}}n(61443);function p(e){return(0,d.jsx)("div",{children:e.list.map((t,n)=>(0,d.jsx)(u,{pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,name:t.name,type:t.type,handleContextMenu:e.handleContextMenu,fatherNowToggleExpansion:e.fatherNowToggleExpansion,active_path:e.active_path,children:t.children,click:e.click,size:t.size},n))})}var h=n(14284),m=n(34289),f=n(53459),v=n(78247),_=(n(62042),n(2543)),x=n(89824),y=n(22022),w=n(88815),j=n(61973),g=n(23430),k=n(99214);const C=a.lazy(()=>Promise.all([n.e(2543),n.e(4091)]).then(n.bind(n,84091))),S=a.lazy(()=>Promise.all([n.e(4946),n.e(1384),n.e(892),n.e(9334),n.e(1075),n.e(1142)]).then(n.bind(n,71142))),b=a.lazy(()=>n.e(4877).then(n.bind(n,64877))),N=a.lazy(()=>Promise.all([n.e(4946),n.e(2626),n.e(892),n.e(9334),n.e(8365)]).then(n.bind(n,16514))),E=a.lazy(()=>Promise.all([n.e(8090),n.e(5744)]).then(n.bind(n,16575))),A=a.lazy(()=>Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8781),n.e(6404)]).then(n.bind(n,35304))),M=a.lazy(()=>n.e(892).then(n.bind(n,20892))),I=a.lazy(()=>Promise.all([n.e(1922),n.e(4935)]).then(n.bind(n,24935)));function $(e){return(0,c.uL)(e)===r.Iw.excel}function R(e){const[t,n]=(0,a.useState)([]),[u,R]=(0,a.useState)(""),[P,z]=(0,a.useState)(""),[U,G]=(0,a.useState)(!1),[D,F]=(0,a.useState)({path:"",name:""}),[L,T]=(0,a.useState)(""),[B,K]=(0,s.fp)(i.AG.confirm),[X,H]=(0,a.useState)(!1),[V,W]=(0,s.fp)(i.AG.fileShellShow),[Y,Z]=(0,s.fp)(i.AG.file_shell_hidden),q=(0,a.useRef)(null),J=(0,a.useRef)(null),[O,Q]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(16),[ne,ae]=(0,s.fp)(i.AG.showPrompt),{t:ie}=(0,y.Bd)(),se=(0,j.Zp)(),oe=(le=D.name,(0,c.uL)(le)===r.Iw.md);var le;const re=function(e){return(0,c.uL)(e)===r.Iw.excalidraw}(D.name),ce=function(e){return(0,c.uL)(e)===r.Iw.mind}(D.name),de=function(e){return(0,c.uL)(e)===r.Iw.timeline}(D.name),ue=$(D.name),pe=(0,a.useRef)(null),he=(0,a.useRef)(null),me=(0,a.useRef)(null),fe=(0,a.useRef)(null),ve=(0,a.useRef)(null),[_e,xe]=(0,a.useState)([]),[ye,we]=(0,a.useState)(-1),[je,ge]=(0,a.useState)("folder"),[ke,Ce]=(0,a.useState)(!0),[Se,be]=(0,a.useState)(!1),Ne=(0,k.oT)(),[Ee]=(0,j.ok)(),Ae="1"===Ee.get("chat_open"),[Me,Ie]=(0,s.fp)(i.AG.studio_chat_width),$e=(0,a.useRef)(null),[Re,Pe]=(0,a.useState)(!1),[ze,Ue]=(0,a.useState)(void 0),[Ge,De]=(0,s.fp)(i.AG.ai_chat_session_by_cwd);let Fe=(0,j.zy)().pathname.split("/").filter(Boolean).pop();Fe=decodeURIComponent(Fe);const{check_user_auth:Le}=(0,v.MH)(),[Te]=(0,s.fp)(i.AG.user_base_info),Be=Le(g.oV.ai_agent_page);(0,a.useEffect)(()=>{Te?.user_data&&Ae&&!Be&&Ne("chat_open",null)},[Ae,Be,Te]);const Ke=(0,m.GG)("file",Fe);const Xe=async()=>{const e=(0,m.GG)("file",Fe);R(e),F({path:e,name:(0,m.mH)(e)});const t=await h.$M.post("studio/get/item",{path:e});if(t.code===f.m.Success){const e=[],a=[];for(const n of t.data.list)"folder"===n.type?e.push(n):"file"===n.type&&a.push(n);n([...e,...a])}};(0,a.useEffect)(()=>{z(""),H(!1),Xe()},[]);const He=async(e,t)=>{if(!$(e)){const e=await h.$M.get(`${encodeURIComponent(t)}`);z(e.data),v.xK.set_value_temp(e.data)}F({path:t,name:e}),T(t),ge("folder"),be(!1)},Ve=(e,t)=>{e.size>w.o5?K({open:!0,handle:()=>{He(e.name,t),K({open:!1,handle:null}),H(!1)},title:"超过20MB了还要打开吗?"}):He(e.name,t)};async function We(){if(!X)return;const e={context:v.xK.get_editor_value()};0===(await h.$M.post(`save/${encodeURIComponent(L)}`,e)).code&&H(!1)}const Ye=e=>{if(e.ctrlKey&&"s"===e.key){if(e.preventDefault(),oe||re||ce||de||ue)return;X&&We()}};(0,a.useEffect)(()=>(document.addEventListener("keydown",Ye),()=>{document.removeEventListener("keydown",Ye)}),[X,oe,re,ce,de,ue]);const Ze=(0,a.useCallback)(_.throttle(e=>{const t=parseFloat(getComputedStyle(J.current).fontSize),n=window.innerWidth/t-4,a=e.clientX/t,i=2.25+q.current.offsetWidth/t;a<=n&&a>=i&&te(parseFloat(a.toFixed(2)))},32),[]),qe=()=>{Q(!1),J.current.removeEventListener("pointermove",Ze)},Je=(0,a.useCallback)(_.throttle(e=>{const t=$e.current;if(!t)return;const n=parseFloat(getComputedStyle(t).fontSize),a=t.parentElement.getBoundingClientRect().right-e.clientX,i=.7*t.parentElement.getBoundingClientRect().width,s=Math.min(Math.max(a,320),i);Ie(parseFloat((s/n).toFixed(2)))},32),[]),Oe=()=>{Pe(!1),document.removeEventListener("pointermove",Je)},Qe=[{r:ie("创建文件"),v:"创建文件"},{r:ie("创建目录"),v:"创建目录"},{r:ie("重命名"),v:"重命名"},{r:ie("删除"),v:"删除"}],et=[{r:ie("重命名"),v:"重命名"},{r:ie("删除"),v:"删除"}],tt=(e,t,n,a,i)=>{e.preventDefault();const s=new c.ik;s.path=n,s.filename=t,s.x=e.clientX,s.y=e.clientY,s.items=a?Qe:et,i===Xe&&(s.items=s.items.slice(0,2)),s.type=a?r.Iw.studio_folder:r.Iw.studio_file;const o=e=>{i(e)};s.textClick=e=>{switch(e){case"创建文件":ae({show:!0,type:x.PromptEnum.FileNew,overlay:!0,data:{dir:n,call:o}});break;case"创建目录":ae({show:!0,type:x.PromptEnum.DirNew,overlay:!0,data:{dir:n,call:o}});break;case"删除":if(X&&(D.path===n||D.path.includes(n))){const e=()=>{o(a),H(!1),F({}),z(""),v.xK.set_value_temp("")};ae({show:!0,type:x.PromptEnum.FilesDelete,overlay:!0,data:{path:n,call:e,filename:t}});break}ae({show:!0,type:x.PromptEnum.FilesDelete,overlay:!0,data:{path:n,filename:t,call:a?()=>{o(!0)}:o}});break;case"重命名":ae({show:!0,type:x.PromptEnum.FileRename,overlay:!0,data:{path:n,dir:(0,m.Yp)(n),call:()=>{o(!0)},filename:t}})}},ae({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:s})};const nt=oe&&"outline"===je;return(0,d.jsxs)("div",{className:"studio studio--file",children:[(0,d.jsxs)(l.A,{ignore_tags:!0,left_children:[(0,d.jsx)(o.rA,{title:"取消",icon:"close",onClick:()=>{W({show:!1,path:""}),Z(void 0),se(-1)}},1),(0,d.jsx)("div",{children:D.name},2)],children:[(0,d.jsx)("title",{children:D.name}),(0,d.jsx)(o.rA,{title:"侧边栏",icon:"list",onClick:()=>Ce(e=>!e),selected:ke}),oe&&[Se?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>pe.current?.save()},"save"):null,(0,d.jsx)(o.rA,{icon:"source"===pe.current?.mode()?"edit":"code",title:"source"===pe.current?.mode()?ie("实时编辑模式"):ie("源码模式"),onClick:()=>pe.current?.toggle_mode()},"mode"),(0,d.jsx)(o.rA,{title:ie("导出PDF"),icon:"print",onClick:()=>pe.current?.export_pdf()},"pdf")],!oe&&(0,c.zr)(D.name)&&(0,d.jsx)(o.rA,{title:"格式化",icon:"data_object",onClick:function(){v.xK.get_editor()?.formatCode()}}),(0,d.jsx)(o.rA,{icon:"terminal",title:"shell",onClick:function(){!0!==Y&&!1!==Y?V.show?W({show:!1,path:""}):(W({show:!0,path:(0,m.GG)("file",Fe)}),Z(!1)):Z(!Y)}}),Le(g.oV.ai_agent_page)&&(0,d.jsx)(o.rA,{title:ie("AI 聊天"),icon:"smart_toy",selected:Ae,onClick:()=>Ne("chat_open",!Ae?"1":null)}),oe?Se?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>pe.current?.save()}):null:re?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>he.current?.save()}):ce?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>me.current?.save()}):de?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>fe.current?.save()}):ue?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>ve.current?.save()}):X?(0,d.jsx)(o.rA,{title:"保存",icon:"save",onClick:We}):null]}),(0,d.jsxs)("div",{className:"studio-body",ref:J,children:[(0,d.jsxs)("div",{className:"studio-nav",style:{display:ke?void 0:"none",width:ee-1+"em"},onContextMenu:e=>{tt(e,D.name,(0,m.GG)("file",Fe),!0,Xe)},children:[(0,d.jsx)("div",{className:"studio-nav-outline",style:{display:nt?void 0:"none"},children:(0,d.jsx)(b,{items:_e,active_pos:ye,on_click:e=>pe.current?.goto_heading(e)})}),(0,d.jsx)("div",{className:"studio-nav-folder",style:{display:nt?"none":void 0},children:(0,d.jsx)(p,{pre_path:u,list:t,click:async(e,t,n)=>{if("folder"===e.type){const e=await h.$M.post("studio/get/item",{path:`${n}`});if(e.code===f.m.Success){const n=[],a=[];for(const t of e.data.list)"folder"===t.type?n.push(t):"file"===t.type&&a.push(t);t([...n,...a])}}else{if(X)return void K({open:!0,handle:()=>{K({open:!1,handle:null}),H(!1),Ve(e,n)},title:"确定不保存就切换吗?"});Ve(e,n)}},active_path:L,handleContextMenu:tt,fatherNowToggleExpansion:Xe})}),oe&&(0,d.jsx)("div",{className:"studio-nav-switch",children:(0,d.jsx)(o.rA,{icon:nt?"folder":"list",title:ie(nt?"文件目录":"大纲"),onClick:()=>ge(nt?"folder":"outline")})})]}),ke&&(0,d.jsx)("div",{className:"studio__divider",ref:q,onPointerDown:()=>{Q(!0),J.current.addEventListener("pointermove",Ze)},onPointerUp:qe}),O&&(0,d.jsx)("div",{className:"shell__overlay",onPointerUp:qe}),oe?(0,d.jsx)("div",{className:"studio-editor studio-editor--md",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(S,{pane:{path:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),name:D.name,on_dirty:be,on_outline:(e,t)=>{xe(e),we(t)},register:e=>{pe.current=e}}})})},L):re?(0,d.jsx)("div",{className:"studio-editor studio-editor--draw",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(E,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),save_path:L,on_dirty:H,on_saved:()=>H(!1),register:e=>{he.current=e}})})},L):ce?(0,d.jsx)("div",{className:"studio-editor studio-editor--mind",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(A,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),on_dirty:H,on_saved:()=>H(!1),register:e=>{me.current=e},on_save:async e=>(await h.$M.post(`save/${encodeURIComponent(L)}`,{context:e})).code===f.m.Success})})},L):de?(0,d.jsx)("div",{className:"studio-editor studio-editor--timeline",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(M,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),on_dirty:H,register:e=>{fe.current=e},on_save:async e=>(await h.$M.post(`save/${encodeURIComponent(L)}`,{context:e})).code===f.m.Success})})},L):ue?(0,d.jsx)("div",{className:"studio-editor studio-editor--excel",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(I,{url:h.$M.getDownloadUrl(encodeURIComponent(L)),save_path:L,on_dirty:H,bind_save:e=>{ve.current={save:e}}})})},L):(0,d.jsx)("div",{className:"studio-editor",children:D.name&&(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(C,{name:D.name,on_change:()=>{X||H(!0)}})})},L),Ae&&(0,d.jsxs)(a.Fragment,{children:[(0,d.jsx)("div",{className:"studio__divider studio__divider--chat",ref:$e,onPointerDown:e=>{e.preventDefault(),Pe(!0),document.addEventListener("pointermove",Je),document.addEventListener("pointerup",Oe,{once:!0})}}),(0,d.jsx)("div",{className:"studio-chat-panel",style:{width:`${Me}em`},children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(N,{inline_header:!0,sync_url:!1,file_cwd_path:Ke,session_id:ze??(at=Ke,i.AG.get_ai_chat_session(Ge,at)),on_session_change:e=>{Ue(e),((e,t)=>{De({...Ge,[e]:t})})(Ke,e)}})})})]})]})]});var at}}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2674],{92674(e,t,n){n.r(t),n.d(t,{default:()=>R});var a=n(96540),i=n(82893),s=n(34843),o=n(85997),l=n(57952),r=n(47022),c=n(34251),d=n(74848);function u(e){{const[t,n]=(0,a.useState)(!1),[i,s]=(0,a.useState)([]),l=e=>{s(e)},p=async()=>{"folder"===e.type?(t||!e.click||i||await e.click(e,l,e.pre_path),n(!t)):e.click&&await e.click(e,l,e.pre_path)},h=async(t=!1)=>{"folder"!==e.type||t?e.fatherNowToggleExpansion&&e.fatherNowToggleExpansion():await e.click(e,l,e.pre_path)};return(0,a.useEffect)(()=>{s(e.children)},[e.children]),(0,d.jsxs)("div",{className:"studio-item",children:[(0,d.jsxs)("div",{onClick:p,onContextMenu:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),e.handleContextMenu&&e.handleContextMenu(t,e.name,e.pre_path,e.type===r.Iw.folder,h)},className:"studio-item-title"+(e.active_path===e.pre_path?" studio-item-title--active":""),children:[(0,d.jsx)("i",{className:"material-icons studio-item-title-tag","data-icon":t?"arrow_drop_down":"arrow_right",children:"file"==e.type?"":t?"arrow_drop_down":"arrow_right"}),(0,d.jsx)("span",{className:"file-icons",children:(0,d.jsx)("span",{"data-type":(0,c.uL)(e.name),"data-dir":"folder"===e.type,"aria-label":e.name,children:(0,d.jsx)(o.In,{icon:"",aria_label:e.name})})}),(0,d.jsx)("span",{className:"studio-item-name",children:e.name})]}),t&&i&&(0,d.jsx)("div",{style:{marginLeft:20},children:i.map((t,n)=>(0,d.jsx)(a.Fragment,{children:(0,d.jsx)(u,{type:t.type,size:t.size,click:e.click,name:t.name,children:t.children,pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,handleContextMenu:e.handleContextMenu,active_path:e.active_path,fatherNowToggleExpansion:h},n)},n))})]})}}n(61443);function p(e){return(0,d.jsx)("div",{children:e.list.map((t,n)=>(0,d.jsx)(u,{pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,name:t.name,type:t.type,handleContextMenu:e.handleContextMenu,fatherNowToggleExpansion:e.fatherNowToggleExpansion,active_path:e.active_path,children:t.children,click:e.click,size:t.size},n))})}var h=n(14284),m=n(34289),f=n(53459),v=n(78247),_=(n(62042),n(2543)),x=n(89824),y=n(22022),w=n(88815),j=n(61973),g=n(23430),k=n(99214);const C=a.lazy(()=>Promise.all([n.e(2543),n.e(4091)]).then(n.bind(n,84091))),S=a.lazy(()=>Promise.all([n.e(4946),n.e(1384),n.e(892),n.e(9334),n.e(1075),n.e(1142)]).then(n.bind(n,71142))),b=a.lazy(()=>n.e(4877).then(n.bind(n,64877))),N=a.lazy(()=>Promise.all([n.e(4946),n.e(2626),n.e(892),n.e(9334),n.e(6104)]).then(n.bind(n,69857))),E=a.lazy(()=>Promise.all([n.e(8090),n.e(5744)]).then(n.bind(n,16575))),A=a.lazy(()=>Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8781),n.e(6404)]).then(n.bind(n,35304))),M=a.lazy(()=>n.e(892).then(n.bind(n,20892))),I=a.lazy(()=>Promise.all([n.e(1922),n.e(4935)]).then(n.bind(n,24935)));function $(e){return(0,c.uL)(e)===r.Iw.excel}function R(e){const[t,n]=(0,a.useState)([]),[u,R]=(0,a.useState)(""),[P,z]=(0,a.useState)(""),[U,G]=(0,a.useState)(!1),[D,F]=(0,a.useState)({path:"",name:""}),[L,T]=(0,a.useState)(""),[B,K]=(0,s.fp)(i.AG.confirm),[X,H]=(0,a.useState)(!1),[V,W]=(0,s.fp)(i.AG.fileShellShow),[Y,Z]=(0,s.fp)(i.AG.file_shell_hidden),q=(0,a.useRef)(null),J=(0,a.useRef)(null),[O,Q]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(16),[ne,ae]=(0,s.fp)(i.AG.showPrompt),{t:ie}=(0,y.Bd)(),se=(0,j.Zp)(),oe=(le=D.name,(0,c.uL)(le)===r.Iw.md);var le;const re=function(e){return(0,c.uL)(e)===r.Iw.excalidraw}(D.name),ce=function(e){return(0,c.uL)(e)===r.Iw.mind}(D.name),de=function(e){return(0,c.uL)(e)===r.Iw.timeline}(D.name),ue=$(D.name),pe=(0,a.useRef)(null),he=(0,a.useRef)(null),me=(0,a.useRef)(null),fe=(0,a.useRef)(null),ve=(0,a.useRef)(null),[_e,xe]=(0,a.useState)([]),[ye,we]=(0,a.useState)(-1),[je,ge]=(0,a.useState)("folder"),[ke,Ce]=(0,a.useState)(!0),[Se,be]=(0,a.useState)(!1),Ne=(0,k.oT)(),[Ee]=(0,j.ok)(),Ae="1"===Ee.get("chat_open"),[Me,Ie]=(0,s.fp)(i.AG.studio_chat_width),$e=(0,a.useRef)(null),[Re,Pe]=(0,a.useState)(!1),[ze,Ue]=(0,a.useState)(void 0),[Ge,De]=(0,s.fp)(i.AG.ai_chat_session_by_cwd);let Fe=(0,j.zy)().pathname.split("/").filter(Boolean).pop();Fe=decodeURIComponent(Fe);const{check_user_auth:Le}=(0,v.MH)(),[Te]=(0,s.fp)(i.AG.user_base_info),Be=Le(g.oV.ai_agent_page);(0,a.useEffect)(()=>{Te?.user_data&&Ae&&!Be&&Ne("chat_open",null)},[Ae,Be,Te]);const Ke=(0,m.GG)("file",Fe);const Xe=async()=>{const e=(0,m.GG)("file",Fe);R(e),F({path:e,name:(0,m.mH)(e)});const t=await h.$M.post("studio/get/item",{path:e});if(t.code===f.m.Success){const e=[],a=[];for(const n of t.data.list)"folder"===n.type?e.push(n):"file"===n.type&&a.push(n);n([...e,...a])}};(0,a.useEffect)(()=>{z(""),H(!1),Xe()},[]);const He=async(e,t)=>{if(!$(e)){const e=await h.$M.get(`${encodeURIComponent(t)}`);z(e.data),v.xK.set_value_temp(e.data)}F({path:t,name:e}),T(t),ge("folder"),be(!1)},Ve=(e,t)=>{e.size>w.o5?K({open:!0,handle:()=>{He(e.name,t),K({open:!1,handle:null}),H(!1)},title:"超过20MB了还要打开吗?"}):He(e.name,t)};async function We(){if(!X)return;const e={context:v.xK.get_editor_value()};0===(await h.$M.post(`save/${encodeURIComponent(L)}`,e)).code&&H(!1)}const Ye=e=>{if(e.ctrlKey&&"s"===e.key){if(e.preventDefault(),oe||re||ce||de||ue)return;X&&We()}};(0,a.useEffect)(()=>(document.addEventListener("keydown",Ye),()=>{document.removeEventListener("keydown",Ye)}),[X,oe,re,ce,de,ue]);const Ze=(0,a.useCallback)(_.throttle(e=>{const t=parseFloat(getComputedStyle(J.current).fontSize),n=window.innerWidth/t-4,a=e.clientX/t,i=2.25+q.current.offsetWidth/t;a<=n&&a>=i&&te(parseFloat(a.toFixed(2)))},32),[]),qe=()=>{Q(!1),J.current.removeEventListener("pointermove",Ze)},Je=(0,a.useCallback)(_.throttle(e=>{const t=$e.current;if(!t)return;const n=parseFloat(getComputedStyle(t).fontSize),a=t.parentElement.getBoundingClientRect().right-e.clientX,i=.7*t.parentElement.getBoundingClientRect().width,s=Math.min(Math.max(a,320),i);Ie(parseFloat((s/n).toFixed(2)))},32),[]),Oe=()=>{Pe(!1),document.removeEventListener("pointermove",Je)},Qe=[{r:ie("创建文件"),v:"创建文件"},{r:ie("创建目录"),v:"创建目录"},{r:ie("重命名"),v:"重命名"},{r:ie("删除"),v:"删除"}],et=[{r:ie("重命名"),v:"重命名"},{r:ie("删除"),v:"删除"}],tt=(e,t,n,a,i)=>{e.preventDefault();const s=new c.ik;s.path=n,s.filename=t,s.x=e.clientX,s.y=e.clientY,s.items=a?Qe:et,i===Xe&&(s.items=s.items.slice(0,2)),s.type=a?r.Iw.studio_folder:r.Iw.studio_file;const o=e=>{i(e)};s.textClick=e=>{switch(e){case"创建文件":ae({show:!0,type:x.PromptEnum.FileNew,overlay:!0,data:{dir:n,call:o}});break;case"创建目录":ae({show:!0,type:x.PromptEnum.DirNew,overlay:!0,data:{dir:n,call:o}});break;case"删除":if(X&&(D.path===n||D.path.includes(n))){const e=()=>{o(a),H(!1),F({}),z(""),v.xK.set_value_temp("")};ae({show:!0,type:x.PromptEnum.FilesDelete,overlay:!0,data:{path:n,call:e,filename:t}});break}ae({show:!0,type:x.PromptEnum.FilesDelete,overlay:!0,data:{path:n,filename:t,call:a?()=>{o(!0)}:o}});break;case"重命名":ae({show:!0,type:x.PromptEnum.FileRename,overlay:!0,data:{path:n,dir:(0,m.Yp)(n),call:()=>{o(!0)},filename:t}})}},ae({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:s})};const nt=oe&&"outline"===je;return(0,d.jsxs)("div",{className:"studio studio--file",children:[(0,d.jsxs)(l.A,{ignore_tags:!0,left_children:[(0,d.jsx)(o.rA,{title:"取消",icon:"close",onClick:()=>{W({show:!1,path:""}),Z(void 0),se(-1)}},1),(0,d.jsx)("div",{children:D.name},2)],children:[(0,d.jsx)("title",{children:D.name}),(0,d.jsx)(o.rA,{title:"侧边栏",icon:"list",onClick:()=>Ce(e=>!e),selected:ke}),oe&&[Se?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>pe.current?.save()},"save"):null,(0,d.jsx)(o.rA,{icon:"source"===pe.current?.mode()?"edit":"code",title:"source"===pe.current?.mode()?ie("实时编辑模式"):ie("源码模式"),onClick:()=>pe.current?.toggle_mode()},"mode"),(0,d.jsx)(o.rA,{title:ie("导出PDF"),icon:"print",onClick:()=>pe.current?.export_pdf()},"pdf")],!oe&&(0,c.zr)(D.name)&&(0,d.jsx)(o.rA,{title:"格式化",icon:"data_object",onClick:function(){v.xK.get_editor()?.formatCode()}}),(0,d.jsx)(o.rA,{icon:"terminal",title:"shell",onClick:function(){!0!==Y&&!1!==Y?V.show?W({show:!1,path:""}):(W({show:!0,path:(0,m.GG)("file",Fe)}),Z(!1)):Z(!Y)}}),Le(g.oV.ai_agent_page)&&(0,d.jsx)(o.rA,{title:ie("AI 聊天"),icon:"smart_toy",selected:Ae,onClick:()=>Ne("chat_open",!Ae?"1":null)}),oe?Se?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>pe.current?.save()}):null:re?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>he.current?.save()}):ce?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>me.current?.save()}):de?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>fe.current?.save()}):ue?(0,d.jsx)(o.rA,{title:ie("保存"),icon:"save",onClick:()=>ve.current?.save()}):X?(0,d.jsx)(o.rA,{title:"保存",icon:"save",onClick:We}):null]}),(0,d.jsxs)("div",{className:"studio-body",ref:J,children:[(0,d.jsxs)("div",{className:"studio-nav",style:{display:ke?void 0:"none",width:ee-1+"em"},onContextMenu:e=>{tt(e,D.name,(0,m.GG)("file",Fe),!0,Xe)},children:[(0,d.jsx)("div",{className:"studio-nav-outline",style:{display:nt?void 0:"none"},children:(0,d.jsx)(b,{items:_e,active_pos:ye,on_click:e=>pe.current?.goto_heading(e)})}),(0,d.jsx)("div",{className:"studio-nav-folder",style:{display:nt?"none":void 0},children:(0,d.jsx)(p,{pre_path:u,list:t,click:async(e,t,n)=>{if("folder"===e.type){const e=await h.$M.post("studio/get/item",{path:`${n}`});if(e.code===f.m.Success){const n=[],a=[];for(const t of e.data.list)"folder"===t.type?n.push(t):"file"===t.type&&a.push(t);t([...n,...a])}}else{if(X)return void K({open:!0,handle:()=>{K({open:!1,handle:null}),H(!1),Ve(e,n)},title:"确定不保存就切换吗?"});Ve(e,n)}},active_path:L,handleContextMenu:tt,fatherNowToggleExpansion:Xe})}),oe&&(0,d.jsx)("div",{className:"studio-nav-switch",children:(0,d.jsx)(o.rA,{icon:nt?"folder":"list",title:ie(nt?"文件目录":"大纲"),onClick:()=>ge(nt?"folder":"outline")})})]}),ke&&(0,d.jsx)("div",{className:"studio__divider",ref:q,onPointerDown:()=>{Q(!0),J.current.addEventListener("pointermove",Ze)},onPointerUp:qe}),O&&(0,d.jsx)("div",{className:"shell__overlay",onPointerUp:qe}),oe?(0,d.jsx)("div",{className:"studio-editor studio-editor--md",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(S,{pane:{path:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),name:D.name,on_dirty:be,on_outline:(e,t)=>{xe(e),we(t)},register:e=>{pe.current=e}}})})},L):re?(0,d.jsx)("div",{className:"studio-editor studio-editor--draw",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(E,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),save_path:L,on_dirty:H,on_saved:()=>H(!1),register:e=>{he.current=e}})})},L):ce?(0,d.jsx)("div",{className:"studio-editor studio-editor--mind",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(A,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),on_dirty:H,on_saved:()=>H(!1),register:e=>{me.current=e},on_save:async e=>(await h.$M.post(`save/${encodeURIComponent(L)}`,{context:e})).code===f.m.Success})})},L):de?(0,d.jsx)("div",{className:"studio-editor studio-editor--timeline",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(M,{reset_key:L,url:h.$M.getDownloadUrl(encodeURIComponent(L)),on_dirty:H,register:e=>{fe.current=e},on_save:async e=>(await h.$M.post(`save/${encodeURIComponent(L)}`,{context:e})).code===f.m.Success})})},L):ue?(0,d.jsx)("div",{className:"studio-editor studio-editor--excel",children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(I,{url:h.$M.getDownloadUrl(encodeURIComponent(L)),save_path:L,on_dirty:H,bind_save:e=>{ve.current={save:e}}})})},L):(0,d.jsx)("div",{className:"studio-editor",children:D.name&&(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(C,{name:D.name,on_change:()=>{X||H(!0)}})})},L),Ae&&(0,d.jsxs)(a.Fragment,{children:[(0,d.jsx)("div",{className:"studio__divider studio__divider--chat",ref:$e,onPointerDown:e=>{e.preventDefault(),Pe(!0),document.addEventListener("pointermove",Je),document.addEventListener("pointerup",Oe,{once:!0})}}),(0,d.jsx)("div",{className:"studio-chat-panel",style:{width:`${Me}em`},children:(0,d.jsx)(a.Suspense,{fallback:null,children:(0,d.jsx)(N,{inline_header:!0,sync_url:!1,file_cwd_path:Ke,session_id:ze??(at=Ke,i.AG.get_ai_chat_session(Ge,at)),on_session_change:e=>{Ue(e),((e,t)=>{De({...Ge,[e]:t})})(Ke,e)}})})})]})]})]});var at}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,6104],{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])},69857(e,s,t){t.r(s),t.d(s,{default:()=>le});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 M(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var I=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),e()&&e()===s){if(m.current.clear(),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;else if(n){g.text=g.text+n;const e=g.content_list?.[0];e&&(e.content=g.text),g.is_loading=!1}if(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)(P,{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)(K,{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 K({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 P({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)=>`![生成图片${s+1}](${e.url||`data:image/png;base64,${e.b64_json}`})${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,batchMode:u,selectedMsgCount:h,sessionVisible:_,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:j,onBatchDeleteMessages:v,bgProcessVisible:b,bgProcessCount:w,onToggleBgProcess:y,inline:S})=>{const{t:N}=(0,i.Bd)(),k=(0,o.Zp)(),{check_user_auth:C}=(0,l.MH)(),[,A]=(0,a.fp)(m.AG.ai_session_collapsed),{open:M}=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()}})}}}(),I=C(U.oV.ai_model_switch)||C(U.oV.ai_agent_setting),$=[];for(const e of t)for(const s of e.models)$.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const R=t.find(e=>e.active),D=R?`${R.index}::${e}`:"",T=(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(V.rA,{icon:"menu",title:N("会话"),onClick:p,selected:_}),(0,B.jsx)(V.rA,{icon:"add",title:N("新会话"),onClick:()=>f()}),I&&$.length>0&&(0,B.jsx)(g.l6,{value:D,options:[{title:N("选择模型"),value:""},...$],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"}),u&&(0,B.jsx)(V.rA,{icon:"done",title:N("完成"),onClick:j}),u&&h>0&&(0,B.jsx)(V.rA,{icon:"delete",title:N("删除选中消息"),onClick:v}),(0,B.jsx)(V.rA,{icon:"zoom_in",title:N("缩放调整"),onClick:M}),(0,B.jsx)(V.rA,{icon:"terminal",title:N("后台进程"),onClick:y,selected:b,tip:w||null}),C(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{k(G.o.ai_rebot_setting_page)}}),C(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"settings",title:"ai setting",onClick:()=>{k(G.o.ai_agent_setting_page)}})]});return S?(0,B.jsx)("div",{className:"chat-inline-header",children:T}):(0,B.jsx)(q.aZ,{position:"right",children:T})};var Y=t(75725);function Z({items:e}){const s=e.filter(e=>!!e.text);return 0===s.length?null:(0,B.jsx)("div",{className:"chat-session-meta",children:s.map((e,s)=>(0,B.jsx)("small",{className:e.className,title:e.title,children:e.text},s))})}function ee(e){return e||"新会话"}function se({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,sysPromptList:v,onChangeSysPrompt:b}){const{t:w}=(0,i.Bd)(),[y,S]=(0,n.useState)(""),N=(0,n.useRef)(null),[k,C]=(0,n.useState)(null),[A,M]=(0,n.useState)(null),[I,$]=(0,n.useState)(null),R=!!a&&!f,D=e=>{if(!e)return"";const s=v?.find(s=>String(s.index)===String(e));return s?s.note||s.prompt.slice(0,20):""},T=e=>[{text:String(e.message_count??""),className:"chat-session-meta__count",title:w("消息数")},{text:D(e.sys_prompt_id),className:"chat-session-meta__prompt",title:w("系统提示词")},{text:"web"!==e.source?e.source:"",className:"chat-session-meta__source",title:w("来源")},{text:f&&e.owner_name||"",className:"chat-session-meta__owner",title:e.owner_name}],H=y.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(y.toLowerCase())||(e.summary||"").toLowerCase().includes(y.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(y.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(y.toLowerCase())):e,E=e.find(e=>e.id===s);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("aside",{className:"chat-session-list",children:[(0,B.jsxs)("div",{className:"chat-session-search",children:[(0,B.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:w("搜索会话"),value:y,onChange:e=>S(e.target.value)}),E&&(0,B.jsxs)("button",{className:"chat-session-current",title:ee(E.title),onClick:()=>(e=>{const s=()=>{const s=N.current,t=s?.querySelector(`[data-session-id="${e}"]`);t&&t.scrollIntoView({block:"center",behavior:"smooth"})};if(!H.some(s=>s.id===e))return S(""),void requestAnimationFrame(()=>requestAnimationFrame(s));s()})(E.id),children:[(0,B.jsx)("i",{className:"material-icons",children:"my_location"}),(0,B.jsx)("span",{children:ee(E.title)})]})]}),(0,B.jsx)("div",{className:"chat-session-items-wrap",ref:N,children:H.map((e,n)=>(0,B.jsx)("div",{"data-session-id":e.id,children:(0,B.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${k===n?"row-dragging":""} ${A===n&&null!==k&&k!==n?"row-drop-target":""}`,draggable:R,onDragStart:()=>C(n),onDragOver:e=>{null!==k&&(e.preventDefault(),A!==n&&M(n))},onDragEnd:()=>{C(null),M(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=k;if(C(null),M(null),null===s||s===e||!a)return;const t=H[s]?.id,n=H[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:ee(e.title)}),e.running&&(0,B.jsx)("span",{className:"chat-session-running",title:w("正在执行中")}),(0,B.jsx)(Z,{items:T(e)}),!u&&(0,B.jsx)("i",{className:"chat-session-more material-icons",title:w("更多操作"),onClick:s=>{s.stopPropagation();const t=s.currentTarget.getBoundingClientRect();$({x:t.right,y:t.bottom,session:e})},children:"more_horiz"})]})},e.id))}),(0,B.jsxs)("div",{className:"chat-session-actions",children:[(0,B.jsx)(V.rA,{icon:u?"check_circle":"checklist",title:w(u?"取消批量选择":"批量选择"),onClick:h}),j&&!u&&(0,B.jsx)(V.rA,{icon:f?"person":"groups",title:w(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,B.jsx)(V.rA,{icon:"delete",title:w("删除选中会话"),onClick:_}),!u&&p&&(0,B.jsx)(V.rA,{icon:"delete_sweep",title:w("删除全部会话"),onClick:p})]})]}),I&&(0,B.jsx)(Y.rY,{click:()=>$(null),children:(0,B.jsx)(Y.sw,{x:I.x,y:I.y,items:(e=>{const s=[{r:w("重命名"),v:"rename",run:()=>o(e.id,e.title)},...f?[]:[{r:w("移动到最上"),v:"to_top",run:()=>{const s=H[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{r:w("移动到最下"),v:"to_bottom",run:()=>{const s=H[H.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{r:e.cmd_auto_allow?w("命令检测关闭"):w("命令检测开启"),v:"cmd_auto",run:()=>r?.(e.id,!e.cmd_auto_allow)}];return v?.length&&s.push({r:w("系统提示词"),items:[{r:w("不使用"),v:"",run:()=>b?.(e.id,"")},...v.map(s=>({r:D(String(s.index)),v:String(s.index),run:()=>b?.(e.id,String(s.index))}))]}),s.push({r:w("字符消耗统计"),v:"usage",run:()=>l(e.id)},{r:w("设置"),v:"setting",run:()=>d?.(e.id)},{r:w("删除"),v:"delete",run:()=>c(e.id)}),s})(I.session),pre_value:I.session.sys_prompt_id?String(I.session.sys_prompt_id):"",click:(e,s)=>{$(null),s?.run?.()}})})]})}function te(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const ne=({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:te(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,I.kf)(e.elapsed_ms)})]})]})]},e.id)}),(0,B.jsx)("div",{ref:o})]})},ae=(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 ie=t(84369);function oe({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 ce=(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,ie.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)(oe,{pendingAttachments:o,onRemove:c}),(0,B.jsx)(ae,{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})]})}),re=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 le(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,[K,P]=(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)([]),[Y,Z]=(0,n.useState)(new Set),[ee,te]=(0,n.useState)([]),[ae,ie]=(0,n.useState)(""),[oe,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=(0,n.useRef)(null),Ne=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=Ne.apply_session;const ke=function(e){const{on_session_loaded:s,set_session_panel_open:t,on_session_change:o,init_cwd:r,write_url_session:l,url_session_id:u,init_session_id:h}=e,{t:_}=(0,i.Bd)(),p=(0,R.y)(),[f,j]=(0,a.fp)(m.AG.ai_last_session_id),[v,b]=(0,n.useState)([]),[w,y]=(0,n.useState)(""),[S,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(!1),[A,M]=(0,n.useState)(!1),[D,T]=(0,n.useState)(!1),V=(0,n.useRef)(!1),H=(0,n.useRef)([]);(0,n.useEffect)(()=>{V.current=k},[k]),(0,n.useEffect)(()=>{H.current=v},[v]);const E=(e,s={})=>c.jV.post("admin/session",{action:e,...s}),K=e=>{if(V.current)return H.current.find(s=>s.id===e)?.user_id},P=async(e,n=!1,a)=>{const i=a??H.current.find(s=>s.id===e)?.user_id,r=V.current&&i?await E("get",{session_id:e,user_id:i}):await c.jV.post("session/get",{session_id:e});if(r.code!==d.m.Success||!r.data)return!1;const m=r.data;return y(m.id),j(m.id),u!==m.id&&l(m.id),o?.(m.id),M(!!m.running),N(m.sys_prompt_id??""),n&&t(!0),s(m),!0},z=async e=>{const t=V.current?await E("list_all_sessions"):await c.jV.get("sessions");if(t.code!==d.m.Success)return!1;const n=t.data??[];b(n);const a=null===e?n[0]?.id??"":e||w||n[0]?.id||"";if(!a)return y(""),l(null),s(null),!1;if(e&&!n.some(s=>s.id===e))return!1;const i=n.find(e=>e.id===a)?.user_id;return await P(a,!1,i)},L=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,I.ed)(e),a=t.find(e=>(0,I.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:v,setSessions:b,sessions_ref:H,activeSessionId:w,setActiveSessionId:y,selectedSysPromptId:S,setSelectedSysPromptId:N,admin_all_mode:k,admin_mode_ref:V,readonly:D,activeSessionRunning:A,setActiveSessionRunning:M,admin_call:E,call:(e,s,t)=>V.current?E(e,s):t(),owner_of_session:K,refreshSessions:async()=>{const e=V.current?await E("list_all_sessions"):await c.jV.get("sessions");e.code===d.m.Success&&b(e.data??[])},markSessionRunning:(e,s)=>{b(t=>{const n=t.find(s=>s.id===e);return n&&!!n.running!==s?t.map(t=>t.id===e?{...t,running:s}:t):t})},loadSession:P,loadSessions:z,createSession:async e=>{const n=await c.jV.post("session",{sys_prompt_id:e||void 0,file_cwd_path:r||void 0});if(n.code!==d.m.Success)return;const a=n.data;y(a.id),N(a.sys_prompt_id??""),t(!0),s(null),await z(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:L,init_active_session:async()=>{if(r){const e=await L(r);e&&await z(e)||await z()}else h?await z(h)||await z():u?await z(u)||await z():f&&await z(f)||await z()},reorderSessions:(e,s)=>{if(V.current)return;const t=H.current.findIndex(s=>s.id===e),n=H.current.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,$.TI)(H.current,t,n);b(a),c.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},deleteSession:e=>{p({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=K(e);s?await E("delete",{session_id:e,user_id:s}):await c.jV.post("session/delete",{session_id:e}),w===e?(y(""),await z(null)):await z(w)}})},renameSession:(e,s)=>{let t=s;p({confirm_fun:async()=>{const s=K(e);s?await E("rename",{session_id:e,user_id:s,title:t}):await c.jV.post("sessions/update/meta",{id:e,title:t}),await z(w)},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=K(e);t?await E("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)(_(s?"命令检测已开启":"命令检测已关闭")),await z(w)},batchDeleteSessions:(e,s)=>{0!==e.size&&p({sub_title:_("cf_ses"),confirm_fun:async()=>{if(V.current)await E("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(w)?(y(""),await z(null)):await z(w)}})},clearAllSessions:()=>{p({sub_title:_("cf_all"),confirm_fun:async()=>{await c.jV.post("sessions/clear",{}),y(""),s(null),await z(null)}})},toggleAllUsersMode:async()=>{const e=!k;C(e),V.current=e,T(e),y(""),s(null);const t=e?await E("list_all_sessions"):await c.jV.get("sessions"),n=t.code===d.m.Success?t.data??[]:[];b(n),n[0]?.id&&await P(n[0].id,!1,n[0].user_id)},changeSystemPrompt:(e,s)=>{const t=s||w;if(!t)return;b(s=>s.map(s=>s.id===t?{...s,sys_prompt_id:e||void 0}:s)),t===w&&N(e);const n=K(t);n?E("sys_prompt",{session_id:t,user_id:n,sys_prompt_id:e||void 0}).catch(console.error):c.jV.post("session/sys_prompt",{session_id:t,sys_prompt_id:e||void 0}).catch(console.error)}}}({on_session_loaded:e=>{if(e&&(e.running&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:e.id,subscribe:!0}),we.current=e.id),ye.current(e),e.live_messages?.length)){const s=y([...e.messages??[],...e.live_messages]);Se.current?.bind_live_bubbles(s,e.live_messages.length)}},set_session_panel_open:e=>P(!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=ke.activeSessionId,be.current=ke.admin_all_mode,je.current=ke.sessions},[ke.activeSessionId,ke.admin_all_mode,ke.sessions]);const Ce=T({active_session_id_ref:ve,local_owner_ref:xe,subscribed_ref:we,set_messages:Ne.setMessages,scroll_to_bottom:()=>Ne.scrollToBottom(!1),auto_scroll_ref:Ne.autoScrollRef,mark_session_running:ke.markSessionRunning,refresh_sessions:ke.refreshSessions,reload_session:e=>ke.loadSession(e),set_active_session_running:ke.setActiveSessionRunning});Se.current=Ce;const Ae=(0,n.useRef)((0,r.sg)(e=>{Ne.setMessages(e),Ne.autoScrollRef.current&&Ne.scrollToBottom(!1)},50)).current,Me=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);if(o||(o={id:_+1+i,sender:"bot",text:"",is_loading:!0},j.push(o),b.set(i,o)),n){o.text=o.text+n;const e=o.content_list?.[0];e&&(e.content=o.text),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(M);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:()=>Ne.messages,setMessages:Ne.setMessages,setMessagesDebounced:Ae,setSending:J,getActiveSessionId:()=>ve.current,setActiveSessionId:ke.setActiveSessionId,refreshSessions:ke.refreshSessions,scrollToBottom:Ne.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:()=>ke.selectedSysPromptId,setLocalOwner:e=>{xe.current=e}}),Ie=e=>{ie(e?.ai_config?.model??"")},$e=async()=>{try{const e=await c.jV.get("public_models");e.code===d.m.Success&&le(e.data?.groups??[])}catch{le([])}},Re=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&Q(e=>[...e,...s])},Be=e=>ke.owner_of_session(e),De=()=>{Ne.batchMode&&(Ne.setSelectedMsgIds(new Set),Z(new Set)),Ne.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,Ie(e.data)),await $e(),await ke.init_active_session();const s=await c.jV.get("system_prompts");s.code===d.m.Success&&te(s.data??[])})(),requestAnimationFrame(()=>Ne.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 Te=G===ke.activeSessionId||ke.activeSessionRunning;return(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(X,{inline:s,currentModelName:ae,setCurrentModelName:ie,modelGroups:oe,onModelChanged:async()=>{await $e();const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Ie(e.data))},batchMode:Ne.batchMode,selectedMsgCount:Ne.selectedMsgIds.size,sessionVisible:!K,onToggleSessionPanel:()=>P(e=>!e),onCreateSession:ke.createSession,onBatchDeleteMessages:Ne.batchDeleteMessages,onToggleBatchMode:De,bgProcessVisible:z,bgProcessCount:de,onToggleBgProcess:()=>L(e=>!e)}),(0,B.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":U},children:[!K&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!0)}),!K&&(0,B.jsx)(se,{sessions:ke.sessions,activeSessionId:ke.activeSessionId,onSelectSession:e=>ke.loadSession(e,!1),onReorderSessions:ke.reorderSessions,onRenameSession:ke.renameSession,onDeleteSession:ke.deleteSession,onToggleCmdAuto:ke.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=Be(e),t=s?await ke.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=ke.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=Be(e);(t?await ke.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 ke.loadSessions(ke.activeSessionId)},cancel:()=>q({open:!1})})},batchMode:Ne.batchMode,selectedSessionIds:Y,onToggleSessionSelect:e=>{Z(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:De,onBatchDeleteSessions:()=>ke.batchDeleteSessions(Y,()=>{Z(new Set),Ne.setBatchMode(!1)}),onClearAllSessions:ke.admin_all_mode?void 0:ke.clearAllSessions,allUsersMode:ke.admin_all_mode,onToggleAllUsersMode:ke.toggleAllUsersMode,showAllUsersEntry:E,sysPromptList:ee,onChangeSysPrompt:(e,s)=>ke.changeSystemPrompt(s,e)}),(0,B.jsx)(re,{panelRef:_e}),(0,B.jsxs)("section",{className:"chat-main",children:[0===Ne.messages?.length&&(0,B.jsx)("div",{className:"chat-header",children:(0,B.jsx)("div",{children:S("ai_ask")})}),(0,B.jsx)(ne,{messages:Ne.messages,batchMode:Ne.batchMode,selectedMsgIds:Ne.selectedMsgIds,sending:Te,chatContainerRef:Ne.chatContainerRef,messagesEndRef:he,onToggleMsgSelect:Ne.toggleMsgSelect,onDelete:Ne.handleDelete,onCopy:Ne.handleCopy,onCopyAll:Ne.handleCopyAll,onToggleBatchMode:De,onBatchCopy:Ne.handleBatchCopy,onBatchDelete:Ne.batchDeleteMessages,showBatchBar:Ne.batchMode&&Ne.selectedMsgIds.size>0&&0===Y.size,t:S}),(0,B.jsx)(ce,{ref:me,onSend:async()=>{if(ke.admin_all_mode)return;const e=(me.current?.getValue()??"").trim();if(!e&&0===W.length)return;if(G===ke.activeSessionId){const s=await A(W);Me.enqueueMessage(e,s),me.current?.clear(),Q([]);const t={id:w(),sender:"user",text:e+(Me.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void Ne.setMessages(e=>[...e,t])}let s=ke.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,ke.setActiveSessionId(s),b?.(s),await ke.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:Ne.messages.length+2,sender:"bot",text:"处理中...",is_loading:!0},i={...n,id:Ne.messages.length+1},o=[...Ne.messages,i,t];Ne.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),Ne.setMessages([...o]),J(null),ke.refreshSessions(),Ne.scrollToBottom(!0),Me.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,Ne.setMessages([...o]),J(null),Me.processPendingQueue()))}Me.startChatStream(s,n,()=>Me.processPendingQueue())},readonly:ke.admin_all_mode,sending:Te,onAbort:Me.abort,pendingAttachments:W,onRemoveAttachment:e=>{Q(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ge.current?.click()},onAddFiles:Re,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Re(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([[6332],{77481(e,t,s){s.d(t,{S:()=>o,X:()=>a});var n=s(96540),i=s(61443),l=s(74848);function a(e){const[t,s]=n.useState([]),a=(0,n.useRef)(-1),[o,r]=(0,n.useState)(-1),[d,c]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]);const u=()=>{a.current=-1,r(-1),c(-1)};return(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let a=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(a=`${t} (${n.label})`)}return(0,l.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,l.jsx)(i.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:a}):t},s)})})}),(0,l.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,l.jsx)("tr",{className:n?(o===s?"row-dragging":"")+(d===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(a.current=s,r(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||a.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",c(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=a.current,s=d;u(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:u,children:t.map((s,n)=>{const i=n===t.length-1?"small":"";return(0,l.jsx)("td",{className:i,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function o(e){return(0,l.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,l.jsx)("div",{children:e},t))})}},46332(e,t,s){s.r(t),s.d(t,{default:()=>pe});var n=s(96540),i=s(75725),l=s(23430),a=s(70447),o=s(85997),r=s(61443),d=s(14284),c=s(53459),u=s(77481),h=s(22022),p=s(82893),m=s(40505),_=s(62042),x=s(21499),j=s(21469),v=s(64694),f=s(74848);function g(e){const{t}=(0,h.Bd)(),[s,l]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(e.getItems){const t=await e.getItems();l(t)}})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e.title}),e.info_click&&(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{e.info_click()},title:"信息"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:t("添加"),onClick:()=>{const t=[];for(let s=0;s<e.headers.length-1;s++)t.push("");l([t,...s])}}),(0,f.jsx)(o.rA,{icon:"save",title:t("保存"),onClick:async()=>{e.save&&await e.save(s)}})]}),children:(0,f.jsx)(u.X,{headers:e.headers,rows:s.map((n,i)=>{const a=[];for(let t=0;t<e.headers.length;t++)a.push((0,f.jsx)(r.Sm,{value:n[t],handleInputChange:e=>{n[t]=e,l([...s])},no_border:!0}));return a.push((0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"delete",title:t("删除"),onClick:()=>(e=>{s.splice(e,1),l([...s])})(i)}),n[0]&&(0,f.jsx)(o.rA,{icon:"content_copy",title:t("复制地址"),onClick:()=>{const e=(0,x.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);(0,m.lW)(e),(0,_.SK)(e)}}),n[0]&&e.need_copy&&(0,f.jsx)(o.rA,{icon:"open_in_new",title:t("打开新页面"),onClick:()=>{const e=(0,x.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);window.open(e)}})]})),a}),width:"10rem",onRowDrag:(e,t)=>{l((0,v.TI)(s,e,t))}})})})}var y=s(34843),w=s(78247),S=s(24659);function b(){const{t:e}=(0,h.Bd)(),[t,s]=(0,y.fp)(p.AG.prompt_card),l=(0,S.K)(),g=[e("路由"),e("auth"),e("备注")],[b,C]=(0,y.fp)(p.AG.editorSetting),[k,A]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("api/customer_router");e.code===c.m.Success&&A(e.data)})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("api_rt")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{(()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})})()},title:"信息"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{A([{note:"",needAuth:!1,router:""},...k])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("api/customer_router/save",k)).code===c.m.Success&&(0,_.SK)("保存成功")}})]}),children:(0,f.jsx)(u.X,{headers:g,rows:k.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.router,handleInputChange:e=>{t.router=e,A([...k])},no_border:!0}),(0,f.jsx)(r.l6,{defaultValue:t.needAuth,onChange:e=>{t.needAuth=e,A([...k])},options:l,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e,A([...k])},no_border:!0}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{k.splice(e,1),A([...k])})(s)}),(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(async e=>{if(!e.router)return void(0,_.zN)("路由不能为空");const t=await d.XO.get(`jscode/${encodeURIComponent(e.router)}`);C({model:"ace/mode/javascript",open:!0,fileName:e.router,save:async t=>{const s={context:t,router:e.router};(await d.XO.post("jscode/save",s)).code===c.m.Success&&(w.xK.set_value_temp(""),C({open:!1,model:"",fileName:"",save:null}),(0,_.SK)("成功"))}}),w.xK.set_value_temp(t.data)})(t)}),t.router&&(0,f.jsx)(o.rA,{icon:"content_copy",title:e("复制地址"),onClick:()=>{(0,m.lW)((0,x.bi)(window.location.origin+j.m.base_url,t.router)),(0,_.SK)(e("已复制"))}})]})];return n}),width:"10rem",onRowDrag:(e,t)=>{A((0,v.TI)(k,e,t))}})})})}var C=s(23496),k=s(4412);function A(){const{t:e}=(0,h.Bd)(),[t,s]=(0,y.fp)(p.AG.prompt_card),[l,a]=(0,y.fp)(p.AG.router_jump),o=[e("路由"),e("路径"),e("过期时间(s)"),e("备注")],r=[e("路由"),e("文件路径"),"token","user id",e("备注")];return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(k.aZ,{position:"right"}),(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{maxWidth:"50rem",children:[(0,f.jsx)(g,{title:e("页面资源路由"),headers:o,getItems:async()=>{const e=await d.XO.get(C.s.setting_customer_router);if(e.code===c.m.Success){if(l?.page_self_router_api_data){for(const t of e.data)t[1]===l?.page_self_router_api_data[1]&&(0,_.N9)("已经存在的页面资源路由配置目录设置");const t={};Object.assign(t,l?.page_self_router_api_data),e.data=[t,...e.data],a({})}return e.data}return[]},save:async e=>{(await d.XO.post(C.s.setting_customer_router_save,e)).code===c.m.Success&&(0,_.SK)("success")},info_click:()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由,会自动识别地址,将页面转到对应结果。路径支持文件路径(如果是文件夹路径的最后最后一个名字将会成为资源实际地址,整个目录将会变成一个http目录),http地址。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})},need_copy:!0}),(0,f.jsx)(g,{title:e("wf_rt"),headers:r,getItems:async()=>{const e=await d.XO.get(C.s.setting_customer_workflow_router);return e.code===c.m.Success?e.data:[]},save:async e=>{(await d.XO.post(C.s.setting_customer_workflow_router_save,e)).code===c.m.Success&&(0,_.SK)("保存成功")},info_click:()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径,请求的时候请设置同样的authorization请求头字段。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})}})]}),(0,f.jsx)(i.VP,{maxWidth:"50rem",children:(0,f.jsx)(b,{})})]})]})}var I=s(74777),N=s(6960),V=s(7523);function $(){const{t:e}=(0,h.Bd)(),{check_user_auth:t}=(0,w.MH)(),[s,i]=(0,n.useState)(!1),[u,m]=(0,n.useState)("https://registry.npmjs.org"),[x,j]=(0,n.useState)(""),[v,g]=(0,n.useState)(180),[S,b]=(0,n.useState)(!1),[C,k]=(0,y.fp)(p.AG.prompt_card);(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("auto_upgrade_setting");if(e.code===c.m.Success){const t=e.data;i(t.open||!1),m(t.version_check_url||"https://registry.npmjs.org"),j(t.exe_download_url||""),g(t.check_interval_seconds||180)}})()},[]);return t(l.oV.sys_setting_page)?(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("自动升级")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{k({open:!0,title:e("信息"),context_div:(0,f.jsx)("div",{children:e("自动升级在 windows 下目前可能不稳定")})})},title:e("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("保存"),clickFun:async()=>{if(!u)return void(0,_.zN)(e("ver_req"));if(s&&(!v||v<10))return void(0,_.zN)(e("chk_10s"));const t=new I.Mm;t.open=s,t.version_check_url=u,t.exe_download_url=x,t.check_interval_seconds=v;(await d.XO.post("auto_upgrade_setting/save",t)).code===c.m.Success&&(0,_.SK)(e("保存成功"))}}),children:[(0,f.jsx)("div",{children:e("ver_url")}),(0,f.jsx)(r.Sm,{placeholder:"https://registry.npmjs.org",value:u,handleInputChange:e=>{m(e)}}),(0,f.jsx)(r.l6,{value:s,onChange:e=>{i(e)},options:[{title:e("开启"),value:!0},{title:e("关闭"),value:!1}]}),s&&(0,f.jsxs)(f.Fragment,{children:[!1,(0,f.jsx)("div",{children:e("检测频率(秒)")}),(0,f.jsx)(r.Sm,{placeholder:e("def_180"),value:v,handleInputChange:e=>{g(Number(e)||180)}}),(0,f.jsx)("div",{style:{marginTop:"12px"},children:(0,f.jsx)(o.C3,{text:e(S?"升级检测中...":"立即升级"),clickFun:async()=>{b(!0);try{(await d.XO.post("auto_upgrade_setting/upgrade_now",{})).code===c.m.Success&&(0,_.SK)(e("已触发升级检测,请查看服务端日志"))}catch(t){(0,_.zN)(e("触发升级失败"))}finally{b(!1)}}})})]})]}):null}function X(){const{t:e}=(0,h.Bd)(),[,t]=(0,y.fp)(p.AG.prompt_card),[s,i]=(0,n.useState)(""),[l,m]=(0,n.useState)(5610),[x,j]=(0,n.useState)(5710);(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("sys_option/status");if(e.code===c.m.Success){const t=e.data?.sys_env;i((t?.browser_proxy_allow||[]).join("\n")),m(t?.browser_proxy_port_start||5610),j(t?.browser_proxy_port_end||5710)}})()},[]);return(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("网页代理")}),(0,f.jsx)(o.rA,{icon:"info",title:e("信息"),onClick:()=>{t({open:!0,title:e("信息"),context_div:(0,f.jsx)("div",{children:(0,f.jsx)("div",{children:e("wbvpn_tip")})})})}})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{const t=s.split("\n").map(e=>e.trim()).filter(e=>!!e);(await d.XO.post(C.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{browser_proxy_allow:t,browser_proxy_port_start:Number(l)||5610,browser_proxy_port_end:Number(x)||5710}})).code===c.m.Success&&(0,_.SK)(e("修改成功"))}}),children:[(0,f.jsx)("div",{children:e("wbvpn_allow")}),(0,f.jsx)(r.Z2,{style:{minHeight:"5rem",resize:"vertical"},placeholder:e("wbvpn_allow_ph"),value:s,onChange:e=>{i(e.target.value)}}),(0,f.jsx)("div",{children:e("wbvpn_port_range")}),(0,f.jsx)(u.S,{isFlex:!0,columns:[(0,f.jsx)(r.Sm,{placeholder:"5610",value:l,handleInputChange:e=>m(e)}),(0,f.jsx)("span",{style:{padding:"0 6px"},children:"-"}),(0,f.jsx)(r.Sm,{placeholder:"5710",value:x,handleInputChange:e=>j(e)})]})]})}function z(){const[e,t]=(0,n.useState)(""),[s,l]=(0,n.useState)(""),[m,x]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[g,S]=(0,n.useState)(!1),[b,A]=(0,n.useState)(""),[z,F]=(0,y.fp)(p.AG.prompt_card),[K,O]=(0,n.useState)(!1),[P,B]=(0,n.useState)(""),[E,M]=(0,n.useState)(""),[D,T]=(0,n.useState)(I.aM.close),[G,q]=(0,n.useState)(!1),[R,W]=(0,n.useState)(void 0),{t:Z,i18n:H}=(0,h.Bd)(),[U,J]=(0,y.fp)(p.AG.user_base_info),{check_user_auth:Q}=(0,w.MH)(),{initUserInfo:L}=(0,n.useContext)(V.F);(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("sys_option/status");if(e.code===c.m.Success){S(e.data.recycle_open),A(e.data.recycle_dir);const s=e.data.sys_env;t(s?.web_site_title),l(s?.logo||""),x(s?.show_login_user_info),v(s?.http_proxy||"");const n=e.data.https_setting;n&&(O(n.open),B(n.cert_path||""),M(n.key_path||""))}const s=await d.XO.get("token");if(s.code===c.m.Success){const e=s.data;if(!e)return;e.length&&W(e.length),e.mode&&T(e.mode),void 0!==e.persist&&q(e.persist)}})()},[]);return(0,f.jsxs)("div",{children:[(0,f.jsx)(k.aZ,{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("span",{className:"credits",children:[Z("系统运行于"),": ",(0,N.s)(U.runing_time_length)]}),(0,f.jsx)("span",{className:"credits",children:(0,f.jsxs)("a",{href:"https://github.com/xiaobaidadada/filecat",target:"_blank",children:["version:7.15.0",null!=U.latest_version&&"7.15.0"!==U.latest_version?` -> ${U.latest_version}`:""]})}),(0,f.jsx)("span",{className:"credits",children:(0,f.jsx)("a",{href:Z("官网地址"),target:"_blank",children:`filecat ${Z("功能文档")}`})}),(0,f.jsxs)("span",{className:"credits",children:[Z("安装方式")," :",U.process_env_run_env]})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:Z("通用设置")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{F({open:!0,title:Z("信息"),context_div:(0,f.jsx)("div",{children:(0,f.jsx)("div",{children:Z("pxy_tip")})})})},title:Z("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:Z("确定修改"),clickFun:async()=>{(await d.XO.post(C.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{web_site_title:e,show_login_user_info:m,http_proxy:j,logo:s}})).code===c.m.Success&&((0,_.SK)("修改成功"),L())}}),children:[Z("网站标题"),(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{t(e)}}),Z("网站 Logo"),(0,f.jsx)(r.Sm,{placeholder:Z("lclorur"),value:s,handleInputChange:e=>{l(e)}}),(0,f.jsx)("div",{children:Z("pxy_url")}),(0,f.jsx)(r.Sm,{placeholder:"http://127.0.0.1:7890",value:j,handleInputChange:e=>{v(e)}}),Z("lgn_usr"),(0,f.jsx)("input",{type:"checkbox",checked:m,onChange:()=>{x(!m)}})]}),(0,f.jsxs)(a.Zp,{title:Z("https_s"),rightBottomCom:(0,f.jsx)(o.C3,{text:Z("确定修改"),clickFun:async()=>{if(K){if(!P)return void(0,_.zN)("证书路径不能为空");if(!E)return void(0,_.zN)("私钥路径不能为空")}const e=new I.CH;e.open=K,e.cert_path=P,e.key_path=E;(await d.XO.post(C.s.setting_sys_option_status_save,{type:I.Mu.https,value:e,open:K})).code===c.m.Success&&(0,_.SK)("HTTPS 设置已保存,需重启服务器才能生效")}}),children:[(0,f.jsx)(r.l6,{value:K,onChange:e=>{O(e)},options:[{title:Z("开启"),value:!0},{title:Z("关闭"),value:!1}]}),K&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{children:Z("ssl_crt")}),(0,f.jsx)(r.Sm,{placeholder:Z("crt_pth"),value:P,handleInputChange:e=>{B(e)}}),(0,f.jsx)("div",{children:Z("ssl_key")}),(0,f.jsx)(r.Sm,{placeholder:Z("ky_pth"),value:E,handleInputChange:e=>{M(e)}})]})]}),(0,f.jsx)($,{}),(0,f.jsx)(X,{})]}),(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:Z("文件回收站")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{F({open:!0,title:Z("信息"),context_div:(0,f.jsx)("div",{children:Z("格式:[被删除的文件所在父目录] 回收站目录 [; ...]")})})},title:Z("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:Z("确定修改"),clickFun:async()=>{if(g&&!b)return void(0,_.zN)("目录不能为空");(await d.XO.post(C.s.setting_sys_option_status_save,{type:I.Mu.cyc,value:b,open:g})).code===c.m.Success&&(0,_.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:Z("目录"),value:b,handleInputChange:e=>{A(e)}}),(0,f.jsx)(r.l6,{value:g,onChange:e=>{S(e)},options:[{title:Z("开启"),value:!0},{title:Z("关闭"),value:!1}]})]}),(0,f.jsxs)(a.Zp,{title:Z("tk_exp"),rightBottomCom:(0,f.jsx)(u.S,{isFlex:!0,columns:[(0,f.jsx)(o.C3,{text:Z("清空token"),clickFun:async()=>{(await d.XO.get("token/clear")).code===c.m.Success&&(0,_.SK)("清理完成,重新登录")}}),(0,f.jsx)(o.C3,{text:Z("保存"),clickFun:async()=>{const e=new I.Gd;e.mode=D,e.persist=G,I.aM.length!==e.mode||R||(0,_.zN)("秒数不能为空"),e.length=parseInt(R);(await d.XO.post("token/save",e)).code===c.m.Success&&(0,_.SK)("保存成功")}})]}),children:[(0,f.jsx)(u.S,{isFlex:!0,columns:[(0,f.jsx)(r.U6,{value:1,context:Z("关闭"),selected:D===I.aM.close,onchange:()=>{T(I.aM.close)}}),(0,f.jsx)(r.U6,{value:1,context:Z("指定时间"),selected:D===I.aM.length,onchange:()=>{T(I.aM.length)}}),(0,f.jsx)(r.U6,{value:1,context:Z("永不过期"),selected:D===I.aM.forver,onchange:()=>{T(I.aM.forver)}})]}),D===I.aM.length&&(0,f.jsx)(r.Sm,{placeholder:Z("秒"),value:R,handleInputChange:e=>{W(e)}}),(0,f.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,whiteSpace:"nowrap"},children:[(0,f.jsx)("input",{type:"checkbox",checked:G,onChange:()=>q(!G)}),Z("持久化")]})]})]})]})})]})}var F=s(92350),K=s(69675),O=s(32361);const P=[{key:"second",min:0,max:59,label:"秒"},{key:"minute",min:0,max:59,label:"分"},{key:"hour",min:0,max:23,label:"时"},{key:"day",min:1,max:31,label:"日"},{key:"month",min:1,max:12,label:"月"},{key:"week",min:0,max:7,label:"星期"}];function B(e){switch(e.mode){case"step":return`*/${e.step??1}`;case"range":return`${e.from??0}-${e.to??0}`;case"list":return(e.values??[]).join(",");default:return"*"}}function E(e){return[B(e.second),B(e.minute),B(e.hour),B(e.day),B(e.month),B(e.week)].join(" ")}function M(e,t,s){const n=(e??"").trim();if(!n)return null;if("*"===n)return{mode:"every"};if(n.startsWith("*/")){const e=Number(n.slice(2));return!Number.isInteger(e)||e<=0?null:{mode:"step",step:e}}if(n.includes("-")&&!n.includes(",")){const[e,i]=n.split("-").map(Number);return Number.isInteger(e)&&Number.isInteger(i)?e<t||i>s||e>i?null:{mode:"range",from:e,to:i}:null}const i=n.split(","),l=[];for(const e of i){const n=Number(e.trim());if(!Number.isInteger(n)||n<t||n>s)return null;l.push(n)}return 0===l.length?null:{mode:"list",values:l}}function D(e){const t=(e??"").trim().split(/\s+/);if(6!==t.length)return null;const s={};for(let e=0;e<6;e++){const n=P[e],i=M(t[e],n.min,n.max);if(!i)return null;s[n.key]=i}return s}function T(e){return e<10?`0${e}`:`${e}`}function G(e,t,s){switch(e.mode){case"step":return`每 ${e.step} ${t}`;case"range":return`${e.from} 到 ${e.to} ${t}`;case"list":return`${(e.values??[]).slice().sort((e,t)=>e-t).join("、")} ${t}`;default:return null}}function q(e){const{second:t,minute:s,hour:n,day:i,month:l,week:a}=e,o=(e,t)=>"list"===e.mode&&1===(e.values??[]).length&&e.values[0]===t,r=[];if("list"===n.mode&&"list"===s.mode&&o(t,0)){const e=(n.values??[]).slice().sort((e,t)=>e-t),t=(s.values??[]).slice().sort((e,t)=>e-t);e.length===t.length&&e.length>1&&t.length>1?r.push(e.map((e,s)=>`${T(e)}:${T(t[s])}`).join("、")):1===e.length&&1===t.length?r.push(`${T(e[0])}:${T(t[0])}`):r.push(`${e.map(T).join("、")} 时 ${t.join("、")} 分`)}else if("list"===n.mode&&"step"===s.mode&&o(t,0))r.push(`${(n.values??[]).map(T).join("、")} 时内每 ${s.step} 分钟`);else if("every"===n.mode&&"list"===s.mode&&o(t,0))r.push(`每小时的 ${(s.values??[]).join("、")} 分`);else if("every"===n.mode&&"step"===s.mode&&o(t,0))r.push(`每 ${s.step} 分钟`);else if("every"===n.mode&&"every"===s.mode&&o(t,0))r.push("每分钟");else if("every"===n.mode&&"every"===s.mode&&"step"===t.mode)r.push(`每 ${t.step} 秒`);else if("every"===n.mode&&"every"===s.mode&&"every"===t.mode)r.push("每秒");else if("every"===n.mode&&"every"===s.mode&&"list"===t.mode)r.push(`每分钟的第 ${(t.values??[]).join("、")} 秒`);else{const e=[],i=G(n,"时"),l=G(s,"分"),a=o(t,0)?null:G(t,"秒");i&&e.push(i),l&&e.push(l),a&&e.push(a),e.length>0&&r.push(e.join(" "))}const d="list"===i.mode&&1===(i.values??[]).length?i.values[0]:null,c="list"===l.mode&&1===(l.values??[]).length?l.values[0]:null,u="list"===a.mode&&1===(a.values??[]).length?a.values[0]:null;let h="";if(null!==c&&null!==d)h=`每年 ${c} 月 ${d} 号`;else if(null!==c)h=`每年 ${c} 月`;else if(null!==d)h=`每月 ${d} 号`;else if(null!==u)h=`每${["周日","周一","周二","周三","周四","周五","周六","周日"][u]??`星期 ${u}`}`;else{const e=[];"every"!==l.mode&&e.push(G(l,"月")),"every"!==i.mode&&e.push(G(i,"号")),"every"!==a.mode&&e.push(`星期 ${G(a,"")}`),e.length&&(h=e.join(" "))}h||(h="每天");const p=r.join(",");return/^(每|每天)/.test(p)?`${p}${"每天"===h?"":","+h} 执行`:`${h} ${p} 执行`}const R=[{label:"任意 (*)",value:"every"},{label:"每隔 (*/n)",value:"step"},{label:"区间 (a-b)",value:"range"},{label:"指定 (a,b)",value:"list"}];function W(e,t,s=!1){const n=[];for(let i=e;i<=t;i++)n.push({label:s?String(i).padStart(2,"0"):String(i),value:i});return n}const Z=({label:e,field:t,min:s,max:i,pad:l,week_label:a,onChange:o})=>{const d=(0,n.useMemo)(()=>W(s,i,l),[s,i,l]),c=(0,n.useMemo)(()=>{if(!a)return d;const e=["周日","周一","周二","周三","周四","周五","周六","周日"];return d.map(t=>({value:t.value,label:`${t.value} (${e[t.value]})`}))},[d,a]);return(0,f.jsxs)("div",{className:"cron-field",children:[(0,f.jsx)("span",{className:"cron-field__label",children:e}),(0,f.jsx)(r.l6,{value:t.mode,onChange:e=>{o("every"===e?{mode:"every"}:"step"===e?{mode:"step",step:t.step??1}:"range"===e?{mode:"range",from:t.from??s,to:t.to??i}:{mode:"list",values:t.values??[s]})},options:R,no_border:!0,width:"7.5rem"}),"step"===t.mode&&(0,f.jsxs)("div",{className:"cron-field__param",children:[(0,f.jsx)("span",{children:"每"}),(0,f.jsx)(r.l6,{value:t.step??1,onChange:e=>o({mode:"step",step:e}),options:W(1,i),no_border:!0,width:"4.5rem"}),(0,f.jsx)("span",{children:e})]}),"range"===t.mode&&(0,f.jsxs)("div",{className:"cron-field__param",children:[(0,f.jsx)(r.l6,{value:t.from??s,onChange:e=>o({mode:"range",from:e,to:t.to??i}),options:c,no_border:!0,width:"6.5rem"}),(0,f.jsx)("span",{children:"到"}),(0,f.jsx)(r.l6,{value:t.to??i,onChange:e=>o({mode:"range",from:t.from??s,to:e}),options:c,no_border:!0,width:"6.5rem"})]}),"list"===t.mode&&(0,f.jsxs)("div",{className:"cron-field__param cron-field__param--list",children:[(t.values??[]).map((e,s)=>(0,f.jsxs)("span",{className:"cron-tag",children:[(0,f.jsx)(r.l6,{value:e,onChange:e=>((e,s)=>{const n=[...t.values??[]];n[e]=s,o({mode:"list",values:n})})(s,e),options:c,no_border:!0,width:"6.5rem"}),(0,f.jsx)("i",{className:"material-icons cron-tag__del",onClick:()=>(e=>{const s=(t.values??[]).filter((t,s)=>s!==e);o(s.length?{mode:"list",values:s}:{mode:"every"})})(s),children:"close"})]},s)),(0,f.jsx)("i",{className:"material-icons cron-tag__add",onClick:()=>{const e=[...t.values??[]],n=new Set(e);let l=s;for(;n.has(l)&&l<i;)l++;o({mode:"list",values:[...e,l]})},children:"add"})]})]})};const H=[{label:"每分钟",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},second:{mode:"list",values:[0]}})},{label:"每 5 分钟",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},minute:{mode:"step",step:5},second:{mode:"list",values:[0]}})},{label:"每小时",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},minute:{mode:"list",values:[0]},second:{mode:"list",values:[0]}})},{label:"每天 0 点",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},hour:{mode:"list",values:[0]},minute:{mode:"list",values:[0]},second:{mode:"list",values:[0]}})},{label:"每天 8 点",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},hour:{mode:"list",values:[8]},minute:{mode:"list",values:[0]},second:{mode:"list",values:[0]}})},{label:"每周一 0 点",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},hour:{mode:"list",values:[0]},minute:{mode:"list",values:[0]},second:{mode:"list",values:[0]},week:{mode:"list",values:[1]}})},{label:"每月 1 号 0 点",make:()=>({second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"},hour:{mode:"list",values:[0]},minute:{mode:"list",values:[0]},second:{mode:"list",values:[0]},day:{mode:"list",values:[1]}})}],U=({value:e,onChange:t,no_border:s})=>{const[i,l]=(0,n.useState)(!1),a=(0,n.useRef)(null),o=(0,n.useRef)(null),r=(0,n.useMemo)(()=>D(e??"")??{second:{mode:"every"},minute:{mode:"every"},hour:{mode:"every"},day:{mode:"every"},month:{mode:"every"},week:{mode:"every"}},[e]),d=!!e&&!D(e??""),c=(0,O.r)({active:i,trigger_ref:a,floating_ref:o,width:384,max_height:26});(0,K.$)(i,[a,o],()=>l(!1));const u=e=>{t(E(e))};return(0,f.jsxs)("div",{className:"cron-input "+(i?"cron-input--open":""),children:[(0,f.jsxs)("div",{ref:a,className:"cron-input__display "+(s?"cron-input__display--no-border":""),title:d?"表达式格式不正确":`${e||""} ${q(r)}`.trim(),onClick:()=>l(!i),children:[(0,f.jsx)("span",{className:"cron-input__expr "+(d?"cron-input__expr--invalid":""),children:e||"(未设置)"}),!s&&(0,f.jsx)("span",{className:"cron-input__desc",children:d?"表达式格式不正确":q(r)}),(0,f.jsx)("i",{className:"material-icons cron-input__arrow",children:"arrow_drop_down"})]}),i&&(0,f.jsxs)("div",{ref:o,className:"cron-editor",style:{left:c.left,top:c.top,...c.css_vars,visibility:c.ready?"visible":"hidden"},children:[(0,f.jsxs)("div",{className:"cron-editor__scroll",children:[(0,f.jsxs)("div",{className:"cron-editor__row",children:[(0,f.jsx)("span",{className:"cron-editor__title",children:"常用"}),(0,f.jsx)("div",{className:"cron-editor__presets",children:H.map(e=>(0,f.jsx)("button",{className:"cron-preset",onClick:()=>u(e.make()),children:e.label},e.label))})]}),(0,f.jsx)("div",{className:"cron-editor__fields",children:P.map(e=>(0,f.jsx)(Z,{label:e.label,field:r[e.key],min:e.min,max:e.max,pad:"day"!==e.key&&"month"!==e.key&&"week"!==e.key,week_label:"week"===e.key,onChange:t=>{return s=e.key,n=t,void u({...r,[s]:n});var s,n}},e.key))})]}),(0,f.jsxs)("div",{className:"cron-editor__footer",children:[(0,f.jsx)("span",{className:"cron-editor__preview",children:E(r)}),(0,f.jsx)("button",{className:"cron-editor__done",onClick:()=>l(!1),children:"完成"})]})]})]})};function J(){const{t:e,i18n:t}=(0,h.Bd)(),{initUserInfo:s,reloadUserInfo:l}=(0,n.useContext)(V.F),[m,x]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[b,C]=(0,y.fp)(p.AG.prompt_card),[,k]=(0,y.fp)(p.AG.editorSetting),[A,I]=(0,n.useState)([]),[N,$]=(0,n.useState)([]),[X,z]=(0,n.useState)([]),[K,O]=(0,n.useState)([]),[P,B]=(0,n.useState)(""),[E,M]=(0,n.useState)([]),D=(0,S.K)(),T=[e("软件"),e("是否安装"),e("路径")],G=[e("编号"),e("路径"),e("备注")],q=[e("编号"),e("路径"),e("是否开启"),e("备注")],R=[e("编号"),e("文件路径"),e("是否开启"),e("系统启动执行"),e("cron表达式"),e("用户id"),e("备注")],W=[e("编号"),e("路径"),e("单用户并发数量"),e("系统并发数量"),e("big_res"),e("big_sz"),e("大文件并发数量"),e("big_ck"),e("备注")],Z=[e("编号"),e("名称"),e("路径"),e("是否开启"),e("params"),e("备注")],{check_user_auth:H}=(0,w.MH)(),J=async()=>{const e=await d.XO.get("env/path/get");e.code===c.m.Success&&z(e.data)},Q=async()=>{const e=await d.XO.get("workflow_setting_get");e.code===c.m.Success&&O(e.data)};(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("outside/software/get");e.code===c.m.Success&&g(e.data);const t=await d.XO.get("pty_cmd");t.code===c.m.Success&&B(t.data),J(),Q();const s=await d.XO.get("protection_dir/sys");s.code===c.m.Success&&I(s.data??[]);const n=await d.XO.get("dir_upload_max_num");n.code===c.m.Success&&$(n.data??[]);const i=await d.XO.get("plugin/list");i.code===c.m.Success&&M(i.data??[])})()},[]);const L=(0,F.Q)(),Y=async()=>{(await d.XO.post("plugin/list/save",E)).code===c.m.Success&&(0,_.SK)(e("保存成功"))};return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(i.J,{widthPer:100,maxWidth:"100rem",children:(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("up_conc")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("文件上传")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{$([...N,{path:"",note:"",user_upload_num:2,sys_upload_num:6,ws_file_standard_size:52428800,ws_file_parallel_num:2,ws_file_block_mb_size:524288}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{for(const e of N)if(e.open_ws_file){if("number"!=typeof e.ws_file_block_mb_size)return void(0,_.zN)(`编号:${e.index??""} 文件块的大小设置有问题`);if("number"!=typeof e.ws_file_parallel_num)return void(0,_.zN)(`编号:${e.index??""} 并发数量设置有问题`);if("number"!=typeof e.ws_file_standard_size)return void(0,_.zN)(`编号:${e.index??""} 大文件size设置有问题`)}(0,v.di)(N,e=>e.index??0);(await d.XO.post("dir_upload_max_num/save",N)).code===c.m.Success&&((0,_.SK)("保存成功"),l())}})]}),children:(0,f.jsx)(u.X,{headers:W,rows:N.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.index,placeholder:s,handleInputChange:e=>{t.index=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.user_upload_num,handleInputChange:e=>{t.user_upload_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.sys_upload_num,handleInputChange:e=>{t.sys_upload_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.l6,{value:!0===t.open_ws_file,onChange:e=>{t.open_ws_file=e,$([...N])},options:D,no_border:!0}),(0,f.jsx)(r.Sm,{value:"number"==typeof t.ws_file_standard_size?t.ws_file_standard_size/1024/1024:void 0,handleInputChange:e=>{t.ws_file_standard_size=1024*parseInt(e)*1024},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.ws_file_parallel_num,handleInputChange:e=>{t.ws_file_parallel_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:"number"==typeof t.ws_file_block_mb_size?t.ws_file_block_mb_size/1024/1024:void 0,handleInputChange:e=>{t.ws_file_block_mb_size=1024*parseInt(e)*1024},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{N.splice(e,1),$([...N])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{$((0,v.TI)(N,e,t))}})})}),(0,f.jsx)(i.J,{widthPer:100,maxWidth:"100rem",children:(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("Workflow Job")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("Workflow")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{O([...K,{open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("workflow_setting_save",K)).code===c.m.Success&&((0,_.SK)("ok"),Q())}})]}),children:(0,f.jsx)(u.X,{headers:R,rows:K.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.file_path,handleInputChange:e=>{t.file_path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,O([...K])},options:D,no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.sys_power_on,onChange:e=>{t.sys_power_on=e,O([...K])},options:D,no_border:!0}),(0,f.jsx)(U,{value:t.cron_str,onChange:e=>{t.cron_str=e,O([...K])},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.user_id,handleInputChange:e=>{t.user_id=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{K.splice(e,1),O([...K])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{O((0,v.TI)(K,e,t))}})})}),(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"50rem",children:(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("PATH")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("环境路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"list",title:e("查看"),onClick:async()=>{const t=await d.XO.get("env/process/view");t.code===c.m.Success?C({open:!0,title:e("进程环境变量"),context_div:(0,f.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"60vh",overflow:"auto",margin:0,fontSize:"0.85rem",lineHeight:"1.5"},children:t.data})}):(0,_.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:async()=>{const t=await d.XO.get("env/process/get");t.code===c.m.Success?(w.xK.set_value_temp(t.data??""),k({model:"ace/mode/ini",open:!0,fileName:"",save:async t=>{(await d.XO.post("env/process/save",{text:t})).code===c.m.Success?(0,_.SK)(e("保存成功")):(0,_.zN)(e("保存失败")),w.xK.set_value_temp("")}})):(0,_.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{z([...X,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("env/path/save",{paths:X})).code===c.m.Success&&((0,_.SK)("保存成功"),J(),s())}})]}),children:(0,f.jsx)(u.X,{headers:q,rows:X.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,z([...X])},options:D,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{X.splice(e,1),z([...X])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{z((0,v.TI)(X,e,t))}})}),(0,f.jsx)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("PTY CMD")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("pty")},title:e("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("更新"),clickFun:async()=>{(await d.XO.post("pty_cmd/save",{str:P})).code===c.m.Success&&((0,_.SK)("保存成功"),l())}}),children:(0,f.jsx)(r.Sm,{placeholder:e("cmd need pty env"),value:P,handleInputChange:e=>{B(e)}})}),(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("插件配置")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("插件配置")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{M([...E,{name:"",path:"",note:"",open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:Y})]}),children:(0,f.jsx)(u.X,{headers:Z,rows:E.map((t,s)=>{const n=[s,(0,f.jsx)(r.Sm,{value:t.name,handleInputChange:e=>{t.name=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,M([...E])},options:D,no_border:!0}),(0,f.jsx)(o.mu,{icon:"edit",save:async e=>{t.params=e,await Y()},title:""}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{E.splice(e,1),M([...E])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{M((0,v.TI)(E,e,t))}})})]})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"50rem",children:(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("系统保护路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L("保护目录")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{I([...A,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("protection_dir/sys/save",A)).code===c.m.Success&&((0,_.SK)("保存成功"),l())}})]}),children:(0,f.jsx)(u.X,{headers:G,rows:A.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{A.splice(e,1),I([...A])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{I((0,v.TI)(A,e,t))}})}),(0,f.jsx)(a.uF,{title:e("外部软件"),titleCom:(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("outside/software/save",j)).code===c.m.Success&&((0,_.SK)("保存成功"),s())}}),children:(0,f.jsx)(u.X,{headers:T,rows:j.map((t,s)=>[(0,f.jsx)("div",{children:t.id}),(0,f.jsx)(a.fq,{ok:t.installed}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0,placeholder:e("use_env")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{L(t.id)},title:e("信息")})]),width:"10rem"})})]})})]})]})}function Q(e){const{t,i18n:s}=(0,h.Bd)(),[i,a]=(0,y.fp)(p.AG.user_base_info),o=[{title:t("用户权限"),list:[{title:t("用户管理"),permission:l.oV.user_manage},{title:t("角色管理"),permission:l.oV.role_manage}]},{title:t("系统管理权限"),list:[{title:t("系统信息"),permission:l.oV.all_sys},{title:t("系统进程关闭"),permission:l.oV.sys_process_close},{title:t("dc_ctdl"),permission:l.oV.docker_container_update},{title:t("dc_idl"),permission:l.oV.docker_images_delete},{title:t("systemd管理"),permission:l.oV.systemd},{title:t("防火墙管理"),permission:l.oV.firewall}]},{title:t("网络功能权限"),list:[{title:t("系统网络"),permission:l.oV.vir_net},{title:t("内网穿透"),permission:l.oV.tcp_proxy},{title:"ddns",permission:l.oV.ddns}]},{title:t("Ai 设置权限"),list:[{title:t("Ai 配置"),permission:l.oV.ai_agent_setting},{title:t("ai_page"),permission:l.oV.ai_agent_page},{title:t("sw_mdl"),permission:l.oV.ai_model_switch}]},{title:t("文件权限"),list:[{title:t("log_del"),permission:l.oV.filecat_file_delete_cut_rename},{title:t("log_wr"),permission:l.oV.filecat_file_context_update_upload_created_copy_decompression},{title:t("内容更新"),permission:l.oV.filecat_file_context_update},{title:t("文件回收站修改"),permission:l.oV.recycle_file_save},{title:t("文件分享"),permission:l.oV.share_file}]},{title:t("系统设置权限"),list:[{title:t("系统页面"),permission:l.oV.sys_setting_page},{title:t("htts"),permission:l.oV.https_file},{title:t("tk_time"),permission:l.oV.token_update},{title:t("修改密码"),permission:l.oV.update_password},{title:t("磁盘挂载"),permission:l.oV.sys_disk_mount},{title:t("通用设置"),permission:l.oV.sys_env_setting_key},{title:t("md_set"),permission:l.oV.md_editor_setting},{title:t("目录挂载"),permission:l.oV.file_mount}]},{title:t("系统环境设置"),list:[{title:t("sys_env"),permission:l.oV.sys_env_page},{title:t("up_lim"),permission:l.oV.dir_upload_max_num},{title:t("path_md"),permission:l.oV.env_path_update},{title:"pty cmd "+t("更新"),permission:l.oV.pty_cmd_update},{title:"workflow job",permission:l.oV.workflow_job},{title:t("path_up"),permission:l.oV.sys_protection_dir},{title:t("外部软件路径"),permission:l.oV.outside_software_path}]},{title:t("个人环境设置"),list:[{title:t("个性化设置"),permission:l.oV.private_sys_env}]},{title:t("自定义路由"),list:[{title:t("自定义路由页面"),permission:l.oV.auth_router_page},{title:t("wf_api"),permission:l.oV.workflow_api},{title:t("自定义资源路由"),permission:l.oV.code_resource},{title:t("api_rt"),permission:l.oV.code_api}]},{title:t("标签编辑权限"),list:[{title:t("ssh代理"),permission:l.oV.ssh_proxy_tag_update},{title:t("http代理"),permission:l.oV.http_proxy_tag_update},{title:t("浏览器代理"),permission:l.oV.browser_proxy_tag_update},{title:t("rdp代理"),permission:l.oV.rdp_proxy_tag_update},{title:t("网络唤醒"),permission:l.oV.wol_proxy_tag_update},{title:t("rtsp播放器"),permission:l.oV.rtsp_proxy_tag_update}]},{title:t("代理功能"),list:[{title:t("ssh代理"),permission:l.oV.ssh_proxy},{title:t("http代理"),permission:l.oV.http_proxy},{title:t("pxy_off"),permission:l.oV.http_proxy_download_cancel},{title:t("浏览器代理"),permission:l.oV.browser_proxy},{title:t("浏览器代理编辑"),permission:l.oV.browser_proxy_edit},{title:t("rdp代理"),permission:l.oV.rdp_proxy}]},{title:t("其他功能"),list:[{title:t("wf_run"),permission:l.oV.workflow_exe},{title:t("wf_user"),permission:l.oV.workflow_exe_user,noDisable:!0},{title:t("网络唤醒"),permission:l.oV.wol_proxy},{title:t("端口扫描"),permission:l.oV.port_scan},{title:t("rtsp播放器"),permission:l.oV.rtsp_proxy},{title:t("ssh_sv"),permission:l.oV.crypto_ssh_file},{title:t("cmd_rst"),permission:l.oV.shell_cmd_filecat_restart},{title:t("cmd_upg"),permission:l.oV.shell_cmd_filecat_upgrade},{title:t("cmd_dwn"),permission:l.oV.shell_cmd_filecat_kill_self},{title:t("cmd_ai"),permission:l.oV.ai_chat_cmd}]}];return(0,f.jsx)(n.Fragment,{children:o.map((t,s)=>(0,f.jsxs)("div",{children:[(0,f.jsx)("h3",{children:t.title}),t.list.map((t,s)=>(0,f.jsxs)("div",{children:[(0,f.jsx)("input",{type:"checkbox",disabled:!t.noDisable&&e.is_disable(t.permission),checked:e.is_selected(t.permission,t.noDisable),onChange:()=>{e.select_auth(t.permission)}}),t.title]},s))]},s))})}const L=new Map;function Y(){const{t:e,i18n:t}=(0,h.Bd)(),{initUserInfo:s,reloadUserInfo:m}=(0,n.useContext)(V.F),[j,g]=(0,y.fp)(p.AG.user_base_info),[w,S]=(0,n.useState)([]),[b,C]=(0,y.fp)(p.AG.prompt_card),[k,A]=(0,n.useState)(!1),[I,N]=(0,n.useState)(!1),[$,X]=(0,y.fp)(p.AG.confirm),[z,K]=(0,n.useState)(""),[O,P]=(0,n.useState)(""),[B,E]=(0,n.useState)(""),[M,D]=(0,n.useState)([]),[T,G]=(0,n.useState)([]),[q,R]=(0,n.useState)([]),[W,Z]=(0,n.useState)(""),[H,U]=(0,n.useState)(""),[J,Y]=(0,n.useState)("en"),[ee,te]=(0,n.useState)(""),[se,ne]=(0,n.useState)([]),[ie,le]=(0,n.useState)(""),[ae,oe]=(0,n.useState)(!1),[re,de]=(0,n.useState)(""),[ce,ue]=(0,n.useState)(""),[he,pe]=(0,n.useState)({}),me=(0,F.o)(),[_e,xe]=(0,n.useState)([]),[je,ve]=(0,n.useState)(void 0),fe=[e("用户id"),e("用户名"),e("目录范围"),e("备注")],ge=async()=>{const e=await d.wm.get("all_users");if(e.code===c.m.Success){const t=e.data??[];if(je){const e=[];for(const s of t)`${s.id}${s.username}${s.cwd}${s.note}`.includes(je)&&e.push(s);S(e)}else S(t)}const t=await d.wm.get("all_roles");if(t.code===c.m.Success){xe(t.data),L.clear();for(const e of t.data)L.set(e.role_id,e)}},ye=e=>{K(e?.username??""),P(e?.password??""),E(e?.cwd??""),D(e?.access_dirs??[]),G(e?.not_access_dirs??[]),R(e?.only_read_dirs??[]),Z(e?.access_cmd??""),U(e?.not_access_cmd??""),Y(e?.language??""),te(e?.theme??""),ne(e?.auth_list??[]),le(e?.note??""),oe(e?.is_root??!1),de(e?.id??""),e?.bind_role_id?we(e.bind_role_id,e.auth_list??[]):(ue(""),pe({}))};(0,n.useEffect)(()=>{ge()},[]);const we=(e,t=[])=>{if(!e)return ue(""),void pe({});const s=L.get(e);if(s){if(s.cwd&&E(s.cwd),s.access_dirs&&s.access_dirs.length>0&&D(s.access_dirs),s.not_access_dirs&&s.not_access_dirs.length>0&&G(s.not_access_dirs),s.only_read_dirs&&s.only_read_dirs.length>0&&R(s.only_read_dirs),s.access_cmd&&Z(s.access_cmd),s.not_access_cmd&&U(s.not_access_cmd),s.language&&Y(s.language),s.theme&&te(s.theme),s.auth_list&&s.auth_list.length>0){const e=new Set(s.auth_list);for(const s of t)e.add(s);ne(Array.from(e))}ue(e),pe(s)}},Se=()=>{if(!z)return void(0,_.zN)("username not empty");if((0,x.CB)(z))return void(0,_.zN)("username not empty char");if(!B)return void(0,_.zN)("cwd not empty");const e=new l.E0;return e.language=J,e.theme=ee,e.access_dirs=M,e.username=z,e.password=O,e.not_access_dirs=T,e.only_read_dirs=q,e.cwd=B,e.note=ie,e.access_cmd=W,e.not_access_cmd=H,e.auth_list=se,e.bind_role_id=ce,e};return(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(0,f.jsx)(i.xh,{children:(0,f.jsx)(a.uF,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("用户")})}),titleCom:(0,f.jsxs)("div",{className:"div-row",style:{gap:"0.5rem"},children:[(0,f.jsx)(r.Sm,{placeholder:e("过滤"),value:je,handleInputChange:e=>{ve(e)},handlerEnter:()=>{ge()}}),(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{A(!0),N(!1),ye(void 0)}})]}),children:(0,f.jsx)(u.X,{headers:fe,rows:w.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.id}),(0,f.jsx)(a.xP,{children:t.username}),(0,f.jsx)(a.xP,{children:t.cwd}),(0,f.jsx)(a.xP,{children:t.note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{A(!1),N(!0),ye(e)})(t)}),!t.is_root&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async t=>{X({open:!0,title:e("确定删除吗"),handle:async()=>{const e=new l.E0;e.username=t,(await d.wm.post("delete_user",e)).code===c.m.Success&&((0,_.SK)("删除完成"),ge(),X({open:!1,handle:null}))}})})(t.username)})]})];return n}),width:"10rem"})})})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(k||I)&&(0,f.jsx)(i.xh,{children:(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e(""+(k?"添加":"编辑"))})," "]}),rightBottomCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:()=>{A(!1),N(!1),ye(void 0)}}),k&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{if(!O)return void(0,_.zN)("password not empty");if((0,x.CB)(O))return void(0,_.zN)("username not empty char");const e=Se(),t=await d.wm.post("create_user",e);ge(),t.code===c.m.Success&&((0,_.SK)("创建完成"),ge(),A(!1),N(!1),ye(void 0))}}),I&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=Se();if(!e)return;e.id=re;(await d.wm.post("save_user",e)).code===c.m.Success&&((0,_.SK)("保存完成"),ge())}})]}),children:[(0,f.jsx)("label",{children:e("用户名")}),(0,f.jsx)(r.Sm,{value:z,handleInputChange:e=>K(e)}),(0,f.jsx)("label",{children:e("密码")}),(0,f.jsx)(r.Sm,{type:"password",value:O,handleInputChange:e=>P(e)}),(0,f.jsxs)("label",{children:[!he?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{D([...M,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{disabled:""!==he.cwd&&void 0!==he.cwd,value:B,handleInputChange:e=>E(e)}),(M??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==he?.access_dirs?.length&&void 0!==he?.access_dirs?.length,value:t,handleInputChange:e=>{M[s]=e,D([...M])}})}),0===he?.access_dirs?.length||void 0===he?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{M.splice(s,1),D([...M])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!he?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{G([...T,""])},title:e("添加")}),e("禁止目录范围")]}),(T??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==he?.not_access_dirs?.length&&void 0!==he?.not_access_dirs?.length,value:t,handleInputChange:e=>{T[s]=e,G([...T])}})}),0===he?.not_access_dirs?.length||void 0===he?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{T.splice(s,1),G([...T])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!he?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{R([...q,""])},title:e("添加")}),e("只读目录范围")]}),(q??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==he?.only_read_dirs?.length&&void 0!==he?.only_read_dirs?.length,value:t,handleInputChange:e=>{q[s]=e,R([...q])}})}),0===he?.only_read_dirs?.length||void 0===he?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{q.splice(s,1),R([...q])},title:e("删除")})]},s)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==he.access_cmd&&void 0!==he.access_cmd,value:W,placeholder:"use blank split",handleInputChange:e=>Z(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==he.not_access_cmd&&void 0!==he.not_access_cmd,value:H,placeholder:"use blank split",handleInputChange:e=>U(e)}),!ae&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)("label",{children:e("角色")}),(0,f.jsx)(r.l6,{value:ce,onChange:e=>{we(e)},options:(()=>{const e=[];e.push({title:"NOT",value:""});for(let t of _e)e.push({title:t.role_name,value:t.role_id});return e})()})]}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{disabled:""!==he.language&&void 0!==he.language,value:J,onChange:e=>{Y(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"English",value:"en"},{title:"中文",value:"zh"}]}),(0,f.jsx)("label",{children:e("主题")}),(0,f.jsx)(r.l6,{disabled:""!==he.theme&&void 0!==he.theme,value:ee,onChange:e=>{te(e)},options:me}),(0,f.jsx)(Q,{is_disable:e=>{if(!0===ae)return!0;if(ce){const t=L.get(ce);if(t)return(t.auth_list??[]).includes(e)}return!1},is_selected:(e,t)=>!t&&!0===ae||void 0!==se?.find(t=>t===e),select_auth:e=>{se?se.includes(e)?((0,v.I)(se,t=>t===e),ne([...se])):ne([...se,e]):ne([e])}}),(0,f.jsx)("label",{children:e("备注")}),(0,f.jsx)(r.Sm,{value:ie,handleInputChange:e=>le(e)})]})})})]})}function ee(){const{t:e,i18n:t}=(0,h.Bd)(),{initUserInfo:s}=(0,n.useContext)(V.F),[m,x]=(0,n.useState)([]),[j,g]=(0,y.fp)(p.AG.prompt_card),[w,S]=(0,n.useState)(!1),[b,C]=(0,n.useState)(!1),[k,A]=(0,y.fp)(p.AG.confirm),[I,N]=(0,n.useState)(""),[$,X]=(0,n.useState)(""),[z,K]=(0,n.useState)([]),[O,P]=(0,n.useState)([]),[B,E]=(0,n.useState)([]),[M,D]=(0,n.useState)(""),[T,G]=(0,n.useState)(""),[q,R]=(0,n.useState)(""),[W,Z]=(0,n.useState)(""),[H,U]=(0,n.useState)([]),[J,L]=(0,n.useState)(""),[Y,ee]=(0,n.useState)(""),te=(0,F.o)(),se=[e("角色id"),e("角色名"),e("备注")],ne=async()=>{const e=await d.wm.get("all_roles");e.code===c.m.Success&&x(e.data)},ie=e=>{N(e?.role_name??""),X(e?.cwd??""),K(e?.access_dirs??[]),P(e?.not_access_dirs??[]),E(e?.only_read_dirs??[]),D(e?.access_cmd??""),G(e?.not_access_cmd??""),R(e?.language??""),Z(e?.theme??""),U(e?.auth_list??[]),L(e?.role_id??""),ee(e?.role_note??"")};(0,n.useEffect)(()=>{ne()},[]);const le=()=>{if(!I)return void(0,_.zN)("role_name not empty");const e=new l.E0;return e.language=q,e.theme=W,e.access_dirs=z,e.role_name=I,e.not_access_dirs=O,e.only_read_dirs=B,e.cwd=$,e.access_cmd=M,e.not_access_cmd=T,e.auth_list=H,e.role_note=Y,e};return(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(0,f.jsx)(i.xh,{children:(0,f.jsx)(a.uF,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("角色")})}),titleCom:(0,f.jsx)("div",{children:(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{S(!0),C(!1),ie(void 0)}})}),children:(0,f.jsx)(u.X,{headers:se,rows:m.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.role_id}),(0,f.jsx)(a.xP,{children:t.role_name}),(0,f.jsx)(a.xP,{children:t.role_note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{S(!1),C(!0),ie(e)})(t)}),!t.is_root&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async t=>{A({open:!0,title:e("确定删除吗"),handle:async()=>{const e=new l.E0;e.role_id=t,(await d.wm.post("delete_role",e)).code===c.m.Success&&((0,_.SK)("删除完成"),ne(),A({open:!1,handle:null}))}})})(t.role_id)})]})];return n}),width:"10rem"})})})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(w||b)&&(0,f.jsx)(i.xh,{children:(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e(""+(w?"添加":"编辑"))})," "]}),rightBottomCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:()=>{S(!1),C(!1),ie(void 0)}}),w&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{const e=le();if(!e)return;const t=await d.wm.post("create_role",e);ne(),t.code===c.m.Success&&((0,_.SK)("创建完成"),ne(),S(!1),C(!1),ie(void 0))}}),b&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=le();if(!e)return;e.role_id=J;(await d.wm.post("save_role",e)).code===c.m.Success&&((0,_.SK)("保存完成"),ne())}})]}),children:[(0,f.jsx)("label",{children:e("角色名")}),(0,f.jsx)(r.Sm,{value:I,handleInputChange:e=>N(e)}),(0,f.jsx)("label",{children:e("角色备注")}),(0,f.jsx)(r.Sm,{value:Y,handleInputChange:e=>ee(e)}),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{K([...z,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{value:$,handleInputChange:e=>X(e)}),(z??[]).map((e,t)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{z[t]=e,K([...z])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{z.splice(t,1),K([...z])},title:"删除"})]},t)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{P([...O,""])},title:"添加"}),e("禁止目录范围")]}),(O??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:t,handleInputChange:e=>{O[s]=e,P([...O])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{O.splice(s,1),P([...O])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{E([...B,""])},title:e("添加")}),e("只读目录范围")]}),(B??[]).map((e,t)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{B[t]=e,E([...B])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{B.splice(t,1),E([...B])},title:"删除"})]},t)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{value:M,placeholder:"use blank split",handleInputChange:e=>D(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{value:T,placeholder:"use blank split",handleInputChange:e=>G(e)}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{value:q,onChange:e=>{R(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"NOT",value:""},{title:"English",value:"en"},{title:"中文",value:"zh"}]}),(0,f.jsx)("label",{children:e("主题")}),(0,f.jsx)(r.l6,{value:W,onChange:e=>{Z(e)},options:te}),(0,f.jsx)(Q,{is_disable:()=>!1,is_selected:(e,t)=>void 0!==H?.find(t=>t===e),select_auth:e=>{H?(H.find(t=>t==e)?(0,v.I)(H,t=>t===e):H.push(e),U([...H])):U([e])}})]})})})]})}var te=s(93245);function se(){const{t:e,i18n:t}=(0,h.Bd)(),{initUserInfo:s,reloadUserInfo:m}=(0,n.useContext)(V.F),[x,j]=(0,n.useState)([]),[g,w]=(0,y.fp)(p.AG.prompt_card),[b,k]=(0,n.useState)([]),[A,N]=(0,n.useState)([]),[$,X]=(0,n.useState)([]),[z,K]=(0,y.fp)(p.AG.user_base_info),O=(0,S.K)(),P=(0,F.o)(),B=[e("编号"),e("路径"),e("是否默认"),e("备注")],E=[e("编号"),e("路径"),e("备注")],M=[e("编号"),e("命令"),e("父编号"),e("备注")],D=[e("文件后缀"),e("命令"),e("其他参数"),e("备注")],[T,G]=(0,n.useState)(""),[q,R]=(0,n.useState)(""),[W,Z]=(0,n.useState)(""),[H,U]=(0,n.useState)(!1),[J,Q]=(0,n.useState)(""),[L,Y]=(0,n.useState)(""),[ee,se]=(0,n.useState)(""),[ne,ie]=(0,n.useState)(!1),[le,ae]=(0,n.useState)(""),[oe,re]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{const e=await d.XO.get("filesSetting");e.code===c.m.Success&&(j(e.data.dirs),N(e.data.quick_cmd),X(e.data.file_quick_cmd));const t=await d.XO.get("protection_dir");t.code===c.m.Success&&k(t.data??[])})(),Q(z?.user_data?.language),Y(z?.user_data?.theme),se(z?.user_data?.upload_file_ignore);const e=z?.user_data?.editor_auto_save;ie(!!e?.enable),ae(null!=e?.interval?String(e.interval):""),re(e?.editors??[])},[]);const de=(0,F.Q)();return(0,f.jsx)(n.Fragment,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsx)(i.xh,{children:(0,f.jsxs)(a.Zp,{title:e("修改密码"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{if(!T||!q)return void(0,_.zN)("账号密码不能为空");if(q!==W)return void(0,_.zN)("两次密码不一样");const e=new l.tl;e.username=T,e.password=q,e.confirm_password=W,e.user_id=z.user_data.id;(await d.wm.post("updatePassword",e)).code===c.m.Success&&(0,_.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:e("新账号"),value:T,handleInputChange:e=>{G(e)}}),(0,f.jsx)(r.cA,{placeholder:e("新密码"),handleInputChange:e=>{R(e)}}),(0,f.jsx)(r.cA,{placeholder:e("确认密码"),handleInputChange:e=>{Z(e)}})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(a.Zp,{title:e("个性化设置"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{(await d.XO.post(C.s.setting_sys_option_status_save,{type:I.Mu.private_sys_env,value:{language:J,theme:L,upload_file_ignore:ee}})).code===c.m.Success&&((0,_.SK)("修改成功"),s())}}),children:[e("语言"),(0,f.jsx)(r.l6,{value:J,onChange:e=>{Q(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"English",value:"en"},{title:"中文",value:"zh"},{title:"Deutsch",value:"de"},{title:"ドイツ語",value:"ja"},{title:"독일어",value:"ko"},{title:"Немецкий язык",value:"ru"},{title:"Allemand",value:"fr"},{title:"Alemán",value:"es"}]}),e("主题"),(0,f.jsx)(r.l6,{value:L,onChange:e=>{Y(e)},options:P}),(0,f.jsx)(r.Sm,{value:ee,handleInputChange:e=>{se(e)},placeholderOut:e("拖拽文件上传忽略列表"),placeholder:"node_modules *.js",no_border:!0})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(a.Zp,{title:e("编辑器自动保存"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{const t=parseInt(String(le),10);if(isNaN(t)||t<1)return void(0,_.zN)(e("请输入不小于 1 的整数(秒)"));(await d.wm.post(C.s.user_save_private_attr,{is_editor_auto_save:!0,editor_auto_save:{enable:ne,interval:t,editors:oe}})).code===c.m.Success&&((0,_.SK)("修改成功"),s())}}),children:[(0,f.jsx)(r.BC,{label:e("开启"),children:(0,f.jsx)(r.l6,{value:ne,onChange:e=>{ie(e)},options:O,no_border:!0})}),(0,f.jsx)(r.BC,{label:e("自动保存间隔(秒)"),children:(0,f.jsx)(r.Sm,{type:"number",value:le,handleInputChange:e=>{ae(e)},placeholder:"30",no_border:!0})}),(0,f.jsx)("h3",{children:e("编辑器")}),te.d.map(t=>(0,f.jsxs)("div",{children:[(0,f.jsx)("input",{type:"checkbox",checked:oe.includes(t.id),onChange:e=>{const s=e.target.checked;re(s?[...oe,t.id]:oe.filter(e=>e!==t.id))}}),e(t.label)]},t.id))]})})]}),(0,f.jsxs)(i.VP,{children:[(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("文件夹路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{de("文件夹路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{j([...x,{note:"",default:!1,path:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{for(let e=0;e<x.length;e++)x[e].index=e;(await d.XO.post("filesSetting/save",{dirs:x})).code===c.m.Success&&((0,_.SK)("保存成功"),m(),s())}})]}),children:(0,f.jsx)(u.X,{headers:B,rows:x.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:t.default,onChange:e=>{((e,t,s)=>{const n=[];for(let e=0;e<x.length;e++)x[e].default=e===s&&t,n.push(x[e]);j(n)})(0,e,s)},options:O,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)("div",{children:0!==s&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{x.splice(e,1),j([...x])})(s)})})];return n}),width:"10rem",onRowDrag:(e,t)=>{0!==e&&0!==t&&j((0,v.TI)(x,e,t))}})}),(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("个人保护路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{de("保护目录")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{k([...b,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("protection_dir/save",b)).code===c.m.Success&&((0,_.SK)("保存成功"),m())}})]}),children:(0,f.jsx)(u.X,{headers:E,rows:b.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{b.splice(e,1),k([...b])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{k((0,v.TI)(b,e,t))}})})]}),(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("目录快捷命令")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{de("目录快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{N([...A,{cmd:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("filesSetting/save",{quick_cmd:A})).code===c.m.Success&&((0,_.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(u.X,{headers:M,rows:A.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.index,handleInputChange:e=>{t.index=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cmd,handleInputChange:e=>{t.cmd=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.father_index,handleInputChange:e=>{t.father_index=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{A.splice(e,1),N([...A])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{N((0,v.TI)(A,e,t))}})}),(0,f.jsx)(a.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("文件快捷命令")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{de("文件快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...$,{cmd:"",note:"",file_suffix:"",params:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.XO.post("filesSetting/save",{file_quick_cmd:$})).code===c.m.Success&&((0,_.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(u.X,{headers:D,rows:$.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.file_suffix,handleInputChange:e=>{t.file_suffix=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cmd,handleInputChange:e=>{t.cmd=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.params,handleInputChange:e=>{t.params=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{$.splice(e,1),X([...$])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{X((0,v.TI)($,e,t))}})})]})]})]})})}var ne=s(45907),ie=s(17903);const le=["password","private_key","secret_key"],ae="webdav",oe="@authorize",re={smb:[{keys:["server","username","password"],on_next:"load_shares"},{keys:["share"]}],baidu:[{keys:["app_id","app_key","secret_key"],on_next:"save_app"},{keys:[oe]}]};function de(){const{t:e}=(0,h.Bd)(),t=(0,ne.y)(),[,s]=(0,y.fp)(p.AG.prompt_card),[i,l]=(0,n.useState)([]),[c,m]=(0,n.useState)([]),[x,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[w,S]=(0,n.useState)(ae),[b,C]=(0,n.useState)(""),[k,A]=(0,n.useState)({}),[I,N]=(0,n.useState)(1),[V,$]=(0,n.useState)([]),[X,z]=(0,n.useState)("oob"),[F,K]=(0,n.useState)(""),[O,P]=(0,n.useState)(!0),B=async()=>{try{const[e,t]=await Promise.all([d.I2.post("credential/list",{}),d.I2.post("credential/meta",{})]);l(Array.isArray(e?.data)?e.data:[]),m(Array.isArray(t?.data)?t.data:[])}catch(e){}};(0,n.useEffect)(()=>{B()},[]);const E=c.find(e=>e.type===w)?.fields??[],M=re[w],D=M?.length??1,T=()=>{j(!1),g(""),S(ae),C(""),A({}),N(1),$([]),K(""),P(!0)},G=t=>{if(!b.trim())return e("请填写备注");for(const s of E){if(!1===t.includes(s.key))continue;const n=String(k[s.key]??"").trim()||v&&le.includes(s.key);if(s.required&&!n)return e(s.label)}},q=async()=>{try{const e=await d.I2.post("baidu/authorize_url",{id:v,mode:X});e?.data&&window.open(e.data,"_blank","noopener,noreferrer")}catch(e){}},R=async()=>{if(F.trim())try{const t=await d.I2.post("baidu/exchange",{id:v,code:F.trim(),mode:X});(0,_.SK)(`${e("授权成功")}:${t?.data?.baidu_name??""}`),K(""),await B()}catch(e){}else(0,_.zN)(e("请填写授权码"))},W=M?.[I-1]?.keys??E.map(e=>e.key),Z=W.includes(oe),H=I===D,U=D>1;return(0,f.jsxs)(a.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("凭证管理")}),(0,f.jsx)(o.rA,{icon:"info",title:e("信息"),onClick:()=>{s({open:!0,title:e("信息"),context_div:(0,f.jsxs)("div",{children:[(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:e("crd_tp")}),(0,f.jsx)("li",{children:e("pwdkept")}),(0,f.jsx)("li",{children:e("tstbfrs")})]}),(0,f.jsxs)("ul",{children:[(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"WebDAV"}),":",e("prtwbdv")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"SSH / SFTP"}),":",e("prtsftp")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"S3 兼容对象存储"}),":",e("prt_s3")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"SMB"}),":",e("prt_smb")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"百度网盘"}),":",e("prt_bd")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:e("本地目录")}),":",e("prt_local")]})]})]})})}})]}),rightBottomCom:(0,f.jsxs)("div",{children:[!x&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{T(),j(!0)}}),x&&(0,f.jsxs)(f.Fragment,{children:[U&&I>1&&(0,f.jsx)(o.rA,{icon:"arrow_back",title:e("上一步"),onClick:()=>N(I-1)}),U&&!H&&(0,f.jsx)(o.rA,{icon:"arrow_forward",title:e("下一步"),onClick:async()=>{const t=G(M?.[I-1]?.keys??[]);if(t)return void(0,_.zN)(`${e("请填写")}${t}`);const s=M?.[I-1]?.on_next;try{if("load_shares"===s&&!await(async()=>{const t=await d.I2.post("share/list",{driver:w,id:v||void 0,config:{server:k.server,username:k.username,password:k.password}}),s=t?.data??[];return s.length?($(s.map(e=>({label:e.name,value:e.name}))),!0):((0,_.zN)(e("没有找到共享")),!1)})())return;if("save_app"===s&&!await(async()=>{try{const e=await d.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:w,note:b,config:k,enabled:O});return!v&&e?.data?.id&&g(e.data.id),!0}catch(e){return!1}})())return;N(I+1)}catch(e){}}}),(!U||H)&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const t=G(E.map(e=>e.key));if(t)(0,_.zN)(`${e("请填写")}${t}`);else try{await d.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:w,note:b,config:k,enabled:O}),(0,_.SK)(e("保存成功")),T(),await B()}catch(e){}}}),(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:T})]})]}),children:[x&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.Sm,{placeholder:e("备注"),value:b,handleInputChange:C}),(0,f.jsx)(r.l6,{value:w,options:c.map(e=>({title:e.name,value:e.type})),onChange:e=>{S(e),A({}),$([]),N(1),K("")}}),Z?(()=>{const s=i.find(e=>e.id===v)?.accounts??[];return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.BC,{label:e("授权方式"),label_width:"6rem",children:(0,f.jsxs)("div",{className:"div-row",children:[(0,f.jsx)(r.U6,{name:"baidu_auth_mode",value:"one_click",context:e("一键授权"),selected:"one_click"===X,onchange:()=>z("one_click")}),(0,f.jsx)(r.U6,{name:"baidu_auth_mode",value:"oob",context:e("outh_ob"),selected:"oob"===X,onchange:()=>z("oob")})]})}),"oob"===X&&(0,f.jsx)(r.BC,{label:e("授权码"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("粘贴授权码 code"),value:F,handleInputChange:K})}),(0,f.jsxs)("div",{className:"div-row",children:[(0,f.jsx)(o.rA,{icon:"open_in_new",title:e("去授权"),onClick:q}),"oob"===X&&(0,f.jsx)(o.rA,{icon:"check",title:e("完成授权"),onClick:R})]}),s.length>0&&(0,f.jsx)(u.X,{headers:[e("账号名"),e("百度账号"),e("授权状态"),e("使用"),e("授权时间"),e("操作")],rows:s.map(s=>[(0,f.jsx)(a.xP,{context:s.note||s.account_name||s.id}),(0,f.jsx)(a.xP,{context:s.account_name||s.id}),(0,f.jsx)(a.xP,{context:s.authorized?e("已授权"):e("未授权")}),(0,f.jsx)(a.xP,{context:!1===s.enabled?e("停用"):e("启用")}),(0,f.jsx)("p",{children:s.obtained_at?(0,ie.eK)(s.obtained_at):"-"}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"network_check",title:e("授权检测"),onClick:()=>(async(t,s)=>{try{const n=await d.I2.post("baidu/verify",{id:t,account_id:s}),i=n?.data??{};i.valid?(0,_.SK)(e("账号可用")):(0,_.zN)(`${e("账号不可用")}:${i.error??""}`),await B()}catch(e){}})(v,s.id)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>((s,n)=>{t({title:e("确认删除"),sub_title:n.note||n.account_name||n.id,confirm_fun:async()=>{try{await d.I2.post("baidu/deauthorize",{id:s,account_id:n.id}),(0,_.SK)(e("已删除")),await B()}catch(e){}}})})(v,s)})]})])})]},oe)})():E.filter(e=>W.includes(e.key)).map(t=>{if("share"===t.key&&"smb"===w)return(0,f.jsx)(r.BC,{label:e(t.label),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:k[t.key]??"",options:V,onChange:e=>A({...k,[t.key]:e})})},t.key);const s="password"===t.type;return(0,f.jsx)(n.Fragment,{children:(0,f.jsx)(r.Sm,{type:s?"password":"text",placeholder:t.label,value:k[t.key]??"",handleInputChange:e=>A({...k,[t.key]:e})})},t.key)})]}),!x&&(0,f.jsx)(u.X,{headers:[e("备注"),e("类型"),e("操作")],rows:i.map(s=>{return[(0,f.jsx)(a.xP,{context:s.note}),(0,f.jsx)(a.xP,{context:(n=s.type,c.find(e=>e.type===n)?.name??n)}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{j(!0),g(e.id),S(e.type),C(e.note??""),A({...e.config??{}}),K(""),P(!1!==e.enabled),N(re[e.type]?.length??1),"smb"===e.type&&d.I2.post("share/list",{driver:"smb",id:e.id,config:e.config??{}}).then(e=>{$((e?.data??[]).map(e=>({label:e.name,value:e.name})))}).catch(()=>{})})(s)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async s=>{t({title:e("确认删除"),sub_title:s.note,confirm_fun:async()=>{try{await d.I2.post("credential/delete",{id:s.id}),(0,_.SK)(e("已删除")),await B()}catch(e){}}})})(s)})]})];var n})})]})}function ce(){const{t:e}=(0,h.Bd)(),t=(0,ne.y)(),[s,i]=(0,n.useState)([]),[l,c]=(0,n.useState)([]),[p,m]=(0,n.useState)([]),[x,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[y,w]=(0,n.useState)("webdav"),[S,b]=(0,n.useState)(""),[C,k]=(0,n.useState)(""),[A,I]=(0,n.useState)(""),[N,V]=(0,n.useState)(""),[$,X]=(0,n.useState)(""),z=async()=>{try{const[e,t,s]=await Promise.all([d.I2.post("list",{}),d.I2.post("credential/list",{}),d.I2.post("driver/list",{})]);i(Array.isArray(e?.data)?e.data:[]),c(Array.isArray(t?.data)?t.data:[]),m(Array.isArray(s?.data)?s.data:[])}catch(e){}};(0,n.useEffect)(()=>{z()},[]);const F=(0,ie.p_)(C,l),K=F.length>0,O=()=>{j(!1),g(""),w("webdav"),b(""),k(""),I(""),V(""),X("")};return(0,f.jsxs)(a.Zp,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("挂载列表")})}),rightBottomCom:(0,f.jsxs)("div",{children:[!x&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{O(),j(!0)}}),x&&(0,f.jsx)(o.rA,{icon:"network_check",title:e("测试连接"),onClick:async()=>{if(C)try{const t=await d.I2.post("test",{id:v||void 0,driver:y,credential_id:C,account_id:A,root_dir:N}),s=t?.data;s?.ok?(0,_.SK)(`${e("连接成功")}(${s.count??0})`):(0,_.zN)(`${e("连接失败")}:${s?.error??""}`)}catch(e){}else(0,_.zN)(e("请选择凭据"))}}),x&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{if(C)if(!K||A)if(S.trim())try{await d.I2.post(v?"update":"add",{id:v||void 0,driver:y,mount_path:S,credential_id:C,account_id:K?A:void 0,root_dir:N,note:$,color:ie.OT,readonly:!1,enabled:!0}),(0,_.SK)(e("保存成功")),O(),await z()}catch(e){}else(0,_.zN)(e("munt_rq"));else(0,_.zN)(e("请选择账号"));else(0,_.zN)(e("请选择凭据"))}}),x&&(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:O})]}),children:[x&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.BC,{label:e("挂载类型"),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:y,options:p.map(e=>({title:e.name,value:e.type})),onChange:e=>{w(e),k(""),I("")}})}),(0,f.jsx)(r.BC,{label:e("凭据"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:C,options:(P=y,(0,ie.XT)(P,l)),onChange:e=>{k(e),I("")}})}),K&&(0,f.jsx)(r.BC,{label:e("账号"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:A,options:F,onChange:I})}),(0,f.jsx)(r.BC,{label:e("本地目录"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.Sm,{placeholder:e("被挂载的本地绝对路径"),value:S,handleInputChange:b})}),(0,f.jsx)(r.BC,{label:e("strtdrt"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("远端目录"),value:N,handleInputChange:V})}),(0,f.jsx)(r.BC,{label:e("备注"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("列表显示的名称"),value:$,handleInputChange:X})})]}),!x&&(0,f.jsx)(u.X,{headers:[e("备注"),e("挂载类型"),e("凭据"),e("账号"),e("操作")],rows:s.map(s=>{const n=l.find(e=>e.id===s.credential_id),i=(n?.accounts??[]).find(e=>e.id===s.account_id);return[(0,f.jsx)("p",{children:s.note}),(0,f.jsx)("p",{children:(a=s.driver,p.find(e=>e.type===a)?.name??a)}),(0,f.jsx)("p",{children:n?n.note:e("凭据已丢失")}),(0,f.jsx)("p",{children:s.account_id?i?i.note||i.account_name||i.nickname||i.id:e("账号已丢失"):"-"}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{j(!0),g(e.id),w(e.driver),b(e.mount_path??""),k(e.credential_id??""),I(e.account_id??""),V(e.root_dir??""),X(e.note??"")})(s)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async s=>{t({title:e("确认删除"),sub_title:s.mount_path,confirm_fun:async()=>{try{await d.I2.post("delete",{id:s.id}),(0,_.SK)(e("已删除")),await z()}catch(e){}}})})(s)})]})];var a})})]});var P}function ue(){const{t:e}=(0,h.Bd)(),{check_user_auth:t}=(0,w.MH)(),s=t(l.oV.file_mount),[r,c]=(0,y.fp)(p.AG.mount_enabled);(0,n.useEffect)(()=>{s&&(async()=>{try{const e=await d.I2.post("enabled/get",{});c(!0===e?.data)}catch(e){c(!1)}})()},[s]);return s?(0,f.jsxs)(n.Fragment,{children:[(0,f.jsxs)(k.aZ,{position:"right",children:[(0,f.jsx)("span",{className:"header-label",children:e("总开关")}),(0,f.jsx)(o.rA,{icon:!0===r?"cloud_done":"cloud_off",title:e(!0===r?"muntont":"muntoff"),selected:!0===r,onClick:async()=>{const t=!r;try{const s=await d.I2.post("enabled/set",{enabled:t}),n=!0===s?.data;c(n),(0,_.SK)(e(n?"挂载已启用":"挂载已停用"))}catch(e){}}})]}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"60rem",children:(0,f.jsx)(de,{})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"60rem",children:(0,f.jsx)(ce,{})})]})})]}):(0,f.jsx)(i.fI,{children:(0,f.jsx)(i.VP,{children:(0,f.jsx)(a.Zp,{self_title:(0,f.jsx)("h2",{children:e("网盘挂载")}),children:(0,f.jsx)("p",{children:e("nmuntpr")})})})})}var he=s(87361);function pe(){const{t:e}=(0,h.Bd)(),{check_user_auth:t}=(0,w.MH)(),s=[{index:1,name:`${e("个人环境")}`,rto:"private_env_setting",component:(0,f.jsx)(se,{})}];return t(l.oV.sys_setting_page)&&s.unshift({index:1,name:e("系统"),rto:"password",component:(0,f.jsx)(z,{})}),t(l.oV.sys_env_page)&&s.push({index:1,name:`${e("系统环境")}`,rto:"env_setting/",component:(0,f.jsx)(J,{})}),t(l.oV.auth_router_page)&&s.push({index:1,name:e("自定义路由"),rto:"customer_router/",component:(0,f.jsx)(A,{})}),t(l.oV.user_manage)&&s.push({index:1,name:e("用户管理"),rto:"user_manager/",component:(0,f.jsx)(Y,{})}),t(l.oV.role_manage)&&s.push({index:1,name:e("角色管理"),rto:"role_manager/",component:(0,f.jsx)(ee,{})}),t(l.oV.file_mount)&&s.push({index:1,name:e("网盘挂载"),rto:"mount_setting/",component:(0,f.jsx)(ue,{})}),(0,f.jsx)(i.W1,{optionList:s,father_route:he.o.setting})}},92350(e,t,s){s.d(t,{Q:()=>u,o:()=>p});var n=s(34843),i=s(82893),l=s(74777),a=s(96540),o=s(22022),r=s(23430),d=s(14284),c=s(74848);function u(){const[e,t]=(0,n.fp)(i.AG.prompt_card),{t:s,i18n:a}=(0,o.Bd)();return e=>{let n;e===l.jk.ffmpeg?n=(0,c.jsx)("div",{children:"视频转换,rtsp播放器等媒体功能都需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置"}):e===l.jk.smartmontools?n=(0,c.jsx)("div",{children:"磁盘检查需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置。"}):"保护目录"===e?n=(0,c.jsxs)("div",{children:["在删除的时候保护目录会拒绝删除。",(0,c.jsxs)("ul",{children:[(0,c.jsx)("li",{children:"可以使用 /* 来表达该目录下所有文件都禁止删除"}),(0,c.jsx)("li",{children:"可以使用 /** 来表达该目录下所有子目录文件都禁止删除"})]})]}):"文件夹路径"===e?n=(0,c.jsx)("div",{children:"用于在文件夹下切换根目录"}):"环境路径"===e?n=(0,c.jsx)("div",{children:"当在不同用户环境下运行的时候由于没有执行终端去加载PATH,这里可以添加额外的PATH路径,点击这里的保存还会更新系统上的path路径"}):"pty"===e?n=(0,c.jsx)("div",{children:"一些需要Pty环境的命令"}):"文件上传"===e?n=(0,c.jsx)("div",{children:(0,c.jsxs)("ul",{children:[(0,c.jsx)("li",{children:"对于不同的目录(包括所有子目录),可能是机械或者固态硬盘,机械硬盘在处理多个小文件的时候会做随机i/o,由于一般只有一个盘头所以会影响整体效率,特别是写操作,这里提供了上传时候的最大数量限制,对于下载数量目前不做限制."}),(0,c.jsx)("li",{children:"大文件支持断点和分块并发传输,建议并发数量设置为2,分块大小设置为10MB,大文件判断为500MB,设置过大的话会上传的时候会占据较大内存"})]})}):"目录快捷命令"===e?n=(0,c.jsx)("div",{children:"右键文件夹空白处用于,打开终端快捷执行命令"}):"文件快捷命令"===e?n=(0,c.jsx)("div",{children:"用于右键特定后缀的文件,执行一些快捷命令,文件后缀可以是多个,用空格分割"}):"Workflow"===e?n=(0,c.jsx)("div",{children:(0,c.jsxs)("ul",{children:[(0,c.jsx)("li",{children:"在特定的时间启动系统中的workflow任务"}),(0,c.jsx)("li",{children:"cron表达式是定时器 格式为: 秒 分 时 日 月 星期"}),(0,c.jsxs)("li",{children:[(0,c.jsx)("li",{children:'1. "*"(通配符,所有值)'}),(0,c.jsx)("li",{children:'2. "," 是枚举: 0 0 1,15 * * *'}),(0,c.jsx)("li",{children:'3. "-" 是范围: 0 0 1-5 * * *'}),(0,c.jsx)("li",{children:'4. "/" 是步长,标识每隔n执行 */3 * * * * * 每隔三秒,必须配合 * 使用 ,/ 只能写一次 ,有了/就成了定时器,而不是指定时间执行'})]})]})}):"插件配置"===e?n=(0,c.jsx)("div",{children:s("路径可以是一个 js 文件也可以是一个node 项目目录")}):"机器人配置"===e&&(n=(0,c.jsxs)("div",{children:[(0,c.jsx)("dv",{children:"机器人功能用于开通各种第三方支持的机器人,让第三方机器人接入本地的 AI 模型。"}),(0,c.jsxs)("ul",{children:[(0,c.jsx)("li",{children:" 1. qq 机器人需要先在手机 app 中添加,然后在https://q.qq.com/qqbot/ 登录机器人配置页面,在开发管理中复制机器人的 appId,appSecret 到这里就完成了配置了。目前 qq 机器人不稳定,且创建后无法删除(2026.07.05)"}),(0,c.jsx)("li",{children:" 2. https://opensource.dingtalk.com/developerpedia/docs/explore/tutorials/stream/bot/nodejs/create-bot 这个是钉钉机器人开通教程,注意复制钉钉的 clientId 的是时候不要复制成appId 了。"}),(0,c.jsx)("li",{children:" 3. 企业微信机器人的开通甚至不需要 pc 操作,在通讯录中点击智能机器人,选择 api 模式,就创建完成了,手机上直接复制 id 和密钥。"}),(0,c.jsx)("li",{children:" 4. 飞书https://open.feishu.cn/document/develop-an-echo-bot/introduction?from=banner 登录这个开发者后台,按照这个地址教程创建机器人,使用的时候这个机器人是作为一个应用,可以在工作台内搜索你的这个机器人的名字。"})]})]})),t({open:!0,title:"信息",context_div:(0,c.jsx)("div",{children:n})})}}let h=r.Ky;function p(){const[e,t]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{try{const e=await d.XO.get("themes");if(0===e.code){const s=e.data||[];h=[...r.Ky,...s],t(h)}else console.warn("获取主题列表失败,使用默认列表"),t(h)}catch(e){t(h)}})()},[]),e}},6960(e,t,s){s.d(t,{s:()=>a});var n=s(72635);const i=1440,l=525600;function a(e){e=e>1e12?e:1e3*e;const t=Date.now(),s=Math.abs(t-e)/6e4;return s<1?n.Ay.t("小于一分钟"):s<60?`${s.toFixed(0)} ${n.Ay.t("分钟前")}`:s<i?`${(s/60).toFixed(0)} ${n.Ay.t("小时前")}`:s<43200?`${(s/i).toFixed(0)} ${n.Ay.t("天前")}`:s<l?`${(s/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(s/l).toFixed(0)} ${n.Ay.t("年前")}`}},93245(e,t,s){s.d(t,{a:()=>r});var n=s(96540),i=s(34843),l=s(82893),a=s(23430);const o=[{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 r(e,t,s,a=!1){const[o]=(0,i.fp)(l.AG.user_base_info),r=o?.user_data?.editor_auto_save,d=(0,n.useRef)(r);d.current=r;const c=(0,n.useRef)(t);c.current=t;const u=(0,n.useRef)(s);u.current=s,(0,n.useEffect)(()=>{if(a)return;const t=d.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const s=setInterval(()=>{c.current()&&u.current(!0)},1e3*t.interval);return()=>clearInterval(s)},[r,e,a])}s.d(t,["d",0,o])},24659(e,t,s){var n=s(22022);s.d(t,["K",0,()=>{const{t:e}=(0,n.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])}}]);