filecat 7.9.0 → 7.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +182 -182
  3. package/build/dist/{4967.3fd3bd40a2b5a3b52428.js → 1060.198d91e2dfc174317c3a.js} +1 -1
  4. package/build/dist/1075.05eed88707339ca32044.js +1 -0
  5. package/build/dist/{1142.121454b1de53689b7367.js → 1142.bc43fae2e5e38d9359df.js} +1 -1
  6. package/build/dist/1384.edbad9c24d883a59724d.js +1 -0
  7. package/build/dist/1417.d390b18dd58ff5c28160.js +1 -0
  8. package/build/dist/1448.4db495e1389c0c8445b3.js +1 -0
  9. package/build/dist/{3324.22efcb1c431177b1cf5f.js → 1455.26a021eb94e5bdd5bec2.js} +1 -1
  10. package/build/dist/{1636.b6a17252dfd0d22f09a7.js → 1636.b80b1883358e132d3424.js} +1 -1
  11. package/build/dist/{1832.8ea5c3e8288df0b7fd5c.js → 1832.a01933ba5df99576ecc2.js} +1 -1
  12. package/build/dist/2300.c99b1dd4e752cdfd5e32.js +2 -0
  13. package/build/dist/{2300.9e1baa1c0368abe53d96.js.LICENSE.txt → 2300.c99b1dd4e752cdfd5e32.js.LICENSE.txt} +1 -1
  14. package/build/dist/239.f570f06d4b9c020f1013.js +1 -0
  15. package/build/dist/{2479.dcc88b3370f0f1d66e02.js → 2479.294792ef5d360ad64abc.js} +1 -1
  16. package/build/dist/2542.26cb302b60de23166227.js +1 -0
  17. package/build/dist/{259.81bb9e049e5ef587a96f.js → 259.3c0eb22e9b43ffb63c9c.js} +1 -1
  18. package/build/dist/2626.3bcfe1f26d9cb796a925.js +1 -0
  19. package/build/dist/{2674.7fd28dae86ccdb247851.js → 2674.15ca3c6ac911cf6e6e2f.js} +1 -1
  20. package/build/dist/3233.43bdd7c12ca829d56116.js +1 -0
  21. package/build/dist/3299.6ab0d94f02171cd762cc.js +1 -0
  22. package/build/dist/{6992.f6a07311a638794c24f7.js → 3471.ef3b5dcfe37963034187.js} +1 -1
  23. package/build/dist/{3528.56eeefab6fca5884e2a6.js → 3528.0f8f34028d92fa87c518.js} +1 -1
  24. package/build/dist/{3659.8a31495bb8f38c0ffa7c.js → 3659.dd03dc2ac52a3ff19105.js} +1 -1
  25. package/build/dist/4004.f0193c43fb891fdfb0e4.js +1 -0
  26. package/build/dist/{4560.8ef2e4b60cc86d019dd6.js → 4560.fd9f8cf2d6022b1d3a94.js} +1 -1
  27. package/build/dist/{4903.b5451ed0802b3f7c07b2.js → 4903.070aaa53a243baf05133.js} +1 -1
  28. package/build/dist/{4946.c95d4f426146e0180172.js → 4946.d578f6ba367a742d80bf.js} +2 -2
  29. package/build/dist/4986.f244efce9cf6be21f846.js +1 -0
  30. package/build/dist/5272.1f0dfac07ba202e7d323.js +1 -0
  31. package/build/dist/{5308.052f45c15785487b3766.js → 5308.d1e5ccb49396fc1b026d.js} +1 -1
  32. package/build/dist/{5516.645e4a900df9bdc1806c.js → 5516.88521f3a3c7101c46df3.js} +1 -1
  33. package/build/dist/5614.43bdd7c12ca829d56116.js +1 -0
  34. package/build/dist/{5139.adf9574d9b54a216e041.js → 5709.81f43e3c021fafdfe36f.js} +1 -1
  35. package/build/dist/{5744.e9f1efb88a617b05b709.js → 5744.0f8a0432b73b2eb0a7ff.js} +1 -1
  36. package/build/dist/{5877.ca081c4798194230243c.js → 5877.98d0475aaf4058b9a715.js} +1 -1
  37. package/build/dist/{6247.917e3fbef5dc5fbaf937.js → 6247.525b0b68872036ac2fa6.js} +1 -1
  38. package/build/dist/{7520.fbb0bc2a05cf94e15418.js → 6322.552511b5cb12cd0c821c.js} +1 -1
  39. package/build/dist/6492.17ecd8515fa512ce9306.js +1 -0
  40. package/build/dist/{676.a75318a8b598d8daadf0.js → 676.356039ef6f28f96b8c8b.js} +1 -1
  41. package/build/dist/{6805.bf0c964ab84f0fcc78be.js → 6805.373ac0e7d6555e4a6459.js} +1 -1
  42. package/build/dist/{6919.8cf13c01184b7148b28e.js → 6919.c7cc8617b658198d4924.js} +1 -1
  43. package/build/dist/{7038.4e4fc8e405c56d3080e2.js → 7038.166f915547d27e4dc5e4.js} +1 -1
  44. package/build/dist/{7759.0b68912ff9ef10869f59.js → 7759.7cd3fe8e5d37df25804c.js} +1 -1
  45. package/build/dist/7873.e3098bc6f510e5bea55f.js +1 -0
  46. package/build/dist/7923.d44556578af4d3d7cea3.js +2 -0
  47. package/build/dist/{7943.19d2de387eeb7f513d8e.js → 7943.acf25a5e98dd13290985.js} +1 -1
  48. package/build/dist/8090.8977224618a14ae42159.js +2 -0
  49. package/build/dist/8302.ce97557b7cf7c8387942.js +1 -0
  50. package/build/dist/8319.6a6b9651c87a1bb4cbb9.js +1 -0
  51. package/build/dist/{8603.4142ce42c1635f493eca.js → 8603.f1cbcfd64cde885f9809.js} +1 -1
  52. package/build/dist/8649.d6055ad75975b803bbc1.js +1 -0
  53. package/build/dist/{8727.3628c746061aed7a4077.js → 8727.8658835acb7e0b6e5acc.js} +1 -1
  54. package/build/dist/{8765.a5633d054abb67142fc3.js → 8765.8758c290a6b132f2ce7f.js} +1 -1
  55. package/build/dist/8772.2c35012c25ac9eb5f74d.js +2 -0
  56. package/build/dist/{8772.e8f9731c1c061f1cdf56.js.LICENSE.txt → 8772.2c35012c25ac9eb5f74d.js.LICENSE.txt} +1 -1
  57. package/build/dist/8781.6bd14487d172e004e3d3.js +1 -0
  58. package/build/dist/{9299.6c06dad1abe098b61766.js → 9299.7358ccf05b1415ed7959.js} +1 -1
  59. package/build/dist/9334.a25983aafdcbde63ae5e.js +1 -0
  60. package/build/dist/{9546.e7206c968e92371ae2b1.js → 9546.2cecad04cf676a6616cd.js} +1 -1
  61. package/build/dist/dark.css +839 -839
  62. package/build/dist/filerobot-image-editor.min.js +42445 -42445
  63. package/build/dist/google-dark.css +2032 -2032
  64. package/build/dist/google.css +1719 -1719
  65. package/build/dist/index.html +1 -1
  66. package/build/dist/main.ab3398f34c41e61310ae.js +2 -0
  67. package/build/dist/{main.3a12152528aff6ae213a.js.LICENSE.txt → main.ab3398f34c41e61310ae.js.LICENSE.txt} +1 -1
  68. package/build/dist/rle.js +17867 -17867
  69. package/build/main.js +1 -1
  70. package/build/plugin/core.type.d.ts +62 -0
  71. package/build/threads.work.filecat.js +1 -1
  72. package/env +26 -26
  73. package/package.json +211 -211
  74. package/shell/build.js +161 -161
  75. package/shell/config/.babelrc +14 -14
  76. package/shell/config/base.webpack.config.js +78 -78
  77. package/shell/config/common-bin.config.js +44 -44
  78. package/shell/config/env.js +10 -10
  79. package/shell/config/prebuild-file-path.js +17 -17
  80. package/shell/config/webpack.exe.config.js +36 -36
  81. package/shell/config/webpack.npm.config.js +44 -44
  82. package/shell/config/webpack.web.config.js +152 -152
  83. package/shell/dev.js +51 -51
  84. package/shell/docker-build.sh +2 -2
  85. package/shell/filecat +1 -1
  86. package/shell/filecat-watch +1 -1
  87. package/shell/install.js +48 -48
  88. package/shell/net-agent/git-clone.bat +23 -23
  89. package/shell/net-agent/git-pull.bat +17 -17
  90. package/shell/net-agent/git-push.bat +17 -17
  91. package/shell/pkg.ts +50 -50
  92. package/shell/postinstall-optional.js +29 -29
  93. package/shell/start/filecat-install.sh +22 -22
  94. package/shell/start/filecat-run.sh +2 -2
  95. package/shell/start/windows-install.js +178 -178
  96. package/shell/start/windows-uninstall.js +131 -131
  97. package/shell/util/file.js +46 -46
  98. package/build/dist/1075.40103ec059c6b23b056e.js +0 -1
  99. package/build/dist/1384.0d0fc5faa899c9eddcbe.js +0 -1
  100. package/build/dist/1417.7e511043474084a2a65b.js +0 -1
  101. package/build/dist/1448.0710f04bed1c52e6a5db.js +0 -1
  102. package/build/dist/2300.9e1baa1c0368abe53d96.js +0 -2
  103. package/build/dist/2542.23fb13b1623c9f7c3fc1.js +0 -1
  104. package/build/dist/2626.05d1faa293e0a3318b9b.js +0 -1
  105. package/build/dist/2851.2195b5906b2c224c7bf7.js +0 -1
  106. package/build/dist/3140.794a212da633caf38b3a.js +0 -2
  107. package/build/dist/3233.fb6bffd5e097e4ac9423.js +0 -1
  108. package/build/dist/3299.f37767d30b6999df4014.js +0 -1
  109. package/build/dist/4004.5d68418ad5c2321cb11f.js +0 -1
  110. package/build/dist/4986.78047106f3a0d2d71199.js +0 -1
  111. package/build/dist/5272.0b70ee8ec5f083fb9f5b.js +0 -1
  112. package/build/dist/5614.fb6bffd5e097e4ac9423.js +0 -1
  113. package/build/dist/6492.3ee4060598de873d8e8f.js +0 -1
  114. package/build/dist/7756.2f851693ba030c42dde8.js +0 -1
  115. package/build/dist/7873.11d04b741d2b499d9cb9.js +0 -1
  116. package/build/dist/7923.861345fd55941e8089a1.js +0 -2
  117. package/build/dist/8014.28b5cf8c3787dc829aa4.js +0 -1
  118. package/build/dist/8302.5ae5bfe8baa0084204bb.js +0 -1
  119. package/build/dist/8319.c15a3674ec7abc493595.js +0 -1
  120. package/build/dist/8772.e8f9731c1c061f1cdf56.js +0 -2
  121. package/build/dist/8781.58f0c51870d3dd2689d7.js +0 -1
  122. package/build/dist/main.3a12152528aff6ae213a.js +0 -2
  123. /package/build/dist/{4946.c95d4f426146e0180172.js.LICENSE.txt → 4946.d578f6ba367a742d80bf.js.LICENSE.txt} +0 -0
  124. /package/build/dist/{7923.861345fd55941e8089a1.js.LICENSE.txt → 7923.d44556578af4d3d7cea3.js.LICENSE.txt} +0 -0
  125. /package/build/dist/{3140.794a212da633caf38b3a.js.LICENSE.txt → 8090.8977224618a14ae42159.js.LICENSE.txt} +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3233,5614],{33616(e){var n;self,n=()=>(()=>{"use strict";var e,n={};return e=n,Object.defineProperty(e,"__esModule",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const n=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(n._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,n=e._renderService.dimensions;if(0===n.css.cell.width||0===n.css.cell.height)return;const t=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),i=Math.max(0,parseInt(r.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),l=o-(parseInt(s.getPropertyValue("padding-top"))+parseInt(s.getPropertyValue("padding-bottom"))),a=i-(parseInt(s.getPropertyValue("padding-right"))+parseInt(s.getPropertyValue("padding-left")))-t;return{cols:Math.max(2,Math.floor(a/n.css.cell.width)),rows:Math.max(1,Math.floor(l/n.css.cell.height))}}},n})(),e.exports=n()},40654(e,n,t){"use strict";t.r(n),t.d(n,{default:()=>E});var r=t(96540),o=t(33616),i=(t(97856),t(85072)),s=t.n(i),l=t(97825),a=t.n(l),c=t(77659),d=t.n(c),u=t(55056),m=t.n(u),p=t(10540),h=t.n(p),x=t(41113),f=t.n(x),g=t(86739),v={};v.styleTagTransform=f(),v.setAttributes=m(),v.insert=d().bind(null,"head"),v.domAPI=a(),v.insertStyleElement=h();s()(g.A,v);g.A&&g.A.locals&&g.A.locals;var y=t(40505),_=t(62042),b=t(84369),w=t(74848);function E(e){const[n,t]=(0,r.useState)(25),i=(0,r.useRef)(null),s=(0,r.useCallback)(new o.FitAddon,[]),l=(0,r.useRef)(null),a=(0,r.useRef)(null),{dragging:c,on_pointer_down:d,on_pointer_up:u}=(0,b.y)({direction:"vertical",target_ref:l,get_start_size:()=>n,px_to_unit:e=>e/parseFloat(getComputedStyle(l.current).fontSize),min:()=>{const e=parseFloat(getComputedStyle(l.current).fontSize);return 2.25+i.current.offsetHeight/e},max:()=>{const e=parseFloat(getComputedStyle(l.current).fontSize);return window.innerHeight/e-4},throttle:32,on_change:e=>{s.fit(),t(parseFloat(e.toFixed(2)))}});if((0,r.useEffect)(()=>{e.terminal&&(e.terminal.options.convertEol=!0,e.terminal.open(a.current),e.terminal.loadAddon(s),s.fit(),e.init&&e.init(e.terminal.rows,e.terminal.cols),e.terminal.attachCustomKeyEventHandler(n=>{if(n.ctrlKey&&"c"===n.key){const t=e.terminal.getSelection();if(t)return(0,y.lW)(t),(0,_.SK)("已复制"),n.preventDefault(),e.terminal.focus(),!1}else if("keydown"===n.type&&"v"===n.key&&n.ctrlKey)return!1;return!0}))},[e.terminal]),(0,r.useEffect)(()=>()=>{e.terminal&&e.terminal.dispose()},[]),e.show)return e.get_simple?(0,w.jsx)("div",{className:"pty",style:{height:"100%"},ref:a}):(0,w.jsxs)("div",{className:"shell",style:{height:`${n}em`,display:""+(e.file_shell_hidden?"none":"block")},ref:l,children:[(0,w.jsx)("div",{className:"shell__divider",ref:i,onPointerDown:d,onPointerUp:u}),(0,w.jsx)("div",{className:"pty",style:{height:n-1+"em"},ref:a}),c&&(0,w.jsx)("div",{className:"shell__overlay",onPointerUp:u})]})}},85614(e,n,t){"use strict";t.r(n),t.d(n,{default:()=>s});var r=t(96540),o=(t(40654),t(74848));const i=r.lazy(()=>Promise.resolve().then(t.bind(t,40654)));function s(e){return(0,o.jsx)(r.Fragment,{children:(0,o.jsx)(i,{...e})})}},84369(e,n,t){"use strict";t.d(n,{y:()=>s});var r=t(96540),o=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function s(e){const{direction:n="vertical",target_ref:t,get_start_size:s,px_to_unit:l,min:a,max:c,throttle:d,on_change:u,on_drag_end:m}=e,[p,h]=(0,r.useState)(!1),x=(0,r.useRef)(null),f=(0,r.useRef)(u);f.current=u;const g=e=>"vertical"===n?e.clientY:e.clientX,v=(0,r.useRef)({direction:n,get_start_size:s,px_to_unit:l,min:a,max:c,get_pos:g});v.current={direction:n,get_start_size:s,px_to_unit:l,min:a,max:c,get_pos:g};const y=(0,r.useCallback)(e=>{const n=x.current;if(!n)return;const{px_to_unit:t,min:r,max:o,get_pos:s}=v.current,l=n.pos-s(e);let a=n.size+t(l);const c=i(r),d=i(o);void 0!==c&&(a=Math.max(c,a)),void 0!==d&&(a=Math.min(d,a)),f.current(a)},[]),_=r.useMemo(()=>void 0===d?y:o.throttle(e=>y(e),d),[d,y]),b=(0,r.useCallback)(()=>{x.current=null,h(!1);const e=_;"function"==typeof e.cancel&&e.cancel(),m?.()},[_,m]),w=(0,r.useCallback)(e=>{const{get_start_size:n,get_pos:t}=v.current;x.current={pos:t(e),size:n()},h(!0)},[]);return(0,r.useEffect)(()=>{if(!p)return;const e=t?.current??window;return e.addEventListener("pointermove",_),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",_),e.removeEventListener("pointerup",b)}},[p,_,b,t]),(0,r.useEffect)(()=>{const e=_;return()=>{"function"==typeof e.cancel&&e.cancel()}},[_]),{dragging:p,on_pointer_down:w,on_pointer_up:b}}},86739(e,n,t){"use strict";t.d(n,{A:()=>l});var r=t(31601),o=t.n(r),i=t(76314),s=t.n(i)()(o());s.push([e.id,'/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * https://github.com/chjj/term.js\n * @license MIT\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the "Software"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Originally forked from (with the author\'s permission):\n * Fabrice Bellard\'s javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n * The original design remains. The terminal itself\n * has been extended to include xterm CSI codes, among\n * other features.\n */\n\n/**\n * Default styles for xterm.js\n */\n\n.xterm {\n cursor: text;\n position: relative;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.xterm.focus,\n.xterm:focus {\n outline: none;\n}\n\n.xterm .xterm-helpers {\n position: absolute;\n top: 0;\n /**\n * The z-index of the helpers must be higher than the canvases in order for\n * IMEs to appear on top.\n */\n z-index: 5;\n}\n\n.xterm .xterm-helper-textarea {\n padding: 0;\n border: 0;\n margin: 0;\n /* Move textarea out of the screen to the far left, so that the cursor is not visible */\n position: absolute;\n opacity: 0;\n left: -9999em;\n top: 0;\n width: 0;\n height: 0;\n z-index: -5;\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\n white-space: nowrap;\n overflow: hidden;\n resize: none;\n}\n\n.xterm .composition-view {\n /* TODO: Composition position got messed up somewhere */\n background: #000;\n color: #FFF;\n display: none;\n position: absolute;\n white-space: nowrap;\n z-index: 1;\n}\n\n.xterm .composition-view.active {\n display: block;\n}\n\n.xterm .xterm-viewport {\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\n background-color: #000;\n overflow-y: scroll;\n cursor: default;\n position: absolute;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n}\n\n.xterm .xterm-screen {\n position: relative;\n}\n\n.xterm .xterm-screen canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.xterm .xterm-scroll-area {\n visibility: hidden;\n}\n\n.xterm-char-measure-element {\n display: inline-block;\n visibility: hidden;\n position: absolute;\n top: 0;\n left: -9999em;\n line-height: normal;\n}\n\n.xterm.enable-mouse-events {\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\n cursor: default;\n}\n\n.xterm.xterm-cursor-pointer,\n.xterm .xterm-cursor-pointer {\n cursor: pointer;\n}\n\n.xterm.column-select.focus {\n /* Column selection mode */\n cursor: crosshair;\n}\n\n.xterm .xterm-accessibility:not(.debug),\n.xterm .xterm-message {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10;\n color: transparent;\n pointer-events: none;\n}\n\n.xterm .xterm-accessibility-tree:not(.debug) *::selection {\n color: transparent;\n}\n\n.xterm .xterm-accessibility-tree {\n user-select: text;\n white-space: pre;\n}\n\n.xterm .live-region {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.xterm-dim {\n /* Dim should not apply to background, so the opacity of the foreground color is applied\n * explicitly in the generated class and reset to 1 here */\n opacity: 1 !important;\n}\n\n.xterm-underline-1 { text-decoration: underline; }\n.xterm-underline-2 { text-decoration: double underline; }\n.xterm-underline-3 { text-decoration: wavy underline; }\n.xterm-underline-4 { text-decoration: dotted underline; }\n.xterm-underline-5 { text-decoration: dashed underline; }\n\n.xterm-overline {\n text-decoration: overline;\n}\n\n.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }\n.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }\n.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }\n.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }\n.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }\n\n.xterm-strikethrough {\n text-decoration: line-through;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration {\n\tz-index: 6;\n\tposition: absolute;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {\n\tz-index: 7;\n}\n\n.xterm-decoration-overview-ruler {\n z-index: 8;\n position: absolute;\n top: 0;\n right: 0;\n pointer-events: none;\n}\n\n.xterm-decoration-top {\n z-index: 2;\n position: relative;\n}\n',""]);const l=s}}]);
@@ -1 +0,0 @@
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)("textarea",{className:"input input--block",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.9.0",null!=U.latest_version&&"7.9.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){s.d(t,{K:()=>i});var n=s(22022);const i=()=>{const{t:e}=(0,n.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4004,6010],{83277(e,s,t){t.d(s,{$j:()=>o,CP:()=>a,Lv:()=>n,cL:()=>i});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='\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';const i=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}},95733(e,s,t){t.r(s),t.d(s,{default:()=>ne});var n=t(96540),a=t(34843),i=t(22022),o=t(52671),c=t(92275),r=t(14284),l=t(7463),d=t(21499),u=t(64694),m=t(78247),h=t(40505),g=t(62042),p=t(45907),_=t(53459),f=t(72693),x=t(82893),j=t(61443),v=t(83277);function b(e){return null==e||e<0?"0":e.toLocaleString()}function w(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,v.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function y(e){const s=(0,v.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,v.$j)(e.content)).filter(Boolean).join("\n\n"):""}function S(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:y(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const N=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function k(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||N.test(e.name)?"text":"binary"}function C(e){return e.text()}function A(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function $(e){const s=[];for(const t of e){const e=k(t);let n="";if("text"===e)try{const e=await C(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await A(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var I=t(14944);var M=t(85997),R=t(34299),D=t(74848);function H(e){const s=e.attachments&&e.attachments.length>0?(0,D.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,D.jsxs)("div",{className:"chat-message-attachment",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{children:e.name}),(0,D.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(E,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(T,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(B,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,D.jsx)(R.default,{context:e.text}):null;return(0,D.jsxs)(D.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,v.$j)(e.content);return a&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(R.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,D.jsx)(n.Fragment,{children:(0,D.jsx)(V,{callList:e.tool_call_ends})},`tool-${s}`)),(0,D.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,D.jsx)(R.default,{context:e.text}):null]})}(e);return 0===t.length?(0,D.jsxs)(D.Fragment,{children:[s,a]}):(0,D.jsxs)(D.Fragment,{children:[t,s,a]})}function V({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,D.jsxs)("div",{className:"chat-message-call-list",children:[(0,D.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,D.jsx)(M.In,{icon:s?"expand_less":"expand_more"}),(0,D.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,D.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,D.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,D.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,D.jsxs)("div",{className:"call-list-item-header",children:[(0,D.jsx)(M.In,{icon:e.success?"check_circle":"error"}),(0,D.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,D.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"参数"}),(0,D.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"错误"}),(0,D.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,D.jsxs)("details",{className:"call-list-details",children:[(0,D.jsx)("summary",{children:"结果"}),(0,D.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function E({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,D.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,D.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,D.jsx)("div",{className:"image-generation-image-wrapper",children:(0,D.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,D.jsx)("p",{className:"image-generation-prompt",children:(0,D.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,D.jsx)(R.default,{context:s})]}):(0,D.jsx)(R.default,{context:s||""})}function T({audio:e,text:s}){if(e){if(e.url)return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,D.jsx)("div",{className:"audio-result",children:(0,D.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,D.jsx)(R.default,{context:t})}function K({content:e,label:s}){const[t,a]=n.useState(!1);return(0,D.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,h.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,D.jsx)(M.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function B({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,D.jsx)(R.default,{context:s})}if(!t)return(0,D.jsx)(R.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,D.jsxs)("div",{className:"embeddings-result",children:[(0,D.jsxs)("div",{className:"embeddings-summary",children:[(0,D.jsx)("strong",{children:"向量嵌入结果"}),(0,D.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,D.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,D.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,D.jsxs)("div",{className:"embeddings-toolbar",children:[(0,D.jsx)(K,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,D.jsx)(K,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,D.jsx)(K,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,D.jsx)("div",{className:"embeddings-preview",children:(0,D.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,D.jsxs)("details",{children:[(0,D.jsx)("summary",{children:"查看详细数据"}),(0,D.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function z(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await r.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const a=n.data||{},i=(a.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=i.map((e,s)=>`![生成图片${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),L=t(23430),F=t(87361),O=t(80389),q=t(7523),G=t(23496);const U=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:c,sysPromptList:l,batchMode:d,selectedMsgCount:u,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),$=(0,o.Zp)(),{check_user_auth:I}=(0,m.MH)(),[,R]=(0,a.fp)(x.AG.ai_session_collapsed),{open:H}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(x.AG.prompt_card),[t,o]=(0,a.fp)(x.AG.ai_chat_zoom),{initUserInfo:c}=(0,n.useContext)(q.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,D.jsx)(O.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),a()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await r.wm.post(G.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,g.SK)(e("缩放调整成功")),c(),a()}})}}}(),V=I(L.oV.ai_model_switch)||I(L.oV.ai_agent_setting),E=[];for(const e of t)for(const s of e.models)E.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const T=t.find(e=>e.active),K=T?`${T.index}::${e}`:"",B=(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(M.rA,{icon:"menu",title:A("会话"),onClick:p,selected:h}),(0,D.jsx)(M.rA,{icon:"add",title:A("新会话"),onClick:()=>f()}),l.length>0&&(0,D.jsx)(j.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...l.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),V&&E.length>0&&(0,D.jsx)(j.l6,{value:K,options:[{title:A("选择模型"),value:""},...E],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...a]=t.split("::"),i=a.join("::");i&&(s(i),r.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===_.m.Success?((0,g.SK)("success"),c()):(0,g.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),d&&u>0&&(0,D.jsx)(M.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,D.jsx)(M.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:H}),(0,D.jsx)(M.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{$(F.o.ai_rebot_setting_page)}}),I(L.oV.ai_agent_setting)&&(0,D.jsx)(M.rA,{icon:"settings",title:"ai setting",onClick:()=>{$(F.o.ai_agent_setting_page)}})]});return C?(0,D.jsx)("div",{className:"chat-inline-header",children:B}):(0,D.jsx)(P.aZ,{position:"right",children:B})};var J=t(83529);function W({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:h,onToggleBatchMode:g,onBatchDeleteSessions:p,onClearAllSessions:_,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j}){const{t:v}=(0,i.Bd)(),[b,w]=(0,n.useState)(""),[y,S]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=!!a&&!f,A=b.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(b.toLowerCase())||(e.summary||"").toLowerCase().includes(b.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(b.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(b.toLowerCase())):e;return(0,D.jsxs)("aside",{className:"chat-session-list",children:[(0,D.jsx)("div",{className:"chat-session-search",children:(0,D.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,D.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,D.jsx)("div",{children:(0,D.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${y===n?"row-dragging":""} ${N===n&&null!==y&&y!==n?"row-drop-target":""}`,draggable:C,onDragStart:()=>S(n),onDragOver:e=>{null!==y&&(e.preventDefault(),N!==n&&k(n))},onDragEnd:()=>{S(null),k(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=y;if(S(null),k(null),null===s||s===e||!a)return;const t=A[s]?.id,n=A[e]?.id;t&&n&&a(t,n)})(n)},onClick:()=>{u&&h?h(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,D.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>h?.(e.id),onClick:e=>e.stopPropagation()}),(0,D.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,D.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,D.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,D.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,D.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,D.jsx)(J.MenuSelect,{list:[{name:v("重命名"),click:()=>o(e.id,e.title)},...f?[]:[{name:v("移动到最上"),click:()=>{const s=A[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{name:v("移动到最下"),click:()=>{const s=A[A.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{name:e.cmd_auto_allow?v("命令检测关闭"):v("命令检测开启"),click:()=>r?.(e.id,!e.cmd_auto_allow)},{name:v("字符消耗统计"),click:()=>l(e.id)},{name:v("设置"),click:()=>d?.(e.id)},{name:v("删除"),click:()=>c(e.id)}],children:(0,D.jsx)(M.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,D.jsxs)("div",{className:"chat-session-actions",children:[(0,D.jsx)(M.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:g}),j&&!u&&(0,D.jsx)(M.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,D.jsx)(M.rA,{icon:"delete",title:v("删除选中会话"),onClick:p}),!u&&_&&(0,D.jsx)(M.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:_})]})]})}function Q(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const X=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:u,onToggleBatchMode:m,onBatchCopy:h,onBatchDelete:g,showBatchBar:p,t:_})=>{const[f,x]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),v=e=>{x(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},b=()=>{x(e=>e.size>0&&j.every(s=>e.has(s))?new Set:new Set(j))};return(0,D.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[p&&(0,D.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,D.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,D.jsx)("button",{onClick:h,children:_("复制所选")}),(0,D.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,D.jsx)("button",{onClick:m,children:_("取消")})]}),e.map(e=>{const n=f.has(e.id);return(0,D.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,D.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,D.jsxs)("div",{className:"ai-loading-bubble",children:[(0,D.jsxs)("div",{className:"ai-loading-dots",children:[(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"}),(0,D.jsx)("span",{className:"ai-loading-dot"})]}),(0,D.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>v(e.id),children:[(0,D.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,D.jsx)("span",{className:"chat-message-summary-text",children:Q(e)||_("(无内容)")})]}):(0,D.jsx)("div",{className:"chat-message-body",children:H(e)}),(0,D.jsxs)("div",{className:"message-collapse-bar",children:[(0,D.jsx)("button",{onClick:()=>v(e.id),children:_(n?"展开":"折叠")}),(0,D.jsx)("button",{onClick:b,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,D.jsx)("span",{className:"message-elapsed",children:(0,d.kf)(e.elapsed_ms)})]}),(0,D.jsx)("div",{className:"message-actions",children:s?(0,D.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?_("取消选择"):_("选择")}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,D.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,D.jsx)("button",{onClick:u,children:_("全部复制")}),(0,D.jsx)("button",{onClick:m,children:_("多选")})]})})]})]},e.id)}),(0,D.jsx)("div",{ref:o})]})},Z=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>g(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,D.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:o,onInput:()=>c?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});var Y=t(84369);function ee({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,D.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,D.jsxs)("div",{className:"chat-attachment-chip",children:[(0,D.jsx)(M.In,{icon:"attach_file"}),(0,D.jsx)("span",{title:e.name,children:e.name}),(0,D.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,D.jsx)(M.In,{icon:"close"})})]},`${e.name}_${t}`))})}const se=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:m,readonly:h=!1},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),f=(0,n.useRef)(null),[j,v]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,Y.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=f.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,D.jsxs)("div",{ref:f,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,D.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,D.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,D.jsxs)("div",{className:"chat-input-shell",children:[(0,D.jsx)(ee,{pendingAttachments:o,onRemove:c}),(0,D.jsx)(Z,{ref:_,placeholder:p(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input",style:S})]}),!h&&(0,D.jsx)(M.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,D.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,D.jsx)(M.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,D.jsx)(M.Vi,{text:p("发送"),clickFun:e}),b&&(0,D.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),te=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[p,_]=(0,n.useState)(!1),[f,j]=(0,a.fp)(x.AG.ai_bg_expanded),[,v]=(0,a.fp)(x.AG.ai_session_collapsed),b=()=>{j(!1)},w=(0,n.useCallback)(async()=>{l(!0);try{const s=new c.hf(c.HK.ai_bg_process_list_req);s.context={};const t=await I.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=w);const y=(0,n.useCallback)(async e=>{_(!0),u(e);try{const s=new c.hf(c.HK.ai_bg_process_output_req);s.context={pid:e};const t=await I.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,g.zN)("获取进程输出失败")}finally{_(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new c.hf(c.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await I.ws.send(s);t?.context?.success?((0,g.SK)("进程已终止"),w(),d===e&&(u(null),h(null))):(0,g.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,g.zN)("终止进程失败")}},[w,d]);(0,n.useEffect)(()=>{w();const e=setInterval(w,5e3);return()=>clearInterval(e)},[w]);const N=t.filter(e=>e.running),k=t.filter(e=>!e.running);return(0,D.jsxs)(D.Fragment,{children:[f&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:b}),(0,D.jsxs)("aside",{className:"chat-bg-process-panel "+(f?"expanded":""),children:[(0,D.jsxs)("div",{className:"chat-bg-process-header",children:[(0,D.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:b})]}),(0,D.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,D.jsx)(M.rA,{icon:"refresh",title:s("刷新"),onClick:w}),(0,D.jsxs)("span",{className:"chat-bg-process-count",children:[N.length," ",s("个运行中"),k.length>0&&` / ${k.length} ${s("个已退出")}`]})]}),(0,D.jsxs)("div",{className:"chat-bg-process-list",children:[r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!r&&0===t.length&&(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),N.map(e=>(0,D.jsxs)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} running`,children:[(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,D.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,D.jsx)(M.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,D.jsx)(M.rA,{icon:"stop",title:s("终止进程"),onClick:()=>S(e.pid)})]})]},e.pid)),k.map(e=>(0,D.jsx)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} finished`,children:(0,D.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,D.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,D.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,D.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,D.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==d&&(0,D.jsxs)("div",{className:"chat-bg-process-output",children:[(0,D.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,D.jsxs)("span",{children:["PID: ",d," ",s("输出")]}),(0,D.jsx)(M.rA,{icon:"close",title:s("关闭"),onClick:()=>{u(null),h(null)}})]}),(0,D.jsx)("div",{className:"chat-bg-process-output-content",children:p?(0,D.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):m?(0,D.jsx)("pre",{className:"chat-bg-process-output-pre",children:m.output||s("(无输出)")}):null})]})]})]})};function ne(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:v,sync_url:y=!0,on_session_change:N}=e,{t:k}=(0,i.Bd)(),[C,A]=(0,o.ok)(),M=y&&C.get("session")||"",R=e=>{y&&A(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},H=(0,p.y)(),{check_user_auth:V}=(0,m.MH)();(0,f.w)();const[E,T]=(0,n.useState)([]),[K,B]=(0,n.useState)([]),[P,L]=(0,n.useState)(!1),[F,O]=(0,n.useState)(""),[q,G]=(0,n.useState)(null),[J,Q]=(0,n.useState)(!1),Z=(0,n.useRef)(null),[Y,ee]=(0,n.useState)([]),[ne]=(0,a.fp)(x.AG.user_base_info),ae=!!ne?.user_data?.is_root,[ie,oe]=(0,a.fp)(x.AG.ai_session_collapsed),[ce,re]=(0,a.fp)(x.AG.ai_bg_expanded),[le,de]=(0,a.fp)(x.AG.prompt_card),[ue]=(0,a.fp)(x.AG.ai_chat_zoom),[me,he]=(0,n.useState)(!1),[ge,pe]=(0,n.useState)(new Set),[_e,fe]=(0,n.useState)(new Set),[xe,je]=(0,n.useState)(""),ve=(0,n.useRef)(null),be=(0,n.useRef)(null),we=(0,n.useRef)(null),ye=(0,n.useRef)(!0),Se=(0,n.useRef)(null),Ne=(0,n.useRef)(0),ke=(0,n.useRef)(null),Ce=(0,n.useRef)({}),Ae=(0,n.useRef)(F),$e=(0,n.useRef)(q);(0,n.useEffect)(()=>{Ae.current=F},[F]),(0,n.useEffect)(()=>{$e.current=q},[q]);const Ie=(0,n.useRef)({}),[Me,Re]=(0,n.useState)([]),[De,He]=(0,n.useState)(""),[Ve,Ee]=(0,n.useState)([]),Te=async()=>{try{const e=await r.jV.get("public_models");e.code===_.m.Success&&Ee(e.data?.groups??[])}catch{Ee([])}},Ke=e=>{He(e?.ai_config?.model??"")},[Be,ze]=(0,n.useState)(0),Pe=(0,n.useRef)((0,l.sg)(e=>{T(e),ye.current&&Le(!1)},50)).current,Le=(e=!1)=>{const s=we.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},Fe=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Fe.current=P},[P]);const Oe=(e,s={})=>r.jV.post("admin/session",{action:e,...s}),qe=async()=>{const e=Fe.current?await Oe("list_all_sessions"):await r.jV.get("sessions");e.code===_.m.Success&&B(e.data??[])},Ge=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:r,refreshSessions:l,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,r)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};h.push(p),t([...h]);const _=new Map;let f=!0,x=p;const j=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",i=t.tool_call_ends,c=t.chunk_index??0;if("[DONE]"!==n)if(f)f=!1,x.text=n,i&&(x.content_list=[{tool_call_ends:i,content:x.text,role:"assistant"}]),x.is_loading=!1,x.chunk_index=c,_.set(c,x),o()===e&&a([...h]);else{const s=_.get(c);if(s)s.text+=n,i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),o()===e&&a([...h]);else{const s={id:Date.now()+Math.random(),sender:"bot",text:n,chunk_index:c};i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),h.push(s),_.set(c,s),o()===e&&a([...h])}}},v=s=>{const n=s.context||{};if(n.session_id===e){if(w(),g.current=null,i(s=>s===e?null:s),x.is_loading=!1,o()===e)if(n.once_messages_list?.length){const e=S(n.once_messages_list);t(s=>{const t=s[s.length-1];return"bot"===t?.sender?[...s.slice(0,-1),...e]:[...s,...e]})}else t([...h]);l(),d(!0),r()}},b=s=>{const n=s.context||{};n.session_id===e&&(w(),g.current=null,i(s=>s===e?null:s),x.text="AI请求出错: "+(n.message||"未知错误"),x.is_loading=!1,o()===e&&t([...h]),r())},w=()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,j),I.ws.off_message(`message_${c.HK.ai_chat_end}`,v),I.ws.off_message(`message_${c.HK.ai_chat_error}`,b)};I.ws.addMsg(c.HK.ai_chat_msg,j),I.ws.addMsg(c.HK.ai_chat_end,v),I.ws.addMsg(c.HK.ai_chat_error,b),I.ws.sendData(c.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(o(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(I.ws.sendData(c.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>E,setMessages:T,setMessagesDebounced:Pe,setSending:G,getActiveSessionId:()=>Ae.current,setActiveSessionId:O,refreshSessions:qe,scrollToBottom:Le,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>xe}),Ue=async e=>{const s=Fe.current?await Oe("list_all_sessions"):await r.jV.get("sessions");if(s.code!==_.m.Success)return!1;const t=s.data??[];B(t);const n=null===e?t[0]?.id??"":e||F||t[0]?.id||"";if(n){const e=t.find(e=>e.id===n)?.user_id;return await Je(n,!1,e)}return T([]),O(""),R(null),!1},Je=async(e,s=!1,t)=>{const n=t??K.find(s=>s.id===e)?.user_id,a=Fe.current&&n?await Oe("get",{session_id:e,user_id:n}):await r.jV.post("session/get",{session_id:e});if(a.code!==_.m.Success||!a.data)return!1;const i=a.data;O(i.id),y&&M!==i.id&&R(i.id),N?.(i.id),Q(!!i.running),ke.current&&ke.current!==i.id&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=i.running?i.id:null,ke.current&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!0});const o=S(i.messages);return i.running&&i.live_messages?.length?T([...o,...S(i.live_messages)]):T(o),je(i.sys_prompt_id??""),s&&oe(!1),Ce.current.refresh?.(),requestAnimationFrame(()=>Le(!1)),!0},We=e=>{if(Fe.current)return K.find(s=>s.id===e)?.user_id},Qe=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&ee(e=>[...e,...s])},Xe=()=>{me&&(pe(new Set),fe(new Set)),he(e=>!e)},Ze=()=>{0!==ge.size&&H({sub_title:k("cf_msgs"),confirm_fun:async()=>{const e=[];if(E.forEach((s,t)=>{ge.has(s.id)&&e.push(t)}),T(E.filter(e=>!ge.has(e.id))),pe(new Set),he(!1),F&&e.length>0){const s=We(F);s?Oe("message_delete",{session_id:F,user_id:s,indices:e}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:e}).catch(console.error)}}})},Ye=async()=>{const e=await r.XO.get("ai_agent_setting/env");if(e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data)),await Te(),v){const e=await(async e=>{if(!e)return null;const s=await r.jV.get("sessions");if(s.code!==_.m.Success)return null;const t=s.data??[],n=(0,d.ed)(e);if(!n)return null;const a=t.find(e=>(0,d.ed)(e.file_cwd_path)===n);if(a)return a.id;const i=await r.jV.post("session",{title:"新会话",file_cwd_path:e});return i.code!==_.m.Success?null:i.data.id})(v);!!e&&await Ue(e)||await Ue()}else if(t){await Ue(t)||await Ue()}else if(M){await Ue(M)||await Ue()}else await Ue();const s=await r.jV.get("system_prompts");s.code===_.m.Success&&Re(s.data??[])};(0,n.useEffect)(()=>{Ye(),requestAnimationFrame(()=>Le(!1)),Ce.current.onCountChange=ze,Ce.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ze(s)};return I.ws.addMsg(c.HK.ai_bg_process_count_notify,e),()=>{I.ws.off_message(`message_${c.HK.ai_bg_process_count_notify}`,e)}},[]),(0,n.useEffect)(()=>{const e=we.current;if(!e)return;const s=()=>{ye.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useEffect)(()=>{const e=()=>Ae.current,s=()=>$e.current,t=(t,n)=>{if(e()&&e()===t){if(Se.current=null,Q(!1),ke.current===t&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),ke.current=null),s()===t)return;n?.length?T(e=>{const s=S(n),t=e[e.length-1];return"bot"===t?.sender?[...e.slice(0,-1),...s]:[...e,...s]}):Je(t).catch(()=>{}),qe()}},n=t=>{const n=t?.context||{};if(!n.session_id)return;var a,i,o;a=n.session_id,i=n.text||"",o=n.tool_call_ends,e()&&e()===a&&s()!==a&&T(e=>{const s=e[e.length-1];if(s&&"bot"===s.sender){const t=[...e],n={...s};return n.text+=i,o&&(n.content_list=[{tool_call_ends:o,content:n.text,role:"assistant"}]),t[t.length-1]=n,Se.current=n.id,ye.current&&requestAnimationFrame(()=>Le(!1)),t}const t={id:Date.now()+Math.random(),sender:"bot",text:i};return o&&(t.content_list=[{tool_call_ends:o,content:i,role:"assistant"}]),Se.current=t.id,ye.current&&requestAnimationFrame(()=>Le(!1)),[...e,t]});const c=Date.now();c-Ne.current>1500&&(Ne.current=c,qe())},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return I.ws.addMsg(c.HK.ai_chat_msg,n),I.ws.addMsg(c.HK.ai_chat_end,a),I.ws.addMsg(c.HK.ai_chat_error,i),()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,n),I.ws.off_message(`message_${c.HK.ai_chat_end}`,a),I.ws.off_message(`message_${c.HK.ai_chat_error}`,i),ke.current&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=null)}},[]),(0,n.useLayoutEffect)(()=>{ye.current&&Le(!1)},[E]);return(0,D.jsxs)(n.Fragment,{children:[(0,D.jsx)(U,{inline:s,currentModelName:De,setCurrentModelName:He,modelGroups:Ve,onModelChanged:async()=>{await Te();const e=await r.XO.get("ai_agent_setting/env");e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data))},sysPromptList:Me,batchMode:me,selectedMsgCount:ge.size,sessionVisible:!ie,onToggleSessionPanel:()=>{oe(e=>!e)},onCreateSession:async e=>{const s=e??"",t=await r.jV.post("session",{title:"新会话",sys_prompt_id:s||void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;const n=t.data;O(n.id),T([]),je(n.sys_prompt_id??""),oe(!1),await Ue(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:Ze,bgProcessVisible:ce,bgProcessCount:Be,onToggleBgProcess:()=>re(e=>!e),selectedSysPromptId:xe,setSelectedSysPromptId:e=>{if(je(e),F){const s=We(F);s?Oe("sys_prompt",{session_id:F,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):r.jV.post("session/sys_prompt",{session_id:F,sys_prompt_id:e||void 0}).catch(console.error)}}}),(0,D.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":ue},children:[!ie&&(0,D.jsx)("div",{className:"chat-session-overlay",onClick:()=>oe(!0)}),!ie&&(0,D.jsx)(W,{sessions:K,activeSessionId:F,onSelectSession:e=>Je(e,!1),onReorderSessions:(e,s)=>{if(Fe.current)return;const t=K.findIndex(s=>s.id===e),n=K.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,u.TI)(K,t,n);B(a),r.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},onRenameSession:(e,s)=>{let t=s;H({confirm_fun:async()=>{const s=We(e);s?await Oe("rename",{session_id:e,user_id:s,title:t}):await r.jV.post("sessions/update/meta",{id:e,title:t}),await Ue(F)},context_div:(0,D.jsx)("div",{className:"card-content",children:(0,D.jsx)(j.Sm,{value:t,handleInputChange:e=>{t=e}})})})},onDeleteSession:e=>{H({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=We(e);s?await Oe("delete",{session_id:e,user_id:s}):await r.jV.post("session/delete",{session_id:e}),F===e?(O(""),await Ue(null)):await Ue(F)}})},onToggleCmdAuto:async(e,s)=>{const t=We(e);t?await Oe("cmd_auto",{session_id:e,user_id:t,allow:s}):await r.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,g.SK)(k(s?"命令检测已开启":"命令检测已关闭")),await Ue(F)},onShowUsageStats:async e=>{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-loading",children:k("加载中...")}),cancel:()=>de({open:!1})});try{const s=We(e),t=s?await Oe("usage_stats",{session_id:e,user_id:s}):await r.jV.post("session/usage_stats",{session_id:e});if(t.code===_.m.Success&&t.data){const e=t.data;de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsxs)("div",{className:"usage-stats-panel",children:[[{l:k("对话轮次"),v:(e.turns??0).toString()},{l:k("AI输入Token"),v:b(e.input_tokens)},{l:k("AI输出Token"),v:b(e.output_tokens)},{l:k("AI输入Token(最近一轮)"),v:b(e.recent_input_tokens)},{l:k("AI输出Token(最近一轮)"),v:b(e.recent_output_tokens)}].map((e,s)=>(0,D.jsxs)("div",{className:"usage-stats-row",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,D.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,D.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,D.jsx)("span",{className:"usage-stats-label",children:k("AI Token总计消耗")}),(0,D.jsx)("span",{className:"usage-stats-value",children:b((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>de({open:!1})})}else de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}catch{de({open:!0,title:k("Token消耗统计"),context_div:(0,D.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>de({open:!1})})}},onShowSessionSetting:e=>{let s=K.find(s=>s.id===e)?.file_cwd_path??"";de({open:!0,title:k("会话设置"),context_div:(0,D.jsxs)("div",{className:"session-setting",children:[(0,D.jsx)("div",{className:"session-setting__label",children:k("服务器工作目录")}),(0,D.jsx)(j.Sm,{value:s,placeholder:k("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=We(e);(t?await Oe("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await r.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===_.m.Success&&(0,g.SK)(k("保存成功"))}catch{}de({open:!1}),await Ue(F)},cancel:()=>de({open:!1})})},batchMode:me,selectedSessionIds:_e,onToggleSessionSelect:e=>{fe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Xe,onBatchDeleteSessions:()=>{0!==_e.size&&H({sub_title:k("cf_ses"),confirm_fun:async()=>{if(Fe.current)await Oe("batch_delete",{session_ids:Array.from(_e)});else for(const e of _e)await r.jV.post("session/delete",{session_id:e});fe(new Set),he(!1),_e.has(F)?(O(""),await Ue(null)):await Ue(F)}})},onClearAllSessions:P?void 0:()=>{H({sub_title:k("cf_all"),confirm_fun:async()=>{await r.jV.post("sessions/clear",{}),O(""),T([]),await Ue(null)}})},allUsersMode:P,onToggleAllUsersMode:async()=>{const e=!P;L(e),Fe.current=e,O(""),T([]);const s=e?await Oe("list_all_sessions"):await r.jV.get("sessions"),t=s.code===_.m.Success?s.data??[]:[];B(t),t[0]?.id&&await Je(t[0].id,!1,t[0].user_id)},showAllUsersEntry:ae}),(0,D.jsx)(te,{panelRef:Ce}),(0,D.jsxs)("section",{className:"chat-main",children:[0===E?.length&&(0,D.jsx)("div",{className:"chat-header",children:(0,D.jsx)("div",{children:k("ai_ask")})}),(0,D.jsx)(X,{messages:E,batchMode:me,selectedMsgIds:ge,sending:q===F||J,chatContainerRef:we,messagesEndRef:be,onToggleMsgSelect:e=>{pe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:e=>{H({sub_title:k("cf_one"),confirm_fun:async()=>{const s=E.findIndex(s=>s.id===e);if(s<0)return;const t=E.filter(s=>s.id!==e);if(T(t),F){const e=We(F);e?Oe("message_delete",{session_id:F,user_id:e,indices:[s]}).catch(console.error):r.jV.post("session/message/delete",{session_id:F,indices:[s]}).catch(console.error)}}})},onCopy:async e=>{(0,h.lW)(w(e)),(0,g.SK)("复制成功")},onCopyAll:async()=>{if(!K.length)return void(0,g.SK)("暂无聊天记录");const e=[];for(const s of K){const t=s.user_id?await Oe("get",{session_id:s.id,user_id:s.user_id}):await r.jV.post("session/get",{session_id:s.id});if(t.code!==_.m.Success||!t.data)continue;const n=t.data,a=S([...n.messages??[],...n.live_messages??[]]).map(w).filter(Boolean).join("\n\n\n");a&&e.push(a)}e.length?((0,h.lW)(e.join("\n\n\n")),(0,g.SK)("复制成功")):(0,g.SK)("暂无聊天记录")},onToggleBatchMode:Xe,onBatchCopy:()=>{const e=E.filter(e=>ge.has(e.id)).map(w).filter(Boolean).join("\n\n\n");e?((0,h.lW)(e),(0,g.SK)("复制成功")):(0,g.SK)("暂无内容")},onBatchDelete:Ze,showBatchBar:me&&ge.size>0&&0===_e.size,t:k}),(0,D.jsx)(se,{ref:Z,onSend:async()=>{if(Fe.current)return;const e=(Z.current?.getValue()??"").trim();if(!e&&0===Y.length)return;if(q===F){const s=await $(Y);Ge.enqueueMessage(e,s),Z.current?.clear(),ee([]);const t={id:Date.now(),sender:"user",text:e+(Ge.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void T(e=>[...e,t])}let s=F;if(!s){const t=await r.jV.post("session",{title:(e||Y[0]?.name||"新会话").slice(0,28),sys_prompt_id:void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;s=t.data.id,O(s),N?.(s),await Ue(s)}const t=await $(Y),n={id:Date.now(),sender:"user",text:e,attachments:t};Z.current?.clear(),ee([]);const a=Ie?.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...E,n,t];T(i),G(s);return void(await z(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),T([...i]),G(null),qe(),Le(!0),Ge.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,T([...i]),G(null),Ge.processPendingQueue()))}Ge.startChatStream(s,n,()=>Ge.processPendingQueue())},readonly:P,sending:q===F||J,onAbort:Ge.abort,pendingAttachments:Y,onRemoveAttachment:e=>{ee(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ve.current?.click()},onAddFiles:Qe,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Qe(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ve})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(22022),i=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.Bd)(),[t,i]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{i(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),x=(0,n.useCallback)(()=>{if(h.current)return;if(0===l.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=l.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):h.current=!1},[t,f,s]);_.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return i.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{i.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>y});var n=t(96540),a=t(23802),i=t(53995),o=t(18569),c=t(77979),r=t(8263),l=t(69428),d=t.n(l),u=(t(3775),t(21499)),m=t(99214),h=t(89117),g=t(86063),p=t(89334),_=t(41105),f=t(52388),x=t(19878),j=(t(72411),t(74848));const v=new a.A({html:!0,highlight:function(e,s){if(s&&x.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${x.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${x.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${v.utils.escapeHtml(e)}</code></pre>`}});async function b(e,s){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=f.A.t("rendering");const t=await(0,g.Hn)(s);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await t.mount(e))}function w(e){const s=e.className.match(/language-([\w-]+)/);return s?s[1]:""}function y(e){const s=(0,n.useRef)(null);return(0,m.VD)(),(0,n.useEffect)(()=>{s.current&&(s.current.innerHTML=v.render(e.context??""),async function(e){const s=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(s)){const s=w(e),t=(0,h.Hm)(s),n=(0,g.hj)(s);if(!t&&!n)continue;const a=e.closest(".code-block-with-copy")??e.parentElement;if(!a)continue;const i=e.textContent??"",o=document.createElement("div");if(a.replaceWith(o),n){try{await b(o,i)}catch(e){console.error("[mind] render failed",e),o.className="md-graph md-graph--mind",o.textContent=String(e)}continue}o.className="md-graph md-graph--loading",o.textContent=f.A.t("rendering");const c=await(0,h.U6)(s,i);o.isConnected&&(c.error?(o.className="md-graph md-graph--error",o.textContent=c.error):(o.className="md-graph",o.innerHTML=c.svg))}}(s.current),(0,p.rg)(s.current))},[e.context]),(0,j.jsx)("div",{ref:s})}v.use(i.A).use(o.A).use(c.A).use(r.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const o=s[t],c=o.content.trim(),r=o.info.trim();let l="";if(r&&x.A.getLanguage(r))try{l=x.A.highlight(c,{language:r}).value}catch(s){l=e.utils.escapeHtml(c)}else try{l=x.A.highlightAuto(c).value}catch(s){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const o=e[t],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][1]=(0,u.bi)(window.location.href,e)}return s(e,t,n,a,i)}}),(0,p.Rh)(v,_.pC)},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),a=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[h,g]=(0,n.useState)(!1),p=(0,n.useRef)(null),_=(0,n.useRef)(u);_.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=p.current;if(!s)return;const{px_to_unit:t,min:n,max:a,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=i(n),d=i(a);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),_.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{p.current=null,g(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;p.current={pos:t(e),size:s()},g(!0)},[]);return(0,n.useEffect)(()=>{if(!h)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[h,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:h,on_pointer_down:w,on_pointer_up:b}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4986],{94986(e,a,s){s.r(a),s.d(a,{WorkerUrl:()=>r});var t=s(35450),r=(s(22130),new URL("file:///Users/xiaobaidadada/code-projects/filecat/node_modules/@excalidraw/excalidraw/dist/prod/subset-worker.chunk.js"));typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{if(e.data.command===t.a.Subset){let a=await(0,t.c)(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]})}})}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4091,5272],{48890(e,n,t){t.d(n,{Kw:()=>i,Tt:()=>o});var i=t(80952),o=(t(82327),t(1766),t(24854),t(90008),t(90846),t(40975),t(44286),t(30766),t(14973),t(69687),t(1234),t(47507),t(87268),t(34678),t(24522));const d=`https://gcore.jsdelivr.net/npm/ace-builds@${i.version}/src-min-noconflict/`;i.config.set("basePath",d),i.config.set("modePath",d),i.config.set("themePath",d),i.config.set("workerPath",d)},84091(e,n,t){t.r(n),t.d(n,{default:()=>m});var i=t(96540),o=(t(80952),t(48890)),d=t(34843),r=t(82893),a=t(78247),s=t(74848);function m(e){const n=(0,i.useRef)(null),[t,m]=(0,d.fp)(r.AG.user_base_info),l=t.user_data.theme?.includes("dark")?"cloud_editor_dark":"cloud9_day";return(0,i.useEffect)(()=>{const t=o.Kw.edit(n.current,{value:a.xK.get_value_temp(e.editor_id),showPrintMargin:!1,theme:`ace/theme/${l}`,mode:e.model??o.Tt.getModeForPath(e.name??"").mode,wrap:!1,highlightActiveLine:!1,fontSize:14,...e.options});return t.setOptions({}),t.container.addEventListener("wheel",function(e){e.preventDefault()}),t.focus(),t.on("change",function(n){e.on_change&&e.on_change()}),n.current=t,t.formatCode=()=>{const e=o.Kw.require("ace/ext/beautify"),t=n.current;t&&e.beautify(t.session)},a.xK.set_editor_temp(t,e.editor_id),()=>{a.xK.delete_editor_temp(e.editor_id),t.destroy()}},[]),(0,s.jsx)("div",{ref:n,style:{height:"100%",width:"100%"}})}},26559(e,n,t){t.d(n,{A:()=>l});var i=t(96540),o=t(34843),d=t(82893),r=t(76118),a=t(69918),s=t(8332),m=t(74848);const l=i.memo(function(e){const[n]=(0,o.fp)(d.AG.md_editor_last_context),[t]=(0,i.useState)(n?.trim()?n:s.$);return(0,m.jsx)("div",{className:e.className,ref:n=>e.setting&&(0,a.Ce)(n,e.setting),children:(0,m.jsx)("div",{className:"md-editor-scroll",children:(0,m.jsx)("div",{className:"md-editor-sheet",children:(0,m.jsx)(r.A,{value:t})})})})})},8332(e,n,t){t.d(n,{$:()=>o,V:()=>i});const i='/* ===== md 主题 =====\n 选择器请从 .md-editor-sheet 开始写 —— 它是正文容器的类名,\n 编辑器与右侧预览用的是同一个类名,一处书写、两处生效。\n\n 注意:css 原样注入页面,不做任何改写。\n 写成 body、h1 这种全局选择器会真的作用到整个后台界面,不要这么写。\n\n 下面每一组都可以直接改,不需要的整段删掉即可。\n ============================================ */\n\n/* ---------- 正文 ---------- */\n.md-editor-sheet {\n font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; /* 字体 */\n font-size: 16px; /* 字号 */\n line-height: 1.7; /* 行高:1.7 约为字号的 1.7 倍 */\n color: #333333; /* 文字颜色 */\n}\n\n/* ---------- 整页底色 ----------\n 底色必须写在 .md-editor-scroll(滚动容器)上,不要写在 .md-editor-sheet。\n 纸张高度只有一屏,写在纸张上的底色长文档一滚就露底(上半截有色、下半截变回灰)。\n 深色主题尤其要注意:这一条不写,滚动时就会白一半黑一半。 */\n.md-editor-scroll {\n background: #ffffff;\n}\n\n/* ---------- 标题 h1 ~ h6 ---------- */\n.md-editor-sheet h1 {\n font-size: 2em; /* 相对正文字号的倍数 */\n font-weight: 600; /* 字重:400 常规 / 600 半粗 / 700 粗 */\n color: #1a1a1a;\n margin-top: 1.4em;\n margin-bottom: 0.6em;\n padding-bottom: 0.3em;\n border-bottom: 1px solid #eaecef; /* 标题下划线,不需要就删掉这行 */\n}\n.md-editor-sheet h2 { font-size: 1.5em; font-weight: 600; margin-top: 1.3em; margin-bottom: 0.6em; }\n.md-editor-sheet h3 { font-size: 1.25em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.5em; }\n.md-editor-sheet h4 { font-size: 1em; font-weight: 600; margin-top: 1.1em; margin-bottom: 0.5em; }\n.md-editor-sheet h5 { font-size: 0.9em; font-weight: 600; margin-top: 1em; margin-bottom: 0.5em; }\n.md-editor-sheet h6 { font-size: 0.85em; font-weight: 600; color: #6a737d; margin-top: 1em; margin-bottom: 0.5em; }\n\n/* ---------- 段落与行内元素 ---------- */\n.md-editor-sheet p {\n margin: 0 0 1em; /* 段落间距:上 右 下 左,下边距控制段与段的距离 */\n}\n.md-editor-sheet strong { font-weight: 600; } /* 加粗文字 */\n.md-editor-sheet em { font-style: italic; } /* 斜体文字 */\n.md-editor-sheet a { color: #0366d6; text-decoration: none; } /* 链接颜色;加下划线写 underline */\n.md-editor-sheet a:hover { text-decoration: underline; } /* 鼠标悬停时的链接样式 */\n.md-editor-sheet del { color: #999999; } /* 删除线文字 */\n\n/* ---------- 引用 ---------- */\n.md-editor-sheet blockquote {\n margin: 0 0 1em;\n padding: 0.4em 1em;\n color: #6a737d; /* 引用文字颜色 */\n border-left: 4px solid #dfe2e5; /* 左侧竖线,这是引用最明显的特征 */\n background: #f6f8fa; /* 引用底色,不需要就删掉 */\n}\n\n/* ---------- 代码 ---------- */\n.md-editor-sheet code {\n font-family: Consolas, Monaco, "Courier New", monospace; /* 等宽字体 */\n font-size: 0.88em;\n color: #476582; /* 行内代码文字色 */\n background: rgba(27, 31, 35, 0.05); /* 行内代码底色 */\n padding: 0.2em 0.4em;\n border-radius: 3px; /* 圆角 */\n}\n.md-editor-sheet pre {\n padding: 1em;\n overflow: auto; /* 内容太宽时出现横向滚动条 */\n background: #f6f8fa; /* 代码块底色 */\n border-radius: 6px;\n margin: 0 0 1em;\n}\n.md-editor-sheet pre code {\n background: transparent; /* 代码块里的 code 不要再叠一层底色 */\n padding: 0;\n}\n\n/* ---------- 列表 ---------- */\n.md-editor-sheet ul, .md-editor-sheet ol {\n padding-left: 2em; /* 缩进 */\n margin: 0 0 1em;\n}\n.md-editor-sheet li { margin: 0.25em 0; } /* 列表项之间的间距 */\n\n/* ---------- 表格 ---------- */\n.md-editor-sheet table {\n width: 100%;\n border-collapse: collapse; /* 相邻边框合并成一条线 */\n margin: 0 0 1em;\n}\n.md-editor-sheet table th, .md-editor-sheet table td {\n padding: 6px 13px;\n border: 1px solid #dfe2e5; /* 单元格边框 */\n}\n.md-editor-sheet table th {\n font-weight: 600;\n background: #f6f8fa; /* 表头底色 */\n}\n\n/* ---------- 分割线 ---------- */\n.md-editor-sheet hr {\n height: 1px; /* 线的粗细 */\n border: 0;\n background: #e1e4e8; /* 线的颜色 */\n margin: 1.6em 0;\n}\n\n/* ---------- 图片 ---------- */\n.md-editor-sheet img {\n max-width: 100%; /* 防止大图撑破版面 */\n border-radius: 4px;\n}\n',o='# 一级标题 Heading 1\n\n## 二级标题 Heading 2\n\n### 三级标题 Heading 3\n\n#### 四级标题 Heading 4\n\n##### 五级标题 Heading 5\n\n###### 六级标题 Heading 6\n\n这是一段普通正文,用来观察字体、字号、行高和文字颜色。中间可以包含 **加粗文字**、*斜体文字*、~~删除线~~、`行内代码` 以及 [一个链接](https://github.com/xiaobaidadada/filecat)。\n\n> 这是一段引用文字。\n> 引用通常用来强调摘录的内容,左侧一般会有一条竖线。\n\n- 无序列表第一项\n- 无序列表第二项\n - 嵌套的子项\n- 无序列表第三项\n\n1. 有序列表第一项\n2. 有序列表第二项\n3. 有序列表第三项\n\n```javascript\n// 代码块\nfunction greet(name) {\n console.log(`Hello, ${name}!`);\n}\ngreet("filecat");\n```\n\n| 列一 | 列二 | 列三 |\n| --- | --- | --- |\n| 内容 A | 内容 B | 内容 C |\n| 内容 D | 内容 E | 内容 F |\n\n---\n\n最后一段正文,用于观察段落之间的间距。\n'},35272(e,n,t){t.r(n),t.d(n,{default:()=>b});var i=t(96540),o=t(22022),d=t(52671),r=t(85997),a=t(4412),s=t(70447),m=t(75725),l=t(61443),c=t(62042),h=t(23430),f=t(78247),g=t(84091),u=t(26559),p=t(96763),x=t(8332),_=t(74848);function b(){const{t:e}=(0,o.Bd)(),n=(0,d.Zp)(),[t]=(0,d.ok)(),{check_user_auth:b}=(0,f.MH)(),v=b(h.oV.md_theme),w=t.get("id")??"",j=!w,[k,N]=(0,i.useState)(""),[y,C]=(0,i.useState)(x.V),[K,z]=(0,i.useState)(!0),[P,S]=(0,i.useState)(!1),A=88;(0,i.useEffect)(()=>{if(!w){const e=x.V;return f.xK.set_value_temp(e,A),N(""),C(e),void z(!1)}Promise.all([(0,p.Kz)(),(0,p.P7)(w)]).then(([e,n])=>{const t=e.find(e=>e.id===w),i=n||x.V;f.xK.set_value_temp(i,A),N(t?.id??""),C(i)}).finally(()=>z(!1))},[w]),(0,i.useEffect)(()=>{if(K)return;const e=f.xK.get_editor(A);e&&(e.setValue(f.xK.get_value_temp(A)??"",-1),e.clearSelection())},[K]),(0,i.useEffect)(()=>{K||(0,p.bN)("theme_preview",y)},[y,K]);return(0,_.jsxs)("div",{children:[(0,_.jsx)(a.aZ,{position:"right",children:(0,_.jsx)(r.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>n(-1)})}),(0,_.jsx)(m.jW,{isFull:!0,more:!0,children:(0,_.jsx)(m.NN,{children:(0,_.jsxs)("div",{className:"md-theme-editor",children:[(0,_.jsx)("div",{className:"md-theme-editor__left",children:(0,_.jsxs)(s.Zp,{title:e(j?"新建主题":"编辑主题"),titleCom:(0,_.jsx)(_.Fragment,{children:v&&(0,_.jsx)(r.C3,{text:e(P?"保存中":"保存"),clickFun:()=>{P||(async()=>{const t=k.trim();if(t){S(!0);try{await(0,p._D)({id:j?void 0:w,name:t,css:f.xK.get_editor_value(A)??y})?((0,c.SK)(e("保存成功")),n(-1)):(0,c.zN)(e("保存失败"))}finally{S(!1)}}else(0,c.zN)(e("请输入主题名称"))})()}})}),children:[(0,_.jsx)(l.BC,{label:e("主题名称"),label_width:"6rem",children:(0,_.jsx)(l.Sm,{value:k,disabled:!v,placeholder:e("请输入主题名称"),handleInputChange:e=>N(e)})}),(0,_.jsx)("div",{className:"md-theme-editor__ace",children:(0,_.jsx)(g.default,{name:"theme.css",editor_id:A,model:"ace/mode/css",on_change:()=>{const e=f.xK.get_editor_value(A);void 0!==e&&C(e)},options:{showPrintMargin:!1,highlightActiveLine:!0,wrap:!0}})})]})}),(0,_.jsx)("div",{className:"md-theme-editor__right",children:(0,_.jsx)(s.Zp,{title:e("预览"),titleCom:(0,_.jsx)("span",{className:"md-theme-editor__tip",children:e("主题实时预览")}),children:(0,_.jsx)(u.A,{className:"md-theme-preview"})})})]})})})]})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3233,5614],{33616(e){var n;self,n=()=>(()=>{"use strict";var e,n={};return e=n,Object.defineProperty(e,"__esModule",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const n=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(n._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,n=e._renderService.dimensions;if(0===n.css.cell.width||0===n.css.cell.height)return;const t=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),i=Math.max(0,parseInt(r.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),l=o-(parseInt(s.getPropertyValue("padding-top"))+parseInt(s.getPropertyValue("padding-bottom"))),a=i-(parseInt(s.getPropertyValue("padding-right"))+parseInt(s.getPropertyValue("padding-left")))-t;return{cols:Math.max(2,Math.floor(a/n.css.cell.width)),rows:Math.max(1,Math.floor(l/n.css.cell.height))}}},n})(),e.exports=n()},40654(e,n,t){"use strict";t.r(n),t.d(n,{default:()=>E});var r=t(96540),o=t(33616),i=(t(97856),t(85072)),s=t.n(i),l=t(97825),a=t.n(l),c=t(77659),d=t.n(c),u=t(55056),m=t.n(u),p=t(10540),h=t.n(p),x=t(41113),f=t.n(x),g=t(86739),v={};v.styleTagTransform=f(),v.setAttributes=m(),v.insert=d().bind(null,"head"),v.domAPI=a(),v.insertStyleElement=h();s()(g.A,v);g.A&&g.A.locals&&g.A.locals;var y=t(40505),_=t(62042),b=t(84369),w=t(74848);function E(e){const[n,t]=(0,r.useState)(25),i=(0,r.useRef)(null),s=(0,r.useCallback)(new o.FitAddon,[]),l=(0,r.useRef)(null),a=(0,r.useRef)(null),{dragging:c,on_pointer_down:d,on_pointer_up:u}=(0,b.y)({direction:"vertical",target_ref:l,get_start_size:()=>n,px_to_unit:e=>e/parseFloat(getComputedStyle(l.current).fontSize),min:()=>{const e=parseFloat(getComputedStyle(l.current).fontSize);return 2.25+i.current.offsetHeight/e},max:()=>{const e=parseFloat(getComputedStyle(l.current).fontSize);return window.innerHeight/e-4},throttle:32,on_change:e=>{s.fit(),t(parseFloat(e.toFixed(2)))}});if((0,r.useEffect)(()=>{e.terminal&&(e.terminal.options.convertEol=!0,e.terminal.open(a.current),e.terminal.loadAddon(s),s.fit(),e.init&&e.init(e.terminal.rows,e.terminal.cols),e.terminal.attachCustomKeyEventHandler(n=>{if(n.ctrlKey&&"c"===n.key){const t=e.terminal.getSelection();if(t)return(0,y.lW)(t),(0,_.SK)("已复制"),n.preventDefault(),e.terminal.focus(),!1}else if("keydown"===n.type&&"v"===n.key&&n.ctrlKey)return!1;return!0}))},[e.terminal]),(0,r.useEffect)(()=>()=>{e.terminal&&e.terminal.dispose()},[]),e.show)return e.get_simple?(0,w.jsx)("div",{className:"pty",style:{height:"100%"},ref:a}):(0,w.jsxs)("div",{className:"shell",style:{height:`${n}em`,display:""+(e.file_shell_hidden?"none":"block")},ref:l,children:[(0,w.jsx)("div",{className:"shell__divider",ref:i,onPointerDown:d,onPointerUp:u}),(0,w.jsx)("div",{className:"pty",style:{height:n-1+"em"},ref:a}),c&&(0,w.jsx)("div",{className:"shell__overlay",onPointerUp:u})]})}},85614(e,n,t){"use strict";t.r(n),t.d(n,{default:()=>s});var r=t(96540),o=(t(40654),t(74848));const i=r.lazy(()=>Promise.resolve().then(t.bind(t,40654)));function s(e){return(0,o.jsx)(r.Fragment,{children:(0,o.jsx)(i,{...e})})}},84369(e,n,t){"use strict";t.d(n,{y:()=>s});var r=t(96540),o=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function s(e){const{direction:n="vertical",target_ref:t,get_start_size:s,px_to_unit:l,min:a,max:c,throttle:d,on_change:u,on_drag_end:m}=e,[p,h]=(0,r.useState)(!1),x=(0,r.useRef)(null),f=(0,r.useRef)(u);f.current=u;const g=e=>"vertical"===n?e.clientY:e.clientX,v=(0,r.useRef)({direction:n,get_start_size:s,px_to_unit:l,min:a,max:c,get_pos:g});v.current={direction:n,get_start_size:s,px_to_unit:l,min:a,max:c,get_pos:g};const y=(0,r.useCallback)(e=>{const n=x.current;if(!n)return;const{px_to_unit:t,min:r,max:o,get_pos:s}=v.current,l=n.pos-s(e);let a=n.size+t(l);const c=i(r),d=i(o);void 0!==c&&(a=Math.max(c,a)),void 0!==d&&(a=Math.min(d,a)),f.current(a)},[]),_=r.useMemo(()=>void 0===d?y:o.throttle(e=>y(e),d),[d,y]),b=(0,r.useCallback)(()=>{x.current=null,h(!1);const e=_;"function"==typeof e.cancel&&e.cancel(),m?.()},[_,m]),w=(0,r.useCallback)(e=>{const{get_start_size:n,get_pos:t}=v.current;x.current={pos:t(e),size:n()},h(!0)},[]);return(0,r.useEffect)(()=>{if(!p)return;const e=t?.current??window;return e.addEventListener("pointermove",_),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",_),e.removeEventListener("pointerup",b)}},[p,_,b,t]),(0,r.useEffect)(()=>{const e=_;return()=>{"function"==typeof e.cancel&&e.cancel()}},[_]),{dragging:p,on_pointer_down:w,on_pointer_up:b}}},86739(e,n,t){"use strict";t.d(n,{A:()=>l});var r=t(31601),o=t.n(r),i=t(76314),s=t.n(i)()(o());s.push([e.id,'/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * https://github.com/chjj/term.js\n * @license MIT\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the "Software"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Originally forked from (with the author\'s permission):\n * Fabrice Bellard\'s javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n * The original design remains. The terminal itself\n * has been extended to include xterm CSI codes, among\n * other features.\n */\n\n/**\n * Default styles for xterm.js\n */\n\n.xterm {\n cursor: text;\n position: relative;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.xterm.focus,\n.xterm:focus {\n outline: none;\n}\n\n.xterm .xterm-helpers {\n position: absolute;\n top: 0;\n /**\n * The z-index of the helpers must be higher than the canvases in order for\n * IMEs to appear on top.\n */\n z-index: 5;\n}\n\n.xterm .xterm-helper-textarea {\n padding: 0;\n border: 0;\n margin: 0;\n /* Move textarea out of the screen to the far left, so that the cursor is not visible */\n position: absolute;\n opacity: 0;\n left: -9999em;\n top: 0;\n width: 0;\n height: 0;\n z-index: -5;\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\n white-space: nowrap;\n overflow: hidden;\n resize: none;\n}\n\n.xterm .composition-view {\n /* TODO: Composition position got messed up somewhere */\n background: #000;\n color: #FFF;\n display: none;\n position: absolute;\n white-space: nowrap;\n z-index: 1;\n}\n\n.xterm .composition-view.active {\n display: block;\n}\n\n.xterm .xterm-viewport {\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\n background-color: #000;\n overflow-y: scroll;\n cursor: default;\n position: absolute;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n}\n\n.xterm .xterm-screen {\n position: relative;\n}\n\n.xterm .xterm-screen canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.xterm .xterm-scroll-area {\n visibility: hidden;\n}\n\n.xterm-char-measure-element {\n display: inline-block;\n visibility: hidden;\n position: absolute;\n top: 0;\n left: -9999em;\n line-height: normal;\n}\n\n.xterm.enable-mouse-events {\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\n cursor: default;\n}\n\n.xterm.xterm-cursor-pointer,\n.xterm .xterm-cursor-pointer {\n cursor: pointer;\n}\n\n.xterm.column-select.focus {\n /* Column selection mode */\n cursor: crosshair;\n}\n\n.xterm .xterm-accessibility:not(.debug),\n.xterm .xterm-message {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10;\n color: transparent;\n pointer-events: none;\n}\n\n.xterm .xterm-accessibility-tree:not(.debug) *::selection {\n color: transparent;\n}\n\n.xterm .xterm-accessibility-tree {\n user-select: text;\n white-space: pre;\n}\n\n.xterm .live-region {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.xterm-dim {\n /* Dim should not apply to background, so the opacity of the foreground color is applied\n * explicitly in the generated class and reset to 1 here */\n opacity: 1 !important;\n}\n\n.xterm-underline-1 { text-decoration: underline; }\n.xterm-underline-2 { text-decoration: double underline; }\n.xterm-underline-3 { text-decoration: wavy underline; }\n.xterm-underline-4 { text-decoration: dotted underline; }\n.xterm-underline-5 { text-decoration: dashed underline; }\n\n.xterm-overline {\n text-decoration: overline;\n}\n\n.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }\n.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }\n.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }\n.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }\n.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }\n\n.xterm-strikethrough {\n text-decoration: line-through;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration {\n\tz-index: 6;\n\tposition: absolute;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {\n\tz-index: 7;\n}\n\n.xterm-decoration-overview-ruler {\n z-index: 8;\n position: absolute;\n top: 0;\n right: 0;\n pointer-events: none;\n}\n\n.xterm-decoration-top {\n z-index: 2;\n position: relative;\n}\n',""]);const l=s}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6492],{11356(t,e){e.k=void 0;e.k=function(t,e){void 0===e&&(e={listUnicodeChar:""}),(e=e||{}).listUnicodeChar=!!e.hasOwnProperty("listUnicodeChar")&&e.listUnicodeChar,e.stripListLeaders=!e.hasOwnProperty("stripListLeaders")||e.stripListLeaders,e.gfm=!e.hasOwnProperty("gfm")||e.gfm,e.useImgAltText=!e.hasOwnProperty("useImgAltText")||e.useImgAltText,e.preserveLinks=!!e.hasOwnProperty("preserveLinks")&&e.preserveLinks;var r=t||"";r=r.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm,"");try{e.stripListLeaders&&(r=e.listUnicodeChar?r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,e.listUnicodeChar+" $1"):r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,"$1")),e.gfm&&(r=r.replace(/\n={2,}/g,"\n").replace(/~{3}.*\n/g,"").replace(/~~/g,"").replace(/`{3}.*\n/g,"")),e.preserveLinks&&(r=r.replace(/\[(.*?)\][\[\(](.*?)[\]\)]/g,"$1 ($2)")),r=r.replace(/<[^>]*>/g,"").replace(/^[=\-]{2,}\s*$/g,"").replace(/\[\^.+?\](\: .*?$)?/g,"").replace(/\s{0,2}\[.*?\]: .*?$/g,"").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g,e.useImgAltText?"$1":"").replace(/\[(.*?)\][\[\(].*?[\]\)]/g,"$1").replace(/^\s{0,3}>\s?/g,"").replace(/(^|\n)\s{0,3}>\s?/g,"\n\n").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g,"").replace(/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/gm,"$1$2$3").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/(`{3,})(.*?)\1/gm,"$2").replace(/`(.+?)`/g,"$1").replace(/\n{2,}/g,"\n\n")}catch(e){return console.error(e),t}return r}},6492(t,e,r){r.r(e),r.d(e,{parseMermaidToExcalidraw:()=>Ie});const o={rect:"rectangle",circle:"ellipse"},n={startOnLoad:!1,flowchart:{curve:"linear"},themeVariables:{fontSize:"20px"},maxEdges:500,maxTextSize:5e4};class s{constructor({converter:t}){this.convert=(t,e)=>this.converter(t,{...e,fontSize:e.fontSize||20}),this.converter=t}}var i,a,l;!function(t){t.ROUND="round",t.STADIUM="stadium",t.DOUBLECIRCLE="doublecircle",t.CIRCLE="circle",t.DIAMOND="diamond",t.CYLINDER="cylinder"}(i||(i={})),function(t){t.COLOR="color"}(a||(a={})),function(t){t.FILL="fill",t.STROKE="stroke",t.STROKE_WIDTH="stroke-width",t.STROKE_DASHARRAY="stroke-dasharray"}(l||(l={}));var c=r(11356);const d={arrow_circle:{endArrowhead:"circle"},arrow_cross:{endArrowhead:"bar"},arrow_open:{endArrowhead:null,startArrowhead:null},double_arrow_circle:{endArrowhead:"circle",startArrowhead:"circle"},double_arrow_cross:{endArrowhead:"bar",startArrowhead:"bar"},double_arrow_point:{endArrowhead:"arrow",startArrowhead:"arrow"}},u=t=>{let e=t.text;return"markdown"===t.labelType&&(e=(0,c.k)(t.text)),h(e)},h=t=>t.replace(/\s?(fa|fab):[a-zA-Z0-9-]+/g,""),p=t=>{const e={};return Object.keys(t).forEach(r=>{switch(r){case l.FILL:e.backgroundColor=t[r],e.fillStyle="solid";break;case l.STROKE:e.strokeColor=t[r];break;case l.STROKE_WIDTH:e.strokeWidth=Number(t[r]?.split("px")[0]);break;case l.STROKE_DASHARRAY:e.strokeStyle="dashed"}}),e},g=t=>{const e={};return Object.keys(t).forEach(r=>{if(r===a.COLOR)e.strokeColor=t[r]}),e},y=(t,e)=>Math.max(20,Math.ceil(t.length*e*.62)),f=new s({converter:(t,e)=>{const r=[],o=e.fontSize,{getGroupIds:n,getParentId:s}=(t=>{const e={};t.subGraphs.map(r=>{r.nodeIds.forEach(o=>{e[r.id]={id:r.id,parent:null,isLeaf:!1},e[o]={id:o,parent:r.id,isLeaf:void 0!==t.vertices[o]}})});const r={};return[...Object.keys(t.vertices),...t.subGraphs.map(t=>t.id)].forEach(t=>{if(!e[t])return;let o=e[t];const n=[];for(o.isLeaf||n.push(`subgraph_group_${o.id}`);o.parent;)n.push(`subgraph_group_${o.parent}`),o=e[o.parent];r[t]=n}),{getGroupIds:t=>r[t]||[],getParentId:t=>e[t]?e[t].parent:null}})(t);return t.subGraphs.reverse().forEach(t=>{const e=n(t.id),s=u(t),i=y(s,o||16)+64,a=Math.max(t.width,i),l=t.x-(a-t.width)/2,c=p(t.containerStyle),d=g(t.labelStyle),h={id:t.id,type:"rectangle",groupIds:e,x:l,y:t.y,width:a,height:t.height,label:{groupIds:e,text:s,fontSize:o,verticalAlign:"top",...d},...c};r.push(h)}),Object.values(t.vertices).forEach(t=>{if(!t)return;const e=n(t.id),s=u(t),a=((t,e,r,o)=>{const n=o||20;if(t!==i.CYLINDER||!e||e.includes("\n"))return n;const s=Math.max(20,r-12);return y(e,n)<=s?n:Math.max(12,Math.floor(s/(.62*e.length)))})(t.type,s,t.width,o),l=p(t.containerStyle),c=g(t.labelStyle);let d={id:t.id,type:"rectangle",groupIds:e,x:t.x,y:t.y,width:t.width,height:t.height,strokeWidth:2,label:{groupIds:e,text:s,fontSize:a,...c},link:t.link||null,...l};switch(t.type){case i.STADIUM:case i.ROUND:d={...d,roundness:{type:3}};break;case i.DOUBLECIRCLE:{const o=5;e.push(`doublecircle_${t.id}}`);const n={type:"ellipse",groupIds:e,x:t.x+o,y:t.y+o,width:t.width-2*o,height:t.height-2*o,strokeWidth:2,roundness:{type:3},label:{groupIds:e,text:s,fontSize:a,...c}};d={...d,groupIds:e,type:"ellipse"},r.push(n);break}case i.CIRCLE:d.type="ellipse";break;case i.DIAMOND:d.type="diamond"}r.push(d)}),t.edges.forEach(t=>{let e=[];const i=s(t.start),a=s(t.end);i&&i===a&&(e=n(i));const{startX:l,startY:c,reflectionPoints:h}=t,p=h.map(t=>{return e=t.x-h[0].x,r=t.y-h[0].y,[e,r];var e,r}),g=(y=t.type||"arrow_point",d[y]);var y;const f=r.find(e=>e.id===t.start),b=r.find(e=>e.id===t.end);if(!f||!b)return;const m={id:`${t.start}_${t.end}`,type:"arrow",groupIds:e,x:l,y:c,strokeWidth:"thick"===t.stroke?4:2,strokeStyle:"dotted"===t.stroke?"dashed":void 0,points:p,...t.text?{label:{text:u(t),fontSize:o,groupIds:e}}:{},roundness:{type:2},...g,start:{id:f.id||""},end:{id:b.id||""}};r.push(m)}),{elements:r}}});let b=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_","");const m=new s({converter:t=>{const e=b(),{width:r,height:o}=t,n={type:"image",x:0,y:0,width:r,height:o,status:"saved",fileId:e};return{files:{[e]:{id:e,mimeType:t.mimeType,dataURL:t.dataURL}},elements:[n]}}}),x=(t,e)=>[t,e],w=t=>t.replace(/\\n/g,"\n"),S=t=>{const e={type:"line",x:t.startX,y:t.startY,points:[x(0,0),x(t.endX-t.startX,t.endY-t.startY)],width:t.endX-t.startX,height:t.endY-t.startY,strokeStyle:t.strokeStyle||"solid",strokeColor:t.strokeColor||"#000",strokeWidth:t.strokeWidth||1};return t.groupId&&Object.assign(e,{groupIds:[t.groupId]}),t.id&&Object.assign(e,{id:t.id}),e},A=t=>{const e={type:"text",x:t.x,y:t.y,width:t.width,height:t.height,text:w(t.text)||"",fontSize:t.fontSize,verticalAlign:"top",strokeColor:t.color};return t.groupId&&Object.assign(e,{groupIds:[t.groupId]}),t.id&&Object.assign(e,{id:t.id}),e},k=t=>{const e={text:w(t?.label?.text||""),fontSize:t?.label?.fontSize,textAlign:t.label?.textAlign,verticalAlign:t.label?.verticalAlign||"middle",strokeColor:t.label?.color||"#000",...t.groupId?{groupIds:[t.groupId]}:{}};let r={};"rectangle"===t.type&&"activation"===t.subtype&&(r={backgroundColor:"#e9ecef",fillStyle:"solid"});const o={id:t.id,type:t.type,x:t.x,y:t.y,width:t.width,height:t.height,label:e,strokeStyle:t?.strokeStyle,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,backgroundColor:t?.bgColor,fillStyle:"solid",...r};return t.groupId&&Object.assign(o,{groupIds:[t.groupId]}),o},E=t=>{const e={type:"arrow",x:t.startX,y:t.startY,points:t.points?.map(([t,e])=>x(t,e))||[x(0,0),x(t.endX-t.startX,t.endY-t.startY)],width:t.endX-t.startX,height:t.endY-t.startY,strokeStyle:t?.strokeStyle||"solid",endArrowhead:t?.endArrowhead||null,startArrowhead:t?.startArrowhead||null,label:{text:w(t?.label?.text||""),fontSize:16,textAlign:t?.label?.textAlign,verticalAlign:t?.label?.verticalAlign},roundness:{type:2},start:t.start,end:t.end};return t.groupId&&Object.assign(e,{groupIds:[t.groupId]}),e},v=t=>{if(!t)return!0;const e=t.trim().toLowerCase();return"transparent"===e||"none"===e||"rgba(0,0,0,0)"===e||"rgba(0, 0, 0, 0)"===e},C=(t,e,r=!0)=>{const o=t,n=o.groupIds??[];if(n.includes(e)||(o.groupIds=[...n,e]),!r||!o.label)return;const s=o.label.groupIds??[];s.includes(e)||(o.label.groupIds=[...s,e])},I=new s({converter:t=>{const e=[],r=[];if(Object.values(t.nodes).forEach(t=>{t&&t.length&&t.forEach(t=>{let o;switch(t.type){case"line":o=S(t);break;case"rectangle":case"ellipse":o=k(t);break;case"text":o=A(t);break;default:throw`unknown type ${t.type}`}"rectangle"===t.type&&"activation"===t?.subtype?r.push(o):e.push(o)})}),Object.values(t.lines).forEach(t=>{t&&e.push(S(t))}),Object.values(t.arrows).forEach(t=>{t&&(e.push(E(t)),t.sequenceNumber&&e.push(k(t.sequenceNumber)))}),e.push(...r),t.loops){const{lines:r,texts:o,nodes:n}=t.loops;r.forEach(t=>{e.push(S(t))}),o.forEach(t=>{e.push(A(t))}),n.forEach(t=>{e.push(k(t))})}return t.groups&&t.groups.forEach(t=>{const{actorKeys:r,name:o}=t;let n=1/0,s=1/0,i=0,a=0;if(!r.length)return;const l=e.filter(t=>{if(t.id){const e=t.id.indexOf("-"),o=t.id.substring(0,e);return r.includes(o)}return!1});if(!l.length)return;if(l.forEach(t=>{void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height&&(n=Math.min(n,t.x),s=Math.min(s,t.y),i=Math.max(i,t.x+t.width),a=Math.max(a,t.y+t.height))}),!(Number.isFinite(n)&&Number.isFinite(s)&&Number.isFinite(i)&&Number.isFinite(a)))return;const c=n-10,d=s-10,u=i-n+20,h=a-s+20,p=b(),g=b(),y=k({type:"rectangle",x:c,y:d,width:u,height:h,bgColor:v(t.fill)?void 0:t.fill,strokeColor:"#1f1f1f",strokeWidth:1,id:p,groupId:g});if(e.unshift(y),e.forEach(t=>{t.id!==p&&void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height&&t.x>=n&&t.x+t.width<=i&&t.y>=s&&t.y+t.height<=a&&C(t,g)}),o){const t=A({type:"text",id:b(),text:o,x:c+4,y:d-24,width:(f=o,m=16,Math.max(20,Math.round(f.length*m*.6))),height:24,fontSize:16,color:"#1f1f1f",groupId:g});C(t,g,!1),e.push(t)}var f,m}),{elements:e}}}),O=new s({converter:t=>{const e=[];return t.nodes.forEach(t=>{t&&t.length&&t.forEach(t=>{let r;switch(t.type){case"line":r=S(t);break;case"rectangle":case"ellipse":r=k(t);break;case"text":r=A(t);break;default:throw`unknown type ${t.type}`}e.push(r)})}),Object.values(t.lines).forEach(t=>{t&&e.push(S(t))}),Object.values(t.arrows).forEach(t=>{if(!t)return;const r=E(t);e.push(r)}),Object.values(t.text).forEach(t=>{const r=A(t);e.push(r)}),Object.values(t.namespaces).forEach(r=>{const o=Object.keys(r.classes),n=[...o],s=[...t.lines,...t.arrows,...t.text];o.forEach(t=>{const e=s.filter(e=>e.metadata&&e.metadata.classId===t).map(t=>t.id);e.length&&n.push(...e)});const i={type:"frame",id:b(),name:r.id,children:n};e.push(i)}),{elements:e}}}),L=new s({converter:t=>{const e=[];return t.nodes.forEach(t=>{t&&t.length&&t.forEach(t=>{let r;switch(t.type){case"line":r=S(t);break;case"rectangle":case"ellipse":r=k(t);break;case"text":r=A(t);break;default:throw`unknown type ${t.type}`}e.push(r)})}),t.lines.forEach(t=>{e.push(S(t))}),t.arrows.forEach(t=>{e.push(E(t))}),t.text.forEach(t=>{e.push(A(t))}),{elements:e}}}),N=(t,e)=>[t,e],$="#000000",T=new Set(["choice","fork","join","stateStart","stateEnd","divider"]),Y=t=>"stateEnd"===t.shape?[`state_end_group_${t.id}`]:void 0,R=t=>"rectWithTitle"===t.shape&&t.description.length?[t.text,...t.description].join("\n"):t.text;let X;const _=(t,e)=>{const r=(()=>{if(void 0!==X)return X;if("undefined"==typeof document)return X=null,X;try{X=document.createElement("canvas").getContext("2d")}catch{X=null}return X})();return r?(r.font=`${e}px Excalifont, sans-serif`,r.measureText(t).width):t.length*e*.6},q=(t,e,r)=>{if(_(t,e)<=r)return[t];const o=[];let n="";for(const s of t){const t=`${n}${s}`;n&&_(t,e)>r?(o.push(n),n=s):n=t}return n&&o.push(n),o},M=(t,e,r)=>{const o=t.map(t=>((t,e,r)=>{if(!t.trim())return t;if(_(t,e)<=r)return t;const o=t.split(/\s+/).filter(Boolean),n=[];let s="";for(const t of o){const o=q(t,e,r);for(const[t,i]of o.entries()){const o=s?`${s}${s&&0===t?" ":""}${i}`:i;_(o,e)<=r?s=o:(s&&n.push(s),s=i)}o.length}return n.push(s),n.join("\n")})(t,e,r)).join("\n"),n=o.split("\n");return{width:Math.max(...n.map(t=>_(t,e))),height:n.length*e*1.25}},z=t=>{const e=R(t);if(!e||T.has(t.shape))return 16;const r=Math.max(1,t.width-10),o=Math.max(1,t.height-10),n=e.split("\n");if(n.length>1){if(Math.max(...n.map(t=>_(t,16)))<=r)return 16}return((t,e,r,o)=>{const n=t.split("\n");for(let t=16;t>=14;t-=1){const{height:o}=M(n,t,e);if(o<=r)return t}return o})(e,r,o,1===n.length?16:14)},D=t=>{const e=p(t.containerStyle),r=(t=>{if(T.has(t.shape))return;const e=R(t);return e?{text:e,fontSize:z(t),verticalAlign:"rectWithTitle"===t.shape||"roundedWithTitle"===t.shape?"top":"middle",...g(t.labelStyle)}:void 0})(t),o="choice"===t.shape?"diamond":"stateStart"===t.shape||"stateEnd"===t.shape?"ellipse":"rectangle",n="rect"===t.shape||"rectWithTitle"===t.shape||"roundedWithTitle"===t.shape,s="stateStart"===t.shape||"fork"===t.shape||"join"===t.shape,i=e.backgroundColor||e.strokeColor||$,a=e.strokeColor||e.backgroundColor||$;return{id:t.id,type:o,...Y(t)?{groupIds:Y(t)}:{},x:t.x,y:t.y,width:t.width,height:t.height,...r?{label:r}:{},...e,...n?{roundness:{type:3}}:{},...s?{backgroundColor:i,strokeColor:a,fillStyle:"solid"}:{}}},W=new s({converter:t=>{const e=[];return t.nodes.forEach(t=>{if(!t.isRenderable)return;const r=D(t);e.push(r);const o=(t=>{if(!t.dividerLine)return null;const e=p(t.containerStyle);return{id:`${t.id}__divider`,type:"line",x:t.dividerLine.startX,y:t.dividerLine.startY,width:t.dividerLine.endX-t.dividerLine.startX,height:t.dividerLine.endY-t.dividerLine.startY,points:[N(0,0),N(t.dividerLine.endX-t.dividerLine.startX,t.dividerLine.endY-t.dividerLine.startY)],strokeColor:e.strokeColor||"#000",strokeWidth:e.strokeWidth||1}})(t);o&&e.push(o),"stateEnd"===t.shape&&e.push((t=>{const e=p(t.containerStyle),r=Math.max(2,.32*Math.min(t.width,t.height)),o=t.endInnerColor||e.strokeColor||e.backgroundColor||$;return{id:`${t.id}__inner`,type:"ellipse",groupIds:Y(t),x:t.x+r,y:t.y+r,width:Math.max(1,t.width-2*r),height:Math.max(1,t.height-2*r),backgroundColor:o,strokeColor:o,fillStyle:"solid",strokeWidth:1}})(t))}),t.edges.forEach(t=>{e.push((t=>{const e=t.reflectionPoints.map((t,e,r)=>{const o=r[0];return 0===e?N(0,0):N(t.x-o.x,t.y-o.y)});return{id:t.id,type:"arrow",x:t.startX,y:t.startY,width:t.endX-t.startX,height:t.endY-t.startY,points:e,strokeColor:t.strokeColor||"#000",strokeWidth:t.strokeWidth||2,strokeStyle:t.strokeStyle||"solid",endArrowhead:t.isNoteEdge?null:"triangle",roundness:{type:2},start:{id:t.start},end:{id:t.end},...t.text?{label:{text:t.text,fontSize:16}}:{}}})(t))}),{elements:e}}}),F=t=>{const e=(t=j(t)).replace(/#(\d+);/g,"&#$1;").replace(/#([a-z]+);/g,"&$1;"),r=document.createElement("textarea");return r.innerHTML=e,r.value},B=t=>{const e=t.getAttribute("transform"),r=e?.match(/translate\(([ \d.-]+),\s*([\d.-]+)\)/);let o=0,n=0;return r&&(o=Number(r[1]),n=Number(r[2])),{transformX:o,transformY:n}},j=function(t){return t.replace(/fl°°/g,"#").replace(/fl°/g,"&").replace(/¶ß/g,";")},K=(t,e=.5)=>{const r=[];return t.forEach(t=>{const o=r[r.length-1];if(!o)return void r.push(t);Math.hypot(t[0]-o[0],t[1]-o[1])<=e||r.push(t)}),r},P=t=>{const e=t.getAttribute("d");if(!e)return null;const r=Array.from(e.matchAll(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi),t=>Number(t[0]));return r.length<4?null:{startX:r[0],startY:r[1],endX:r[r.length-2],endY:r[r.length-1]}},U=t=>{const e=t.getAttribute("data-points");if(!e){const e=P(t);return e?[{x:e.startX,y:e.startY},{x:e.endX,y:e.endY}]:[]}try{const t=atob(e),r=JSON.parse(t);return Array.isArray(r)?r.filter(t=>t&&"number"==typeof t.x&&"number"==typeof t.y&&Number.isFinite(t.x)&&Number.isFinite(t.y)):[]}catch{return[]}},H=(t,e={x:0,y:0},r="LM")=>{if("path"!==t.tagName.toLowerCase())throw new Error(`Invalid input: Expected an HTMLElement of tag "path", got ${t.tagName}`);const o=t.getAttribute("d");if(!o)throw new Error('Path element does not contain a "d" attribute');const n=o.split(new RegExp(`(?=[${r}])`)),s=n[0].substring(1).split(",").map(t=>parseFloat(t)),i=n[n.length-1].substring(1).split(",").map(t=>parseFloat(t)),a=n.map(t=>{const e=t[0],r=t.substring(1).split(",").map(t=>parseFloat(t));return"C"===e?{x:r[4],y:r[5],command:e}:{x:r[0],y:r[1],command:e}}).filter((t,e,r)=>{if(0===e||e===r.length-1)return!0;if(t.x===r[e-1].x&&t.y===r[e-1].y)return!1;if(e===r.length-2&&"C"===t.command)return!1;if(e===r.length-2&&(r[e-1].x===t.x||r[e-1].y===t.y)){const e=r[r.length-1];return Math.hypot(e.x-t.x,e.y-t.y)>20}return t.x!==r[e-1].x||t.y!==r[e-1].y}).map(t=>({x:t.x+e.x,y:t.y+e.y}));return{startX:s[0]+e.x,startY:s[1]+e.y,endX:i[0]+e.x,endY:i[1]+e.y,reflectionPoints:a}},V=(t,e={})=>(t=>({...t,elements:t.elements.map(t=>{if(!("points"in t)||!Array.isArray(t.points))return t;const e=t.points;if(e.length<2)return t;const r=K(e);return r.length===e.length?t:{...t,points:r}})}))((()=>{switch(t.type){case"graphImage":return m.convert(t,e);case"flowchart":return f.convert(t,e);case"sequence":return I.convert(t,e);case"class":return O.convert(t,e);case"erd":return L.convert(t,e);case"state":return W.convert(t,e);default:throw new Error(`graphToExcalidraw: unknown graph type "${t.type}, only flowcharts are supported!"`)}})());var G=r(62300);const J=t=>t.replace(/\s*!important\s*$/i,"").trim(),Z=(t,e)=>{let r=e;for(;r<t.length&&/\s/.test(t[r]);)r+=1;const o=r;for(;r<t.length&&/[a-z-]/i.test(t[r]);)r+=1;if(r===o)return!1;for(;r<t.length&&/\s/.test(t[r]);)r+=1;return":"===t[r]},Q=t=>{const e=[];let r=0;for(;r<t.length;){for(;r<t.length&&/[\s;,]/.test(t[r]);)r+=1;if(r>=t.length)break;const o=r;for(;r<t.length&&":"!==t[r]&&";"!==t[r]&&","!==t[r];)r+=1;if(r>=t.length||":"!==t[r])break;const n=t.substring(o,r).trim().toLowerCase();r+=1;const s=r;let i=0,a=null;for(;r<t.length;){const e=t[r];if(a)e===a&&"\\"!==t[r-1]&&(a=null),r+=1;else if('"'!==e&&"'"!==e)if("("!==e)if(")"!==e){if(0===i){if(";"===e||","===e)break;if(/\s/.test(e)&&Z(t,r))break}r+=1}else i=Math.max(0,i-1),r+=1;else i+=1,r+=1;else a=e,r+=1}const l=J(t.substring(s,r));n&&l&&e.push({property:n,value:l}),r<t.length&&(";"===t[r]||","===t[r])&&(r+=1)}return e},tt=t=>{const e=J(t);if(!e)return!1;if("undefined"!=typeof CSS&&"function"==typeof CSS.supports)return CSS.supports("color",e);if("undefined"!=typeof document){const t=document.createElement("div");return t.style.color="",t.style.color=e,""!==t.style.color}return!1},et=(t,e)=>{const r=t.getAttribute("style");return r&&Q(r).find(t=>t.property===e)?.value||""},rt=(...t)=>{for(const e of t){const t=J(e||"");if(tt(t))return t}},ot=(t,e)=>{const r=t.querySelector("text, foreignObject, div, span, p")||t,o=rt(r.getAttribute?.("fill"),et(r,"fill"),r.style?.fill);if(o)return o;const n=rt(r.getAttribute?.("color"),et(r,"color"),r.style?.color);if(n)return n;const s=rt(e);return s||void 0},nt=(t,e,r)=>{switch(e){case l.FILL:case l.STROKE:tt(r)&&(t[e]=r);break;case l.STROKE_WIDTH:case l.STROKE_DASHARRAY:t[e]=r}},st=(t,e,r)=>{e===a.COLOR&&tt(r)&&(t[a.COLOR]=r)},it=(t,e,r)=>{t&&Q(t).forEach(({property:t,value:o})=>{nt(e,t,o),st(r,t,o)})},at=(t,e)=>{t&&Q(t).forEach(({property:t,value:r})=>{"fill"===t&&tt(r)?e[a.COLOR]=r:st(e,t,r)})},lt=(t,e)=>{if(!t)return;[[l.FILL,t.getAttribute("fill")],[l.STROKE,t.getAttribute("stroke")],[l.STROKE_WIDTH,t.getAttribute("stroke-width")],[l.STROKE_DASHARRAY,t.getAttribute("stroke-dasharray")]].forEach(([t,r])=>{const o=J(r||"");o&&nt(e,t,o)})},ct=(t,e)=>{if(!t)return;const r=t.getAttribute("fill")||t.getAttribute("color"),o=J(r||"");tt(o)&&(e[a.COLOR]=o)},dt=(t,e,r,o)=>{if(!(e instanceof Map))return;const n=e.get(t);n&&(n.styles?.forEach(t=>{Q(t).forEach(({property:t,value:e})=>{nt(r,t,e),st(o,t,e)})}),n.textStyles?.forEach(t=>{Q(t).forEach(({property:t,value:e})=>{st(o,t,e)})}))},ut=(t,e,r)=>{const o=e.querySelector(`[id*="${t.domId}"]`);if(!o)return;let n;"a"===o.parentElement?.tagName.toLowerCase()&&(n=o.parentElement.getAttribute("xlink:href"));const s=ht(n?o.parentElement:o,e),i=o.getBBox(),a={width:i.width,height:i.height},l={},c={};t.classes&&r instanceof Map&&(Array.isArray(t.classes)?t.classes:[t.classes]).forEach(t=>{dt(t,r,l,c)}),t.styles?.forEach(t=>{it(t,l,c)});const d=o.querySelector(".label-container");it(d?.getAttribute("style"),l,c),lt(d,l);return Array.from(o.querySelectorAll(".label, .nodeLabel, .label text, .label tspan, .label span, .label div")).forEach(t=>{at(t.getAttribute("style"),c),ct(t,c)}),{id:t.id,labelType:t.labelType,text:F(t.text||""),type:t.type,link:n||void 0,...s,...a,containerStyle:l,labelStyle:c}},ht=(t,e)=>{if(!t)throw new Error("Element not found");let r=t.parentElement?.parentElement;const o=t.childNodes[0];let n={x:0,y:0};if(o){const{transformX:t,transformY:e}=B(o),r=o.getBBox();n={x:Number(o.getAttribute("x"))||t+r.x||0,y:Number(o.getAttribute("y"))||e+r.y||0}}const{transformX:s,transformY:i}=B(t),a={x:s+n.x,y:i+n.y};for(;r&&r.id!==e.id;){if("root"===r.classList.value&&r.hasAttribute("transform")){const{transformX:t,transformY:e}=B(r);a.x+=t,a.y+=e}r=r.parentElement}return a},pt=(t,e)=>{const r=t.getVertices(),o=t.getEdges(),n=t.getSubGraphs(),s=t.getClasses(),i={},a=s instanceof Map?s:{};r instanceof Map?r.forEach((t,r)=>{i[r]=ut(t,e,a)}):"object"==typeof r&&null!==r&&Object.entries(r).forEach(([t,r])=>{i[t]=ut(r,e,a)});const l=new Map,c=(Array.isArray(o)?o:[]).map(t=>{if(!e.querySelector(`[id*="${t.id}"]`))return null;const r=`${t.start}-${t.end}`,o=l.get(r)||0;return l.set(r,o+1),((t,e,r)=>{const o=r.querySelector(`[id*="${t.id}"]`);if(!o)throw new Error("Edge element not found");const n=ht(o,r),s=H(o,n);return t.length=void 0,{...t,...s,text:F(t.text)}})(t,0,e)}).filter(t=>null!==t&&t.reflectionPoints.length>1),d=(Array.isArray(n)?n:[]).map(t=>((t,e,r)=>{const o=t.nodes.map(t=>t.startsWith("flowchart-")?t.split("-")[1]:t),n=e.querySelector(`[id='${t.id}']`);if(!n)throw new Error("SubGraph element not found");const s=ht(n,e),i=n.getBBox(),a={width:i.width,height:i.height},l={},c={},d=n.querySelector(":scope > rect, :scope > path, :scope > polygon, :scope > ellipse")||n.querySelector(".cluster > rect, .cluster > path, .cluster > polygon, .cluster > ellipse")||n.querySelector("rect, path, polygon, ellipse");it(n.getAttribute("style"),l,c),it(d?.getAttribute("style"),l,c),lt(d,l);const u=n.querySelector(".cluster-label text, .cluster-label tspan")||n.querySelector("text");return at(u?.getAttribute("style"),c),ct(u,c),dt(t.id,r,l,c),t.classes?.forEach(t=>{dt(t,r,l,c)}),{id:t.id,nodeIds:o,text:F(t.title),labelType:"text",...s,...a,containerStyle:l,labelStyle:c}})(t,e,a));return{type:"flowchart",subGraphs:d,vertices:i,edges:c}},gt=(t,e,r,o,n)=>{const s={type:"arrow"};return s.startX=t,s.startY=e,s.endX=r,s.endY=o,Object.assign(s,{...n}),s},yt=(t,e,r,o)=>({type:"text",x:t,y:e,text:r,width:o?.width||20,height:o?.height||20,fontSize:o?.fontSize||20,id:o?.id,color:o?.color,groupId:o?.groupId,metadata:o?.metadata}),ft=(t,e,r)=>{const o={},n=Number(t.getAttribute("x")),s=Number(t.getAttribute("y"));o.type="text",o.text=F(e),r?.id&&(o.id=r.id),r?.groupId&&(o.groupId=r.groupId);const i=t.getBBox();o.width=i.width,o.height=i.height,o.x=n-i.width/2,o.y=s;const a=parseInt(getComputedStyle(t).fontSize);return o.fontSize=a,o.color=ot(t),o},bt=(t,e,r={})=>{const o={};o.type=e;const{label:n,subtype:s,id:i,groupId:a}=r;o.id=i,a&&(o.groupId=a),n&&(o.label={text:F(n.text),fontSize:16,textAlign:n?.textAlign,verticalAlign:n?.verticalAlign});const l=t.getBBox();switch(o.x=l.x,o.y=l.y,o.width=l.width,o.height=l.height,o.subtype=s,s){case"highlight":const e=t.getAttribute("fill");e&&(o.bgColor=J(e));break;case"note":o.strokeStyle="dashed"}return o},mt=(t,e,r,o,n,s)=>{const i={};i.startX=e,i.startY=r,i.endX=o,s?.groupId&&(i.groupId=s.groupId),s?.id&&(i.id=s.id),i.endY=n;const a=t.getAttribute("stroke");return i.strokeColor=a?J(a):null,i.strokeWidth=Number(t.getAttribute("stroke-width")),i.type="line",i},xt={0:"SOLID",1:"DOTTED",3:"SOLID_CROSS",4:"DOTTED_CROSS",5:"SOLID_OPEN",6:"DOTTED_OPEN",24:"SOLID_POINT",25:"DOTTED_POINT"},wt=0,St=1,At=2,kt=3,Et=4,vt=5,Ct=6,It=24,Ot=25,Lt=27,Nt=t=>{let e;switch(t){case wt:case kt:case vt:case It:e="solid";break;case St:case Et:case Ct:case Ot:e="dotted";break;default:e="solid"}return e},$t=(t,e,r)=>{if(!t)throw"root node not found";const n=b(),s=Array.from(t.children),i=[];return s.forEach((t,s)=>{const a=`${r?.id}-${s}`;let l;switch(t.tagName){case"line":const r=Number(t.getAttribute("x1")),s=Number(t.getAttribute("y1")),i=Number(t.getAttribute("x2")),c=Number(t.getAttribute("y2"));l=mt(t,r,s,i,c,{groupId:n,id:a});break;case"text":l=ft(t,e,{groupId:n,id:a});break;case"circle":l=bt(t,"ellipse",{label:t.textContent?{text:t.textContent}:void 0,groupId:n,id:a});default:l=bt(t,o[t.tagName],{label:t.textContent?{text:t.textContent}:void 0,groupId:n,id:a})}i.push(l)}),i},Tt=(t,e)=>{const r=e.getAttribute("fill"),o=e.getAttribute("stroke"),n=e.getAttribute("stroke-width"),s=e.getAttribute("stroke-dasharray");r&&"none"!==r&&(t.bgColor=J(r)),o&&"none"!==o&&(t.strokeColor=J(o)),n&&(t.strokeWidth=Number(n)),s&&s.trim()&&(t.strokeStyle="dashed")},Yt=(t,e,r)=>{const o=[],n=Array.from(e.querySelectorAll('[class*="messageLine"]')),s=Object.keys(xt),i=t.filter(t=>s.includes(t.type.toString()));return n.forEach((t,e)=>{const n=i[e],s=xt[n.type],a=((t,e)=>{const r={};e?.label&&(r.label={text:F(e.label),fontSize:16});const o=t.tagName;if("line"===o)r.startX=Number(t.getAttribute("x1")),r.startY=Number(t.getAttribute("y1")),r.endX=Number(t.getAttribute("x2")),r.endY=Number(t.getAttribute("y2"));else if("path"===o){const e=t.getAttribute("d");if(!e)throw new Error('Path element does not contain a "d" attribute');const o=e.split(/(?=[LC])/),n=o[0].substring(1).split(",").map(t=>parseFloat(t)),s=[];o.forEach(t=>{const e=t.substring(1).trim().split(" ").map(t=>{const[e,r]=t.split(",");return[parseFloat(e)-n[0],parseFloat(r)-n[1]]});s.push(...e)});const i=s[s.length-1];r.startX=n[0],r.startY=n[1],r.endX=i[0],r.endY=i[1],r.points=s}if(e?.label){const t=10;r.startY=r.startY-t,r.endY=r.endY-t}const n=t.getAttribute("stroke"),s=(n&&"none"!==n?n:"")||getComputedStyle(t).stroke||"";return r.strokeColor=s?J(s):null,r.strokeWidth=Number(t.getAttribute("stroke-width")),r.type="arrow",r.strokeStyle=e?.strokeStyle||"solid",r.startArrowhead=e?.startArrowhead||null,r.endArrowhead=e?.endArrowhead||null,r})(t,{label:n?.message,strokeStyle:Nt(n.type),endArrowhead:"SOLID_OPEN"===s||"DOTTED_OPEN"===s?null:"arrow"}),l=r[n.from],c=r[n.to];l?.topId&&c?.topId&&(a.start={type:l.bindType||"rectangle",id:l.topId},a.end={type:c.bindType||"rectangle",id:c.topId}),((t,e)=>{if(t.nextElementSibling?.classList.contains("sequenceNumber")){const r=t.nextElementSibling?.textContent;if(!r)throw new Error("sequence number not present");const o=30,n=o/2,s=10,i={type:"rectangle",x:e.startX-s,y:e.startY-n,label:{text:r,fontSize:14},bgColor:"#e9ecef",height:o,subtype:"sequence"};Object.assign(e,{sequenceNumber:i})}})(t,a),o.push(a)}),o},Rt=(t,e)=>{const r=t.db,o=[],n=r.getBoxes().map(t=>({...t,fill:J(t.fill||"")})),s=(t=>{const e=Array.from(t.querySelectorAll(".rect")).filter(t=>"g"!==t.parentElement?.tagName),r=[];return e.forEach(t=>{const e=bt(t,"rectangle",{label:{text:""},subtype:"highlight"});r.push(e)}),r})(e),i=r.getActors(),{nodes:a,lines:l,actorMap:c}=((t,e)=>{const r=Array.from(e.querySelectorAll(".actor-top")),o=Array.from(e.querySelectorAll(".actor-bottom")),n=[],s=[],i={},a=t instanceof Map?Array.from(t.values()):Object.values(t),l=Array.from(e.querySelectorAll(".actor-line")),c=(t,e)=>{const r=t.name,o=l.find(t=>t.getAttribute("name")===r);if(o)return o;const n="participant"===t.type?e.parentElement?.previousElementSibling:e.previousElementSibling;return n?"line"===n.tagName?n:n.querySelector("line"):null};return a.forEach(t=>{const e=r.find(e=>e.getAttribute("name")===t.name),a=o.find(e=>e.getAttribute("name")===t.name);if(!e||!a)throw"root not found";const l=t.description;if("participant"===t.type){const r=bt(e,"rectangle",{id:`${t.name}-top`,label:{text:l},subtype:"actor"});if(Tt(r,e),!r)throw"Top Node element not found!";n.push([r]);const o=bt(a,"rectangle",{id:`${t.name}-bottom`,label:{text:l},subtype:"actor"});i[t.name]={topId:`${t.name}-top`,bottomId:`${t.name}-bottom`,bindType:"rectangle"},Tt(o,a),n.push([o]);const d=c(t,e);if("line"!==d?.tagName)throw"Line not found";const u=Number(d.getAttribute("x1"));if(!r.height)throw"Top node element height is null";const h=r.y+r.height,p=o.y,g=Number(d.getAttribute("x2")),y=mt(d,u,h,g,p);s.push(y)}else if("actor"===t.type){const r=$t(e,l,{id:`${t.name}-top`});n.push(r);const o=$t(a,l,{id:`${t.name}-bottom`});n.push(o);const d=c(t,e);if("line"!==d?.tagName)throw"Line not found";const u=Number(d.getAttribute("x1")),h=Number(d.getAttribute("y1")),p=Number(d.getAttribute("x2")),g=o.find(t=>"ellipse"===t.type);if(g){const t=g.y,e=mt(d,u,h,p,t);s.push(e)}const y=r.find(t=>"ellipse"===t.type),f=o.find(t=>"ellipse"===t.type);y?.id&&f?.id&&(i[t.name]={topId:y.id,bottomId:f.id,bindType:"ellipse"})}}),{nodes:n,lines:s,actorMap:i}})(i,e),d=r.getMessages(),u=Yt(d,e,c),h=((t,e)=>{const r=Array.from(e.querySelectorAll(".note")).map(t=>t.parentElement),o=t.filter(t=>t.type===At),n=[];return r.forEach((t,e)=>{if(!t)return;const r=t.firstChild,s=o[e].message,i=bt(r,"rectangle",{label:{text:s},subtype:"note"}),a=r.getAttribute("fill"),l=r.getAttribute("stroke"),c=r.getAttribute("stroke-width"),d=r.getAttribute("stroke-dasharray");a&&"none"!==a&&(i.bgColor=J(a)),l&&"none"!==l&&(i.strokeColor=J(l)),c&&(i.strokeWidth=Number(c)),d&&d.trim()&&(i.strokeStyle="dashed"),n.push(i)}),n})(d,e),p=(t=>{const e=Array.from(t.querySelectorAll("[class*=activation]")),r=[];return e.forEach(t=>{const e=bt(t,"rectangle",{label:{text:""},subtype:"activation"});(()=>{const r=t.getAttribute("fill"),o=t.getAttribute("stroke"),n=t.getAttribute("stroke-width"),s=t.getAttribute("stroke-dasharray");r&&"none"!==r&&(e.bgColor=J(r)),o&&"none"!==o&&(e.strokeColor=J(o)),n&&(e.strokeWidth=Number(n)),s&&s.trim()&&(e.strokeStyle="dashed")})(),r.push(e)}),r})(e),g=((t,e)=>{const r=Array.from(e.querySelectorAll(".loopLine")),o=[],n=[],s=[];r.forEach(t=>{const e=Number(t.getAttribute("x1")),r=Number(t.getAttribute("y1")),n=Number(t.getAttribute("x2")),s=Number(t.getAttribute("y2")),i=mt(t,e,r,n,s);i.strokeStyle="dotted",i.strokeColor="#adb5bd",i.strokeWidth=2,o.push(i)});const i=Array.from(e.querySelectorAll(".loopText")),a=t.filter(t=>t.type===Lt).map(t=>t.message);i.forEach(t=>{const e=t.textContent||"",r=ft(t,e),o=e.match(/\[(.*?)\]/)?.[1]||"";a.includes(o)&&(r.x+=16),n.push(r)});const l=Array.from(e?.querySelectorAll(".labelBox")),c=Array.from(e?.querySelectorAll(".labelText"));return l.forEach((t,e)=>{const r=c[e]?.textContent||"",o=bt(t,"rectangle",{label:{text:r}});o.strokeColor="#adb5bd",o.bgColor="#e9ecef",o.width=void 0,s.push(o)}),{lines:o,texts:n,nodes:s}})(d,e);return o.push(s),o.push(...a),o.push(h),o.push(p),{type:"sequence",lines:l,arrows:u,nodes:o,loops:g,groups:n}},Xt=0,_t=1,qt=2,Mt=0,zt=1,Dt=t=>{let e;switch(t){case Xt:e="diamond_outline";break;case qt:e="diamond";break;case _t:e="triangle_outline";break;case"none":e=null;break;default:e="arrow"}return e},Wt=(t,e)=>{let r=0,o=0,n=t;for(;n&&n!==e;){const{transformX:t,transformY:e}=B(n);r+=t,o+=e,n=n.parentElement}return{tx:r,ty:o}},Ft=new Set(["triangle_outline","diamond","diamond_outline"]),Bt=(t,e=.5)=>{if(t.length<=2)return[...t];const r=[t[0]];for(let o=1;o<t.length-1;o++){const n=r[r.length-1],s=t[o],i=t[o+1],a=i.x-n.x,l=i.y-n.y,c=Math.hypot(a,l);if(!c)continue;const d=Math.abs(a*(s.y-n.y)-l*(s.x-n.x))/c,u=((s.x-n.x)*a+(s.y-n.y)*l)/(c*c);d<=e&&u>=-e&&u<=1+e||r.push(s)}return r.push(t[t.length-1]),r},jt=t=>{const e=K(U(t).map(t=>[t.x,t.y])).map(([t,e])=>({x:t,y:e})),r=P(t);return r&&e.length>=2&&(e[0]={x:r.startX,y:r.startY},e[e.length-1]={x:r.endX,y:r.endY}),Bt(e)},Kt=(t,e,r)=>{const o=t.x-e.x,n=t.y-e.y,s=Math.hypot(o,n);return s?{x:t.x+o/s*r,y:t.y+n/s*r}:t},Pt=t=>{const e=t.points?.map(([e,r])=>({x:t.startX+e,y:t.startY+r})).filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y));if(!e||e.length<2)return t;const r=[...e],o=!!t.startArrowhead&&Ft.has(t.startArrowhead),n=!!t.endArrowhead&&Ft.has(t.endArrowhead);if(!o&&!n)return t;if(o&&(r[0]=Kt(r[0],r[1],16)),n){const t=r.length-1;r[t]=Kt(r[t],r[t-1],16)}return((t,e)=>{const r=K(e.map(t=>[t.x,t.y])).map(([t,e])=>({x:t,y:e}));if(r.length<2)throw new Error("Arrow route must contain at least two points");const o=r[0],n=r[r.length-1];t.startX=o.x,t.startY=o.y,t.endX=n.x,t.endY=n.y,t.points=r.map(t=>[t.x-o.x,t.y-o.y])})(t,r),t},Ut=(t,e,r)=>{if(t.length<2)throw new Error(`Class diagram edge ${e?.id||"<unknown>"} is missing usable path points`);const o=t[0],n=t[t.length-1],s=gt(o.x,o.y,n.x,n.y,{id:e?.getAttribute("data-id")||e?.id||void 0,...r,points:t.map(t=>[t.x-o.x,t.y-o.y])});return e&&((t,e)=>{const r=J(t.getAttribute("stroke")||getComputedStyle(t).stroke||""),o=parseFloat(t.getAttribute("stroke-width")||getComputedStyle(t).strokeWidth||"1");tt(r)&&"none"!==r&&(e.strokeColor=r),Number.isFinite(o)&&o>0&&(e.strokeWidth=o)})(e,s),Pt(s)},Ht=(t,e)=>Ut((t=>{const e=[];return t.forEach(t=>{jt(t).forEach(t=>{const r=e[e.length-1];r&&r.x===t.x&&r.y===t.y||e.push(t)})}),Bt(e)})(t),t[0],e),Vt=(t,e)=>{const r=(t=>t.points?.map(([e,r])=>({x:t.startX+e,y:t.startY+r})).filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y))||[])(t);if(r.length<2)return null;const o="start"===e,n=o?r[0]:r[r.length-1],s=o?r[1]:r[r.length-2],i=s.x===n.x?o?-1:1:Math.sign(s.x-n.x),a=s.y===n.y?1:Math.sign(s.y-n.y);return{x:n.x+20*i,y:n.y+(a>=0?12:-28)}},Gt=(t,e)=>{let r=t;for(;r&&r!==e;){if(r.classList.contains("annotation-group"))return"header";if(r.classList.contains("label-group"))return"header";if(r.classList.contains("members-group"))return"members";if(r.classList.contains("methods-group"))return"methods";r=r.parentElement}return"other"},Jt=(t,e,r)=>{const o=[],n=[],s=[];return Object.values(t).forEach(t=>{const{domId:i,id:a}=t,l=b(),c=(t=>{const e={};return t?(t.forEach(t=>{Q(t).forEach(({property:t,value:r})=>{t&&r&&(e[t]=J(r))})}),e):e})(t.styles||t.cssStyles);let d;try{d=r?r(a):void 0}catch{d=void 0}const u=d&&e.querySelector(`#${d}`)||e.querySelector(`#${i}`)||e.querySelector(`[data-id='${a}']`)||(t=>{const r=new RegExp(`^classId-${t}(?:-|$)`);return Array.from(e.querySelectorAll("[id]")).filter(t=>r.test(t.id))[0]})(a);if(!u)throw Error(`DOM Node with id ${i} not found`);const h=u.querySelector("rect")||u,p=h.getBBox(),{tx:g,ty:y}=Wt(h,e),f={type:"rectangle",id:a,groupId:l,x:p.x+g,y:p.y+y,width:p.width,height:p.height,metadata:{classId:a}},m=h.getAttribute("fill"),x=h.getAttribute("stroke"),w=h.getAttribute("stroke-width"),S=h.getAttribute("stroke-dasharray"),A=getComputedStyle(h),k=J(m||c.fill||(m?A.fill:"")),E=J(x||c.stroke||(x?A.stroke:"")),v=w||c["stroke-width"]||(w?A.strokeWidth:""),C=S||c["stroke-dasharray"]||(S?"none"===A.strokeDasharray?"":A.strokeDasharray:""),I=t=>{if(!t)return!1;if(!tt(t))return!1;const e=t.toLowerCase();return!("none"===e||"transparent"===e||"rgba(0, 0, 0, 0)"===e||"black"===e||"#000"===e||"#000000"===e||"rgb(0, 0, 0)"===e||"rgba(0, 0, 0, 1)"===e)};I(k)?f.bgColor=k:f.bgColor=void 0,I(E)?f.strokeColor=E:f.strokeColor=void 0,f.strokeWidth=v?Number(v):void 0,C&&C.trim().length>0?f.strokeStyle="dashed":f.strokeStyle=void 0,o.push(f);[...Array.from(u.querySelectorAll("line")),...Array.from(u.querySelectorAll("g.divider path"))].forEach(t=>{const{tx:r,ty:o}=Wt(t,e);let s,i,c,d;if("line"===t.tagName.toLowerCase())s=Number(t.getAttribute("x1"))+r,i=Number(t.getAttribute("y1"))+o,c=Number(t.getAttribute("x2"))+r,d=Number(t.getAttribute("y2"))+o;else{const e=t.getBBox();s=e.x+r,c=e.x+e.width+r;const n=e.y+e.height/2+o;i=n,d=n}if(s===c&&i===d)return;const u=mt(t,s,i,c,d,{groupId:l,id:b()});f.strokeColor?u.strokeColor=f.strokeColor:u.strokeColor=void 0,void 0!==f.strokeWidth?u.strokeWidth=f.strokeWidth:u.strokeWidth=void 0,f.strokeStyle?u.strokeStyle=f.strokeStyle:u.strokeStyle=void 0,u.metadata={classId:a},n.push(u)});const O=Array.from(u.querySelectorAll("text, foreignObject")),L=[];O.forEach(t=>{const r="foreignobject"===t.tagName.toLowerCase(),o=r?[]:Array.from(t.querySelectorAll("tspan")),n=o.length?o.map(t=>t.textContent?.trim()).filter(Boolean).join("\n"):t.textContent?.trim()||"";if(!n)return;const s=t.getBBox(),{ty:i}=Wt(t,e);let a=parseFloat(getComputedStyle(t).fontSize||"");if(r&&(!Number.isFinite(a)||!a)){const e=t.querySelector("div, span, p");e&&(a=parseFloat(getComputedStyle(e).fontSize||""))}(!Number.isFinite(a)||a<=0)&&(a=Math.max(12,.6*s.height)),a*=.9;const l=ot(t,c.color);L.push({section:Gt(t,u),text:F(n),x:s.x,y:s.y+i,width:f&&f.width?Math.max(f.width-8,s.width):s.width,height:s.height,fontSize:a,color:l})});const N=L.filter(t=>"header"===t.section).sort((t,e)=>t.y-e.y||t.x-e.x);if(!f.label){const t=0===N.length&&1===L.length?L:N;t.length>0&&(f.label={text:t.map(t=>t.text).join("\n"),fontSize:Math.max(...t.map(t=>t.fontSize)),color:t.find(t=>t.color)?.color,verticalAlign:"top"})}L.filter(t=>N.length>0?"header"!==t.section:!(f.label&&1===L.length)).forEach(t=>{const e=yt((f?.x||0)+4,t.y,t.text,{width:t.width,height:t.height,fontSize:t.fontSize,color:t.color,id:b(),groupId:l,metadata:{classId:a}});s.push(e)})}),{nodes:o,lines:n,text:s}},Zt=(t,e,r,o)=>{const n=Array.from(r.querySelectorAll('.edgePaths path[data-edge="true"]:not([id^="edgeNote"]):not([id*="-cyclic-special-"])'));if(0===t.length)return{arrows:[],text:[]};const s=[],i=[];let a=0;return t.forEach(t=>{const{id1:l,id2:c,relation:d}=t,u=e.find(t=>t.id===l),h=e.find(t=>t.id===c);if(!u)throw new Error(`parseRelations: Cannot find node with id ${l}`);if(!h)throw new Error(`parseRelations: Cannot find node with id ${c}`);const p=(t=>{let e;switch(t){case Mt:e="solid";break;case zt:e="dotted";break;default:e="solid"}return e})(d.lineType),g=Dt(d.type1),y=Dt(d.type2);let f;if(l===c){const e=((t,e)=>[`${t}-cyclic-special-1`,`${t}-cyclic-special-mid`,`${t}-cyclic-special-2`].map(t=>e.querySelector(`path[id="${t}"][data-edge="true"]`)).filter(t=>null!==t))(l,r);if(!e.length)throw new Error(`parseRelations: Cannot find rendered SVG edge for relation ${l} -> ${c}`);f=Ht(e,{strokeStyle:p,startArrowhead:g,endArrowhead:y,label:t.title?{text:t.title}:void 0,start:{type:"rectangle",id:u.id},end:{type:"rectangle",id:h.id}})}else{const e=n[a];if(!e)throw new Error(`parseRelations: Cannot find rendered SVG edge for relation ${l} -> ${c}`);a+=1,f=((t,e)=>{const r=jt(t);return Ut([r[0],r[r.length-1]],t,e)})(e,{strokeStyle:p,startArrowhead:g,endArrowhead:y,label:t.title?{text:t.title}:void 0,start:{type:"rectangle",id:u.id},end:{type:"rectangle",id:h.id}})}s.push(f);const{relationTitle1:b,relationTitle2:m}=t,x=l===c,w=20,S=15,A=15;let k,E;if(b&&"none"!==b){if(x){const t=Vt(f,"start");t&&(k=t.x,E=t.y)}else switch(o){case"TB":k=f.startX-w,f.endX<f.startX&&(k-=A),E=f.startY+S;break;case"BT":k=f.startX+w,f.endX>f.startX&&(k+=A),E=f.startY-S;break;case"LR":k=f.startX+w,E=f.startY+S,f.endY>f.startY&&(E+=A);break;case"RL":k=f.startX-w,E=f.startY-S,f.startY>f.endY&&(E-=A);break;default:k=f.startX-w,E=f.startY+S}k??=f.startX-w,E??=f.startY+S;const t=yt(k,E,b,{fontSize:16});i.push(t)}if(m&&"none"!==m){if(x){const t=Vt(f,"end");t&&(k=t.x,E=t.y)}else switch(o){case"TB":k=f.endX+w,f.endX<f.startX&&(k+=A),E=f.endY-S;break;case"BT":k=f.endX-w,f.endX>f.startX&&(k-=A),E=f.endY+S;break;case"LR":k=f.endX-w,E=f.endY-S,f.endY>f.startY&&(E-=A);break;case"RL":k=f.endX+w,E=f.endY+S,f.startY>f.endY&&(E+=A);break;default:k=f.endX+w,E=f.endY-S}k??=f.endX+w,E??=f.endY+S;const t=yt(k,E,m,{fontSize:16});i.push(t)}}),{arrows:s,text:i}},Qt=(t,e,r)=>{const o=[],n=[];return t.forEach((t,s)=>{const{id:i,text:a,class:l}=t,c=e.querySelector(`#${i}`);if(!c)throw new Error(`Node with id ${i} not found!`);const{transformX:d,transformY:u}=B(c),h=c.firstChild,p=bt(h,"rectangle",{id:i,subtype:"note",label:{text:a}});if(Object.assign(p,{x:p.x+d,y:p.y+u}),o.push(p),l){const t=r.find(t=>t.id===l);if(!t)throw new Error(`class node with id ${l} not found!`);const o=e.querySelector(`path[id="edgeNote${s+1}"][data-edge="true"]`);if(o)return void n.push(((t,e)=>Ht([t],e))(o,{strokeStyle:"dotted",startArrowhead:null,endArrowhead:null,start:{id:p.id,type:"rectangle"},end:{id:t.id,type:"rectangle"}}));const i=p.x+(p.width||0)/2,a=p.y+(p.height||0),c=i,d=t.y,u=gt(i,a,c,d,{strokeStyle:"dotted",startArrowhead:null,endArrowhead:null,start:{id:p.id,type:"rectangle"},end:{id:t.id,type:"rectangle"}});n.push(u)}}),{notes:o,connectors:n}},te=(t,e)=>{let r=0,o=0,n=t;for(;n&&n!==e;){const{transformX:t,transformY:e}=B(n);r+=t,o+=e,n=n.parentElement}return{tx:r,ty:o}},ee=t=>{const e=t.querySelector("text, foreignObject, div, span, p")||t;let r=parseFloat(getComputedStyle(e).fontSize||"");return(!Number.isFinite(r)||r<=0)&&(r=Math.max(12,.75*t.getBBox().height)),r},re=(t,e,r)=>{const o=(t=>{const e=Array.from(t.querySelectorAll("tspan")),r=e.length?e.map(t=>t.textContent?.trim()).filter(Boolean).join("\n"):t.textContent?.trim()||"";return F(r)})(t);if(!o)return null;const n=t.getBBox(),{tx:s,ty:i}=te(t,e);return{className:t.getAttribute("class")||"",text:o,x:n.x+s,y:n.y+i,width:n.width,height:n.height,fontSize:ee(t),color:ot(t,r)}},oe=t=>{switch(t?.toLowerCase()){case"one":return"cardinality_one";case"many":return"cardinality_many";case"only_one":return"cardinality_exactly_one";case"one_or_more":return"cardinality_one_or_many";case"zero_or_one":return"cardinality_zero_or_one";case"zero_or_more":return"cardinality_zero_or_many";default:return null}},ne=t=>{switch(t){case"dotted":return"dotted";case"dashed":return"dashed";default:return"solid"}},se=(t,e)=>{const r=e.querySelector(`[id="${t.id}"]`);if(!r)throw new Error(`ER entity ${t.id} not found in rendered SVG`);const o=t.attributes.length?b():void 0,n=r.getBBox(),{tx:s,ty:i}=te(r,e),a=(t=>{const e={};return t?(t.forEach(t=>{Q(t).forEach(({property:t,value:r})=>{t&&r&&(e[t]=J(r))})}),e):e})([...t.cssStyles||[],...t.cssCompiledStyles||[]]),l=J(a.fill||""),c=J(a.stroke||""),d=(t=>{if(null==t||""===t)return;const e="number"==typeof t?t:parseFloat(J(t));return!Number.isFinite(e)||e<=0?void 0:e})(a["stroke-width"]),u=J(a["stroke-dasharray"]||""),h=Array.from(r.querySelectorAll("g.label")).map(t=>re(t,e,a.color)).filter(t=>null!==t),p=h.find(t=>t.className.includes("name"))||h[0],g=h.filter(t=>t!==p),y=p?.text||F(t.alias||t.label||""),f={type:"rectangle",id:t.id,groupId:o,x:n.x+s,y:n.y+i,width:n.width,height:n.height,label:{text:y,fontSize:t.attributes.length?18:p?.fontSize||16,color:p?.color,textAlign:"center",verticalAlign:t.attributes.length?"top":"middle"},metadata:{entityId:t.id,entityLabel:t.label,entityAlias:t.alias}};tt(l)&&"none"!==l&&(f.bgColor=l),tt(c)&&"none"!==c&&(f.strokeColor=c),d&&Number.isFinite(d)&&d>0&&(f.strokeWidth=d),u&&"none"!==u&&(f.strokeStyle="dashed");const m=Array.from(r.querySelectorAll(".divider path, path.divider, line.divider")).map(r=>((t,e,r,o,n,s,i)=>{const{tx:a,ty:l}=te(t,e);let c=0,d=0,u=0,h=0;if("line"===t.tagName.toLowerCase())c=Number(t.getAttribute("x1"))+a,d=Number(t.getAttribute("y1"))+l,u=Number(t.getAttribute("x2"))+a,h=Number(t.getAttribute("y2"))+l;else{const e=P(t);if(!e)return null;c=e.startX+a,d=e.startY+l,u=e.endX+a,h=e.endY+l}const p={type:"line",id:b(),groupId:r,startX:c,startY:d,endX:u,endY:h,metadata:{entityId:o}};return n&&tt(n)&&"none"!==n&&(p.strokeColor=n),void 0!==s&&(p.strokeWidth=s),i&&(p.strokeStyle=i),p})(r,e,o,t.id,f.strokeColor,f.strokeWidth,f.strokeStyle)).filter(t=>null!==t),x=g.map(e=>yt(e.x,e.y,e.text,{id:b(),groupId:o,width:e.width,height:e.height,fontSize:18,color:e.color,metadata:{entityId:t.id}}));return{container:f,lines:m,text:x}},ie=(t,e)=>{const r=((t,e)=>{const r=e.querySelector(`path[id="${t.id}"][data-edge="true"]`);return r?[r]:t.start!==t.end?[]:[`${t.start}-cyclic-special-1`,`${t.start}-cyclic-special-mid`,`${t.start}-cyclic-special-2`].map(t=>e.querySelector(`path[id="${t}"][data-edge="true"]`)).filter(t=>null!==t)})(t,e);if(!r.length)throw new Error(`ER relationship ${t.id} not found in rendered SVG`);const o=(t=>{const e=[];return t.forEach(t=>{U(t).forEach(t=>{const r=e[e.length-1];r&&r.x===t.x&&r.y===t.y||e.push(t)})}),e})(r);if(o.length<2)throw new Error(`ER relationship ${t.id} is missing usable path points`);const n=o[0],s=o[o.length-1],i=r[0],a=J(i.getAttribute("stroke")||getComputedStyle(i).stroke||""),l=Number(i.getAttribute("stroke-width")||getComputedStyle(i).strokeWidth||1),c=gt(n.x,n.y,s.x,s.y,{id:t.id,label:t.label?{text:F(t.label),fontSize:16,textAlign:"center"}:void 0,strokeStyle:ne(t.pattern),startArrowhead:oe(t.arrowTypeStart),endArrowhead:oe(t.arrowTypeEnd),start:{type:"rectangle",id:t.start},end:{type:"rectangle",id:t.end},points:o.map(t=>[t.x-n.x,t.y-n.y])});return tt(a)&&"none"!==a&&(c.strokeColor=a),Number.isFinite(l)&&l>0&&(c.strokeWidth=l),c},ae=t=>{const e=J(t||"");return!!e&&("none"!==e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e&&"rgba(0,0,0,0)"!==e&&tt(e))},le=(t,e,r)=>{switch(e){case l.FILL:case l.STROKE:ae(r)&&(t[e]=J(r));break;case l.STROKE_WIDTH:case l.STROKE_DASHARRAY:J(r)&&(t[e]=J(r))}},ce=(t,e,r)=>{e===a.COLOR&&ae(r)&&(t[a.COLOR]=J(r))},de=(t,e)=>{t&&Q(t).forEach(({property:t,value:r})=>{t===l.FILL&&ae(r)?e[a.COLOR]=J(r):ce(e,t,r)})},ue=(t,e)=>{let r=0,o=0,n=t;for(;n&&n!==e;){const{transformX:t,transformY:e}=B(n);r+=t,o+=e,n=n.parentElement}return{tx:r,ty:o}},he=(t,e)=>{const r=t.querySelector("line.divider");if(!r)return;const{tx:o,ty:n}=ue(r,e);return{startX:Number(r.getAttribute("x1"))+o,startY:Number(r.getAttribute("y1"))+n,endX:Number(r.getAttribute("x2"))+o,endY:Number(r.getAttribute("y2"))+n}},pe=t=>{const e=t.getBBox();return Math.abs(e.width*e.height)},ge=(t,e)=>{const r=t.getAttribute("style");if(!r)return;const o=Q(r).find(t=>t.property===e);return o?J(o.value):void 0},ye=(t,e)=>{const r=t.map(t=>({element:t,area:pe(t)})).filter(({area:t})=>Number.isFinite(t)&&t>0);if(0===r.length)return null;return r.sort((t,r)=>"largest"===e?r.area-t.area:t.area-r.area)[0].element},fe=(t,e)=>{const r=Array.from(t.querySelectorAll("circle, ellipse, path"));return((t,e)=>{if(!t)return;if(!e.has(l.FILL)&&!e.has(l.STROKE))return;const r=J(t.getAttribute("fill")||ge(t,l.FILL)||""),o=J(t.getAttribute("stroke")||ge(t,l.STROKE)||"");return ae(r)?r:ae(o)?o:void 0})(ye(r,"smallest"),e)},be=t=>(t=>{if(t.length<2)return t;const e=t.slice(1),r=e.filter(t=>t.trim().length>0).reduce((t,e)=>{const r=e.match(/^\s*/)?.[0].length??0;return Math.min(t,r)},Number.POSITIVE_INFINITY);return!Number.isFinite(r)||r<=0?t.map(t=>t.trimEnd()):[t[0].trimEnd(),...e.map(t=>t.replace(new RegExp(`^\\s{0,${r}}`),"").trimEnd())]})(Array.isArray(t.label)?t.label.map(t=>F(t)):F(t.label||"").split("\n")).join("\n"),me=t=>{if(!t.description)return[];return(Array.isArray(t.description)?t.description:[t.description]).map(t=>F(t)).filter(t=>t.length>0)},xe=(t,e,r)=>{const o=r(t);if(!o)throw new Error(`State node element not found for "${t.id}"`);const n=((t,e)=>{switch(e){case"roundedWithTitle":case"rectWithTitle":return t.querySelector("rect.outer")||t.querySelector("rect")||t;case"divider":return t.querySelector("rect.divider")||t.querySelector("rect")||t;case"stateStart":case"stateEnd":return ye(Array.from(t.querySelectorAll("circle, ellipse, path")),"largest")||t;default:return t.querySelector("rect, path, circle, ellipse, polygon")||t}})(o,t.shape),s={},i={},c=[t.labelStyle,...t.cssCompiledStyles||[],...t.cssStyles||[]],d=(t=>{const e=new Set;return t.filter(Boolean).forEach(t=>{Q(t||"").forEach(({property:t})=>{e.add(t)})}),e})(c);c.filter(Boolean).forEach(t=>{((t,e,r)=>{t&&Q(t).forEach(({property:t,value:o})=>{le(e,t,o),ce(r,t,o)})})(t,s,i)}),((t,e,r)=>{if(!t)return;[[l.FILL,t.getAttribute("fill")],[l.STROKE,t.getAttribute("stroke")],[l.STROKE_WIDTH,t.getAttribute("stroke-width")],[l.STROKE_DASHARRAY,t.getAttribute("stroke-dasharray")]].forEach(([t,o])=>{if(!r.has(t))return;if(e[t])return;const n=J(o||"");n&&le(e,t,n)})})(n,s,d),((t,e,r)=>{if(!t)return;const o=[t,...Array.from(t.querySelectorAll("text, foreignObject, div, span, p"))];for(const t of o){if(e[a.COLOR])break;if((r.has(a.COLOR)||r.has(l.FILL))&&(de(t.getAttribute("style"),e),e[a.COLOR]))break;const o=J(t.getAttribute("fill")||t.getAttribute("color")||"");(r.has(a.COLOR)||r.has(l.FILL))&&ae(o)&&(e[a.COLOR]=o)}})(o,i,d);const u=((t,e)=>{const r=t.getBBox(),{tx:o,ty:n}=ue(t,e);return{x:r.x+o,y:r.y+n,width:r.width,height:r.height}})(n,e);return{id:t.id,shape:t.shape,text:be(t),description:me(t),x:u.x,y:u.y,width:u.width,height:u.height,parentId:t.parentId,position:t.position,containerStyle:s,labelStyle:i,dividerLine:"rectWithTitle"===t.shape?he(o,e):void 0,endInnerColor:"stateEnd"===t.shape?fe(o,d):void 0,isRenderable:"noteGroup"!==t.shape}},we=(t,e)=>{const r=e.querySelector(`[id='${t.id}']`);if(!r)return null;const{tx:o,ty:n}=ue(r,e),s=H(r,{x:o,y:n},"MCL");if(s.reflectionPoints.length<2)return null;const i={};[t.style].filter(Boolean).forEach(t=>{Q(t||"").forEach(({property:t,value:e})=>{((t,e)=>{switch(t){case l.STROKE:ae(e)&&(i.strokeColor=J(e));break;case l.STROKE_WIDTH:{const t=parseFloat(J(e));Number.isFinite(t)&&t>0&&(i.strokeWidth=t);break}case l.STROKE_DASHARRAY:J(e)&&(i.strokeStyle="dashed")}})(t,e)})});const a="none"===t.arrowhead||t.classes?.includes("note-edge");return{id:t.id,start:t.start,end:t.end,text:F(t.label||""),...s,strokeColor:i.strokeColor,strokeWidth:i.strokeWidth,strokeStyle:a?"dashed":i.strokeStyle,isNoteEdge:a}},Se=(t,e)=>{const{nodes:r,edges:o}=t.getData(),n=(t=>{const e=new Set,r=t=>(t&&e.add(t),t),o=t=>{const o=t.find(t=>!e.has(t));return r(o||null)};return e=>{const n=[`[id='${e.domId}']`,`[id='${e.id}']`,`[data-id='${e.id}']`];for(const e of n){const o=t.querySelector(e);if(o)return r(o)}switch(e.shape){case"divider":return o(Array.from(t.querySelectorAll("g.statediagram-cluster-alt")));case"stateStart":return o(Array.from(t.querySelectorAll("g.node.default")).filter(t=>t.querySelector("circle.state-start")));case"stateEnd":return o(Array.from(t.querySelectorAll("g.node.default")).filter(t=>!t.querySelector("circle.state-start")));default:return null}}})(e);return{type:"state",nodes:r.map(t=>xe(t,e,n)),edges:o.map(t=>we(t,e)).filter(t=>null!==t)}};let Ae=Promise.resolve();let ke=null,Ee=0;const ve=t=>{const e=t.querySelector("svg");if(!e)throw new Error("SVG element not found");const r=e.getBoundingClientRect(),o=r.width,n=r.height;e.setAttribute("width",`${o}`),e.setAttribute("height",`${n}`);const s=unescape(encodeURIComponent(e.outerHTML));return{type:"graphImage",mimeType:"image/svg+xml",dataURL:`data:image/svg+xml;base64,${btoa(s)}`,width:o,height:n}},Ce=async(t,e=n)=>(t=>{const e=Ae.then(t,t);return Ae=e.then(()=>{},()=>{}),e})(async()=>{const r=e.themeVariables?.fontSize??n.themeVariables.fontSize,o={...n,...e,fontSize:r,themeVariables:{...n.themeVariables,...e.themeVariables,fontSize:r}},s=(t=>JSON.stringify(t))(o);s!==ke&&(G.default.initialize(o),ke=s);const i=await G.default.mermaidAPI.getDiagramFromText((t=>{let e=t;return e=e.replace(/style.*:\S*#.*;/g,t=>t.substring(0,t.length-1)),e=e.replace(/classDef.*:\S*#.*;/g,t=>t.substring(0,t.length-1)),e=e.replace(/#\w+;/g,t=>{const e=t.substring(1,t.length-1);return/^\+?\d+$/.test(e)?`fl°°${e}¶ß`:`fl°${e}¶ß`}),e})(t)),a="mermaid-to-excalidraw-"+Ee++,l=document.createElement("div");l.setAttribute("style","opacity: 0; position: fixed; z-index: -1; left: -99999px; top: -99999px;");const c=`${a}-container`;l.id=c,document.getElementById(c)?.remove(),document.body.appendChild(l);try{const{svg:e}=await G.default.render(a,t,l);let r;l.innerHTML=e;try{switch(i.type){case"flowchart-v2":case"graph":r=pt(i.db,l);break;case"sequence":r=Rt(i,l);break;case"class":case"classDiagram":r=((t,e)=>{const r=t.db,o=r.getDirection?.()||"TB",n=[],s=[],i=[],a=[],l=r.getNamespaces?.()||[],c=r.getClasses?.()||{},d=c instanceof Map?Object.fromEntries(c):c;if(d&&Object.keys(d).length){const t="function"==typeof r.lookUpDomId?r.lookUpDomId.bind(r):void 0,o=Jt(d,e,t);n.push(o.nodes),s.push(...o.lines),i.push(...o.text),a.push(...o.nodes)}const u=r.getRelations?.()||[],{arrows:h,text:p}=Zt(u,a,e,o),g=r.getNotes?.()||[],{notes:y,connectors:f}=Qt(g,e,a);return n.push(y),h.push(...f),i.push(...p),{type:"class",nodes:n,lines:s,arrows:h,text:i,namespaces:l}})(i,l);break;case"er":r=((t,e)=>{const r=t.getData(),o=r.nodes,n=r.edges,s=[],i=[],a=[];o.forEach(t=>{const r=se(t,e);s.push(r.container),i.push(...r.lines),a.push(...r.text)});const l=n.map(t=>ie(t,e));return{type:"erd",nodes:[s],lines:i,arrows:l,text:a}})(i.db,l);break;case"state":case"stateDiagram":r=Se(i.db,l);break;default:r=ve(l)}}catch(t){console.error("Error processing Mermaid diagram:",t),r=ve(l)}return r}finally{l.remove()}}),Ie=async(t,e)=>{const r=e||{},o=parseInt(r.themeVariables?.fontSize??"")||20,n=await Ce(t,{...r,themeVariables:{...r.themeVariables}});return V(n,{fontSize:o})}}}]);