filecat 7.12.1 → 7.13.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.
Files changed (41) hide show
  1. package/build/dist/2300.3c83fc27783efb65df57.js +2 -0
  2. package/build/dist/2674.2713dbaf7b4dbb6baa4c.js +1 -0
  3. package/build/dist/2728.d0205a036e2caff34c1c.js +1 -0
  4. package/build/dist/3299.b85fad5623f990484bd9.js +1 -0
  5. package/build/dist/3528.55d2faabf2edbde62652.js +1 -0
  6. package/build/dist/4004.ca7e777145c700c5b186.js +1 -0
  7. package/build/dist/{4220.b65b40382726a69ba0bc.js → 4220.6e56dcffa8e57c91e363.js} +1 -1
  8. package/build/dist/4493.f527f1994d14470017f4.js +1 -0
  9. package/build/dist/5602.b92e2770ff00ee6da48a.js +2 -0
  10. package/build/dist/5602.b92e2770ff00ee6da48a.js.LICENSE.txt +28 -0
  11. package/build/dist/{5877.e2316c84a95490f77439.js → 5877.0d338155dc591229a758.js} +1 -1
  12. package/build/dist/6404.bcf224539211a7979990.js +1 -0
  13. package/build/dist/{7310.bf944d03f24fcf109680.js → 7310.258969acc0782007bdf5.js} +1 -1
  14. package/build/dist/735.38718e61fe313f131a3e.js +1 -0
  15. package/build/dist/{8090.8977224618a14ae42159.js → 8090.8b172ffd0f62ceebf881.js} +2 -2
  16. package/build/dist/8277.c76a3bbffade9d2d859b.js +1 -0
  17. package/build/dist/8302.c72a3767319d87419737.js +1 -0
  18. package/build/dist/8725.970abee75f92962aeab9.js +1 -0
  19. package/build/dist/9334.d3102e0ed30ae564f506.js +1 -0
  20. package/build/dist/{9546.2cecad04cf676a6616cd.js → 9546.ba8ea7791f14ee133338.js} +1 -1
  21. package/build/dist/index.html +1 -1
  22. package/build/dist/main.e03c0b1342da0ac83715.js +2 -0
  23. package/build/main.js +1 -1
  24. package/build/ripgrep/rg.exe +0 -0
  25. package/package.json +1 -1
  26. package/shell/config/webpack.web.config.js +5 -0
  27. package/build/dist/1417.d390b18dd58ff5c28160.js +0 -1
  28. package/build/dist/2300.c99b1dd4e752cdfd5e32.js +0 -2
  29. package/build/dist/2479.294792ef5d360ad64abc.js +0 -1
  30. package/build/dist/2674.46c009a7ec426b7d8828.js +0 -1
  31. package/build/dist/3299.5c01eebc0f62cdc7bb39.js +0 -1
  32. package/build/dist/3528.0f8f34028d92fa87c518.js +0 -1
  33. package/build/dist/4004.916c0413a6db61a54e11.js +0 -1
  34. package/build/dist/4193.58d3a34cac783ff289c6.js +0 -1
  35. package/build/dist/7943.acf25a5e98dd13290985.js +0 -1
  36. package/build/dist/8302.894efa465f6037f9f5a8.js +0 -1
  37. package/build/dist/9334.f04716a7e41f783abc47.js +0 -1
  38. package/build/dist/main.65dcea654963fc771a86.js +0 -2
  39. /package/build/dist/{2300.c99b1dd4e752cdfd5e32.js.LICENSE.txt → 2300.3c83fc27783efb65df57.js.LICENSE.txt} +0 -0
  40. /package/build/dist/{8090.8977224618a14ae42159.js.LICENSE.txt → 8090.8b172ffd0f62ceebf881.js.LICENSE.txt} +0 -0
  41. /package/build/dist/{main.65dcea654963fc771a86.js.LICENSE.txt → main.e03c0b1342da0ac83715.js.LICENSE.txt} +0 -0
@@ -0,0 +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(4004)]).then(n.bind(n,95733))),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([[2728],{52851(t,r,n){var e=n(52528),o=n(66984),c=Object.prototype.hasOwnProperty;const a=function(t,r,n){var a=t[r];c.call(t,r)&&(0,o.A)(a,n)&&(void 0!==n||r in t)||(0,e.A)(t,r,n)};n.d(r,["A",0,a])},52528(t,r,n){var e=n(84171);const o=function(t,r,n){"__proto__"==r&&e.A?(0,e.A)(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n};n.d(r,["A",0,o])},90565(t,r,n){var e=n(43988);const o=function(t){var r=new t.constructor(t.byteLength);return new e.A(r).set(new e.A(t)),r};n.d(r,["A",0,o])},80154(t,r,n){var e=n(41917),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,c=o&&"object"==typeof module&&module&&!module.nodeType&&module,a=c&&c.exports===o?e.A.Buffer:void 0,u=a?a.allocUnsafe:void 0;const i=function(t,r){if(r)return t.slice();var n=t.length,e=u?u(n):new t.constructor(n);return t.copy(e),e};n.d(r,["A",0,i])},1801(t,r,n){var e=n(90565);const o=function(t,r){var n=r?(0,e.A)(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)};n.d(r,["A",0,o])},39759(t,r,n){const e=function(t,r){var n=-1,e=t.length;for(r||(r=Array(e));++n<e;)r[n]=t[n];return r};n.d(r,["A",0,e])},22031(t,r,n){var e=n(52851),o=n(52528);const c=function(t,r,n,c){var a=!n;n||(n={});for(var u=-1,i=r.length;++u<i;){var A=r[u],f=c?c(n[A],t[A],A,n,t):void 0;void 0===f&&(f=t[A]),a?(0,o.A)(n,A,f):(0,e.A)(n,A,f)}return n};n.d(r,["A",0,c])},15647(t,r,n){const e=(0,n(40367).A)(Object.getPrototypeOf,Object);n.d(r,["A",0,e])},50407(t,r,n){n.d(r,{A:()=>i});var e=n(23149),o=Object.create;const c=function(){function t(){}return function(r){if(!(0,e.A)(r))return{};if(o)return o(r);t.prototype=r;var n=new t;return t.prototype=void 0,n}}();var a=n(15647),u=n(97271);const i=function(t){return"function"!=typeof t.constructor||(0,u.A)(t)?{}:c((0,a.A)(t))}},6832(t,r,n){var e=n(66984),o=n(38446),c=n(25353),a=n(23149);const u=function(t,r,n){if(!(0,a.A)(n))return!1;var u=typeof r;return!!("number"==u?(0,o.A)(n)&&(0,c.A)(r,n.length):"string"==u&&r in n)&&(0,e.A)(n[r],t)};n.d(r,["A",0,u])},35758(t,r,n){n.d(r,{A:()=>tt});var e=n(22080),o=n(72641),c=n(52851),a=n(22031),u=n(27422);const i=function(t,r){return t&&(0,a.A)(r,(0,u.A)(r),t)};var A=n(79999);const f=function(t,r){return t&&(0,a.A)(r,(0,A.A)(r),t)};var s=n(80154),v=n(39759),b=n(14792);const j=function(t,r){return(0,a.A)(t,(0,b.A)(t),r)};var l=n(76912),p=n(15647),y=n(13153);const d=Object.getOwnPropertySymbols?function(t){for(var r=[];t;)(0,l.A)(r,(0,b.A)(t)),t=(0,p.A)(t);return r}:y.A;const w=function(t,r){return(0,a.A)(t,d(t),r)};var g=n(19042),O=n(33831);const h=function(t){return(0,O.A)(t,A.A,d)};var m=n(9137),x=Object.prototype.hasOwnProperty;const S=function(t){var r=t.length,n=new t.constructor(r);return r&&"string"==typeof t[0]&&x.call(t,"index")&&(n.index=t.index,n.input=t.input),n};var U=n(90565);const I=function(t,r){var n=r?(0,U.A)(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)};var _=/\w*$/;const F=function(t){var r=new t.constructor(t.source,_.exec(t));return r.lastIndex=t.lastIndex,r};var P=n(241),k=P.A?P.A.prototype:void 0,B=k?k.valueOf:void 0;const E=function(t){return B?Object(B.call(t)):{}};var M=n(1801);const C=function(t,r,n){var e=t.constructor;switch(r){case"[object ArrayBuffer]":return(0,U.A)(t);case"[object Boolean]":case"[object Date]":return new e(+t);case"[object DataView]":return I(t,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return(0,M.A)(t,n);case"[object Map]":case"[object Set]":return new e;case"[object Number]":case"[object String]":return new e(t);case"[object RegExp]":return F(t);case"[object Symbol]":return E(t)}};var D=n(50407),L=n(92049),N=n(41200),R=n(53098);const T=function(t){return(0,R.A)(t)&&"[object Map]"==(0,m.A)(t)};var V=n(52789),G=n(64841),W=G.A&&G.A.isMap;const $=W?(0,V.A)(W):T;var q=n(23149);const z=function(t){return(0,R.A)(t)&&"[object Set]"==(0,m.A)(t)};var H=G.A&&G.A.isSet;const J=H?(0,V.A)(H):z;var K="[object Arguments]",Q="[object Function]",X="[object Object]",Y={};Y[K]=Y["[object Array]"]=Y["[object ArrayBuffer]"]=Y["[object DataView]"]=Y["[object Boolean]"]=Y["[object Date]"]=Y["[object Float32Array]"]=Y["[object Float64Array]"]=Y["[object Int8Array]"]=Y["[object Int16Array]"]=Y["[object Int32Array]"]=Y["[object Map]"]=Y["[object Number]"]=Y[X]=Y["[object RegExp]"]=Y["[object Set]"]=Y["[object String]"]=Y["[object Symbol]"]=Y["[object Uint8Array]"]=Y["[object Uint8ClampedArray]"]=Y["[object Uint16Array]"]=Y["[object Uint32Array]"]=!0,Y["[object Error]"]=Y[Q]=Y["[object WeakMap]"]=!1;const Z=function t(r,n,a,b,l,p){var y,d=1&n,O=2&n,x=4&n;if(a&&(y=l?a(r,b,l,p):a(r)),void 0!==y)return y;if(!(0,q.A)(r))return r;var U=(0,L.A)(r);if(U){if(y=S(r),!d)return(0,v.A)(r,y)}else{var I=(0,m.A)(r),_=I==Q||"[object GeneratorFunction]"==I;if((0,N.A)(r))return(0,s.A)(r,d);if(I==X||I==K||_&&!l){if(y=O||_?{}:(0,D.A)(r),!d)return O?w(r,f(y,r)):j(r,i(y,r))}else{if(!Y[I])return l?r:{};y=C(r,I,d)}}p||(p=new e.A);var F=p.get(r);if(F)return F;p.set(r,y),J(r)?r.forEach(function(e){y.add(t(e,n,a,e,r,p))}):$(r)&&r.forEach(function(e,o){y.set(o,t(e,n,a,o,r,p))});var P=x?O?h:g.A:O?A.A:u.A,k=U?void 0:P(r);return(0,o.A)(k||r,function(e,o){k&&(e=r[o=e]),(0,c.A)(y,o,t(e,n,a,o,r,p))}),y};const tt=function(t){return Z(t,5)}},79999(t,r,n){n.d(r,{A:()=>f});var e=n(2505),o=n(23149),c=n(97271);const a=function(t){var r=[];if(null!=t)for(var n in Object(t))r.push(n);return r};var u=Object.prototype.hasOwnProperty;const i=function(t){if(!(0,o.A)(t))return a(t);var r=(0,c.A)(t),n=[];for(var e in t)("constructor"!=e||!r&&u.call(t,e))&&n.push(e);return n};var A=n(38446);const f=function(t){return(0,A.A)(t)?(0,e.A)(t,!0):i(t)}},10419(t,r,n){n.d(r,{A:()=>D});var e=n(22080),o=n(52528),c=n(66984);const a=function(t,r,n){(void 0!==n&&!(0,c.A)(t[r],n)||void 0===n&&!(r in t))&&(0,o.A)(t,r,n)};var u=n(97132),i=n(80154),A=n(1801),f=n(39759),s=n(50407),v=n(25175),b=n(92049),j=n(53533),l=n(41200),p=n(89610),y=n(23149),d=n(2383),w=n(15647),g=n(53098),O=Function.prototype,h=Object.prototype,m=O.toString,x=h.hasOwnProperty,S=m.call(Object);const U=function(t){if(!(0,g.A)(t)||"[object Object]"!=(0,d.A)(t))return!1;var r=(0,w.A)(t);if(null===r)return!0;var n=x.call(r,"constructor")&&r.constructor;return"function"==typeof n&&n instanceof n&&m.call(n)==S};var I=n(54749);const _=function(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]};var F=n(22031),P=n(79999);const k=function(t){return(0,F.A)(t,(0,P.A)(t))};const B=function(t,r,n,e,o,c,u){var d=_(t,n),w=_(r,n),g=u.get(w);if(g)a(t,n,g);else{var O=c?c(d,w,n+"",t,r,u):void 0,h=void 0===O;if(h){var m=(0,b.A)(w),x=!m&&(0,l.A)(w),S=!m&&!x&&(0,I.A)(w);O=w,m||x||S?(0,b.A)(d)?O=d:(0,j.A)(d)?O=(0,f.A)(d):x?(h=!1,O=(0,i.A)(w,!0)):S?(h=!1,O=(0,A.A)(w,!0)):O=[]:U(w)||(0,v.A)(w)?(O=d,(0,v.A)(d)?O=k(d):(0,y.A)(d)&&!(0,p.A)(d)||(O=(0,s.A)(w))):h=!1}h&&(u.set(w,O),o(O,w,e,c,u),u.delete(w)),a(t,n,O)}};const E=function t(r,n,o,c,i){r!==n&&(0,u.A)(n,function(u,A){if(i||(i=new e.A),(0,y.A)(u))B(r,n,A,o,t,c,i);else{var f=c?c(_(r,A),u,A+"",r,n,i):void 0;void 0===f&&(f=u),a(r,A,f)}},P.A)};var M=n(24326),C=n(6832);const D=function(t){return(0,M.A)(function(r,n){var e=-1,o=n.length,c=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(c=t.length>3&&"function"==typeof c?(o--,c):void 0,a&&(0,C.A)(n[0],n[1],a)&&(c=o<3?void 0:c,o=1),r=Object(r);++e<o;){var u=n[e];u&&t(r,u,e,c)}return r})}(function(t,r,n){E(t,r,n)})}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3299],{77481(e,t,s){s.d(t,{S:()=>o,X:()=>l});var n=s(96540),i=s(61443),a=s(74848);function l(e){const[t,s]=n.useState([]),l=(0,n.useRef)(-1),[o,r]=(0,n.useState)(-1),[c,d]=(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 h=()=>{l.current=-1,r(-1),d(-1)};return(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let l=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(l=`${t} (${n.label})`)}return(0,a.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,a.jsx)(i.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:l}):t},s)})})}),(0,a.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,a.jsx)("tr",{className:n?(o===s?"row-dragging":"")+(c===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(l.current=s,r(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||l.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=l.current,s=c;h(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:h,children:t.map((s,n)=>{const i=n===t.length-1?"small":"";return(0,a.jsx)("td",{className:i,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function o(e){return(0,a.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,a.jsx)("div",{children:e},t))})}},53299(e,t,s){s.r(t),s.d(t,{default:()=>J});var n=s(96540),i=s(75725),a=s(23430),l=s(70447),o=s(85997),r=s(61443),c=s(14284),d=s(53459),h=s(77481),u=s(22022),p=s(82893),_=s(40505),x=s(62042),m=s(21499),j=s(21469),v=s(64694),f=s(74848);function g(e){const{t}=(0,u.Bd)(),[s,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(e.getItems){const t=await e.getItems();a(t)}})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.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("");a([t,...s])}}),(0,f.jsx)(o.rA,{icon:"save",title:t("保存"),onClick:async()=>{e.save&&await e.save(s)}})]}),children:(0,f.jsx)(h.X,{headers:e.headers,rows:s.map((n,i)=>{const l=[];for(let t=0;t<e.headers.length;t++)l.push((0,f.jsx)(r.Sm,{value:n[t],handleInputChange:e=>{n[t]=e,a([...s])},no_border:!0}));return l.push((0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"delete",title:t("删除"),onClick:()=>(e=>{s.splice(e,1),a([...s])})(i)}),n[0]&&(0,f.jsx)(o.rA,{icon:"content_copy",title:t("复制地址"),onClick:()=>{const e=(0,m.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);(0,_.lW)(e),(0,x.SK)(e)}}),n[0]&&e.need_copy&&(0,f.jsx)(o.rA,{icon:"open_in_new",title:t("打开新页面"),onClick:()=>{const e=(0,m.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);window.open(e)}})]})),l}),width:"10rem",onRowDrag:(e,t)=>{a((0,v.TI)(s,e,t))}})})})}var w=s(34843),y=s(78247),S=s(24659);function C(){const{t:e}=(0,u.Bd)(),[t,s]=(0,w.fp)(p.AG.prompt_card),a=(0,S.K)(),g=[e("路由"),e("auth"),e("备注")],[C,b]=(0,w.fp)(p.AG.editorSetting),[k,A]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("api/customer_router");e.code===d.m.Success&&A(e.data)})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.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 c.XO.post("api/customer_router/save",k)).code===d.m.Success&&(0,x.SK)("保存成功")}})]}),children:(0,f.jsx)(h.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:a,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,x.zN)("路由不能为空");const t=await c.XO.get(`jscode/${encodeURIComponent(e.router)}`);b({model:"ace/mode/javascript",open:!0,fileName:e.router,save:async t=>{const s={context:t,router:e.router};(await c.XO.post("jscode/save",s)).code===d.m.Success&&(y.xK.set_value_temp(""),b({open:!1,model:"",fileName:"",save:null}),(0,x.SK)("成功"))}}),y.xK.set_value_temp(t.data)})(t)}),t.router&&(0,f.jsx)(o.rA,{icon:"content_copy",title:e("复制地址"),onClick:()=>{(0,_.lW)((0,m.bi)(window.location.origin+j.m.base_url,t.router)),(0,x.SK)(e("已复制"))}})]})];return n}),width:"10rem",onRowDrag:(e,t)=>{A((0,v.TI)(k,e,t))}})})})}var b=s(23496),k=s(4412);function A(){const{t:e}=(0,u.Bd)(),[t,s]=(0,w.fp)(p.AG.prompt_card),[a,l]=(0,w.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 c.XO.get(b.s.setting_customer_router);if(e.code===d.m.Success){if(a?.page_self_router_api_data){for(const t of e.data)t[1]===a?.page_self_router_api_data[1]&&(0,x.N9)("已经存在的页面资源路由配置目录设置");const t={};Object.assign(t,a?.page_self_router_api_data),e.data=[t,...e.data],l({})}return e.data}return[]},save:async e=>{(await c.XO.post(b.s.setting_customer_router_save,e)).code===d.m.Success&&(0,x.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 c.XO.get(b.s.setting_customer_workflow_router);return e.code===d.m.Success?e.data:[]},save:async e=>{(await c.XO.post(b.s.setting_customer_workflow_router_save,e)).code===d.m.Success&&(0,x.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)(C,{})})]})]})}var I=s(74777),V=s(6960),N=s(7523);function X(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),[s,i]=(0,n.useState)(!1),[h,_]=(0,n.useState)("https://registry.npmjs.org"),[m,j]=(0,n.useState)(""),[v,g]=(0,n.useState)(180),[S,C]=(0,n.useState)(!1),[b,k]=(0,w.fp)(p.AG.prompt_card);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("auto_upgrade_setting");if(e.code===d.m.Success){const t=e.data;i(t.open||!1),_(t.version_check_url||"https://registry.npmjs.org"),j(t.exe_download_url||""),g(t.check_interval_seconds||180)}})()},[]);return t(a.oV.sys_setting_page)?(0,f.jsxs)(l.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(!h)return void(0,x.zN)(e("ver_req"));if(s&&(!v||v<10))return void(0,x.zN)(e("chk_10s"));const t=new I.Mm;t.open=s,t.version_check_url=h,t.exe_download_url=m,t.check_interval_seconds=v;(await c.XO.post("auto_upgrade_setting/save",t)).code===d.m.Success&&(0,x.SK)(e("保存成功"))}}),children:[(0,f.jsx)("div",{children:e("ver_url")}),(0,f.jsx)(r.Sm,{placeholder:"https://registry.npmjs.org",value:h,handleInputChange:e=>{_(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()=>{C(!0);try{(await c.XO.post("auto_upgrade_setting/upgrade_now",{})).code===d.m.Success&&(0,x.SK)(e("已触发升级检测,请查看服务端日志"))}catch(t){(0,x.zN)(e("触发升级失败"))}finally{C(!1)}}})})]})]}):null}function z(){const{t:e}=(0,u.Bd)(),[,t]=(0,w.fp)(p.AG.prompt_card),[s,i]=(0,n.useState)(""),[a,_]=(0,n.useState)(5610),[m,j]=(0,n.useState)(5710);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("sys_option/status");if(e.code===d.m.Success){const t=e.data?.sys_env;i((t?.browser_proxy_allow||[]).join("\n")),_(t?.browser_proxy_port_start||5610),j(t?.browser_proxy_port_end||5710)}})()},[]);return(0,f.jsxs)(l.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 c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{browser_proxy_allow:t,browser_proxy_port_start:Number(a)||5610,browser_proxy_port_end:Number(m)||5710}})).code===d.m.Success&&(0,x.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)(h.S,{isFlex:!0,columns:[(0,f.jsx)(r.Sm,{placeholder:"5610",value:a,handleInputChange:e=>_(e)}),(0,f.jsx)("span",{style:{padding:"0 6px"},children:"-"}),(0,f.jsx)(r.Sm,{placeholder:"5710",value:m,handleInputChange:e=>j(e)})]})]})}function F(){const[e,t]=(0,n.useState)(""),[s,a]=(0,n.useState)(""),[_,m]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[g,S]=(0,n.useState)(!1),[C,A]=(0,n.useState)(""),[F,K]=(0,w.fp)(p.AG.prompt_card),[O,P]=(0,n.useState)(!1),[B,$]=(0,n.useState)(""),[M,D]=(0,n.useState)(""),[T,E]=(0,n.useState)(I.aM.close),[G,q]=(0,n.useState)(!1),[W,Z]=(0,n.useState)(void 0),{t:R,i18n:H}=(0,u.Bd)(),[U,Q]=(0,w.fp)(p.AG.user_base_info),{check_user_auth:J}=(0,y.MH)(),{initUserInfo:L}=(0,n.useContext)(N.F);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("sys_option/status");if(e.code===d.m.Success){S(e.data.recycle_open),A(e.data.recycle_dir);const s=e.data.sys_env;t(s?.web_site_title),a(s?.logo||""),m(s?.show_login_user_info),v(s?.http_proxy||"");const n=e.data.https_setting;n&&(P(n.open),$(n.cert_path||""),D(n.key_path||""))}const s=await c.XO.get("token");if(s.code===d.m.Success){const e=s.data;if(!e)return;e.length&&Z(e.length),e.mode&&E(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:[R("系统运行于"),": ",(0,V.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.13.0",null!=U.latest_version&&"7.13.0"!==U.latest_version?` -> ${U.latest_version}`:""]})}),(0,f.jsx)("span",{className:"credits",children:(0,f.jsx)("a",{href:R("官网地址"),target:"_blank",children:`filecat ${R("功能文档")}`})}),(0,f.jsxs)("span",{className:"credits",children:[R("安装方式")," :",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)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:R("通用设置")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{K({open:!0,title:R("信息"),context_div:(0,f.jsx)("div",{children:(0,f.jsx)("div",{children:R("pxy_tip")})})})},title:R("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:R("确定修改"),clickFun:async()=>{(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{web_site_title:e,show_login_user_info:_,http_proxy:j,logo:s}})).code===d.m.Success&&((0,x.SK)("修改成功"),L())}}),children:[R("网站标题"),(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{t(e)}}),R("网站 Logo"),(0,f.jsx)(r.Sm,{placeholder:R("lclorur"),value:s,handleInputChange:e=>{a(e)}}),(0,f.jsx)("div",{children:R("pxy_url")}),(0,f.jsx)(r.Sm,{placeholder:"http://127.0.0.1:7890",value:j,handleInputChange:e=>{v(e)}}),R("lgn_usr"),(0,f.jsx)("input",{type:"checkbox",checked:_,onChange:()=>{m(!_)}})]}),(0,f.jsxs)(l.Zp,{title:R("https_s"),rightBottomCom:(0,f.jsx)(o.C3,{text:R("确定修改"),clickFun:async()=>{if(O){if(!B)return void(0,x.zN)("证书路径不能为空");if(!M)return void(0,x.zN)("私钥路径不能为空")}const e=new I.CH;e.open=O,e.cert_path=B,e.key_path=M;(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.https,value:e,open:O})).code===d.m.Success&&(0,x.SK)("HTTPS 设置已保存,需重启服务器才能生效")}}),children:[(0,f.jsx)(r.l6,{value:O,onChange:e=>{P(e)},options:[{title:R("开启"),value:!0},{title:R("关闭"),value:!1}]}),O&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{children:R("ssl_crt")}),(0,f.jsx)(r.Sm,{placeholder:R("crt_pth"),value:B,handleInputChange:e=>{$(e)}}),(0,f.jsx)("div",{children:R("ssl_key")}),(0,f.jsx)(r.Sm,{placeholder:R("ky_pth"),value:M,handleInputChange:e=>{D(e)}})]})]}),(0,f.jsx)(X,{}),(0,f.jsx)(z,{})]}),(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:R("文件回收站")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{K({open:!0,title:R("信息"),context_div:(0,f.jsx)("div",{children:R("格式:[被删除的文件所在父目录] 回收站目录 [; ...]")})})},title:R("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:R("确定修改"),clickFun:async()=>{if(g&&!C)return void(0,x.zN)("目录不能为空");(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.cyc,value:C,open:g})).code===d.m.Success&&(0,x.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:R("目录"),value:C,handleInputChange:e=>{A(e)}}),(0,f.jsx)(r.l6,{value:g,onChange:e=>{S(e)},options:[{title:R("开启"),value:!0},{title:R("关闭"),value:!1}]})]}),(0,f.jsxs)(l.Zp,{title:R("tk_exp"),rightBottomCom:(0,f.jsx)(h.S,{isFlex:!0,columns:[(0,f.jsx)(o.C3,{text:R("清空token"),clickFun:async()=>{(await c.XO.get("token/clear")).code===d.m.Success&&(0,x.SK)("清理完成,重新登录")}}),(0,f.jsx)(o.C3,{text:R("保存"),clickFun:async()=>{const e=new I.Gd;e.mode=T,e.persist=G,I.aM.length!==e.mode||W||(0,x.zN)("秒数不能为空"),e.length=parseInt(W);(await c.XO.post("token/save",e)).code===d.m.Success&&(0,x.SK)("保存成功")}})]}),children:[(0,f.jsx)(h.S,{isFlex:!0,columns:[(0,f.jsx)(r.U6,{value:1,context:R("关闭"),selected:T===I.aM.close,onchange:()=>{E(I.aM.close)}}),(0,f.jsx)(r.U6,{value:1,context:R("指定时间"),selected:T===I.aM.length,onchange:()=>{E(I.aM.length)}}),(0,f.jsx)(r.U6,{value:1,context:R("永不过期"),selected:T===I.aM.forver,onchange:()=>{E(I.aM.forver)}})]}),T===I.aM.length&&(0,f.jsx)(r.Sm,{placeholder:R("秒"),value:W,handleInputChange:e=>{Z(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)}),R("持久化")]})]})]})]})})]})}var K=s(92350);function O(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:a}=(0,n.useContext)(N.F),[_,m]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[C,b]=(0,w.fp)(p.AG.prompt_card),[,k]=(0,w.fp)(p.AG.editorSetting),[A,I]=(0,n.useState)([]),[V,X]=(0,n.useState)([]),[z,F]=(0,n.useState)([]),[O,P]=(0,n.useState)([]),[B,$]=(0,n.useState)(""),[M,D]=(0,n.useState)([]),T=(0,S.K)(),E=[e("软件"),e("是否安装"),e("路径")],G=[e("编号"),e("路径"),e("备注")],q=[e("编号"),e("路径"),e("是否开启"),e("备注")],W=[e("编号"),e("文件路径"),e("是否开启"),e("系统启动执行"),e("corn表达式"),e("用户id"),e("备注")],Z=[e("编号"),e("路径"),e("单用户并发数量"),e("系统并发数量"),e("big_res"),e("big_sz"),e("大文件并发数量"),e("big_ck"),e("备注")],R=[e("编号"),e("名称"),e("路径"),e("是否开启"),e("params"),e("备注")],{check_user_auth:H}=(0,y.MH)(),U=async()=>{const e=await c.XO.get("env/path/get");e.code===d.m.Success&&F(e.data)},Q=async()=>{const e=await c.XO.get("workflow_setting_get");e.code===d.m.Success&&P(e.data)};(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("outside/software/get");e.code===d.m.Success&&g(e.data);const t=await c.XO.get("pty_cmd");t.code===d.m.Success&&$(t.data),U(),Q();const s=await c.XO.get("protection_dir/sys");s.code===d.m.Success&&I(s.data??[]);const n=await c.XO.get("dir_upload_max_num");n.code===d.m.Success&&X(n.data??[]);const i=await c.XO.get("plugin/list");i.code===d.m.Success&&D(i.data??[])})()},[]);const J=(0,K.Q)(),L=async()=>{(await c.XO.post("plugin/list/save",M)).code===d.m.Success&&(0,x.SK)(e("保存成功"))};return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(i.J,{widthPer:100,maxWidth:"100rem",children:(0,f.jsx)(l.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:()=>{J("文件上传")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...V,{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 V)if(e.open_ws_file){if("number"!=typeof e.ws_file_block_mb_size)return void(0,x.zN)(`编号:${e.index??""} 文件块的大小设置有问题`);if("number"!=typeof e.ws_file_parallel_num)return void(0,x.zN)(`编号:${e.index??""} 并发数量设置有问题`);if("number"!=typeof e.ws_file_standard_size)return void(0,x.zN)(`编号:${e.index??""} 大文件size设置有问题`)}(0,v.di)(V,e=>e.index??0);(await c.XO.post("dir_upload_max_num/save",V)).code===d.m.Success&&((0,x.SK)("保存成功"),a())}})]}),children:(0,f.jsx)(h.X,{headers:Z,rows:V.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,X([...V])},options:T,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=>{V.splice(e,1),X([...V])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{X((0,v.TI)(V,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)(l.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:()=>{J("环境路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"list",title:e("查看"),onClick:async()=>{const t=await c.XO.get("env/process/view");t.code===d.m.Success?b({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,x.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:async()=>{const t=await c.XO.get("env/process/get");t.code===d.m.Success?(y.xK.set_value_temp(t.data??""),k({model:"ace/mode/ini",open:!0,fileName:"",save:async t=>{(await c.XO.post("env/process/save",{text:t})).code===d.m.Success?(0,x.SK)(e("保存成功")):(0,x.zN)(e("保存失败")),y.xK.set_value_temp("")}})):(0,x.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{F([...z,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("env/path/save",{paths:z})).code===d.m.Success&&((0,x.SK)("保存成功"),U(),s())}})]}),children:(0,f.jsx)(h.X,{headers:q,rows:z.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,F([...z])},options:T,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=>{z.splice(e,1),F([...z])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{F((0,v.TI)(z,e,t))}})}),(0,f.jsx)(l.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:()=>{J("pty")},title:e("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("更新"),clickFun:async()=>{(await c.XO.post("pty_cmd/save",{str:B})).code===d.m.Success&&((0,x.SK)("保存成功"),a())}}),children:(0,f.jsx)(r.Sm,{placeholder:e("cmd need pty env"),value:B,handleInputChange:e=>{$(e)}})}),(0,f.jsx)(l.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:()=>{J("Workflow")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{P([...O,{open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("workflow_setting_save",O)).code===d.m.Success&&((0,x.SK)("ok"),Q())}})]}),children:(0,f.jsx)(h.X,{headers:W,rows:O.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,P([...O])},options:T,no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.sys_power_on,onChange:e=>{t.sys_power_on=e,P([...O])},options:T,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cron_str,handleInputChange:e=>{t.cron_str=e},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=>{O.splice(e,1),P([...O])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{P((0,v.TI)(O,e,t))}})}),(0,f.jsx)(l.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:()=>{J("插件配置")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{D([...M,{name:"",path:"",note:"",open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:L})]}),children:(0,f.jsx)(h.X,{headers:R,rows:M.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,D([...M])},options:T,no_border:!0}),(0,f.jsx)(o.mu,{icon:"edit",save:async e=>{t.params=e,await L()},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=>{M.splice(e,1),D([...M])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{D((0,v.TI)(M,e,t))}})})]})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"50rem",children:(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.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:()=>{J("保护目录")},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 c.XO.post("protection_dir/sys/save",A)).code===d.m.Success&&((0,x.SK)("保存成功"),a())}})]}),children:(0,f.jsx)(h.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)(l.uF,{title:e("外部软件"),titleCom:(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("outside/software/save",j)).code===d.m.Success&&((0,x.SK)("保存成功"),s())}}),children:(0,f.jsx)(h.X,{headers:E,rows:j.map((t,s)=>[(0,f.jsx)("div",{children:t.id}),(0,f.jsx)(l.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:()=>{J(t.id)},title:e("信息")})]),width:"10rem"})})]})})]})]})}function P(e){const{t,i18n:s}=(0,u.Bd)(),[i,l]=(0,w.fp)(p.AG.user_base_info),o=[{title:t("用户权限"),list:[{title:t("用户管理"),permission:a.oV.user_manage},{title:t("角色管理"),permission:a.oV.role_manage}]},{title:t("系统管理权限"),list:[{title:t("系统信息"),permission:a.oV.all_sys},{title:t("系统进程关闭"),permission:a.oV.sys_process_close},{title:t("dc_ctdl"),permission:a.oV.docker_container_update},{title:t("dc_idl"),permission:a.oV.docker_images_delete},{title:t("systemd管理"),permission:a.oV.systemd},{title:t("防火墙管理"),permission:a.oV.firewall}]},{title:t("网络功能权限"),list:[{title:t("系统网络"),permission:a.oV.vir_net},{title:t("内网穿透"),permission:a.oV.tcp_proxy},{title:"ddns",permission:a.oV.ddns}]},{title:t("Ai 设置权限"),list:[{title:t("Ai 配置"),permission:a.oV.ai_agent_setting},{title:t("ai_page"),permission:a.oV.ai_agent_page},{title:t("sw_mdl"),permission:a.oV.ai_model_switch}]},{title:t("文件权限"),list:[{title:t("log_del"),permission:a.oV.filecat_file_delete_cut_rename},{title:t("log_wr"),permission:a.oV.filecat_file_context_update_upload_created_copy_decompression},{title:t("内容更新"),permission:a.oV.filecat_file_context_update},{title:t("文件回收站修改"),permission:a.oV.recycle_file_save},{title:t("文件分享"),permission:a.oV.share_file}]},{title:t("系统设置权限"),list:[{title:t("系统页面"),permission:a.oV.sys_setting_page},{title:t("htts"),permission:a.oV.https_file},{title:t("tk_time"),permission:a.oV.token_update},{title:t("修改密码"),permission:a.oV.update_password},{title:t("磁盘挂载"),permission:a.oV.sys_disk_mount},{title:t("通用设置"),permission:a.oV.sys_env_setting_key},{title:t("md_set"),permission:a.oV.md_editor_setting},{title:t("目录挂载"),permission:a.oV.file_mount}]},{title:t("系统环境设置"),list:[{title:t("sys_env"),permission:a.oV.sys_env_page},{title:t("up_lim"),permission:a.oV.dir_upload_max_num},{title:t("path_md"),permission:a.oV.env_path_update},{title:"pty cmd "+t("更新"),permission:a.oV.pty_cmd_update},{title:"workflow job",permission:a.oV.workflow_job},{title:t("path_up"),permission:a.oV.sys_protection_dir},{title:t("外部软件路径"),permission:a.oV.outside_software_path}]},{title:t("个人环境设置"),list:[{title:t("个性化设置"),permission:a.oV.private_sys_env}]},{title:t("自定义路由"),list:[{title:t("自定义路由页面"),permission:a.oV.auth_router_page},{title:t("wf_api"),permission:a.oV.workflow_api},{title:t("自定义资源路由"),permission:a.oV.code_resource},{title:t("api_rt"),permission:a.oV.code_api}]},{title:t("标签编辑权限"),list:[{title:t("ssh代理"),permission:a.oV.ssh_proxy_tag_update},{title:t("http代理"),permission:a.oV.http_proxy_tag_update},{title:t("浏览器代理"),permission:a.oV.browser_proxy_tag_update},{title:t("rdp代理"),permission:a.oV.rdp_proxy_tag_update},{title:t("网络唤醒"),permission:a.oV.wol_proxy_tag_update},{title:t("rtsp播放器"),permission:a.oV.rtsp_proxy_tag_update}]},{title:t("代理功能"),list:[{title:t("ssh代理"),permission:a.oV.ssh_proxy},{title:t("http代理"),permission:a.oV.http_proxy},{title:t("pxy_off"),permission:a.oV.http_proxy_download_cancel},{title:t("浏览器代理"),permission:a.oV.browser_proxy},{title:t("浏览器代理编辑"),permission:a.oV.browser_proxy_edit},{title:t("rdp代理"),permission:a.oV.rdp_proxy}]},{title:t("其他功能"),list:[{title:t("wf_run"),permission:a.oV.workflow_exe},{title:t("wf_user"),permission:a.oV.workflow_exe_user,noDisable:!0},{title:t("网络唤醒"),permission:a.oV.wol_proxy},{title:t("端口扫描"),permission:a.oV.port_scan},{title:t("rtsp播放器"),permission:a.oV.rtsp_proxy},{title:t("ssh_sv"),permission:a.oV.crypto_ssh_file},{title:t("cmd_rst"),permission:a.oV.shell_cmd_filecat_restart},{title:t("cmd_upg"),permission:a.oV.shell_cmd_filecat_upgrade},{title:t("cmd_dwn"),permission:a.oV.shell_cmd_filecat_kill_self},{title:t("cmd_ai"),permission:a.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 B=new Map;function $(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:_}=(0,n.useContext)(N.F),[j,g]=(0,w.fp)(p.AG.user_base_info),[y,S]=(0,n.useState)([]),[C,b]=(0,w.fp)(p.AG.prompt_card),[k,A]=(0,n.useState)(!1),[I,V]=(0,n.useState)(!1),[X,z]=(0,w.fp)(p.AG.confirm),[F,O]=(0,n.useState)(""),[$,M]=(0,n.useState)(""),[D,T]=(0,n.useState)(""),[E,G]=(0,n.useState)([]),[q,W]=(0,n.useState)([]),[Z,R]=(0,n.useState)([]),[H,U]=(0,n.useState)(""),[Q,J]=(0,n.useState)(""),[L,Y]=(0,n.useState)("en"),[ee,te]=(0,n.useState)(""),[se,ne]=(0,n.useState)([]),[ie,ae]=(0,n.useState)(""),[le,oe]=(0,n.useState)(!1),[re,ce]=(0,n.useState)(""),[de,he]=(0,n.useState)(""),[ue,pe]=(0,n.useState)({}),_e=(0,K.o)(),[xe,me]=(0,n.useState)([]),[je,ve]=(0,n.useState)(void 0),fe=[e("用户id"),e("用户名"),e("目录范围"),e("备注")],ge=async()=>{const e=await c.wm.get("all_users");if(e.code===d.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 c.wm.get("all_roles");if(t.code===d.m.Success){me(t.data),B.clear();for(const e of t.data)B.set(e.role_id,e)}},we=e=>{O(e?.username??""),M(e?.password??""),T(e?.cwd??""),G(e?.access_dirs??[]),W(e?.not_access_dirs??[]),R(e?.only_read_dirs??[]),U(e?.access_cmd??""),J(e?.not_access_cmd??""),Y(e?.language??""),te(e?.theme??""),ne(e?.auth_list??[]),ae(e?.note??""),oe(e?.is_root??!1),ce(e?.id??""),e?.bind_role_id?ye(e.bind_role_id,e.auth_list??[]):(he(""),pe({}))};(0,n.useEffect)(()=>{ge()},[]);const ye=(e,t=[])=>{if(!e)return he(""),void pe({});const s=B.get(e);if(s){if(s.cwd&&T(s.cwd),s.access_dirs&&s.access_dirs.length>0&&G(s.access_dirs),s.not_access_dirs&&s.not_access_dirs.length>0&&W(s.not_access_dirs),s.only_read_dirs&&s.only_read_dirs.length>0&&R(s.only_read_dirs),s.access_cmd&&U(s.access_cmd),s.not_access_cmd&&J(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))}he(e),pe(s)}},Se=()=>{if(!F)return void(0,x.zN)("username not empty");if((0,m.CB)(F))return void(0,x.zN)("username not empty char");if(!D)return void(0,x.zN)("cwd not empty");const e=new a.E0;return e.language=L,e.theme=ee,e.access_dirs=E,e.username=F,e.password=$,e.not_access_dirs=q,e.only_read_dirs=Z,e.cwd=D,e.note=ie,e.access_cmd=H,e.not_access_cmd=Q,e.auth_list=se,e.bind_role_id=de,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)(l.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),V(!1),we(void 0)}})]}),children:(0,f.jsx)(h.X,{headers:fe,rows:y.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.id}),(0,f.jsx)(l.xP,{children:t.username}),(0,f.jsx)(l.xP,{children:t.cwd}),(0,f.jsx)(l.xP,{children:t.note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{A(!1),V(!0),we(e)})(t)}),!t.is_root&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async t=>{z({open:!0,title:e("确定删除吗"),handle:async()=>{const e=new a.E0;e.username=t,(await c.wm.post("delete_user",e)).code===d.m.Success&&((0,x.SK)("删除完成"),ge(),z({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)(l.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),V(!1),we(void 0)}}),k&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{if(!$)return void(0,x.zN)("password not empty");if((0,m.CB)($))return void(0,x.zN)("username not empty char");const e=Se(),t=await c.wm.post("create_user",e);ge(),t.code===d.m.Success&&((0,x.SK)("创建完成"),ge(),A(!1),V(!1),we(void 0))}}),I&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=Se();if(!e)return;e.id=re;(await c.wm.post("save_user",e)).code===d.m.Success&&((0,x.SK)("保存完成"),ge())}})]}),children:[(0,f.jsx)("label",{children:e("用户名")}),(0,f.jsx)(r.Sm,{value:F,handleInputChange:e=>O(e)}),(0,f.jsx)("label",{children:e("密码")}),(0,f.jsx)(r.Sm,{type:"password",value:$,handleInputChange:e=>M(e)}),(0,f.jsxs)("label",{children:[!ue?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{G([...E,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{disabled:""!==ue.cwd&&void 0!==ue.cwd,value:D,handleInputChange:e=>T(e)}),(E??[]).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!==ue?.access_dirs?.length&&void 0!==ue?.access_dirs?.length,value:t,handleInputChange:e=>{E[s]=e,G([...E])}})}),0===ue?.access_dirs?.length||void 0===ue?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{E.splice(s,1),G([...E])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!ue?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{W([...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!==ue?.not_access_dirs?.length&&void 0!==ue?.not_access_dirs?.length,value:t,handleInputChange:e=>{q[s]=e,W([...q])}})}),0===ue?.not_access_dirs?.length||void 0===ue?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{q.splice(s,1),W([...q])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!ue?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{R([...Z,""])},title:e("添加")}),e("只读目录范围")]}),(Z??[]).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!==ue?.only_read_dirs?.length&&void 0!==ue?.only_read_dirs?.length,value:t,handleInputChange:e=>{Z[s]=e,R([...Z])}})}),0===ue?.only_read_dirs?.length||void 0===ue?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{Z.splice(s,1),R([...Z])},title:e("删除")})]},s)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==ue.access_cmd&&void 0!==ue.access_cmd,value:H,placeholder:"use blank split",handleInputChange:e=>U(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==ue.not_access_cmd&&void 0!==ue.not_access_cmd,value:Q,placeholder:"use blank split",handleInputChange:e=>J(e)}),!le&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)("label",{children:e("角色")}),(0,f.jsx)(r.l6,{value:de,onChange:e=>{ye(e)},options:(()=>{const e=[];e.push({title:"NOT",value:""});for(let t of xe)e.push({title:t.role_name,value:t.role_id});return e})()})]}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{disabled:""!==ue.language&&void 0!==ue.language,value:L,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:""!==ue.theme&&void 0!==ue.theme,value:ee,onChange:e=>{te(e)},options:_e}),(0,f.jsx)(P,{is_disable:e=>{if(!0===le)return!0;if(de){const t=B.get(de);if(t)return(t.auth_list??[]).includes(e)}return!1},is_selected:(e,t)=>!t&&!0===le||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=>ae(e)})]})})})]})}function M(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s}=(0,n.useContext)(N.F),[_,m]=(0,n.useState)([]),[j,g]=(0,w.fp)(p.AG.prompt_card),[y,S]=(0,n.useState)(!1),[C,b]=(0,n.useState)(!1),[k,A]=(0,w.fp)(p.AG.confirm),[I,V]=(0,n.useState)(""),[X,z]=(0,n.useState)(""),[F,O]=(0,n.useState)([]),[B,$]=(0,n.useState)([]),[M,D]=(0,n.useState)([]),[T,E]=(0,n.useState)(""),[G,q]=(0,n.useState)(""),[W,Z]=(0,n.useState)(""),[R,H]=(0,n.useState)(""),[U,Q]=(0,n.useState)([]),[J,L]=(0,n.useState)(""),[Y,ee]=(0,n.useState)(""),te=(0,K.o)(),se=[e("角色id"),e("角色名"),e("备注")],ne=async()=>{const e=await c.wm.get("all_roles");e.code===d.m.Success&&m(e.data)},ie=e=>{V(e?.role_name??""),z(e?.cwd??""),O(e?.access_dirs??[]),$(e?.not_access_dirs??[]),D(e?.only_read_dirs??[]),E(e?.access_cmd??""),q(e?.not_access_cmd??""),Z(e?.language??""),H(e?.theme??""),Q(e?.auth_list??[]),L(e?.role_id??""),ee(e?.role_note??"")};(0,n.useEffect)(()=>{ne()},[]);const ae=()=>{if(!I)return void(0,x.zN)("role_name not empty");const e=new a.E0;return e.language=W,e.theme=R,e.access_dirs=F,e.role_name=I,e.not_access_dirs=B,e.only_read_dirs=M,e.cwd=X,e.access_cmd=T,e.not_access_cmd=G,e.auth_list=U,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)(l.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),b(!1),ie(void 0)}})}),children:(0,f.jsx)(h.X,{headers:se,rows:_.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.role_id}),(0,f.jsx)(l.xP,{children:t.role_name}),(0,f.jsx)(l.xP,{children:t.role_note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{S(!1),b(!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 a.E0;e.role_id=t,(await c.wm.post("delete_role",e)).code===d.m.Success&&((0,x.SK)("删除完成"),ne(),A({open:!1,handle:null}))}})})(t.role_id)})]})];return n}),width:"10rem"})})})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(y||C)&&(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e(""+(y?"添加":"编辑"))})," "]}),rightBottomCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:()=>{S(!1),b(!1),ie(void 0)}}),y&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{const e=ae();if(!e)return;const t=await c.wm.post("create_role",e);ne(),t.code===d.m.Success&&((0,x.SK)("创建完成"),ne(),S(!1),b(!1),ie(void 0))}}),C&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=ae();if(!e)return;e.role_id=J;(await c.wm.post("save_role",e)).code===d.m.Success&&((0,x.SK)("保存完成"),ne())}})]}),children:[(0,f.jsx)("label",{children:e("角色名")}),(0,f.jsx)(r.Sm,{value:I,handleInputChange:e=>V(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:()=>{O([...F,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{value:X,handleInputChange:e=>z(e)}),(F??[]).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=>{F[t]=e,O([...F])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{F.splice(t,1),O([...F])},title:"删除"})]},t)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{$([...B,""])},title:"添加"}),e("禁止目录范围")]}),(B??[]).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=>{B[s]=e,$([...B])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{B.splice(s,1),$([...B])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{D([...M,""])},title:e("添加")}),e("只读目录范围")]}),(M??[]).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=>{M[t]=e,D([...M])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{M.splice(t,1),D([...M])},title:"删除"})]},t)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{value:T,placeholder:"use blank split",handleInputChange:e=>E(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{value:G,placeholder:"use blank split",handleInputChange:e=>q(e)}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{value:W,onChange:e=>{Z(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:R,onChange:e=>{H(e)},options:te}),(0,f.jsx)(P,{is_disable:()=>!1,is_selected:(e,t)=>void 0!==U?.find(t=>t===e),select_auth:e=>{U?(U.find(t=>t==e)?(0,v.I)(U,t=>t===e):U.push(e),Q([...U])):Q([e])}})]})})})]})}function D(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:_}=(0,n.useContext)(N.F),[m,j]=(0,n.useState)([]),[g,y]=(0,w.fp)(p.AG.prompt_card),[C,k]=(0,n.useState)([]),[A,V]=(0,n.useState)([]),[X,z]=(0,n.useState)([]),[F,O]=(0,w.fp)(p.AG.user_base_info),P=(0,S.K)(),B=(0,K.o)(),$=[e("编号"),e("路径"),e("是否默认"),e("备注")],M=[e("编号"),e("路径"),e("备注")],D=[e("编号"),e("命令"),e("父编号"),e("备注")],T=[e("文件后缀"),e("命令"),e("其他参数"),e("备注")],[E,G]=(0,n.useState)(""),[q,W]=(0,n.useState)(""),[Z,R]=(0,n.useState)(""),[H,U]=(0,n.useState)(!1),[Q,J]=(0,n.useState)(""),[L,Y]=(0,n.useState)(""),[ee,te]=(0,n.useState)("");(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("filesSetting");e.code===d.m.Success&&(j(e.data.dirs),V(e.data.quick_cmd),z(e.data.file_quick_cmd));const t=await c.XO.get("protection_dir");t.code===d.m.Success&&k(t.data??[])})(),J(F?.user_data?.language),Y(F?.user_data?.theme),te(F?.user_data?.upload_file_ignore)},[]);const se=(0,K.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)(l.Zp,{title:e("修改密码"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{if(!E||!q)return void(0,x.zN)("账号密码不能为空");if(q!==Z)return void(0,x.zN)("两次密码不一样");const e=new a.tl;e.username=E,e.password=q,e.confirm_password=Z,e.user_id=F.user_data.id;(await c.wm.post("updatePassword",e)).code===d.m.Success&&(0,x.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:e("新账号"),value:E,handleInputChange:e=>{G(e)}}),(0,f.jsx)(r.cA,{placeholder:e("新密码"),handleInputChange:e=>{W(e)}}),(0,f.jsx)(r.cA,{placeholder:e("确认密码"),handleInputChange:e=>{R(e)}})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{title:e("个性化设置"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.private_sys_env,value:{language:Q,theme:L,upload_file_ignore:ee}})).code===d.m.Success&&((0,x.SK)("修改成功"),s())}}),children:[e("语言"),(0,f.jsx)(r.l6,{value:Q,onChange:e=>{J(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:B}),(0,f.jsx)(r.Sm,{value:ee,handleInputChange:e=>{te(e)},placeholderOut:e("拖拽文件上传忽略列表"),placeholder:"node_modules *.js",no_border:!0})]})})]}),(0,f.jsxs)(i.VP,{children:[(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.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:()=>{se("文件夹路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{j([...m,{note:"",default:!1,path:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{for(let e=0;e<m.length;e++)m[e].index=e;(await c.XO.post("filesSetting/save",{dirs:m})).code===d.m.Success&&((0,x.SK)("保存成功"),_(),s())}})]}),children:(0,f.jsx)(h.X,{headers:$,rows:m.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<m.length;e++)m[e].default=e===s&&t,n.push(m[e]);j(n)})(0,e,s)},options:P,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=>{m.splice(e,1),j([...m])})(s)})})];return n}),width:"10rem",onRowDrag:(e,t)=>{0!==e&&0!==t&&j((0,v.TI)(m,e,t))}})}),(0,f.jsx)(l.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:()=>{se("保护目录")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{k([...C,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("protection_dir/save",C)).code===d.m.Success&&((0,x.SK)("保存成功"),_())}})]}),children:(0,f.jsx)(h.X,{headers:M,rows:C.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=>{C.splice(e,1),k([...C])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{k((0,v.TI)(C,e,t))}})})]}),(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.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:()=>{se("目录快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{V([...A,{cmd:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("filesSetting/save",{quick_cmd:A})).code===d.m.Success&&((0,x.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(h.X,{headers:D,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),V([...A])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{V((0,v.TI)(A,e,t))}})}),(0,f.jsx)(l.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:()=>{se("文件快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{z([...X,{cmd:"",note:"",file_suffix:"",params:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("filesSetting/save",{file_quick_cmd:X})).code===d.m.Success&&((0,x.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(h.X,{headers:T,rows:X.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=>{X.splice(e,1),z([...X])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{z((0,v.TI)(X,e,t))}})})]})]})]})})}var T=s(45907),E=s(17903);const G=["password","private_key","secret_key"],q="webdav",W="@authorize",Z={smb:[{keys:["server","username","password"],on_next:"load_shares"},{keys:["share"]}],baidu:[{keys:["app_id","app_key","secret_key"],on_next:"save_app"},{keys:[W]}]};function R(){const{t:e}=(0,u.Bd)(),t=(0,T.y)(),[,s]=(0,w.fp)(p.AG.prompt_card),[i,a]=(0,n.useState)([]),[d,_]=(0,n.useState)([]),[m,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[y,S]=(0,n.useState)(q),[C,b]=(0,n.useState)(""),[k,A]=(0,n.useState)({}),[I,V]=(0,n.useState)(1),[N,X]=(0,n.useState)([]),[z,F]=(0,n.useState)("oob"),[K,O]=(0,n.useState)(""),[P,B]=(0,n.useState)(!0),$=async()=>{try{const[e,t]=await Promise.all([c.I2.post("credential/list",{}),c.I2.post("credential/meta",{})]);a(Array.isArray(e?.data)?e.data:[]),_(Array.isArray(t?.data)?t.data:[])}catch(e){}};(0,n.useEffect)(()=>{$()},[]);const M=d.find(e=>e.type===y)?.fields??[],D=Z[y],R=D?.length??1,H=()=>{j(!1),g(""),S(q),b(""),A({}),V(1),X([]),O(""),B(!0)},U=t=>{if(!C.trim())return e("请填写备注");for(const s of M){if(!1===t.includes(s.key))continue;const n=String(k[s.key]??"").trim()||v&&G.includes(s.key);if(s.required&&!n)return e(s.label)}},Q=async()=>{try{const e=await c.I2.post("baidu/authorize_url",{id:v,mode:z});e?.data&&window.open(e.data,"_blank","noopener,noreferrer")}catch(e){}},J=async()=>{if(K.trim())try{const t=await c.I2.post("baidu/exchange",{id:v,code:K.trim(),mode:z});(0,x.SK)(`${e("授权成功")}:${t?.data?.baidu_name??""}`),O(""),await $()}catch(e){}else(0,x.zN)(e("请填写授权码"))},L=D?.[I-1]?.keys??M.map(e=>e.key),Y=L.includes(W),ee=I===R,te=R>1;return(0,f.jsxs)(l.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:[!m&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{H(),j(!0)}}),m&&(0,f.jsxs)(f.Fragment,{children:[te&&I>1&&(0,f.jsx)(o.rA,{icon:"arrow_back",title:e("上一步"),onClick:()=>V(I-1)}),te&&!ee&&(0,f.jsx)(o.rA,{icon:"arrow_forward",title:e("下一步"),onClick:async()=>{const t=U(D?.[I-1]?.keys??[]);if(t)return void(0,x.zN)(`${e("请填写")}${t}`);const s=D?.[I-1]?.on_next;try{if("load_shares"===s&&!await(async()=>{const t=await c.I2.post("share/list",{driver:y,id:v||void 0,config:{server:k.server,username:k.username,password:k.password}}),s=t?.data??[];return s.length?(X(s.map(e=>({label:e.name,value:e.name}))),!0):((0,x.zN)(e("没有找到共享")),!1)})())return;if("save_app"===s&&!await(async()=>{try{const e=await c.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:y,note:C,config:k,enabled:P});return!v&&e?.data?.id&&g(e.data.id),!0}catch(e){return!1}})())return;V(I+1)}catch(e){}}}),(!te||ee)&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const t=U(M.map(e=>e.key));if(t)(0,x.zN)(`${e("请填写")}${t}`);else try{await c.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:y,note:C,config:k,enabled:P}),(0,x.SK)(e("保存成功")),H(),await $()}catch(e){}}}),(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:H})]})]}),children:[m&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.Sm,{placeholder:e("备注"),value:C,handleInputChange:b}),(0,f.jsx)(r.l6,{value:y,options:d.map(e=>({title:e.name,value:e.type})),onChange:e=>{S(e),A({}),X([]),V(1),O("")}}),Y?(()=>{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"===z,onchange:()=>F("one_click")}),(0,f.jsx)(r.U6,{name:"baidu_auth_mode",value:"oob",context:e("outh_ob"),selected:"oob"===z,onchange:()=>F("oob")})]})}),"oob"===z&&(0,f.jsx)(r.BC,{label:e("授权码"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("粘贴授权码 code"),value:K,handleInputChange:O})}),(0,f.jsxs)("div",{className:"div-row",children:[(0,f.jsx)(o.rA,{icon:"open_in_new",title:e("去授权"),onClick:Q}),"oob"===z&&(0,f.jsx)(o.rA,{icon:"check",title:e("完成授权"),onClick:J})]}),s.length>0&&(0,f.jsx)(h.X,{headers:[e("账号名"),e("百度账号"),e("授权状态"),e("使用"),e("授权时间"),e("操作")],rows:s.map(s=>[(0,f.jsx)(l.xP,{context:s.note||s.account_name||s.id}),(0,f.jsx)(l.xP,{context:s.account_name||s.id}),(0,f.jsx)(l.xP,{context:s.authorized?e("已授权"):e("未授权")}),(0,f.jsx)(l.xP,{context:!1===s.enabled?e("停用"):e("启用")}),(0,f.jsx)("p",{children:s.obtained_at?(0,E.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 c.I2.post("baidu/verify",{id:t,account_id:s}),i=n?.data??{};i.valid?(0,x.SK)(e("账号可用")):(0,x.zN)(`${e("账号不可用")}:${i.error??""}`),await $()}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 c.I2.post("baidu/deauthorize",{id:s,account_id:n.id}),(0,x.SK)(e("已删除")),await $()}catch(e){}}})})(v,s)})]})])})]},W)})():M.filter(e=>L.includes(e.key)).map(t=>{if("share"===t.key&&"smb"===y)return(0,f.jsx)(r.BC,{label:e(t.label),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:k[t.key]??"",options:N,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)})]}),!m&&(0,f.jsx)(h.X,{headers:[e("备注"),e("类型"),e("操作")],rows:i.map(s=>{return[(0,f.jsx)(l.xP,{context:s.note}),(0,f.jsx)(l.xP,{context:(n=s.type,d.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),b(e.note??""),A({...e.config??{}}),O(""),B(!1!==e.enabled),V(Z[e.type]?.length??1),"smb"===e.type&&c.I2.post("share/list",{driver:"smb",id:e.id,config:e.config??{}}).then(e=>{X((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 c.I2.post("credential/delete",{id:s.id}),(0,x.SK)(e("已删除")),await $()}catch(e){}}})})(s)})]})];var n})})]})}function H(){const{t:e}=(0,u.Bd)(),t=(0,T.y)(),[s,i]=(0,n.useState)([]),[a,d]=(0,n.useState)([]),[p,_]=(0,n.useState)([]),[m,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[w,y]=(0,n.useState)("webdav"),[S,C]=(0,n.useState)(""),[b,k]=(0,n.useState)(""),[A,I]=(0,n.useState)(""),[V,N]=(0,n.useState)(""),[X,z]=(0,n.useState)(""),F=async()=>{try{const[e,t,s]=await Promise.all([c.I2.post("list",{}),c.I2.post("credential/list",{}),c.I2.post("driver/list",{})]);i(Array.isArray(e?.data)?e.data:[]),d(Array.isArray(t?.data)?t.data:[]),_(Array.isArray(s?.data)?s.data:[])}catch(e){}};(0,n.useEffect)(()=>{F()},[]);const K=(0,E.p_)(b,a),O=K.length>0,P=()=>{j(!1),g(""),y("webdav"),C(""),k(""),I(""),N(""),z("")};return(0,f.jsxs)(l.Zp,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("挂载列表")})}),rightBottomCom:(0,f.jsxs)("div",{children:[!m&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{P(),j(!0)}}),m&&(0,f.jsx)(o.rA,{icon:"network_check",title:e("测试连接"),onClick:async()=>{if(b)try{const t=await c.I2.post("test",{id:v||void 0,driver:w,credential_id:b,account_id:A,root_dir:V}),s=t?.data;s?.ok?(0,x.SK)(`${e("连接成功")}(${s.count??0})`):(0,x.zN)(`${e("连接失败")}:${s?.error??""}`)}catch(e){}else(0,x.zN)(e("请选择凭据"))}}),m&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{if(b)if(!O||A)if(S.trim())try{await c.I2.post(v?"update":"add",{id:v||void 0,driver:w,mount_path:S,credential_id:b,account_id:O?A:void 0,root_dir:V,note:X,color:E.OT,readonly:!1,enabled:!0}),(0,x.SK)(e("保存成功")),P(),await F()}catch(e){}else(0,x.zN)(e("munt_rq"));else(0,x.zN)(e("请选择账号"));else(0,x.zN)(e("请选择凭据"))}}),m&&(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:P})]}),children:[m&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.BC,{label:e("挂载类型"),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:w,options:p.map(e=>({title:e.name,value:e.type})),onChange:e=>{y(e),k(""),I("")}})}),(0,f.jsx)(r.BC,{label:e("凭据"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:b,options:(B=w,(0,E.XT)(B,a)),onChange:e=>{k(e),I("")}})}),O&&(0,f.jsx)(r.BC,{label:e("账号"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:A,options:K,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:C})}),(0,f.jsx)(r.BC,{label:e("strtdrt"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("远端目录"),value:V,handleInputChange:N})}),(0,f.jsx)(r.BC,{label:e("备注"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("列表显示的名称"),value:X,handleInputChange:z})})]}),!m&&(0,f.jsx)(h.X,{headers:[e("备注"),e("挂载类型"),e("凭据"),e("账号"),e("操作")],rows:s.map(s=>{const n=a.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:(l=s.driver,p.find(e=>e.type===l)?.name??l)}),(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),y(e.driver),C(e.mount_path??""),k(e.credential_id??""),I(e.account_id??""),N(e.root_dir??""),z(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 c.I2.post("delete",{id:s.id}),(0,x.SK)(e("已删除")),await F()}catch(e){}}})})(s)})]})];var l})})]});var B}function U(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),s=t(a.oV.file_mount),[r,d]=(0,w.fp)(p.AG.mount_enabled);(0,n.useEffect)(()=>{s&&(async()=>{try{const e=await c.I2.post("enabled/get",{});d(!0===e?.data)}catch(e){d(!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 c.I2.post("enabled/set",{enabled:t}),n=!0===s?.data;d(n),(0,x.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)(R,{})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"60rem",children:(0,f.jsx)(H,{})})]})})]}):(0,f.jsx)(i.fI,{children:(0,f.jsx)(i.VP,{children:(0,f.jsx)(l.Zp,{self_title:(0,f.jsx)("h2",{children:e("网盘挂载")}),children:(0,f.jsx)("p",{children:e("nmuntpr")})})})})}var Q=s(87361);function J(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),s=[{index:1,name:`${e("个人环境")}`,rto:"private_env_setting",component:(0,f.jsx)(D,{})}];return t(a.oV.sys_setting_page)&&s.unshift({index:1,name:e("系统"),rto:"password",component:(0,f.jsx)(F,{})}),t(a.oV.sys_env_page)&&s.push({index:1,name:`${e("系统环境")}`,rto:"env_setting/",component:(0,f.jsx)(O,{})}),t(a.oV.auth_router_page)&&s.push({index:1,name:e("自定义路由"),rto:"customer_router/",component:(0,f.jsx)(A,{})}),t(a.oV.user_manage)&&s.push({index:1,name:e("用户管理"),rto:"user_manager/",component:(0,f.jsx)($,{})}),t(a.oV.role_manage)&&s.push({index:1,name:e("角色管理"),rto:"role_manager/",component:(0,f.jsx)(M,{})}),t(a.oV.file_mount)&&s.push({index:1,name:e("网盘挂载"),rto:"mount_setting/",component:(0,f.jsx)(U,{})}),(0,f.jsx)(i.W1,{optionList:s,father_route:Q.o.setting})}},92350(e,t,s){s.d(t,{Q:()=>h,o:()=>p});var n=s(34843),i=s(82893),a=s(74777),l=s(96540),o=s(22022),r=s(23430),c=s(14284),d=s(74848);function h(){const[e,t]=(0,n.fp)(i.AG.prompt_card),{t:s,i18n:l}=(0,o.Bd)();return e=>{let n;e===a.jk.ffmpeg?n=(0,d.jsx)("div",{children:"视频转换,rtsp播放器等媒体功能都需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置"}):e===a.jk.smartmontools?n=(0,d.jsx)("div",{children:"磁盘检查需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置。"}):"保护目录"===e?n=(0,d.jsxs)("div",{children:["在删除的时候保护目录会拒绝删除。",(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"可以使用 /* 来表达该目录下所有文件都禁止删除"}),(0,d.jsx)("li",{children:"可以使用 /** 来表达该目录下所有子目录文件都禁止删除"})]})]}):"文件夹路径"===e?n=(0,d.jsx)("div",{children:"用于在文件夹下切换根目录"}):"环境路径"===e?n=(0,d.jsx)("div",{children:"当在不同用户环境下运行的时候由于没有执行终端去加载PATH,这里可以添加额外的PATH路径,点击这里的保存还会更新系统上的path路径"}):"pty"===e?n=(0,d.jsx)("div",{children:"一些需要Pty环境的命令"}):"文件上传"===e?n=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"对于不同的目录(包括所有子目录),可能是机械或者固态硬盘,机械硬盘在处理多个小文件的时候会做随机i/o,由于一般只有一个盘头所以会影响整体效率,特别是写操作,这里提供了上传时候的最大数量限制,对于下载数量目前不做限制."}),(0,d.jsx)("li",{children:"大文件支持断点和分块并发传输,建议并发数量设置为2,分块大小设置为10MB,大文件判断为500MB,设置过大的话会上传的时候会占据较大内存"})]})}):"目录快捷命令"===e?n=(0,d.jsx)("div",{children:"右键文件夹空白处用于,打开终端快捷执行命令"}):"文件快捷命令"===e?n=(0,d.jsx)("div",{children:"用于右键特定后缀的文件,执行一些快捷命令,文件后缀可以是多个,用空格分割"}):"Workflow"===e?n=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"在特定的时间启动系统中的workflow任务"}),(0,d.jsx)("li",{children:"cron表达式是定时器 格式为: 秒 分 时 日 月 星期"}),(0,d.jsxs)("li",{children:[(0,d.jsx)("li",{children:'1. "*"(通配符,所有值)'}),(0,d.jsx)("li",{children:'2. "," 是枚举: 0 0 1,15 * * *'}),(0,d.jsx)("li",{children:'3. "-" 是范围: 0 0 1-5 * * *'}),(0,d.jsx)("li",{children:'4. "/" 是步长,标识每隔n执行 */3 * * * * * 每隔三秒,必须配合 * 使用 ,/ 只能写一次 ,有了/就成了定时器,而不是指定时间执行'})]})]})}):"插件配置"===e?n=(0,d.jsx)("div",{children:s("路径可以是一个 js 文件也可以是一个node 项目目录")}):"机器人配置"===e&&(n=(0,d.jsxs)("div",{children:[(0,d.jsx)("dv",{children:"机器人功能用于开通各种第三方支持的机器人,让第三方机器人接入本地的 AI 模型。"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:" 1. qq 机器人需要先在手机 app 中添加,然后在https://q.qq.com/qqbot/ 登录机器人配置页面,在开发管理中复制机器人的 appId,appSecret 到这里就完成了配置了。目前 qq 机器人不稳定,且创建后无法删除(2026.07.05)"}),(0,d.jsx)("li",{children:" 2. https://opensource.dingtalk.com/developerpedia/docs/explore/tutorials/stream/bot/nodejs/create-bot 这个是钉钉机器人开通教程,注意复制钉钉的 clientId 的是时候不要复制成appId 了。"}),(0,d.jsx)("li",{children:" 3. 企业微信机器人的开通甚至不需要 pc 操作,在通讯录中点击智能机器人,选择 api 模式,就创建完成了,手机上直接复制 id 和密钥。"}),(0,d.jsx)("li",{children:" 4. 飞书https://open.feishu.cn/document/develop-an-echo-bot/introduction?from=banner 登录这个开发者后台,按照这个地址教程创建机器人,使用的时候这个机器人是作为一个应用,可以在工作台内搜索你的这个机器人的名字。"})]})]})),t({open:!0,title:"信息",context_div:(0,d.jsx)("div",{children:n})})}}let u=r.Ky;function p(){const[e,t]=(0,l.useState)([]);return(0,l.useEffect)(()=>{(async()=>{try{const e=await c.XO.get("themes");if(0===e.code){const s=e.data||[];u=[...r.Ky,...s],t(u)}else console.warn("获取主题列表失败,使用默认列表"),t(u)}catch(e){t(u)}})()},[]),e}},6960(e,t,s){s.d(t,{s:()=>l});var n=s(72635);const i=1440,a=525600;function l(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<a?`${(s/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(s/a).toFixed(0)} ${n.Ay.t("年前")}`}},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"}]}])}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3528],{48890(e,t,s){s.d(t,{Kw:()=>a,Tt:()=>i});var a=s(80952),i=(s(82327),s(1766),s(24854),s(90008),s(90846),s(40975),s(44286),s(30766),s(14973),s(69687),s(1234),s(47507),s(87268),s(34678),s(24522));const n=`https://gcore.jsdelivr.net/npm/ace-builds@${a.version}/src-min-noconflict/`;a.config.set("basePath",n),a.config.set("modePath",n),a.config.set("themePath",n),a.config.set("workerPath",n)},53528(e,t,s){s.r(t),s.d(t,{default:()=>q});var a=s(96540),i=s(14284),n=s(62042),c=s(22022),l=s(85997),o=s(61443),r=s(57952),d=s(61973),h=s(34289),m=s(87361),_=s(2543),g=s(34251),p=s(47022),u=s(74848);const f={M:{label:"M",cls:"mod"},A:{label:"A",cls:"add"},D:{label:"D",cls:"del"},R:{label:"R",cls:"ren"},C:{label:"C",cls:"ren"},U:{label:"U",cls:"conf"},"?":{label:"?",cls:"untracked"}};function x(e){const t=e.lastIndexOf("/");return-1===t?e:e.substring(t+1)}function j(e){const t={type:"folder",name:"",full_path:"",children:[]};for(const s of e){const e=s.path.split("/").filter(Boolean);let a=t;for(let t=0;t<e.length;t++){const i=e[t],n=t===e.length-1;let c=a.children.find(e=>e.name===i);c||(c={type:n?"file":"folder",name:i,full_path:a.full_path?`${a.full_path}/${i}`:i,children:[]},a.children.push(c)),n&&(c.data=s.data),a=c}}const s=e=>{e.sort((e,t)=>e.type!==t.type?"folder"===e.type?-1:1:e.name.localeCompare(t.name));for(const t of e)t.children.length&&s(t.children)};return s(t.children),t.children}function N(e){const{t}=(0,c.Bd)(),{file:s,staged:a,status:i,selected:n,active:o,leaf:r}=e,d=f[i]??{label:i,cls:"mod"},h=r?s.path.substring(0,s.path.lastIndexOf("/")):"";return(0,u.jsxs)("div",{className:"git-file"+(o?" git-file--active":""),children:[(0,u.jsx)("input",{type:"checkbox",checked:n.has(s.path),onChange:()=>e.on_toggle(s.path),onClick:e=>e.stopPropagation()}),(0,u.jsx)("span",{className:"file-icons",children:(0,u.jsx)("span",{"data-type":(0,g.uL)(s.path),"data-dir":!1,"aria-label":s.path,children:(0,u.jsx)(l.In,{icon:"",aria_label:s.path})})}),(0,u.jsx)("span",{className:"git-file__name",title:s.oldPath?`${s.oldPath} → ${s.path}`:s.path,onClick:()=>e.on_view_diff(s,a),children:r?x(s.path):s.path}),(0,u.jsx)("span",{className:`git-file__badge git-file__badge--${d.cls}`,children:d.label}),h&&(0,u.jsx)("span",{className:"git-file__dir",title:h,children:h}),(0,u.jsxs)("span",{className:"git-file__ops",children:[(0,u.jsx)(l.rA,{icon:"format_list_numbered",title:t("逐行归属"),onClick:()=>e.on_view_blame(s)}),(0,u.jsx)(l.rA,{icon:a?"remove":"add",title:t(a?"取消暂存":"暂存"),onClick:()=>e.on_stage_one(s,a)})]})]})}function v(e){const{node:t,staged:s,file_map:i,prefix:n}=e,[c,o]=(0,a.useState)(!0),r=n?`${n}/${t.name}`:t.name;if("file"===t.type){const t=i.get(r);if(!t)return null;const a=s?t.conflicted?"U":t.index:t.untracked?"?":t.conflicted?"U":t.worktree;return(0,u.jsx)(N,{file:t,staged:s,status:a,selected:e.selected,active:e.active_path===t.path,leaf:!0,on_toggle:e.on_toggle,on_view_diff:e.on_view_diff,on_stage_one:e.on_stage_one,on_view_blame:e.on_view_blame})}return(0,u.jsxs)("div",{className:"git-tree__folder",children:[(0,u.jsxs)("div",{className:"git-tree__dir",onClick:()=>o(!c),children:[(0,u.jsx)("i",{className:"material-icons git-tree__arrow","data-icon":c?"arrow_drop_down":"arrow_right",children:c?"arrow_drop_down":"arrow_right"}),(0,u.jsx)("span",{className:"file-icons",children:(0,u.jsx)("span",{"data-type":p.Iw.folder,"data-dir":!0,"aria-label":t.name,children:(0,u.jsx)(l.In,{icon:"",aria_label:t.name})})}),(0,u.jsx)("span",{className:"git-tree__dir-name",children:t.name})]}),c&&(0,u.jsx)("div",{className:"git-tree__children",children:t.children?.map((t,a)=>(0,u.jsx)(v,{node:t,staged:s,file_map:i,prefix:r,selected:e.selected,active_path:e.active_path,on_toggle:e.on_toggle,on_view_diff:e.on_view_diff,on_stage_one:e.on_stage_one,on_view_blame:e.on_view_blame},a))})]})}function y(e){const{t}=(0,c.Bd)(),{title:s,files:i,staged:n,selected:l}=e,o=(0,a.useMemo)(()=>i.map(e=>e.path),[i]),r=o.filter(e=>l.has(e)).length,d=i.length>0&&r===i.length,h=r>0&&!d,m=(0,a.useMemo)(()=>{const e=new Map;for(const t of i)e.set(t.path,t);return e},[i]),_=(0,a.useMemo)(()=>e.tree_mode?function(e){const t=j(e.map(e=>({path:e.path,data:e}))),s=e=>({type:e.type,name:e.name,size:0,children:e.children.length?e.children.map(s):void 0});return t.map(s)}(i):[],[i,e.tree_mode]);return 0===i.length?null:(0,u.jsxs)("div",{className:"git-section",children:[(0,u.jsxs)("div",{className:"git-section__header",children:[(0,u.jsx)("input",{type:"checkbox",checked:d,ref:e=>{e&&(e.indeterminate=h)},onChange:()=>e.on_toggle_all(o,!d)}),(0,u.jsxs)("span",{className:"git-section__title",children:[s," (",i.length,")"]}),(0,u.jsx)("span",{className:"git-section__action",onClick:()=>e.on_stage_section(i,n),children:t(n?"全部取消暂存":"全部暂存")})]}),e.tree_mode?(0,u.jsx)("div",{className:"git-tree",children:_.map((t,s)=>(0,u.jsx)(v,{node:t,staged:n,file_map:m,prefix:"",selected:e.selected,active_path:e.active_path,on_toggle:e.on_toggle,on_view_diff:e.on_view_diff,on_stage_one:e.on_stage_one,on_view_blame:e.on_view_blame},s))}):i.map(t=>(0,u.jsx)(N,{file:t,staged:n,status:e.status_of(t),selected:e.selected,active:e.active_path===t.path,leaf:!0,on_toggle:e.on_toggle,on_view_diff:e.on_view_diff,on_stage_one:e.on_stage_one,on_view_blame:e.on_view_blame},t.path+(n?"_s":"_w")))]})}function b(e){const{t}=(0,c.Bd)(),{files:s}=e,[i,n]=(0,a.useState)(!1),o=s.filter(e=>e.staged),r=s.filter(e=>e.untracked||" "!==e.worktree),d={selected:e.selected,on_toggle:e.on_toggle,on_toggle_all:e.on_toggle_all,active_path:e.active_path,tree_mode:i,on_view_diff:e.on_view_diff,on_stage_section:e.on_stage_section,on_stage_one:e.on_stage_one,on_view_blame:e.on_view_blame};return(0,u.jsxs)("div",{className:"git-change-list",children:[(0,u.jsx)("div",{className:"git-change-toolbar",children:(0,u.jsx)(l.rA,{icon:"account_tree",title:t("树形展示"),selected:i,onClick:()=>n(!i)})}),(0,u.jsx)(y,{title:t("已暂存的更改"),files:o,staged:!0,status_of:e=>e.conflicted?"U":e.index,...d}),(0,u.jsx)(y,{title:t("更改"),files:r,staged:!1,status_of:e=>e.untracked?"?":e.conflicted?"U":e.worktree,...d}),0===s.length&&(0,u.jsx)("div",{className:"git-change-empty",children:t("没有已更改的文件")})]})}var w=s(48890);function k({valueA:e,valueB:t,mode:s="split",theme:i,filename:n}){const c=(0,a.useRef)(null),l=(0,a.useRef)(null),o=(0,a.useMemo)(()=>n&&w.Tt.getModeForPath(n).mode||"ace/mode/text",[n]);return(0,a.useEffect)(()=>{const a=c.current;if(!a)return;const n=w.Kw.require("ace/ext/diff"),r={valueA:e??"",valueB:t??"",diffProvider:new n.DiffProvider},d="inline"===s,h=d?new n.InlineDiffView({...r,inline:"a"},a):new n.SplitDiffView(r);d||(h.container=a,a.appendChild(h.editorA.container),a.appendChild(h.editorB.container)),i&&h.setTheme(i),h.editorA?.session.setMode(o),h.editorB?.session.setMode(o),h.onInput(),h.foldUnchanged();const m=requestAnimationFrame(()=>{h.editorA?.resize(!0),h.editorB?.resize(!0)});return l.current=h,()=>{cancelAnimationFrame(m);try{h.destroy()}catch(e){}l.current=null,a.innerHTML=""}},[e,t,s,i,o]),(0,u.jsx)("div",{className:"ace-diff",ref:c})}const S={text:"",binary:!1,exists:!1};function C({dir_path:e,file:t,left_ref:s,right_ref:n,mode:l="unified"}){const{t:o}=(0,c.Bd)(),[r,d]=(0,a.useState)(S),[h,m]=(0,a.useState)(S),[_,g]=(0,a.useState)(!1),[p,f]=(0,a.useState)(""),x=(0,a.useRef)(0);return(0,a.useEffect)(()=>{const a=++x.current;g(!0),f("");const c=s=>i.TU.post("file_content",{path:e,file:t,ref:s});Promise.all([c(s),c(n)]).then(([e,t])=>{a===x.current&&(d(0===e.code?e.data:S),m(0===t.code?t.data:S))}).catch(e=>{a===x.current&&(f("string"==typeof e?e:e?.message||""),d(S),m(S))}).finally(()=>{a===x.current&&g(!1)})},[e,t,s,n]),_?(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:o("加载中")})}):p?(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:p})}):r.binary||h.binary?(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:o("二进制文件无法比较")})}):r.text===h.text?(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:o("无差异")})}):(0,u.jsx)(k,{valueA:r.text??"",valueB:h.text??"",mode:"split"===l?"split":"inline",filename:t})}function z({dir_path:e,entries:t,is_search:s,has_more:o,loading_more:r,active_hash:d,on_select:h,on_scroll_bottom:m,on_search_result:_}){const{t:g}=(0,c.Bd)(),[p,f]=(0,a.useState)(!1),[x,j]=(0,a.useState)(""),[N,v]=(0,a.useState)(""),[y,b]=(0,a.useState)(!1),{rows:w,width:k}=function(e){const t=[],s=[];let a=1;for(const i of e){let e=t.indexOf(i.hash);e<0&&(e=t.indexOf(null),e<0&&(e=t.length,t.push(null)));const n=i.parents||[],c=[];for(const s of n)s&&t.forEach((a,i)=>{i!==e&&a===s&&(c.push(i),t[i]=null)});const l=[];t.forEach((t,s)=>{null===t||s===e||c.includes(s)||l.push(s)}),t[e]=n[0]??null;const o=[e];for(const e of n.slice(1)){let s=t.indexOf(e);s<0&&(s=t.indexOf(null),s<0&&(s=t.length,t.push(null)),t[s]=e),o.push(s)}for(;t.length&&null===t[t.length-1];)t.pop();s.push({column:e,pass_through:l,out_edges:o,merge_in:c}),a=Math.max(a,t.length,e+1,...o.map(e=>e+1))}return{rows:s,width:a}}(s?[]:t),S=async()=>{if(x.trim()||N.trim()){b(!0);try{const t=await i.TU.post("search_commit",{path:e,keyword:x.trim(),author:N.trim(),maxCount:100});0===t.code?_(t.data||[]):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{b(!1)}}else(0,n.zN)(g("请输入搜索条件"))},C=(e,t,s)=>{const a=39,i=12,n=s?i:-2,c=e=>16*e+8,l=c(e.column),o=[];for(const t of e.pass_through)o.push((0,u.jsx)("line",{x1:c(t),y1:n,x2:c(t),y2:41,className:"git-log__graph-edge"},`p${t}`));for(const[t,a]of e.merge_in.entries()){const e=c(a);s||o.push((0,u.jsx)("path",{fill:"none",d:`M ${e} -2 C ${e} 19.5 ${l} 19.5 ${l} 12`,className:"git-log__graph-edge"},`m${t}`))}for(const[t,s]of e.out_edges.entries())if(s===e.column)o.push((0,u.jsx)("line",{x1:l,y1:n,x2:l,y2:41,className:"git-log__graph-edge"},`o${t}`));else{const e=c(s);o.push((0,u.jsx)("path",{fill:"none",d:`M ${l} 12 C ${l} 25.5 ${e} 25.5 ${e} 39`,className:"git-log__graph-edge"},`o${t}`))}return(0,u.jsx)("div",{className:"git-log__graph",children:(0,u.jsxs)("svg",{width:16*k,height:a,overflow:"visible",children:[o,(0,u.jsx)("circle",{cx:l,cy:i,r:3.5,className:"git-log__graph-dot"+(t?" git-log__graph-dot--unpushed":"")})]})})};return(0,u.jsxs)("div",{className:"git-log-wrap",children:[(0,u.jsxs)("div",{className:"git-log-search",children:[(0,u.jsx)(l.rA,{icon:"search",title:g("搜索提交"),onClick:()=>{p?(j(""),v(""),_(null),f(!1)):f(!0)}}),p&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{className:"input input--block",autoFocus:!0,value:x,placeholder:g("提交信息关键词"),onChange:e=>j(e.target.value),onKeyDown:e=>"Enter"===e.key&&S()}),(0,u.jsx)("input",{className:"input input--block",value:N,placeholder:g("作者"),onChange:e=>v(e.target.value),onKeyDown:e=>"Enter"===e.key&&S()}),(0,u.jsx)(l.rA,{icon:"check",title:g("搜索"),onClick:S})]})]}),(0,u.jsxs)("div",{className:"git-log",onScroll:m,children:[y&&(0,u.jsx)("div",{className:"git-change-empty",children:g("加载中")}),!y&&0===t.length&&(0,u.jsx)("div",{className:"git-change-empty",children:g("暂无提交记录")}),!y&&t.map((e,t)=>(0,u.jsxs)("div",{className:`git-log__entry${d===e.hash?" git-log__entry--active":""}${e.unpushed?" git-log__entry--unpushed":""}`,onClick:()=>h(e.hash),children:[!s&&C(w[t],!!e.unpushed,0===t),(0,u.jsxs)("div",{className:"git-log__main",children:[(0,u.jsxs)("div",{className:"git-log__row",children:[e.unpushed&&(0,u.jsx)("span",{className:"git-log__unpushed",title:g("未推送")}),(0,u.jsx)("span",{className:"git-log__hash",children:e.hash}),(e.refs||[]).map(e=>(0,u.jsx)("span",{className:"git-log__ref"+(e.includes("HEAD")?" git-log__ref--head":""),children:e.replace("HEAD -> ","")},e)),(0,u.jsx)("span",{className:"git-log__msg",title:e.message,children:e.message})]}),(0,u.jsxs)("div",{className:"git-log__meta",children:[e.author," · ",e.date]})]})]},e.hash)),!y&&!s&&r&&(0,u.jsx)("div",{className:"git-log__more",children:g("加载中")}),!y&&!s&&!r&&!o&&t.length>0&&(0,u.jsx)("div",{className:"git-log__more",children:g("已到底部")})]})]})}var A=s(45907);function $({nodes:e,selected:t,on_select:s}){const[i,n]=(0,a.useState)(new Set),c=e=>e.map(e=>{if("folder"===e.type){const t=!i.has(e.full_path);return(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"git-commit-tree__dir",onClick:()=>{return t=e.full_path,void n(e=>{const s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s});var t},children:[(0,u.jsx)("i",{className:"material-icons git-tree__arrow",children:t?"arrow_drop_down":"arrow_right"}),(0,u.jsx)("span",{className:"file-icons",children:(0,u.jsx)("span",{"data-type":p.Iw.folder,"data-dir":!0,"aria-label":e.name,children:(0,u.jsx)(l.In,{icon:"",aria_label:e.name})})}),(0,u.jsx)("span",{className:"git-commit-tree__dir-name",children:e.name})]}),t&&(0,u.jsx)("div",{className:"git-commit-tree__children",children:c(e.children)})]},e.full_path)}const a=e.data;return(0,u.jsxs)("div",{className:"git-commit-file git-commit-file--leaf"+(t===e.full_path?" git-commit-file--active":""),onClick:()=>s(e.full_path),title:e.full_path,children:[(0,u.jsx)("span",{className:"file-icons",children:(0,u.jsx)("span",{"data-type":(0,g.uL)(e.name),"aria-label":e.name,children:(0,u.jsx)(l.In,{icon:"",aria_label:e.name})})}),(0,u.jsx)("span",{className:"git-commit-file__name",children:e.name}),a&&null!==a.additions&&(0,u.jsxs)("span",{className:"git-commit-file__stat",children:[(0,u.jsxs)("span",{className:"git-stat--add",children:["+",a.additions]}),(0,u.jsxs)("span",{className:"git-stat--del",children:["-",a.deletions]})]})]},e.full_path)});return(0,u.jsx)(u.Fragment,{children:c(e)})}function U({dir_path:e,hash:t,on_close:s,on_changed:o}){const{t:r}=(0,c.Bd)(),d=(0,A.y)(),[h,m]=(0,a.useState)(null),[_,g]=(0,a.useState)(null),[p,f]=(0,a.useState)("unified"),[x,N]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(g(null),y(!1),w())},[t,e]);const b=(0,a.useMemo)(()=>j((h?.files??[]).map(e=>({path:e.path,data:e}))),[h]),w=async()=>{try{const s=await i.TU.post("commit_detail",{path:e,hash:t});0===s.code?m(s.data):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}};if(!h)return(0,u.jsx)("div",{className:"git-card git-card--diff",children:(0,u.jsx)("div",{className:"git-change-empty",children:r("加载中")})});return(0,u.jsxs)("div",{className:"git-card git-card--diff",children:[(0,u.jsxs)("div",{className:"git-commit-meta",children:[(0,u.jsxs)("div",{className:"git-commit-meta__row",children:[(0,u.jsx)("span",{className:"git-commit-meta__hash",children:h.short_hash}),(0,u.jsx)("span",{className:"git-commit-meta__subject",title:h.subject,children:h.subject}),_&&(0,u.jsx)(l.rA,{icon:"compare_arrows",title:r("与工作区对比"),onClick:()=>{_?y(!0):(0,n.zN)(r("请先选择文件"))}}),(0,u.jsx)(l.rA,{icon:"undo",title:r("撤销提交"),onClick:()=>{d({title:r("撤销提交"),sub_title:`${r("将生成一个反向提交来撤销")} ${h.short_hash} ?`,confirm_fun:async()=>{try{const s=await i.TU.post("revert",{path:e,hash:t});0===s.code?((0,n.SK)(r("已撤销")),o?.()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}}})}}),(0,u.jsx)(l.rA,{icon:"content_cut",title:r("摘取提交"),onClick:()=>{d({title:r("摘取提交"),sub_title:`${r("将该提交应用到当前分支")} ${h.short_hash} ?`,confirm_fun:async()=>{try{const s=await i.TU.post("cherry_pick",{path:e,hash:t});0===s.code?((0,n.SK)(r("摘取成功")),o?.()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}}})}}),(0,u.jsx)(l.rA,{icon:"close",title:r("关闭"),onClick:s})]}),(0,u.jsxs)("div",{className:"git-commit-meta__sub",children:[h.author," <",h.email,"> · ",h.date]})]}),(0,u.jsxs)("div",{className:"git-commit-body",children:[(0,u.jsxs)("div",{className:"git-commit-files",children:[(0,u.jsxs)("div",{className:"git-commit-file__count",children:[r("全部文件")," (",h.files.length,")"]}),(0,u.jsx)($,{nodes:b,selected:_,on_select:e=>{g(e),y(!1)}})]}),(0,u.jsxs)("div",{className:"git-commit-diff",children:[(0,u.jsxs)("div",{className:"git-diff-header",children:[(0,u.jsx)("span",{className:"git-diff-header__badge",children:v?r("与工作区对比"):`${r("提交")} ${h.short_hash}`}),(0,u.jsx)("span",{className:"git-diff-header__path",title:_??"",children:_??`${r("全部文件")} (${h.files.length})`}),(0,u.jsxs)("div",{className:"git-diff-header__modes",children:[(0,u.jsx)(l.rA,{icon:"view_agenda",title:r("单栏"),selected:"unified"===p,onClick:()=>f("unified")}),(0,u.jsx)(l.rA,{icon:"view_column",title:r("并排"),selected:"split"===p,onClick:()=>f("split")})]})]}),_?v?(0,u.jsx)(C,{dir_path:e,file:_,left_ref:t,right_ref:"worktree",mode:p}):(0,u.jsx)(C,{dir_path:e,file:_,left_ref:`${t}^`,right_ref:t,mode:p}):(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:r("请选择文件查看改动")})})]})]})]})}function T(e){let t=0;for(let s=0;s<e.length;s++)t+=e.charCodeAt(s);return`hsl(${t%360}, 55%, 45%)`}function K({dir_path:e,file:t,on_close:s}){const{t:o}=(0,c.Bd)(),[r,d]=(0,a.useState)([]),[h,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&_()},[t,e]);const _=async()=>{m(!0);try{const s=await i.TU.post("blame",{path:e,file:t});0===s.code?d(s.data||[]):((0,n.zN)(s.message),d([]))}catch(e){(0,n.zN)(e?.message),d([])}finally{m(!1)}};return(0,u.jsxs)("div",{className:"git-card git-card--diff",children:[(0,u.jsxs)("div",{className:"git-diff-header",children:[(0,u.jsx)("span",{className:"git-diff-header__badge",children:o("逐行归属")}),(0,u.jsx)("span",{className:"git-diff-header__path",title:t,children:t}),(0,u.jsx)("div",{className:"git-diff-header__modes",children:(0,u.jsx)(l.rA,{icon:"close",title:o("关闭"),onClick:s})})]}),h&&(0,u.jsx)("div",{className:"git-change-empty",children:o("加载中")}),!h&&0===r.length&&(0,u.jsx)("div",{className:"git-change-empty",children:o("无法读取该文件的归属信息")}),!h&&r.length>0&&(0,u.jsx)("div",{className:"git-blame",children:r.map((e,t)=>(0,u.jsxs)("div",{className:"git-blame__row",children:[(0,u.jsx)("span",{className:"git-blame__hash",title:e.hash,children:e.hash}),(0,u.jsx)("span",{className:"git-blame__author",style:{color:T(e.author)},title:`${e.author} · ${e.date}`,children:e.author}),(0,u.jsx)("span",{className:"git-blame__date",children:e.date}),(0,u.jsx)("span",{className:"git-blame__num",children:e.line_num}),(0,u.jsx)("span",{className:"git-blame__code",children:e.text||" "})]},t))})]})}function E({current:e,branches:t,on_checkout:s,on_create:i,on_delete:n,on_merge:o,ahead:r,behind:d}){const{t:h}=(0,c.Bd)(),m=(0,A.y)(),[_,g]=(0,a.useState)(!1),[p,f]=(0,a.useState)(""),x=()=>{const e=p.trim();e&&(i(e),f(""),g(!1))};return(0,u.jsxs)("div",{className:"git-branch-row",children:[(0,u.jsxs)("span",{className:"git-branch__name",children:[h("分支"),": ",e]}),(r>0||d>0)&&(0,u.jsxs)("span",{className:"git-branch__counts",children:[r>0&&(0,u.jsxs)("span",{className:"git-ahead",title:h("领先上游"),children:["↑",r]}),d>0&&(0,u.jsxs)("span",{className:"git-behind",title:h("落后上游"),children:["↓",d]})]}),(0,u.jsx)("div",{className:"git-branch__list",children:t.map(t=>{const a=t===e;return(0,u.jsxs)("div",{className:"git-branch-chip"+(a?" git-branch-chip--current":""),onClick:()=>!a&&s(t),title:a?h("当前分支"):`${h("切换到")} ${t}`,children:[t,!a&&(0,u.jsxs)("span",{className:"git-branch-chip__ops",children:[(0,u.jsx)("span",{className:"git-branch-chip__op",title:h("合并到此分支"),onClick:e=>{e.stopPropagation(),o(t)},children:"⇥"}),(0,u.jsx)("span",{className:"git-branch-chip__op",title:h("删除分支"),onClick:e=>{var s;e.stopPropagation(),s=t,m({title:h("删除分支"),sub_title:`${h("确认删除分支")} ${s} ?`,confirm_fun:()=>n(s,!1)})},children:"×"})]})]},t)})}),_?(0,u.jsxs)("span",{className:"git-branch-new",children:[(0,u.jsx)("input",{className:"input input--block",autoFocus:!0,value:p,placeholder:h("新分支名"),onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"===e.key&&(g(!1),f(""))}}),(0,u.jsx)(l.rA,{icon:"check",title:h("确定"),onClick:x}),(0,u.jsx)(l.rA,{icon:"close",title:h("取消"),onClick:()=>{g(!1),f("")}})]}):(0,u.jsx)(l.rA,{icon:"add",title:h("新建分支"),onClick:()=>g(!0)})]})}function B(e){const{t}=(0,c.Bd)(),{dir_path:s,user_config:r,proxy_config:d}=e,[h,m]=(0,a.useState)(!1),[_,g]=(0,a.useState)(r.name),[p,f]=(0,a.useState)(r.email),[x,j]=(0,a.useState)(!1),[N,v]=(0,a.useState)(d?.global.http||""),[y,b]=(0,a.useState)(d?.global.https||""),[w,k]=(0,a.useState)(d?.local.http||""),[S,C]=(0,a.useState)(d?.local.https||"");return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"git-config-row",children:[(0,u.jsx)("span",{className:"git-config__label",children:t("用户配置")}),h?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:_,placeholder:"user.name",handleInputChange:e=>g(e)}),(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:p,placeholder:"user.email",handleInputChange:e=>f(e)}),(0,u.jsx)(l.rA,{icon:"check",title:t("保存"),onClick:async()=>{try{const a=await i.TU.post("set_user_config",{path:s,name:_,email:p});0===a.code?((0,n.SK)(t("用户配置已保存")),m(!1),e.on_user_config_saved({name:_,email:p})):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}}}),(0,u.jsx)(l.rA,{icon:"close",title:t("取消"),onClick:()=>m(!1)})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{className:"git-config__value",children:[r.name," / ",r.email]}),(0,u.jsx)(l.rA,{icon:"edit",title:t("编辑"),onClick:()=>{g(r.name),f(r.email),m(!0)}})]})]}),(0,u.jsxs)("div",{className:"git-config-row",children:[(0,u.jsx)("span",{className:"git-config__label",children:t("代理配置")}),x?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:N,placeholder:"global http",handleInputChange:e=>v(e)}),(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:y,placeholder:"global https",handleInputChange:e=>b(e)}),(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:w,placeholder:"local http",handleInputChange:e=>k(e)}),(0,u.jsx)(o.Sm,{maxWidth:"15rem",value:S,placeholder:"local https",handleInputChange:e=>C(e)}),(0,u.jsx)(l.rA,{icon:"check",title:t("保存"),onClick:async()=>{const a=[{scope:"global",type:"http",value:N},{scope:"global",type:"https",value:y},{scope:"local",type:"http",value:w},{scope:"local",type:"https",value:S}];try{for(const e of a)await i.TU.post("set_proxy",{path:s,...e});(0,n.SK)(t("代理配置已保存")),j(!1),e.on_proxy_saved({global:{http:N,https:y},local:{http:w,https:S}})}catch(e){(0,n.zN)(e?.message)}}}),(0,u.jsx)(l.rA,{icon:"close",title:t("取消"),onClick:()=>j(!1)})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"git-config__value",children:(()=>{if(!d)return"-";const e=d.global;if(e.http||e.https)return`global ${e.http||e.https}`;const t=d.local;return t.http||t.https?`local ${t.http||t.https}`:"-"})()}),(0,u.jsx)(l.rA,{icon:"edit",title:t("编辑"),onClick:()=>{v(d?.global.http||""),b(d?.global.https||""),k(d?.local.http||""),C(d?.local.https||""),j(!0)}})]})]})]})}function F({dir_path:e,target_hash:t,on_changed:s}){const{t:o}=(0,c.Bd)(),r=(0,A.y)(),[d,h]=(0,a.useState)([]),[m,_]=(0,a.useState)(!1),[g,p]=(0,a.useState)(""),[f,x]=(0,a.useState)(""),[j,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{v()},[e]);const v=async()=>{try{const t=await i.TU.post("tags",{path:e});0===t.code&&h(t.data||[])}catch(e){}};return(0,u.jsxs)("div",{className:"git-sub-panel",children:[(0,u.jsxs)("div",{className:"git-sub-panel__header",children:[(0,u.jsxs)("span",{className:"git-sub-panel__title",children:[o("标签")," (",d.length,")"]}),(0,u.jsx)(l.rA,{icon:"add",title:o("新建标签"),onClick:()=>_(!m)})]}),m&&(0,u.jsxs)("div",{className:"git-sub-panel__form",children:[(0,u.jsx)("input",{className:"input input--block",autoFocus:!0,value:g,placeholder:o("标签名"),onChange:e=>p(e.target.value)}),(0,u.jsx)("input",{className:"input input--block",value:f,placeholder:o("备注"),onChange:e=>x(e.target.value)}),(0,u.jsxs)("div",{className:"git-sub-panel__form-actions",children:[(0,u.jsx)("span",{className:"git-sub-panel__hint",children:t?`${o("基于提交")} ${t}`:o("基于当前提交")}),(0,u.jsx)(l.rA,{icon:"check",title:o("保存"),onClick:async()=>{const a=g.trim();if(a){N(!0);try{const c=await i.TU.post("tag_create",{path:e,name:a,message:f.trim(),hash:t});0===c.code?((0,n.SK)(o("标签创建成功")),p(""),x(""),_(!1),await v(),s()):(0,n.zN)(c.message)}catch(e){(0,n.zN)(e?.message)}finally{N(!1)}}else(0,n.zN)(o("请输入标签名"))}}),(0,u.jsx)(l.rA,{icon:"close",title:o("取消"),onClick:()=>{_(!1),p(""),x("")}})]})]}),(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===d.length&&(0,u.jsx)("div",{className:"git-change-empty",children:o("暂无标签")}),d.map(t=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:t.name,children:t.name}),(0,u.jsx)("span",{className:"git-sub-item__desc",title:t.message,children:t.message}),(0,u.jsx)("span",{className:"git-sub-item__meta",children:t.date}),(0,u.jsxs)("span",{className:"git-sub-item__ops",children:[(0,u.jsx)(l.rA,{icon:"upload",title:o("推送到远程"),onClick:()=>(async t=>{try{const s=await i.TU.post("tag_push",{path:e,name:t});0===s.code?(0,n.SK)(o("标签推送成功")):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}})(t.name)}),(0,u.jsx)(l.rA,{icon:"delete",title:o("删除标签"),onClick:()=>{return s=t.name,void r({title:o("删除标签"),sub_title:`${o("确认删除标签")} ${s} ?`,confirm_fun:async()=>{try{const t=await i.TU.post("tag_delete",{path:e,name:s});0===t.code?((0,n.SK)(o("标签删除成功")),await v()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}}});var s}})]})]},t.name))]})]})}function I({dir_path:e,on_changed:t}){const{t:s}=(0,c.Bd)(),o=(0,A.y)(),[r,d]=(0,a.useState)([]),[h,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{h&&_()},[e,h]);const _=async()=>{try{const t=await i.TU.post("stash_list",{path:e});0===t.code&&d(t.data||[])}catch(e){}},g=async(a,c)=>{try{const l=await i.TU.post("stash_apply",{path:e,ref:a,pop:c});0===l.code?((0,n.SK)(s(c?"已恢复并删除记录":"已应用")),await _(),t()):(0,n.zN)(l.message)}catch(e){(0,n.zN)(e?.message)}};return(0,u.jsxs)("div",{className:"git-stash",children:[(0,u.jsx)("div",{className:"git-sub-panel__header",children:(0,u.jsxs)("span",{className:"git-sub-panel__title",onClick:()=>m(!h),style:{cursor:"pointer"},children:[s("暂存工作区记录")," ",h?"▾":"▸"]})}),h&&(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===r.length&&(0,u.jsx)("div",{className:"git-change-empty",children:s("暂无记录")}),r.map(t=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:t.message,children:t.message}),(0,u.jsx)("span",{className:"git-sub-item__meta",children:t.date}),(0,u.jsxs)("span",{className:"git-sub-item__ops",children:[(0,u.jsx)(l.rA,{icon:"play_arrow",title:s("应用"),onClick:()=>g(t.ref,!1)}),(0,u.jsx)(l.rA,{icon:"unarchive",title:s("恢复并删除"),onClick:()=>g(t.ref,!0)}),(0,u.jsx)(l.rA,{icon:"delete",title:s("删除"),onClick:()=>{return a=t.ref,void o({title:s("删除记录"),sub_title:`${s("确认删除")} ${a} ?`,confirm_fun:async()=>{try{const t=await i.TU.post("stash_drop",{path:e,ref:a});0===t.code?((0,n.SK)(s("已删除")),await _()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}}});var a}})]})]},t.ref))]})]})}function M({dir_path:e,current_branch:t,on_checkout:s,on_compare:r}){const{t:d}=(0,c.Bd)(),h=(0,A.y)(),[m,_]=(0,a.useState)([]),[g,p]=(0,a.useState)([]),[f,x]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,y]=(0,a.useState)(null),[b,w]=(0,a.useState)("");(0,a.useEffect)(()=>{f&&k()},[e,f]);const k=async()=>{try{const t=await i.TU.post("remote_branches",{path:e});0===t.code&&(_(t.data?.branches||[]),p(t.data?.remotes||[]))}catch(e){}},S=async t=>{N(!0);try{const s=await i.TU.post("fetch",{path:e,prune:t});0===s.code?((0,n.SK)(d("拉取完成")),await k()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{N(!1)}},C=async()=>{const t=v;if(t&&b.trim()){N(!0);try{const a=await i.TU.post("remote_branch_rename",{path:e,branch:t,new_name:b.trim()});0===a.code?((0,n.SK)(d("重命名成功")),y(null),await k(),s()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{N(!1)}}};return(0,u.jsxs)("div",{className:"git-remote",children:[(0,u.jsxs)("div",{className:"git-sub-panel__header",children:[(0,u.jsxs)("span",{className:"git-sub-panel__title",onClick:()=>x(!f),children:[d("远程分支")," (",m.length,") ",f?"▾":"▸"]}),(0,u.jsx)(l.rA,{icon:"cloud_download",title:d("拉取远程信息"),onClick:()=>S(!1)}),(0,u.jsx)(l.rA,{icon:"cleaning_services",title:d("拉取并清理已删除分支"),onClick:()=>S(!0)})]}),f&&(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===g.length&&(0,u.jsx)("div",{className:"git-change-empty",children:d("未配置远程仓库")}),m.map(c=>(0,u.jsxs)(a.Fragment,{children:[(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:c.name,children:c.name}),(0,u.jsx)("span",{className:"git-sub-item__meta",children:c.date}),(0,u.jsxs)("span",{className:"git-sub-item__ops",children:[(0,u.jsx)(l.rA,{icon:"call_split",title:d("签出到本地"),onClick:()=>(async t=>{N(!0);try{const a=await i.TU.post("checkout_remote",{path:e,branch:t});0===a.code?((0,n.SK)(d("切换分支成功")),s()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{N(!1)}})(c.name)}),(0,u.jsx)(l.rA,{icon:"compare_arrows",title:d("与当前分支比较"),onClick:()=>r(c.name)}),(0,u.jsx)(l.rA,{icon:"merge",title:d("合并到当前分支"),onClick:()=>(async a=>{h({title:d("合并到当前分支"),sub_title:`${d("将")} ${a} ${d("合并到")} ${t} ?`,confirm_fun:async()=>{try{const t=await i.TU.post("merge",{path:e,branch:a});0===t.code?((0,n.SK)(d("合并成功")),s()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}}})})(c.name)}),(0,u.jsx)(l.rA,{icon:"drive_file_rename_outline",title:d("重命名"),onClick:()=>(e=>{const t=e.indexOf("/"),s=t>=0?e.substring(t+1):e;w(s),y(e)})(c.name)}),(0,u.jsx)(l.rA,{icon:"delete",title:d("删除"),onClick:()=>{return t=c.name,void h({title:d("删除远程分支"),sub_title:`${d("确认删除远程分支")} ${t} ? ${d("该分支会从远程仓库删除")}`,confirm_fun:async()=>{try{const s=await i.TU.post("remote_branch_delete",{path:e,branch:t});0===s.code?((0,n.SK)(d("删除成功")),await k()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}}});var t}})]})]}),v===c.name&&(0,u.jsxs)("div",{className:"git-remote__rename",children:[(0,u.jsx)(o.Sm,{value:b,width:"12rem",handleInputChange:e=>w(e)}),(0,u.jsx)(l.rA,{icon:"check",title:d("确定"),onClick:C}),(0,u.jsx)(l.rA,{icon:"close",title:d("取消"),onClick:()=>y(null)})]})]},c.name))]})]})}function P({dir_path:e,branch:t,current_branch:s,on_close:o}){const{t:r}=(0,c.Bd)(),[d,h]=(0,a.useState)([]),[m,_]=(0,a.useState)(null),[g,p]=(0,a.useState)("unified"),[f,x]=(0,a.useState)(!0);(0,a.useEffect)(()=>{_(null),N()},[e,t,s]);const N=async()=>{x(!0);try{const a=await i.TU.post("diff_files",{path:e,from:s,to:t});0===a.code?h(a.data||[]):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{x(!1)}},v=(0,a.useMemo)(()=>j(d.map(e=>({path:e.path,data:e}))),[d]);return(0,u.jsxs)("div",{className:"git-card git-card--diff",children:[(0,u.jsxs)("div",{className:"git-diff-header",children:[(0,u.jsx)("span",{className:"git-diff-header__badge",children:r("分支比较")}),(0,u.jsxs)("span",{className:"git-diff-header__path",title:`${s} ↔ ${t}`,children:[s," ↔ ",t]}),m&&(0,u.jsxs)("div",{className:"git-diff-header__modes",children:[(0,u.jsx)(l.rA,{icon:"view_agenda",title:r("单栏"),selected:"unified"===g,onClick:()=>p("unified")}),(0,u.jsx)(l.rA,{icon:"view_column",title:r("并排"),selected:"split"===g,onClick:()=>p("split")})]}),(0,u.jsx)(l.rA,{icon:"close",title:r("关闭"),onClick:o})]}),(0,u.jsxs)("div",{className:"git-commit-body",children:[(0,u.jsxs)("div",{className:"git-commit-files",children:[(0,u.jsxs)("div",{className:"git-commit-file__count",children:[r("全部文件")," (",d.length,")"]}),(0,u.jsx)($,{nodes:v,selected:m,on_select:_})]}),(0,u.jsx)("div",{className:"git-commit-diff",children:f?(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:r("加载中")})}):m?(0,u.jsx)(C,{dir_path:e,file:m,left_ref:s,right_ref:t,mode:g}):(0,u.jsx)("div",{className:"git-diff-empty",children:(0,u.jsx)("span",{children:r("请选择文件查看改动")})})})]})]})}function D({dir_path:e,on_resolved:t}){const{t:s}=(0,c.Bd)(),o=(0,A.y)(),[r,d]=(0,a.useState)([]),[h,m]=(0,a.useState)("");(0,a.useEffect)(()=>{_()},[e]);const _=async()=>{try{const t=await i.TU.post("conflicts",{path:e});0===t.code&&(d(t.data?.files||[]),m(t.data?.state||""))}catch(e){}},g=async(a,c)=>{try{const l=await i.TU.post("resolve",{path:e,file:a,side:c});0===l.code?((0,n.SK)(s("已解决冲突")),await _(),t()):(0,n.zN)(l.message)}catch(e){(0,n.zN)(e?.message)}};return 0===r.length?null:(0,u.jsxs)("div",{className:"git-card git-conflict",children:[(0,u.jsxs)("div",{className:"git-sub-panel__header",children:[(0,u.jsxs)("span",{className:"git-sub-panel__title",children:[s("冲突")," (",r.length,")",h&&(0,u.jsx)("span",{className:"git-conflict__state",children:h})]}),(0,u.jsx)(l.rA,{icon:"done_all",title:s("标记全部已解决"),onClick:async()=>{try{const a=await i.TU.post("conflict_action",{path:e,action:"merge_continue"});0===a.code?((0,n.SK)(s("合并已完成")),t()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}}}),(0,u.jsx)(l.rA,{icon:"undo",title:s("放弃合并"),onClick:()=>{const a="rebase"===h?"rebase_abort":"cherry-pick"===h?"cherry_pick_abort":"revert"===h?"revert_abort":"merge_abort";o({title:s("放弃合并"),sub_title:s("确认放弃当前合并并恢复到操作前状态"),confirm_fun:async()=>{try{const c=await i.TU.post("conflict_action",{path:e,action:a});0===c.code?((0,n.SK)(s("已放弃合并")),t()):(0,n.zN)(c.message)}catch(e){(0,n.zN)(e?.message)}}})}})]}),r.map(e=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:e,children:e}),(0,u.jsxs)("span",{className:"git-sub-item__ops",children:[(0,u.jsx)(l.rA,{icon:"person",title:s("采用我方版本"),onClick:()=>g(e,"ours")}),(0,u.jsx)(l.rA,{icon:"group",title:s("采用对方版本"),onClick:()=>g(e,"theirs")}),(0,u.jsx)(l.rA,{icon:"check",title:s("标记已解决"),onClick:()=>g(e,"resolved")})]})]},e))]})}function R({dir_path:e,on_changed:t}){const{t:s}=(0,c.Bd)(),o=(0,A.y)(),[r,d]=(0,a.useState)([]),[h,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{h&&_()},[e,h]);const _=async()=>{try{const t=await i.TU.post("reflog",{path:e,maxCount:100});0===t.code&&d(t.data||[])}catch(e){}};return(0,u.jsxs)("div",{className:"git-reflog",children:[(0,u.jsx)("div",{className:"git-sub-panel__header",children:(0,u.jsxs)("span",{className:"git-sub-panel__title",onClick:()=>m(!h),style:{cursor:"pointer"},children:[s("操作历史")," (",r.length,") ",h?"▾":"▸"]})}),h&&(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===r.length&&(0,u.jsx)("div",{className:"git-change-empty",children:s("暂无记录")}),r.map(a=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:a.message,children:a.selector}),(0,u.jsx)("span",{className:"git-sub-item__desc",title:a.message,children:a.message}),(0,u.jsx)("span",{className:"git-sub-item__meta",children:a.date}),(0,u.jsxs)("span",{className:"git-sub-item__ops",children:[(0,u.jsx)(l.rA,{icon:"undo",title:s("回退到此处"),onClick:()=>{return c=a,void o({title:s("回退到此处"),sub_title:`${c.selector} · ${c.message}`,confirm_fun:async()=>{try{const a=await i.TU.post("reset_commit",{path:e,hash:c.selector,mode:"mixed"});0===a.code?((0,n.SK)(s("已回退")),await _(),t()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}}});var c}}),(0,u.jsx)(l.rA,{icon:"delete_forever",title:s("强制回退(丢弃改动)"),onClick:()=>{return c=a,void o({title:s("强制回退(丢弃改动)"),sub_title:`${s("此操作将永久丢弃未提交的改动")}:${c.selector} · ${c.message}`,confirm_fun:async()=>{try{const a=await i.TU.post("reset_commit",{path:e,hash:c.selector,mode:"hard"});0===a.code?((0,n.SK)(s("已强制回退")),await _(),t()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}}});var c}})]})]},a.selector))]})]})}function W({items:e,on_read:t,on_save:s,on_delete:i}){const{t:n}=(0,c.Bd)(),[r,d]=(0,a.useState)(null),[h,m]=(0,a.useState)(""),[_,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>{r&&!e.some(e=>e.name===r)&&d(null)},[e,r]);const p=async()=>{if(r){g(!0);try{await s(r,h)}finally{g(!1)}}};return(0,u.jsx)("div",{className:"hook-editor",children:(0,u.jsxs)("div",{className:"hook-editor__list",children:[e.map(e=>(0,u.jsxs)(a.Fragment,{children:[(0,u.jsxs)("div",{className:"hook-item"+(r===e.name?" hook-item--editing":""),children:[(0,u.jsx)("span",{className:"hook-item__dot"+(e.enabled?" hook-item__dot--on":"")}),(0,u.jsx)("span",{className:"hook-item__name",children:e.name}),(0,u.jsxs)("span",{className:"hook-item__ops",children:[(0,u.jsx)(l.rA,{icon:r===e.name?"expand_less":"edit",title:n("编辑"),onClick:()=>(async e=>{if(r!==e){g(!0);try{m(await t(e)),d(e)}finally{g(!1)}}else d(null)})(e.name)}),e.enabled&&(0,u.jsx)(l.rA,{icon:"block",title:n("停用钩子"),onClick:()=>(async e=>{g(!0);try{await i(e)}finally{g(!1)}})(e.name)})]})]}),r===e.name&&(0,u.jsxs)("div",{className:"hook-item__editor",children:[(0,u.jsxs)("div",{className:"hook-item__editor-bar",children:[(0,u.jsx)("span",{className:"hook-item__editor-name",children:e.name}),(0,u.jsx)(l.rA,{icon:"check",title:n("保存并启用"),onClick:p}),(0,u.jsx)(l.rA,{icon:"close",title:n("取消"),onClick:()=>d(null)})]}),(0,u.jsx)(o.Z2,{className:"hook-item__text",value:h,spellCheck:!1,disabled:_,onChange:e=>m(e.target.value)})]})]},e.name)),0===e.length&&(0,u.jsx)("div",{className:"git-change-empty",children:n("暂无记录")})]})})}function H({dir_path:e}){const{t}=(0,c.Bd)(),s=(0,A.y)(),[l,o]=(0,a.useState)([]),[r,d]=(0,a.useState)(!1);(0,a.useEffect)(()=>{r&&h()},[e,r]);const h=async()=>{try{const t=await i.TU.post("hooks",{path:e});0===t.code&&o(t.data||[])}catch(e){}};return(0,u.jsxs)("div",{className:"git-hook",children:[(0,u.jsx)("div",{className:"git-sub-panel__header",children:(0,u.jsxs)("span",{className:"git-sub-panel__title",onClick:()=>d(!r),children:[t("钩子")," ",r?"▾":"▸"]})}),r&&(0,u.jsx)(W,{items:l,on_read:async t=>{try{const s=await i.TU.post("hook_read",{path:e,name:t});if(0===s.code)return s.data?.content||"";(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}return""},on_save:async(s,a)=>{try{const c=await i.TU.post("hook_save",{path:e,name:s,content:a});0===c.code?((0,n.SK)(t("已保存并启用")),await h()):(0,n.zN)(c.message)}catch(e){(0,n.zN)(e?.message)}},on_delete:async a=>{s({title:t("停用钩子"),sub_title:`${t("确认删除并停用")} ${a} ?`,confirm_fun:async()=>{try{const s=await i.TU.post("hook_delete",{path:e,name:a});0===s.code?((0,n.SK)(t("已停用")),await h()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}}})}})]})}function O({dir_path:e,on_info_loaded:t,on_changed:s}){const{t:o}=(0,c.Bd)(),[r,d]=(0,a.useState)(null),[h,m]=(0,a.useState)([]),[_,g]=(0,a.useState)(!1),[p,f]=(0,a.useState)(!1);(0,a.useEffect)(()=>{x(),j()},[e]);const x=async()=>{try{const s=await i.TU.post("repo_info",{path:e});0===s.code&&(d(s.data),t(s.data))}catch(e){}},j=async()=>{try{const t=await i.TU.post("submodules",{path:e});0===t.code&&m(t.data||[])}catch(e){}},N=e=>o("uninitialized"===e?"未初始化":"modified"===e?"与记录不一致":"正常");return(0,u.jsxs)("div",{className:"git-repo-panel",children:[(0,u.jsxs)("div",{className:"git-config-row",children:[(0,u.jsx)("span",{className:"git-config__label",children:o("远程地址")}),(0,u.jsx)("span",{className:"git-config__value",title:r?.remote_url,children:r?.remote_url||o("未配置")})]}),(0,u.jsxs)("div",{className:"git-config-row",children:[(0,u.jsx)("span",{className:"git-config__label",children:o("当前提交")}),(0,u.jsxs)("span",{className:"git-config__value",children:[r?.head_hash||"",r&&(r.ahead>0||r.behind>0)&&(0,u.jsxs)("span",{className:"git-repo-panel__counts",children:[r.ahead>0&&(0,u.jsxs)("span",{className:"git-ahead",children:["↑",r.ahead]}),r.behind>0&&(0,u.jsxs)("span",{className:"git-behind",children:["↓",r.behind]})]})]})]}),(0,u.jsxs)("div",{className:"git-sub-panel__header",children:[(0,u.jsxs)("span",{className:"git-sub-panel__title",onClick:()=>g(!_),style:{cursor:"pointer"},children:[o("子模块")," (",h.length,") ",_?"▾":"▸"]}),h.length>0&&(0,u.jsx)(l.rA,{icon:"sync",title:o("初始化并更新子模块"),onClick:async()=>{f(!0);try{const t=await i.TU.post("submodule_update",{path:e});0===t.code?((0,n.SK)(o("子模块更新完成")),await j(),s()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{f(!1)}}})]}),_&&(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===h.length&&(0,u.jsx)("div",{className:"git-change-empty",children:o("无子模块")}),h.map(e=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:e.path,children:e.path}),(0,u.jsx)("span",{className:"git-sub-item__desc",title:e.desc,children:e.desc}),(0,u.jsx)("span",{className:`git-sub-item__meta git-sub-status--${e.status}`,children:N(e.status)})]},e.path))]})]})}function L({dir_path:e,on_changed:t}){const{t:s}=(0,c.Bd)(),o=(0,d.Zp)(),[r,h]=(0,a.useState)([]),[_,g]=(0,a.useState)([]),[p,f]=(0,a.useState)("none"),[x,j]=(0,a.useState)(""),[N,v]=(0,a.useState)(""),[y,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{w(),k()},[e]);const w=async()=>{try{const t=await i.TU.post("repos",{path:e});0===t.code&&h(t.data||[])}catch(e){}},k=async()=>{try{const t=await i.TU.post("dirs",{path:e});0===t.code&&g(t.data?.dirs||[])}catch(e){}},S=async()=>{const a=x.trim();if(a){b(!0);try{const c=await i.TU.post("init",{path:`${e}/${a}`.replace(/\/+/g,"/")});0===c.code?((0,n.SK)(s("仓库初始化成功")),f("none"),j(""),await w(),await k(),t()):(0,n.zN)(c.message)}catch(e){(0,n.zN)(e?.message)}finally{b(!1)}}else(0,n.zN)(s("请输入目录名"))},C=async()=>{const a=x.trim();if(a)if(N.trim()){b(!0);try{const c=await i.TU.post("clone",{target:`${e}/${a}`.replace(/\/+/g,"/"),url:N.trim()});0===c.code?((0,n.SK)(s("克隆成功")),f("none"),j(""),v(""),await w(),await k(),t()):(0,n.zN)(c.message)}catch(e){(0,n.zN)(e?.message)}finally{b(!1)}}else(0,n.zN)(s("请输入仓库地址"));else(0,n.zN)(s("请输入目录名"))};return(0,u.jsxs)("div",{className:"git-repo-manager",children:[(0,u.jsxs)("div",{className:"git-repo-manager__header",children:[(0,u.jsxs)("span",{className:"git-sub-panel__title",children:[s("仓库")," (",r.length,")"]}),(0,u.jsx)(l.rA,{icon:"add",title:s("初始化仓库"),selected:"init"===p,onClick:()=>{f("init"===p?"none":"init"),j("")}}),(0,u.jsx)(l.rA,{icon:"cloud_download",title:s("克隆仓库"),selected:"clone"===p,onClick:()=>{f("clone"===p?"none":"clone"),j("")}})]}),"none"!==p&&(0,u.jsxs)("div",{className:"git-sub-panel__form",children:[(0,u.jsx)("input",{className:"input input--block",autoFocus:!0,value:x,placeholder:s("目录名"),onChange:e=>j(e.target.value),onKeyDown:e=>"Enter"===e.key&&("init"===p?S():C())}),"clone"===p&&(0,u.jsx)("input",{className:"input input--block",value:N,placeholder:s("仓库地址"),onChange:e=>v(e.target.value),onKeyDown:e=>"Enter"===e.key&&C()}),(0,u.jsxs)("div",{className:"git-sub-panel__form-actions",children:[(0,u.jsx)("span",{className:"git-sub-panel__hint",children:`${e}/${x||"..."}`.replace(/\/+/g,"/")}),(0,u.jsx)(l.rA,{icon:"check",title:s("保存"),onClick:"init"===p?S:C}),(0,u.jsx)(l.rA,{icon:"close",title:s("取消"),onClick:()=>{f("none"),j(""),v("")}})]}),_.length>0&&(0,u.jsx)("div",{className:"git-repo-manager__dirs",children:_.map(e=>(0,u.jsx)("span",{className:"git-repo-manager__dir",onClick:()=>j(e),children:e},e))})]}),(0,u.jsxs)("div",{className:"git-sub-panel__list",children:[0===r.length&&(0,u.jsx)("div",{className:"git-change-empty",children:s("当前目录下没有仓库")}),r.map(t=>(0,u.jsxs)("div",{className:"git-sub-item",children:[(0,u.jsx)("span",{className:"git-sub-item__name",title:t.name,children:t.name}),(0,u.jsx)("span",{className:"git-sub-item__meta",children:t.branch}),(0,u.jsx)("span",{className:"git-sub-item__ops",children:(0,u.jsx)(l.rA,{icon:"login",title:s("进入"),onClick:()=>{return s=t,void o(`${m.o.git_page}/${e}/${s.name}/`.replace(/\/+/g,"/"));var s}})})]},t.path))]})]})}const Z=100;function q(){const{t:e}=(0,c.Bd)(),t=(0,A.y)(),s=(0,d.Zp)();let g=decodeURIComponent((0,h.GG)(m.o.git_page,(0,h.vX)()));g=g.replace(/\/+$/,"");const[p,f]=(0,a.useState)([]),[x,j]=(0,a.useState)([]),[N,v]=(0,a.useState)(!1),[y,w]=(0,a.useState)(!1),k=(0,a.useRef)(!1),[S,$]=(0,a.useState)({current:"",branches:[]}),[T,W]=(0,a.useState)(""),[q,G]=(0,a.useState)(new Set),[V,X]=(0,a.useState)("status"),[J,Q]=(0,a.useState)(!1),[Y,ee]=(0,a.useState)(20),[te,se]=(0,a.useState)(!1),ae=(0,a.useRef)(null),ie=(0,a.useRef)(null),[ne,ce]=(0,a.useState)(null),[le,oe]=(0,a.useState)("unified"),[re,de]=(0,a.useState)({name:"",email:""}),[he,me]=(0,a.useState)(null),[_e,ge]=(0,a.useState)(0),[pe,ue]=(0,a.useState)(null),[fe,xe]=(0,a.useState)(null),[je,Ne]=(0,a.useState)(!1);(0,a.useEffect)(()=>{g&&ye().then(e=>{e&&(be(),we(),ke(),Se(),ve())})},[g]);const ve=async()=>{try{const e=await i.TU.post("conflicts",{path:g});0===e.code&&ge((e.data?.files||[]).length)}catch(e){}},ye=async()=>{try{Q(!0);const e=await i.TU.post("status",{path:g});return 0===e.code&&(f(e.data||[]),Ne(!1),!0)}catch(e){const t="string"==typeof e?e:e?.message;return t&&t.includes("not a git repository")&&Ne(!0),!1}finally{Q(!1)}},be=async()=>{try{const e=await i.TU.post("log",{path:g,maxCount:Z,skip:0});if(0===e.code){const t=e.data||[];j(t),v(t.length>=Z)}}catch(e){}},we=async()=>{try{const e=await i.TU.post("branches",{path:g});0===e.code&&$(e.data||{current:"",branches:[]})}catch(e){}},ke=async()=>{try{const e=await i.TU.post("get_user_config",{path:g});0===e.code&&de(e.data)}catch(e){}},Se=async()=>{try{const e=await i.TU.post("get_proxy",{path:g});0===e.code&&me(e.data)}catch(e){}},Ce=async(t,s)=>{t.untracked?(0,n.zN)(e("未跟踪文件无差异")):ce({kind:"working",path:t.path,staged:s})},ze=async()=>{const e=p.filter(e=>!e.staged);try{Q(!0);const t=await i.TU.post("add",{path:g,files:e.map(e=>e.path)});if(0!==t.code)return void(0,n.zN)(t.message)}catch(e){return void(0,n.zN)(e?.message)}finally{Q(!1)}await Ae(!1)},Ae=async t=>{try{Q(!0);const s=await i.TU.post("commit",{path:g,message:T.trim(),allChanged:t});0===s.code?((0,n.SK)(e("提交成功")),W(""),ce(null),await ye(),be()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},$e=async(t=!1)=>{try{Q(!0);const s=await i.TU.post("push",{path:g,force:t});0===s.code?(0,n.SK)(e("推送成功")):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},Ue=async()=>{ce(null),await ye(),be(),we()},Te=(0,a.useCallback)(_.throttle(e=>{const t=parseFloat(getComputedStyle(ie.current).fontSize),s=window.innerWidth/t-4,a=e.clientX/t,i=2.25+ae.current.offsetWidth/t;a<=s&&a>=i&&ee(parseFloat(a.toFixed(2)))},32),[]),Ke=()=>{se(!1),ie.current.removeEventListener("pointermove",Te)},Ee=g.split("/").filter(Boolean).pop()||g;return(0,u.jsxs)("div",{className:"studio",children:[(0,u.jsx)(r.A,{ignore_tags:!0,left_children:[(0,u.jsx)(l.rA,{title:e("取消"),icon:"close",onClick:()=>s(-1)},"close"),(0,u.jsx)("span",{children:Ee},"title")],children:(0,u.jsx)(l.rA,{icon:"refresh",title:e("刷新"),onClick:()=>{ye(),be(),we(),ke(),Se()}})}),je?(0,u.jsx)("div",{className:"studio-body",children:(0,u.jsx)("div",{className:"studio-editor",children:(0,u.jsx)("div",{className:"git-main",children:(0,u.jsx)("div",{className:"git-card",children:(0,u.jsx)(L,{dir_path:g,on_changed:()=>{Ne(!1),ye(),be(),we()}})})})})}):(0,u.jsxs)("div",{className:"studio-body",ref:ie,children:[(0,u.jsxs)("div",{className:"studio-nav studio-nav--git",style:{width:Y-1+"em"},children:[(0,u.jsx)("div",{className:"menu git-menu not-select-div",children:(0,u.jsx)("div",{className:"wrapper",children:(0,u.jsxs)("ul",{children:[(0,u.jsxs)("li",{className:"status"===V?"active":"",onClick:()=>X("status"),children:[e("变更")," (",p.length,")"]}),(0,u.jsxs)("li",{className:"log"===V?"active":"",onClick:()=>X("log"),children:[e("提交记录")," (",x.length,")"]})]})})}),"status"===V&&(0,u.jsx)("div",{className:"git-scroll",children:(0,u.jsx)(b,{files:p,selected:q,on_toggle:e=>{const t=new Set(q);t.has(e)?t.delete(e):t.add(e),G(t)},on_toggle_all:(e,t)=>{const s=new Set(q);for(const a of e)t?s.add(a):s.delete(a);G(s)},active_path:"working"===ne?.kind?ne.path:null,on_view_diff:Ce,on_stage_section:async(t,s)=>{if(0===t.length)return;const a=t.map(e=>e.path);try{const t=s?await i.TU.post("reset",{path:g,files:a}):await i.TU.post("add",{path:g,files:a});0===t.code?((0,n.SK)(e(s?"已取消暂存":"已暂存")),await ye()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}},on_stage_one:async(e,t)=>{try{const s=t?await i.TU.post("reset",{path:g,files:[e.path]}):await i.TU.post("add",{path:g,files:[e.path]});0===s.code?(await ye(),"working"===ne?.kind&&ne.path===e.path&&Ce(e,!t)):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}},on_view_blame:e=>{ce({kind:"blame",file:e.path})}})}),"log"===V&&(0,u.jsx)("div",{className:"git-scroll",children:(0,u.jsx)(z,{dir_path:g,entries:pe??x,is_search:null!==pe,has_more:N,loading_more:y,active_hash:"commit"===ne?.kind?ne.hash:null,on_select:e=>{ce({kind:"commit",hash:e})},on_scroll_bottom:e=>{if(null!==pe)return;const t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&(async()=>{if(!k.current&&N){k.current=!0,w(!0);try{const e=await i.TU.post("log",{path:g,maxCount:Z,skip:x.length});if(0===e.code){const t=e.data||[];j(e=>[...e,...t]),v(t.length>=Z)}}catch(e){}finally{k.current=!1,w(!1)}}})()},on_search_result:e=>{ue(e),null===e&&be()}})})]}),(0,u.jsx)("div",{className:"studio__divider",ref:ae,onPointerDown:()=>{se(!0),ie.current.addEventListener("pointermove",Te)},onPointerUp:Ke}),te&&(0,u.jsx)("div",{className:"shell__overlay",onPointerUp:Ke}),(0,u.jsx)("div",{className:"studio-editor",children:(0,u.jsxs)("div",{className:"git-main",children:[(0,u.jsx)(D,{dir_path:g,on_resolved:Ue}),(0,u.jsxs)("div",{className:"git-card",children:[(0,u.jsx)(E,{current:S.current,branches:S.branches,on_checkout:async t=>{try{Q(!0);const s=await i.TU.post("checkout",{path:g,branch:t});0===s.code?((0,n.SK)(e("切换分支成功")),await Ue()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},on_create:async t=>{try{Q(!0);const s=await i.TU.post("branch_create",{path:g,name:t});0===s.code?((0,n.SK)(e("分支创建成功")),await Ue()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},on_delete:async(t,s)=>{try{Q(!0);const a=await i.TU.post("branch_delete",{path:g,name:t,force:s});0===a.code?((0,n.SK)(e("分支删除成功")),await Ue()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},on_merge:async t=>{try{Q(!0);const s=await i.TU.post("merge",{path:g,branch:t});0===s.code?((0,n.SK)(e("合并成功")),await Ue()):(0,n.zN)(s.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}},ahead:fe?.ahead,behind:fe?.behind}),(0,u.jsx)(M,{dir_path:g,current_branch:S.current,on_checkout:Ue,on_compare:e=>ce({kind:"remote",branch:e})}),(0,u.jsx)(o.Z2,{placeholder:e("git_msg"),value:T,onChange:e=>W(e.target.value),rows:3}),(0,u.jsxs)("div",{className:"git-btn-row",children:[(0,u.jsx)(l.rA,{icon:"check",title:e("提交"),onClick:async()=>{if(!T.trim())return void(0,n.zN)(e("请输入提交信息"));if(0===p.filter(e=>e.staged).length){return 0===p.filter(e=>!e.staged).length?void(0,n.zN)(e("没有可提交的更改")):void t({title:e("提交"),sub_title:e("存在未暂存的改动,是否一并暂存并提交?"),confirm_fun:ze})}await Ae(!1)}}),(0,u.jsx)(l.rA,{icon:"edit_note",title:e("修改最后一次提交"),onClick:async()=>{try{Q(!0);const t=await i.TU.post("commit_amend",{path:g,message:T});0===t.code?((0,n.SK)(e("已修改最后一次提交")),W(""),ce(null),await ye(),be()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}}}),(0,u.jsx)(l.rA,{icon:"download",title:e("拉取"),onClick:async()=>{try{Q(!0);const t=await i.TU.post("pull",{path:g});0===t.code?((0,n.SK)(e("拉取成功")),await ye(),be()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{Q(!1)}}}),(0,u.jsx)(l.rA,{icon:"upload",title:e("推送"),onClick:()=>$e(!1)}),(0,u.jsx)(l.rA,{icon:"keyboard_double_arrow_up",title:e("强制推送"),onClick:()=>$e(!0)}),(0,u.jsx)("span",{className:"git-btn-gap"}),(0,u.jsx)(l.rA,{icon:"inventory_2",title:e("暂存工作区"),onClick:async()=>{try{const t=await i.TU.post("stash",{path:g});0===t.code?((0,n.SK)(e("暂存工作区成功")),ce(null),await ye()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}}}),(0,u.jsx)(l.rA,{icon:"unarchive",title:e("恢复工作区"),onClick:async()=>{try{const t=await i.TU.post("stash_pop",{path:g});0===t.code?((0,n.SK)(e("恢复工作区成功")),await ye()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}}})]}),(0,u.jsx)(I,{dir_path:g,on_changed:Ue}),(0,u.jsx)(F,{dir_path:g,target_hash:"commit"===ne?.kind?ne.hash:void 0,on_changed:Ue}),(0,u.jsx)(R,{dir_path:g,on_changed:Ue})]}),ne?"commit"===ne.kind?(0,u.jsx)(U,{dir_path:g,hash:ne.hash,on_close:()=>ce(null),on_changed:Ue}):"blame"===ne.kind?(0,u.jsx)(K,{dir_path:g,file:ne.file,on_close:()=>ce(null)}):"remote"===ne.kind?(0,u.jsx)(P,{dir_path:g,branch:ne.branch,current_branch:S.current,on_close:()=>ce(null)}):(0,u.jsxs)("div",{className:"git-card git-card--diff",children:[(0,u.jsxs)("div",{className:"git-diff-header",children:[(0,u.jsx)("span",{className:"git-diff-header__badge",children:ne.staged?e("已暂存"):e("未暂存")}),(0,u.jsx)("span",{className:"git-diff-header__path",title:ne.path,children:ne.path}),(0,u.jsxs)("div",{className:"git-diff-header__modes",children:[(0,u.jsx)(l.rA,{icon:"view_agenda",title:e("单栏"),selected:"unified"===le,onClick:()=>oe("unified")}),(0,u.jsx)(l.rA,{icon:"view_column",title:e("并排"),selected:"split"===le,onClick:()=>oe("split")}),(0,u.jsx)(l.rA,{icon:"close",title:e("关闭"),onClick:()=>ce(null)})]})]}),ne.staged?(0,u.jsx)(C,{dir_path:g,file:ne.path,left_ref:"HEAD",right_ref:"staged",mode:le}):(0,u.jsx)(C,{dir_path:g,file:ne.path,left_ref:"HEAD",right_ref:"worktree",mode:le})]}):(0,u.jsx)("div",{className:"git-card git-card--placeholder",children:e("点击左侧文件查看差异")}),(0,u.jsxs)("div",{className:"git-card",children:[(0,u.jsx)(B,{dir_path:g,user_config:re,proxy_config:he,on_user_config_saved:de,on_proxy_saved:me}),(0,u.jsx)(O,{dir_path:g,on_info_loaded:xe,on_changed:Ue}),(0,u.jsx)(H,{dir_path:g})]})]})})]})]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4004,6010],{83277(e,s,t){t.d(s,{$j:()=>i,Lv:()=>n});class n{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}const a=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function i(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n\n\n# 聊天循环最大次数\ntool_call_max=500\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n\n# ===== 模型类型(request_type)=====\n# 必填项,不同类型的 model 接口格式不同,默认 completions。\n# 可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n#request_type=completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,可实现不同模型担任不同角色/能力,供 AI agent 在对话中动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n#tool_mode=false\n\n# ===== 是否支持图片(support_image)=====\n# 开启后:1) 注册 read_image 工具,让 AI 能读取本地图片;\n# 2) 工具读到的图片会以 OpenAI 多模态格式 image_url 随消息发给模型,模型就能真正"看图"。\n# 关闭后:AI 看不到图片,read_image 只会返回一句文字说明。\n# 主流模型(gpt-4o、豆包、qwen-vl、deepseek-vl 等)都支持,默认开启。\nsupport_image=true\n',"cL",0,a])},95733(e,s,t){t.r(s),t.d(s,{default:()=>ae});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(92275),r=t(14284),l=t(7463),d=t(21499),u=t(64694),m=t(78247),h=t(40505),g=t(62042),p=t(45907),_=t(53459),f=t(72693),x=t(82893),j=t(61443),v=t(83277);function b(e){return null==e||e<0?"0":e.toLocaleString()}function w(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,v.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function y(e){const s=(0,v.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,v.$j)(e.content)).filter(Boolean).join("\n\n"):""}function S(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:y(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const N=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function k(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||N.test(e.name)?"text":"binary"}function C(e){return e.text()}function A(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function $(e){const s=[];for(const t of e){const e=k(t);let n="";if("text"===e)try{const e=await C(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await A(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var I=t(14944);function M(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var R=t(85997),D=t(34299),H=t(74848);function V(e){const s=e.attachments&&e.attachments.length>0?(0,H.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,H.jsxs)("div",{className:"chat-message-attachment",children:[(0,H.jsx)(R.In,{icon:"attach_file"}),(0,H.jsx)("span",{children:e.name}),(0,H.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(E,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(K,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(z,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,H.jsx)(D.default,{context:e.text}):null;return(0,H.jsxs)(H.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,v.$j)(e.content);return a&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(D.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(T,{callList:e.tool_call_ends})},`tool-${s}`)),(0,H.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,H.jsx)(D.default,{context:e.text}):null]})}(e);return 0===t.length?(0,H.jsxs)(H.Fragment,{children:[s,a]}):(0,H.jsxs)(H.Fragment,{children:[t,s,a]})}function T({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,H.jsxs)("div",{className:"chat-message-call-list",children:[(0,H.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,H.jsx)(R.In,{icon:s?"expand_less":"expand_more"}),(0,H.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,H.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,H.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,H.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,H.jsxs)("div",{className:"call-list-item-header",children:[(0,H.jsx)(R.In,{icon:e.success?"check_circle":"error"}),(0,H.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,H.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"参数"}),(0,H.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"错误"}),(0,H.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"结果"}),(0,H.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function E({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,H.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,H.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,H.jsx)("div",{className:"image-generation-image-wrapper",children:(0,H.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,H.jsx)("div",{className:"image-generation-image-wrapper",children:(0,H.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,H.jsx)("p",{className:"image-generation-prompt",children:(0,H.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,H.jsx)(D.default,{context:s})]}):(0,H.jsx)(D.default,{context:s||""})}function K({audio:e,text:s}){if(e){if(e.url)return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,H.jsx)("div",{className:"audio-result",children:(0,H.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,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,H.jsx)(D.default,{context:t})}function B({content:e,label:s}){const[t,a]=n.useState(!1);return(0,H.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,h.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,H.jsx)(R.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function z({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,H.jsx)(D.default,{context:s})}if(!t)return(0,H.jsx)(D.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,H.jsxs)("div",{className:"embeddings-result",children:[(0,H.jsxs)("div",{className:"embeddings-summary",children:[(0,H.jsx)("strong",{children:"向量嵌入结果"}),(0,H.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,H.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,H.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,H.jsxs)("div",{className:"embeddings-toolbar",children:[(0,H.jsx)(B,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,H.jsx)(B,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,H.jsx)(B,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,H.jsx)("div",{className:"embeddings-preview",children:(0,H.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,H.jsxs)("details",{children:[(0,H.jsx)("summary",{children:"查看详细数据"}),(0,H.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function L(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await r.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const a=n.data||{},i=(a.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=i.map((e,s)=>`![生成图片${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 r.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var P=t(4412),F=t(23430),O=t(87361),q=t(80389),G=t(7523),U=t(23496);const J=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:c,sysPromptList:l,batchMode:d,selectedMsgCount:u,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),$=(0,o.Zp)(),{check_user_auth:I}=(0,m.MH)(),[,M]=(0,a.fp)(x.AG.ai_session_collapsed),{open:D}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(x.AG.prompt_card),[t,o]=(0,a.fp)(x.AG.ai_chat_zoom),{initUserInfo:c}=(0,n.useContext)(G.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,H.jsx)(q.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),a()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await r.wm.post(U.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,g.SK)(e("缩放调整成功")),c(),a()}})}}}(),V=I(F.oV.ai_model_switch)||I(F.oV.ai_agent_setting),T=[];for(const e of t)for(const s of e.models)T.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const E=t.find(e=>e.active),K=E?`${E.index}::${e}`:"",B=(0,H.jsxs)(n.Fragment,{children:[(0,H.jsx)(R.rA,{icon:"menu",title:A("会话"),onClick:p,selected:h}),(0,H.jsx)(R.rA,{icon:"add",title:A("新会话"),onClick:()=>f()}),l.length>0&&(0,H.jsx)(j.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...l.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),V&&T.length>0&&(0,H.jsx)(j.l6,{value:K,options:[{title:A("选择模型"),value:""},...T],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...a]=t.split("::"),i=a.join("::");i&&(s(i),r.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===_.m.Success?((0,g.SK)("success"),c()):(0,g.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),d&&u>0&&(0,H.jsx)(R.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,H.jsx)(R.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:D}),(0,H.jsx)(R.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),I(F.oV.ai_agent_setting)&&(0,H.jsx)(R.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{$(O.o.ai_rebot_setting_page)}}),I(F.oV.ai_agent_setting)&&(0,H.jsx)(R.rA,{icon:"settings",title:"ai setting",onClick:()=>{$(O.o.ai_agent_setting_page)}})]});return C?(0,H.jsx)("div",{className:"chat-inline-header",children:B}):(0,H.jsx)(P.aZ,{position:"right",children:B})};var W=t(89824);function Q({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:h,onToggleBatchMode:g,onBatchDeleteSessions:p,onClearAllSessions:_,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j}){const{t:v}=(0,i.Bd)(),[b,w]=(0,n.useState)(""),[y,S]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=!!a&&!f,A=b.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(b.toLowerCase())||(e.summary||"").toLowerCase().includes(b.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(b.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(b.toLowerCase())):e;return(0,H.jsxs)("aside",{className:"chat-session-list",children:[(0,H.jsx)("div",{className:"chat-session-search",children:(0,H.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,H.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,H.jsx)("div",{children:(0,H.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${y===n?"row-dragging":""} ${N===n&&null!==y&&y!==n?"row-drop-target":""}`,draggable:C,onDragStart:()=>S(n),onDragOver:e=>{null!==y&&(e.preventDefault(),N!==n&&k(n))},onDragEnd:()=>{S(null),k(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=y;if(S(null),k(null),null===s||s===e||!a)return;const t=A[s]?.id,n=A[e]?.id;t&&n&&a(t,n)})(n)},onClick:()=>{u&&h?h(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,H.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>h?.(e.id),onClick:e=>e.stopPropagation()}),(0,H.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,H.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,H.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,H.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,H.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,H.jsx)(W.MenuSelect,{list:[{name:v("重命名"),click:()=>o(e.id,e.title)},...f?[]:[{name:v("移动到最上"),click:()=>{const s=A[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{name:v("移动到最下"),click:()=>{const s=A[A.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{name:e.cmd_auto_allow?v("命令检测关闭"):v("命令检测开启"),click:()=>r?.(e.id,!e.cmd_auto_allow)},{name:v("字符消耗统计"),click:()=>l(e.id)},{name:v("设置"),click:()=>d?.(e.id)},{name:v("删除"),click:()=>c(e.id)}],children:(0,H.jsx)(R.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,H.jsxs)("div",{className:"chat-session-actions",children:[(0,H.jsx)(R.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:g}),j&&!u&&(0,H.jsx)(R.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,H.jsx)(R.rA,{icon:"delete",title:v("删除选中会话"),onClick:p}),!u&&_&&(0,H.jsx)(R.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:_})]})]})}function X(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const Z=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:u,onToggleBatchMode:m,onBatchCopy:h,onBatchDelete:g,showBatchBar:p,t:_})=>{const[f,x]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),v=e=>{x(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},b=()=>{x(e=>e.size>0&&j.every(s=>e.has(s))?new Set:new Set(j))};return(0,H.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[p&&(0,H.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,H.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,H.jsx)("button",{onClick:h,children:_("复制所选")}),(0,H.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,H.jsx)("button",{onClick:m,children:_("取消")})]}),e.map(e=>{const n=f.has(e.id);return(0,H.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,H.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,H.jsxs)("div",{className:"ai-loading-bubble",children:[(0,H.jsxs)("div",{className:"ai-loading-dots",children:[(0,H.jsx)("span",{className:"ai-loading-dot"}),(0,H.jsx)("span",{className:"ai-loading-dot"}),(0,H.jsx)("span",{className:"ai-loading-dot"})]}),(0,H.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,H.jsxs)(H.Fragment,{children:[n?(0,H.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>v(e.id),children:[(0,H.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,H.jsx)("span",{className:"chat-message-summary-text",children:X(e)||_("(无内容)")})]}):(0,H.jsx)("div",{className:"chat-message-body",children:V(e)}),(0,H.jsxs)("div",{className:"message-collapse-bar",children:[(0,H.jsx)("button",{onClick:()=>v(e.id),children:_(n?"展开":"折叠")}),(0,H.jsx)("button",{onClick:b,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,H.jsx)("span",{className:"message-elapsed",children:(0,d.kf)(e.elapsed_ms)})]}),(0,H.jsx)("div",{className:"message-actions",children:s?(0,H.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?_("取消选择"):_("选择")}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,H.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,H.jsx)("button",{onClick:u,children:_("全部复制")}),(0,H.jsx)("button",{onClick:m,children:_("多选")})]})})]})]},e.id)}),(0,H.jsx)("div",{ref:o})]})},Y=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>g(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,H.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:o,onInput:()=>c?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});var ee=t(84369);function se({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,H.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,H.jsxs)("div",{className:"chat-attachment-chip",children:[(0,H.jsx)(R.In,{icon:"attach_file"}),(0,H.jsx)("span",{title:e.name,children:e.name}),(0,H.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,H.jsx)(R.In,{icon:"close"})})]},`${e.name}_${t}`))})}const te=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:m,readonly:h=!1},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),f=(0,n.useRef)(null),[j,v]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,ee.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=f.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,H.jsxs)("div",{ref:f,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,H.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,H.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,H.jsxs)("div",{className:"chat-input-shell",children:[(0,H.jsx)(se,{pendingAttachments:o,onRemove:c}),(0,H.jsx)(Y,{ref:_,placeholder:p(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input",style:S})]}),!h&&(0,H.jsx)(R.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,H.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,H.jsx)(R.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,H.jsx)(R.Vi,{text:p("发送"),clickFun:e}),b&&(0,H.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),ne=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[p,_]=(0,n.useState)(!1),[f,j]=(0,a.fp)(x.AG.ai_bg_expanded),[,v]=(0,a.fp)(x.AG.ai_session_collapsed),b=()=>{j(!1)},w=(0,n.useCallback)(async()=>{l(!0);try{const s=new c.hf(c.HK.ai_bg_process_list_req);s.context={};const t=await I.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=w);const y=(0,n.useCallback)(async e=>{_(!0),u(e);try{const s=new c.hf(c.HK.ai_bg_process_output_req);s.context={pid:e};const t=await I.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,g.zN)("获取进程输出失败")}finally{_(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new c.hf(c.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await I.ws.send(s);t?.context?.success?((0,g.SK)("进程已终止"),w(),d===e&&(u(null),h(null))):(0,g.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,g.zN)("终止进程失败")}},[w,d]);(0,n.useEffect)(()=>{w();const e=setInterval(w,5e3);return()=>clearInterval(e)},[w]);const N=t.filter(e=>e.running),k=t.filter(e=>!e.running);return(0,H.jsxs)(H.Fragment,{children:[f&&(0,H.jsx)("div",{className:"chat-session-overlay",onClick:b}),(0,H.jsxs)("aside",{className:"chat-bg-process-panel "+(f?"expanded":""),children:[(0,H.jsxs)("div",{className:"chat-bg-process-header",children:[(0,H.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,H.jsx)(R.rA,{icon:"close",title:s("关闭"),onClick:b})]}),(0,H.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,H.jsx)(R.rA,{icon:"refresh",title:s("刷新"),onClick:w}),(0,H.jsxs)("span",{className:"chat-bg-process-count",children:[N.length," ",s("个运行中"),k.length>0&&` / ${k.length} ${s("个已退出")}`]})]}),(0,H.jsxs)("div",{className:"chat-bg-process-list",children:[r&&0===t.length&&(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!r&&0===t.length&&(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),N.map(e=>(0,H.jsxs)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} running`,children:[(0,H.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,H.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,H.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,H.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,H.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,H.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,H.jsx)(R.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,H.jsx)(R.rA,{icon:"stop",title:s("终止进程"),onClick:()=>S(e.pid)})]})]},e.pid)),k.map(e=>(0,H.jsx)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} finished`,children:(0,H.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,H.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,H.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,H.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,H.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==d&&(0,H.jsxs)("div",{className:"chat-bg-process-output",children:[(0,H.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,H.jsxs)("span",{children:["PID: ",d," ",s("输出")]}),(0,H.jsx)(R.rA,{icon:"close",title:s("关闭"),onClick:()=>{u(null),h(null)}})]}),(0,H.jsx)("div",{className:"chat-bg-process-output-content",children:p?(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):m?(0,H.jsx)("pre",{className:"chat-bg-process-output-pre",children:m.output||s("(无输出)")}):null})]})]})]})};t(99214);function ae(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:v,sync_url:y=!0,on_session_change:N}=e,{t:k}=(0,i.Bd)(),[C,A]=(0,o.ok)(),R=y&&C.get("session")||"",D=e=>{y&&A(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},V=(0,p.y)(),{check_user_auth:T}=(0,m.MH)();(0,f.w)();const[E,K]=(0,n.useState)([]),[B,z]=(0,n.useState)([]),[P,F]=(0,n.useState)(!1),[O,q]=(0,n.useState)(""),[G,U]=(0,n.useState)(null),[W,X]=(0,n.useState)(!1),Y=(0,n.useRef)(null),[ee,se]=(0,n.useState)([]),[ae]=(0,a.fp)(x.AG.user_base_info),ie=!!ae?.user_data?.is_root,[oe,ce]=(0,a.fp)(x.AG.ai_session_collapsed),[re,le]=(0,a.fp)(x.AG.ai_bg_expanded),[de,ue]=(0,a.fp)(x.AG.prompt_card),[me]=(0,a.fp)(x.AG.ai_chat_zoom),[he,ge]=(0,n.useState)(!1),[pe,_e]=(0,n.useState)(new Set),[fe,xe]=(0,n.useState)(new Set),[je,ve]=(0,n.useState)(""),be=(0,n.useRef)(null),we=(0,n.useRef)(null),ye=(0,n.useRef)(null),Se=(0,n.useRef)(!0),Ne=(0,n.useRef)(null),ke=(0,n.useRef)(null),Ce=(0,n.useRef)({}),Ae=(0,n.useRef)(O),$e=(0,n.useRef)(G);(0,n.useEffect)(()=>{Ae.current=O},[O]),(0,n.useEffect)(()=>{$e.current=G},[G]);const Ie=(0,n.useRef)({}),[Me,Re]=(0,n.useState)([]),[De,He]=(0,n.useState)(""),[Ve,Te]=(0,n.useState)([]),Ee=async()=>{try{const e=await r.jV.get("public_models");e.code===_.m.Success&&Te(e.data?.groups??[])}catch{Te([])}},Ke=e=>{He(e?.ai_config?.model??"")},[Be,ze]=(0,n.useState)(0),Le=(0,n.useRef)((0,l.sg)(e=>{K(e),Se.current&&Pe(!1)},50)).current,Pe=(e=!1)=>{const s=ye.current;s&&(s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"}),requestAnimationFrame(()=>{const s=ye.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})}))},Fe=(0,n.useRef)(!1),Oe=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Oe.current=P},[P]);const qe=(e,s={})=>r.jV.post("admin/session",{action:e,...s}),Ge=async()=>{const e=Oe.current?await qe("list_all_sessions"):await r.jV.get("sessions");e.code===_.m.Success&&z(e.data??[])},Ue=(e,s)=>{z(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})},Je=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:r,refreshSessions:l,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,r)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI thinking ...",is_loading:!0};h.push(p),t([...h]);const _=new Map,f=()=>{o()===e&&a([...h])},x=()=>{const e=h.indexOf(p);-1!==e&&h.splice(e,1)},j=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 p.text=n,p.is_loading=!0,h.includes(p)||h.push(p),void f();if("[DONE]"===n)return;if(!n&&!a)return;x();let o=_.get(i);o||(o={id:Date.now()+Math.random(),sender:"bot",text:"",is_loading:!0},h.push(o),_.set(i,o)),n&&(o.text=o.text+n,o.is_loading=!1),a&&(o.content_list=[{tool_call_ends:a,content:o.text,role:"assistant"}],o.is_loading=!1),f()},v=s=>{const n=s.context||{};if(n.session_id===e){if(w(),g.current=null,i(s=>s===e?null:s),o()===e)if(n.once_messages_list?.length){const e=S(n.once_messages_list);t(s=>{const t=s.filter(M),n=t[t.length-1];return"bot"===n?.sender?[...t.slice(0,-1),...e]:[...t,...e]})}else t(h.filter(M));l(),d(!0),r()}},b=s=>{const n=s.context||{};if(n.session_id!==e)return;w(),g.current=null,i(s=>s===e?null:s);const a="AI request error: "+(n.message||"未知错误");x();const c=[...h].reverse().find(e=>"bot"===e.sender);c?(c.text=c.text?`${c.text}\n\n${a}`:a,c.is_loading=!1):h.push({id:Date.now()+Math.random(),sender:"bot",text:a}),o()===e&&t([...h]),r()},w=()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,j),I.ws.off_message(`message_${c.HK.ai_chat_end}`,v),I.ws.off_message(`message_${c.HK.ai_chat_error}`,b)};I.ws.addMsg(c.HK.ai_chat_msg,j),I.ws.addMsg(c.HK.ai_chat_end,v),I.ws.addMsg(c.HK.ai_chat_error,b),I.ws.sendData(c.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(o(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(I.ws.sendData(c.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>E,setMessages:K,setMessagesDebounced:Le,setSending:U,getActiveSessionId:()=>Ae.current,setActiveSessionId:q,refreshSessions:Ge,scrollToBottom:Pe,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>je}),We=async e=>{const s=Oe.current?await qe("list_all_sessions"):await r.jV.get("sessions");if(s.code!==_.m.Success)return!1;const t=s.data??[];z(t);const n=null===e?t[0]?.id??"":e||O||t[0]?.id||"";if(n){const e=t.find(e=>e.id===n)?.user_id;return await Qe(n,!1,e)}return K([]),q(""),D(null),!1},Qe=async(e,s=!1,t)=>{const n=t??B.find(s=>s.id===e)?.user_id,a=Oe.current&&n?await qe("get",{session_id:e,user_id:n}):await r.jV.post("session/get",{session_id:e});if(a.code!==_.m.Success||!a.data)return!1;const i=a.data;q(i.id),y&&R!==i.id&&D(i.id),N?.(i.id),X(!!i.running),ke.current&&ke.current!==i.id&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=i.running?i.id:null,ke.current&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!0});const o=S(i.messages);return i.running&&i.live_messages?.length?K([...o,...S(i.live_messages)]):K(o),ve(i.sys_prompt_id??""),s&&ce(!1),Ce.current.refresh?.(),Fe.current=!0,!0},Xe=e=>{if(Oe.current)return B.find(s=>s.id===e)?.user_id},Ze=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&se(e=>[...e,...s])},Ye=()=>{he&&(_e(new Set),xe(new Set)),ge(e=>!e)},es=()=>{0!==pe.size&&V({sub_title:k("cf_msgs"),confirm_fun:async()=>{const e=[];if(E.forEach((s,t)=>{pe.has(s.id)&&e.push(t)}),K(E.filter(e=>!pe.has(e.id))),_e(new Set),ge(!1),O&&e.length>0){const s=Xe(O);s?qe("message_delete",{session_id:O,user_id:s,indices:e}).catch(console.error):r.jV.post("session/message/delete",{session_id:O,indices:e}).catch(console.error)}}})},ss=async()=>{const e=await r.XO.get("ai_agent_setting/env");if(e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data)),await Ee(),v){const e=await(async e=>{if(!e)return null;const s=await r.jV.get("sessions");if(s.code!==_.m.Success)return null;const t=s.data??[];e=(0,d.ed)(e);const n=t.find(s=>(0,d.ed)(s.file_cwd_path)===e);if(n)return n.id;const a=await r.jV.post("session",{file_cwd_path:e});return a.code!==_.m.Success?null:a.data.id})(v);!!e&&await We(e)||await We()}else if(t){await We(t)||await We()}else if(R){await We(R)||await We()}else await We();const s=await r.jV.get("system_prompts");s.code===_.m.Success&&Re(s.data??[])};(0,n.useEffect)(()=>{ss(),requestAnimationFrame(()=>Pe(!1)),Ce.current.onCountChange=ze,Ce.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ze(s)};return I.ws.addMsg(c.HK.ai_bg_process_count_notify,e),()=>{I.ws.off_message(`message_${c.HK.ai_bg_process_count_notify}`,e)}},[]),(0,n.useEffect)(()=>{const e=ye.current;if(!e)return;const s=()=>{Se.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};e.addEventListener("scroll",s);const t=()=>{Se.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()}},[]),(0,n.useEffect)(()=>{const e=()=>Ae.current,s=()=>$e.current,t=(t,n)=>{if(Ue(t,!1),e()&&e()===t){if(Ne.current=null,X(!1),ke.current===t&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),ke.current=null),s()===t)return;n?.length?K(e=>{const s=S(n),t=e.filter(e=>"bot"!==e.sender||e.text||e.content_list?.length||e.attachments?.length),a=t[t.length-1];return"bot"===a?.sender?[...t.slice(0,-1),...s]:[...t,...s]}):Qe(t).catch(()=>{})}Ge()},n=t=>{const n=t?.context||{};var a,i,o,c;n.session_id&&(a=n.session_id,i=n.text||"",o=n.tool_call_ends,c=n.notice,e()&&e()===a&&s()!==a&&K(e=>{const s=e[e.length-1],t=s&&"bot"===s.sender?{...s}:{id:Date.now()+Math.random(),sender:"bot",text:""};return c?(t.text=i,t.is_loading=!0):i&&(t.text=t.text+i,t.is_loading=!1),o&&(t.content_list=[{tool_call_ends:o,content:t.text,role:"assistant"}]),Ne.current=t.id,Se.current&&requestAnimationFrame(()=>Pe(!1)),s&&"bot"===s.sender?[...e.slice(0,-1),t]:[...e,t]}),Ue(n.session_id,!0))},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return I.ws.addMsg(c.HK.ai_chat_msg,n),I.ws.addMsg(c.HK.ai_chat_end,a),I.ws.addMsg(c.HK.ai_chat_error,i),()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,n),I.ws.off_message(`message_${c.HK.ai_chat_end}`,a),I.ws.off_message(`message_${c.HK.ai_chat_error}`,i),ke.current&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=null)}},[]),(0,n.useLayoutEffect)(()=>{Fe.current&&(Fe.current=!1,Se.current=!0),Se.current&&Pe(!1)},[E]);return(0,H.jsxs)(n.Fragment,{children:[(0,H.jsx)(J,{inline:s,currentModelName:De,setCurrentModelName:He,modelGroups:Ve,onModelChanged:async()=>{await Ee();const e=await r.XO.get("ai_agent_setting/env");e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data))},sysPromptList:Me,batchMode:he,selectedMsgCount:pe.size,sessionVisible:!oe,onToggleSessionPanel:()=>{ce(e=>!e)},onCreateSession:async e=>{const s=e??"",t=await r.jV.post("session",{sys_prompt_id:s||void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;const n=t.data;q(n.id),K([]),ve(n.sys_prompt_id??""),ce(!1),await We(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:es,bgProcessVisible:re,bgProcessCount:Be,onToggleBgProcess:()=>le(e=>!e),selectedSysPromptId:je,setSelectedSysPromptId:e=>{if(ve(e),O){const s=Xe(O);s?qe("sys_prompt",{session_id:O,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):r.jV.post("session/sys_prompt",{session_id:O,sys_prompt_id:e||void 0}).catch(console.error)}}}),(0,H.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":me},children:[!oe&&(0,H.jsx)("div",{className:"chat-session-overlay",onClick:()=>ce(!0)}),!oe&&(0,H.jsx)(Q,{sessions:B,activeSessionId:O,onSelectSession:e=>Qe(e,!1),onReorderSessions:(e,s)=>{if(Oe.current)return;const t=B.findIndex(s=>s.id===e),n=B.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,u.TI)(B,t,n);z(a),r.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},onRenameSession:(e,s)=>{let t=s;V({confirm_fun:async()=>{const s=Xe(e);s?await qe("rename",{session_id:e,user_id:s,title:t}):await r.jV.post("sessions/update/meta",{id:e,title:t}),await We(O)},context_div:(0,H.jsx)("div",{className:"card-content",children:(0,H.jsx)(j.Sm,{value:t,handleInputChange:e=>{t=e}})})})},onDeleteSession:e=>{V({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=Xe(e);s?await qe("delete",{session_id:e,user_id:s}):await r.jV.post("session/delete",{session_id:e}),O===e?(q(""),await We(null)):await We(O)}})},onToggleCmdAuto:async(e,s)=>{const t=Xe(e);t?await qe("cmd_auto",{session_id:e,user_id:t,allow:s}):await r.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,g.SK)(k(s?"命令检测已开启":"命令检测已关闭")),await We(O)},onShowUsageStats:async e=>{ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-loading",children:k("加载中...")}),cancel:()=>ue({open:!1})});try{const s=Xe(e),t=s?await qe("usage_stats",{session_id:e,user_id:s}):await r.jV.post("session/usage_stats",{session_id:e});if(t.code===_.m.Success&&t.data){const e=t.data;ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsxs)("div",{className:"usage-stats-panel",children:[[{l:k("对话轮次"),v:(e.turns??0).toString()},{l:k("AI输入Token"),v:b(e.input_tokens)},{l:k("AI输出Token"),v:b(e.output_tokens)},{l:k("AI输入Token(最近一轮)"),v:b(e.recent_input_tokens)},{l:k("AI输出Token(最近一轮)"),v:b(e.recent_output_tokens)}].map((e,s)=>(0,H.jsxs)("div",{className:"usage-stats-row",children:[(0,H.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,H.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,H.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,H.jsx)("span",{className:"usage-stats-label",children:k("AI Token总计消耗")}),(0,H.jsx)("span",{className:"usage-stats-value",children:b((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>ue({open:!1})})}else ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>ue({open:!1})})}catch{ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>ue({open:!1})})}},onShowSessionSetting:e=>{let s=B.find(s=>s.id===e)?.file_cwd_path??"";ue({open:!0,title:k("会话设置"),context_div:(0,H.jsxs)("div",{className:"session-setting",children:[(0,H.jsx)("div",{className:"session-setting__label",children:k("服务器工作目录")}),(0,H.jsx)(j.Sm,{value:s,placeholder:k("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=Xe(e);(t?await qe("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await r.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===_.m.Success&&(0,g.SK)(k("保存成功"))}catch{}ue({open:!1}),await We(O)},cancel:()=>ue({open:!1})})},batchMode:he,selectedSessionIds:fe,onToggleSessionSelect:e=>{xe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Ye,onBatchDeleteSessions:()=>{0!==fe.size&&V({sub_title:k("cf_ses"),confirm_fun:async()=>{if(Oe.current)await qe("batch_delete",{session_ids:Array.from(fe)});else for(const e of fe)await r.jV.post("session/delete",{session_id:e});xe(new Set),ge(!1),fe.has(O)?(q(""),await We(null)):await We(O)}})},onClearAllSessions:P?void 0:()=>{V({sub_title:k("cf_all"),confirm_fun:async()=>{await r.jV.post("sessions/clear",{}),q(""),K([]),await We(null)}})},allUsersMode:P,onToggleAllUsersMode:async()=>{const e=!P;F(e),Oe.current=e,q(""),K([]);const s=e?await qe("list_all_sessions"):await r.jV.get("sessions"),t=s.code===_.m.Success?s.data??[]:[];z(t),t[0]?.id&&await Qe(t[0].id,!1,t[0].user_id)},showAllUsersEntry:ie}),(0,H.jsx)(ne,{panelRef:Ce}),(0,H.jsxs)("section",{className:"chat-main",children:[0===E?.length&&(0,H.jsx)("div",{className:"chat-header",children:(0,H.jsx)("div",{children:k("ai_ask")})}),(0,H.jsx)(Z,{messages:E,batchMode:he,selectedMsgIds:pe,sending:G===O||W,chatContainerRef:ye,messagesEndRef:we,onToggleMsgSelect:e=>{_e(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:e=>{V({sub_title:k("cf_one"),confirm_fun:async()=>{const s=E.findIndex(s=>s.id===e);if(s<0)return;const t=E.filter(s=>s.id!==e);if(K(t),O){const e=Xe(O);e?qe("message_delete",{session_id:O,user_id:e,indices:[s]}).catch(console.error):r.jV.post("session/message/delete",{session_id:O,indices:[s]}).catch(console.error)}}})},onCopy:async e=>{(0,h.lW)(w(e)),(0,g.SK)("复制成功")},onCopyAll:async()=>{if(!B.length)return void(0,g.SK)("暂无聊天记录");const e=[];for(const s of B){const t=s.user_id?await qe("get",{session_id:s.id,user_id:s.user_id}):await r.jV.post("session/get",{session_id:s.id});if(t.code!==_.m.Success||!t.data)continue;const n=t.data,a=S([...n.messages??[],...n.live_messages??[]]).map(w).filter(Boolean).join("\n\n\n");a&&e.push(a)}e.length?((0,h.lW)(e.join("\n\n\n")),(0,g.SK)("复制成功")):(0,g.SK)("暂无聊天记录")},onToggleBatchMode:Ye,onBatchCopy:()=>{const e=E.filter(e=>pe.has(e.id)).map(w).filter(Boolean).join("\n\n\n");e?((0,h.lW)(e),(0,g.SK)("复制成功")):(0,g.SK)("暂无内容")},onBatchDelete:es,showBatchBar:he&&pe.size>0&&0===fe.size,t:k}),(0,H.jsx)(te,{ref:Y,onSend:async()=>{if(Oe.current)return;const e=(Y.current?.getValue()??"").trim();if(!e&&0===ee.length)return;if(G===O){const s=await $(ee);Je.enqueueMessage(e,s),Y.current?.clear(),se([]);const t={id:Date.now(),sender:"user",text:e+(Je.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void K(e=>[...e,t])}let s=O;if(!s){const t=await r.jV.post("session",{title:(e||ee[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;s=t.data.id,q(s),N?.(s),await We(s)}const t=await $(ee),n={id:Date.now(),sender:"user",text:e,attachments:t};Y.current?.clear(),se([]);const a=Ie?.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...E,n,t];K(i),U(s);return void(await L(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),K([...i]),U(null),Ge(),Pe(!0),Je.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,K([...i]),U(null),Je.processPendingQueue()))}Je.startChatStream(s,n,()=>Je.processPendingQueue())},readonly:P,sending:G===O||W,onAbort:Je.abort,pendingAttachments:ee,onRemoveAttachment:e=>{se(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{be.current?.click()},onAddFiles:Ze,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Ze(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:be})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(22022),i=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.Bd)(),[t,i]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{i(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),x=(0,n.useCallback)(()=>{if(h.current)return;if(0===l.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=l.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):h.current=!1},[t,f,s]);_.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return i.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{i.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>y});var n=t(96540),a=t(23802),i=t(53995),o=t(18569),c=t(77979),r=t(8263),l=t(69428),d=t.n(l),u=(t(3775),t(21499)),m=t(99214),h=t(89117),g=t(86063),p=t(89334),_=t(41105),f=t(52388),x=t(19878),j=(t(72411),t(74848));const v=new a.A({html:!0,highlight:function(e,s){if(s&&x.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${x.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${x.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${v.utils.escapeHtml(e)}</code></pre>`}});async function b(e,s){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=f.A.t("rendering");const t=await(0,g.Hn)(s);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await t.mount(e))}function w(e){const s=e.className.match(/language-([\w-]+)/);return s?s[1]:""}function y(e){const s=(0,n.useRef)(null);return(0,m.VD)(),(0,n.useEffect)(()=>{s.current&&(s.current.innerHTML=v.render(e.context??""),async function(e){const s=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(s)){const s=w(e),t=(0,h.Hm)(s),n=(0,g.hj)(s);if(!t&&!n)continue;const a=e.closest(".code-block-with-copy")??e.parentElement;if(!a)continue;const i=e.textContent??"",o=document.createElement("div");if(a.replaceWith(o),n){try{await b(o,i)}catch(e){console.error("[mind] render failed",e),o.className="md-graph md-graph--mind",o.textContent=String(e)}continue}o.className="md-graph md-graph--loading",o.textContent=f.A.t("rendering");const c=await(0,h.U6)(s,i);o.isConnected&&(c.error?(o.className="md-graph md-graph--error",o.textContent=c.error):(o.className="md-graph",o.innerHTML=c.svg))}}(s.current),(0,p.rg)(s.current))},[e.context]),(0,j.jsx)("div",{ref:s})}v.use(i.A).use(o.A).use(c.A).use(r.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const o=s[t],c=o.content.trim(),r=o.info.trim();let l="";if(r&&x.A.getLanguage(r))try{l=x.A.highlight(c,{language:r}).value}catch(s){l=e.utils.escapeHtml(c)}else try{l=x.A.highlightAuto(c).value}catch(s){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const o=e[t],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][1]=(0,u.bi)(window.location.href,e)}return s(e,t,n,a,i)}}),(0,p.Rh)(v,_.pC)},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),a=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[h,g]=(0,n.useState)(!1),p=(0,n.useRef)(null),_=(0,n.useRef)(u);_.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=p.current;if(!s)return;const{px_to_unit:t,min:n,max:a,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=i(n),d=i(a);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),_.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{p.current=null,g(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;p.current={pos:t(e),size:s()},g(!0)},[]);return(0,n.useEffect)(()=>{if(!h)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[h,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:h,on_pointer_down:w,on_pointer_up:b}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);