diff --git a/webui/dist/assets/index-B31Ybn7V.js b/webui/dist/assets/index-B31Ybn7V.js new file mode 100644 index 00000000..06eeb156 --- /dev/null +++ b/webui/dist/assets/index-B31Ybn7V.js @@ -0,0 +1,52 @@ +import{r as u,j as e,L as Kc,e as Jt,b as fy,f as py,g as gy,h as jy,k as lt,l as vy,m as yy,O as Np,n as Ny}from"./router-CWhjJi2n.js";import{a as by,b as wy,g as _y}from"./react-vendor-Dtc2IqVY.js";import{I as Sy,c as Cy,J as ai,K as qc,L as wu,M as ky,N as er,O as sr,P as Ty,n as _u}from"./utils-CCeOswSm.js";import{L as bp,T as wp,C as _p,R as Ey,a as Sp,V as zy,b as My,S as Cp,c as Ay,d as kp,I as Dy,e as Tp,f as Oy,g as Ep,h as Ry,i as Ly,j as Uy,O as zp,P as By,k as Mp,l as Ap,D as Dp,A as Op,m as Rp,n as Hy,o as qy,p as Lp,q as Gy,r as Up,s as Vy,t as Fy,u as $y,v as Qy,w as Yy,x as Bp,y as Hp,F as qp,z as Gp,B as Vp,E as Xy,G as Fp,H as $p,J as Qp,K as Yp,M as Xp,N as Kp,Q as Zp,U as Ky,W as Zy,X as Jy}from"./radix-extra-Cw1azsjZ.js";import{aj as Iy,ak as Py,al as Wy,am as eN,an as Gc,ao as Vc,ap as tr,aq as sN,ar as Su,as as Fc,at as tN,au as aN,av as lN}from"./charts-Dhri-zxi.js";import{S as nN,H as Jp,O as Ip,o as iN,C as Pp,p as Wp,T as eg,D as sg,R as rN,q as cN,I as tg,J as oN,K as ag,L as lg,M as dN,N as ng,V as uN,Q as ig,U as rg,X as mN,Y as hN,Z as cg,_ as xN,$ as fN,a0 as og,a1 as pN,a2 as gN,a3 as dg,a4 as jN,a5 as vN,a6 as yN,a7 as ug,a8 as mg,a9 as hg,aa as xg,ab as fg,ac as pg,ad as NN}from"./radix-core-BlBHu_Lw.js";import{R as pt,P as Nr,C as pa,a as Da,Z as ln,b as Wc,F as Aa,c as bN,S as Rl,A as wN,D as _N,d as eo,e as Wn,M as si,T as SN,X as li,f as gg,g as CN,I as Xt,h as ba,i as fa,j as so,E as mr,k as Zt,l as jg,H as kN,m as es,n as nl,U as hr,o as Ou,p as Ru,L as Yf,K as vg,q as ro,r as TN,s as dr,t as vt,u as EN,B as ir,v as to,w as $u,x as zN,y as MN,z as _t,G as xr,J as ti,N as Ll,O as fr,Q as AN,V as DN,W as br,Y as ot,_ as ao,$ as nn,a0 as wr,a1 as cn,a2 as il,a3 as _r,a4 as Qu,a5 as ON,a6 as RN,a7 as LN,a8 as rn,a9 as UN,aa as Lu,ab as pr,ac as BN,ad as HN,ae as Uu,af as qN,ag as yg,ah as Xf,ai as GN,aj as VN,ak as FN,al as Ol,am as Cu,an as Kf,ao as $N,ap as QN,aq as YN,ar as XN,as as KN,at as Ng,au as bg,av as wg,aw as ZN,ax as JN,ay as Zf,az as IN,aA as PN,aB as Jf,aC as WN,aD as eb}from"./icons-Bw5y5Hqz.js";import{S as sb,p as tb,j as ab,a as lb,E as If,R as nb,o as ib}from"./codemirror-BHeANvwm.js";import{_ as Lt,c as rb,g as _g,D as cb}from"./misc-Ii-X5qWA.js";import{u as ob,a as Pf,D as db,c as ub,S as mb,h as hb,b as xb,s as fb,K as pb,P as gb,d as jb,C as vb}from"./dnd-Dyi3CnuX.js";import{D as yb,U as Nb}from"./uppy-DSH7n_-V.js";import{M as bb,r as wb,a as _b,b as Sb}from"./markdown-A1ShuLvG.js";import{r as Cb,H as lo,P as no,u as kb,a as Tb,R as Eb,B as zb,b as Mb,C as Ab,M as Db,c as Ob}from"./reactflow-B3n3_Vkw.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const h of document.querySelectorAll('link[rel="modulepreload"]'))d(h);new MutationObserver(h=>{for(const x of h)if(x.type==="childList")for(const f of x.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&d(f)}).observe(document,{childList:!0,subtree:!0});function c(h){const x={};return h.integrity&&(x.integrity=h.integrity),h.referrerPolicy&&(x.referrerPolicy=h.referrerPolicy),h.crossOrigin==="use-credentials"?x.credentials="include":h.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function d(h){if(h.ep)return;h.ep=!0;const x=c(h);fetch(h.href,x)}})();var ku={exports:{}},ar={},Tu={exports:{}},Eu={};var Wf;function Rb(){return Wf||(Wf=1,(function(n){function r(N,G){var q=N.length;N.push(G);e:for(;0>>1,_=N[ie];if(0>>1;ieh($,q))de<_&&0>h(ge,$)?(N[ie]=ge,N[de]=q,ie=de):(N[ie]=$,N[xe]=q,ie=xe);else if(de<_&&0>h(ge,q))N[ie]=ge,N[de]=q,ie=de;else break e}}return G}function h(N,G){var q=N.sortIndex-G.sortIndex;return q!==0?q:N.id-G.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var x=performance;n.unstable_now=function(){return x.now()}}else{var f=Date,j=f.now();n.unstable_now=function(){return f.now()-j}}var p=[],w=[],v=1,k=null,T=3,E=!1,R=!1,K=!1,U=!1,A=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,H=typeof setImmediate<"u"?setImmediate:null;function z(N){for(var G=c(w);G!==null;){if(G.callback===null)d(w);else if(G.startTime<=N)d(w),G.sortIndex=G.expirationTime,r(p,G);else break;G=c(w)}}function B(N){if(K=!1,z(N),!R)if(c(p)!==null)R=!0,X||(X=!0,ye());else{var G=c(w);G!==null&&_e(B,G.startTime-N)}}var X=!1,S=-1,O=5,te=-1;function he(){return U?!0:!(n.unstable_now()-teN&&he());){var ie=k.callback;if(typeof ie=="function"){k.callback=null,T=k.priorityLevel;var _=ie(k.expirationTime<=N);if(N=n.unstable_now(),typeof _=="function"){k.callback=_,z(N),G=!0;break s}k===c(p)&&d(p),z(N)}else d(p);k=c(p)}if(k!==null)G=!0;else{var me=c(w);me!==null&&_e(B,me.startTime-N),G=!1}}break e}finally{k=null,T=q,E=!1}G=void 0}}finally{G?ye():X=!1}}}var ye;if(typeof H=="function")ye=function(){H(Ne)};else if(typeof MessageChannel<"u"){var pe=new MessageChannel,je=pe.port2;pe.port1.onmessage=Ne,ye=function(){je.postMessage(null)}}else ye=function(){A(Ne,0)};function _e(N,G){S=A(function(){N(n.unstable_now())},G)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(N){N.callback=null},n.unstable_forceFrameRate=function(N){0>N||125ie?(N.sortIndex=q,r(w,N),c(p)===null&&N===c(w)&&(K?(Z(S),S=-1):K=!0,_e(B,q-ie))):(N.sortIndex=_,r(p,N),R||E||(R=!0,X||(X=!0,ye()))),N},n.unstable_shouldYield=he,n.unstable_wrapCallback=function(N){var G=T;return function(){var q=T;T=G;try{return N.apply(this,arguments)}finally{T=q}}}})(Eu)),Eu}var ep;function Lb(){return ep||(ep=1,Tu.exports=Rb()),Tu.exports}var sp;function Ub(){if(sp)return ar;sp=1;var n=Lb(),r=by(),c=wy();function d(s){var t="https://react.dev/errors/"+s;if(1_||(s.current=ie[_],ie[_]=null,_--)}function $(s,t){_++,ie[_]=s.current,s.current=t}var de=me(null),ge=me(null),le=me(null),L=me(null);function F(s,t){switch($(le,t),$(ge,s),$(de,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?ff(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=ff(t),s=pf(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}xe(de),$(de,s)}function D(){xe(de),xe(ge),xe(le)}function ee(s){s.memoizedState!==null&&$(L,s);var t=de.current,a=pf(t,s.type);t!==a&&($(ge,s),$(de,a))}function we(s){ge.current===s&&(xe(de),xe(ge)),L.current===s&&(xe(L),Ji._currentValue=q)}var ze,ss;function Ze(s){if(ze===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);ze=t&&t[1]||"",ss=-1)":-1i||C[l]!==I[i]){var ae=` +`+C[l].replace(" at new "," at ");return s.displayName&&ae.includes("")&&(ae=ae.replace("",s.displayName)),ae}while(1<=l&&0<=i);break}}}finally{Ls=!1,Error.prepareStackTrace=a}return(a=s?s.displayName||s.name:"")?Ze(a):""}function re(s,t){switch(s.tag){case 26:case 27:case 5:return Ze(s.type);case 16:return Ze("Lazy");case 13:return s.child!==t&&t!==null?Ze("Suspense Fallback"):Ze("Suspense");case 19:return Ze("SuspenseList");case 0:case 15:return Gs(s.type,!1);case 11:return Gs(s.type.render,!1);case 1:return Gs(s.type,!0);case 31:return Ze("Activity");default:return""}}function be(s){try{var t="",a=null;do t+=re(s,a),a=s,s=s.return;while(s);return t}catch(l){return` +Error generating stack: `+l.message+` +`+l.stack}}var Xe=Object.prototype.hasOwnProperty,Ue=n.unstable_scheduleCallback,st=n.unstable_cancelCallback,It=n.unstable_shouldYield,bt=n.unstable_requestPaint,Je=n.unstable_now,Be=n.unstable_getCurrentPriorityLevel,jt=n.unstable_ImmediatePriority,nt=n.unstable_UserBlockingPriority,St=n.unstable_NormalPriority,Ct=n.unstable_LowPriority,rl=n.unstable_IdlePriority,cl=n.log,ol=n.unstable_setDisableYieldValue,Se=null,Oe=null;function it(s){if(typeof cl=="function"&&ol(s),Oe&&typeof Oe.setStrictMode=="function")try{Oe.setStrictMode(Se,s)}catch{}}var dt=Math.clz32?Math.clz32:ut,di=Math.log,on=Math.LN2;function ut(s){return s>>>=0,s===0?32:31-(di(s)/on|0)|0}var Pt=256,Wt=262144,Ua=4194304;function Ut(s){var t=s&42;if(t!==0)return t;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ba(s,t,a){var l=s.pendingLanes;if(l===0)return 0;var i=0,o=s.suspendedLanes,m=s.pingedLanes;s=s.warmLanes;var g=l&134217727;return g!==0?(l=g&~o,l!==0?i=Ut(l):(m&=g,m!==0?i=Ut(m):a||(a=g&~s,a!==0&&(i=Ut(a))))):(g=l&~o,g!==0?i=Ut(g):m!==0?i=Ut(m):a||(a=l&~s,a!==0&&(i=Ut(a)))),i===0?0:t!==0&&t!==i&&(t&o)===0&&(o=i&-i,a=t&-t,o>=a||o===32&&(a&4194048)!==0)?t:i}function _a(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function W(s,t){switch(s){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ve(){var s=Ua;return Ua<<=1,(Ua&62914560)===0&&(Ua=4194304),s}function Me(s){for(var t=[],a=0;31>a;a++)t.push(s);return t}function tt(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Bt(s,t,a,l,i,o){var m=s.pendingLanes;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=a,s.entangledLanes&=a,s.errorRecoveryDisabledLanes&=a,s.shellSuspendCounter=0;var g=s.entanglements,C=s.expirationTimes,I=s.hiddenUpdates;for(a=m&~a;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var oj=/[\n"\\]/g;function aa(s){return s.replace(oj,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function go(s,t,a,l,i,o,m,g){s.name="",m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"?s.type=m:s.removeAttribute("type"),t!=null?m==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+ta(t)):s.value!==""+ta(t)&&(s.value=""+ta(t)):m!=="submit"&&m!=="reset"||s.removeAttribute("value"),t!=null?jo(s,m,ta(t)):a!=null?jo(s,m,ta(a)):l!=null&&s.removeAttribute("value"),i==null&&o!=null&&(s.defaultChecked=!!o),i!=null&&(s.checked=i&&typeof i!="function"&&typeof i!="symbol"),g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"?s.name=""+ta(g):s.removeAttribute("name")}function cm(s,t,a,l,i,o,m,g){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(s.type=o),t!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){po(s);return}a=a!=null?""+ta(a):"",t=t!=null?""+ta(t):a,g||t===s.value||(s.value=t),s.defaultValue=t}l=l??i,l=typeof l!="function"&&typeof l!="symbol"&&!!l,s.checked=g?s.checked:!!l,s.defaultChecked=!!l,m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(s.name=m),po(s)}function jo(s,t,a){t==="number"&&zr(s.ownerDocument)===s||s.defaultValue===""+a||(s.defaultValue=""+a)}function pn(s,t,a,l){if(s=s.options,t){t={};for(var i=0;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wo=!1;if(Ga)try{var xi={};Object.defineProperty(xi,"passive",{get:function(){wo=!0}}),window.addEventListener("test",xi,xi),window.removeEventListener("test",xi,xi)}catch{wo=!1}var ul=null,_o=null,Ar=null;function fm(){if(Ar)return Ar;var s,t=_o,a=t.length,l,i="value"in ul?ul.value:ul.textContent,o=i.length;for(s=0;s=gi),Nm=" ",bm=!1;function wm(s,t){switch(s){case"keyup":return Uj.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _m(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var yn=!1;function Hj(s,t){switch(s){case"compositionend":return _m(t);case"keypress":return t.which!==32?null:(bm=!0,Nm);case"textInput":return s=t.data,s===Nm&&bm?null:s;default:return null}}function qj(s,t){if(yn)return s==="compositionend"||!Eo&&wm(s,t)?(s=fm(),Ar=_o=ul=null,yn=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:a,offset:t-s};s=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Am(a)}}function Om(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?Om(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function Rm(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=zr(s.document);t instanceof s.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)s=t.contentWindow;else break;t=zr(s.document)}return t}function Ao(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t&&(t==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||t==="textarea"||s.contentEditable==="true")}var Kj=Ga&&"documentMode"in document&&11>=document.documentMode,Nn=null,Do=null,Ni=null,Oo=!1;function Lm(s,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Oo||Nn==null||Nn!==zr(l)||(l=Nn,"selectionStart"in l&&Ao(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Ni&&yi(Ni,l)||(Ni=l,l=Sc(Do,"onSelect"),0>=m,i-=m,Ca=1<<32-dt(t)+i|a<Ie?(is=Te,Te=null):is=Te.sibling;var ys=P(V,Te,J[Ie],oe);if(ys===null){Te===null&&(Te=is);break}s&&Te&&ys.alternate===null&&t(V,Te),M=o(ys,M,Ie),vs===null?Ee=ys:vs.sibling=ys,vs=ys,Te=is}if(Ie===J.length)return a(V,Te),fs&&Fa(V,Ie),Ee;if(Te===null){for(;IeIe?(is=Te,Te=null):is=Te.sibling;var Dl=P(V,Te,ys.value,oe);if(Dl===null){Te===null&&(Te=is);break}s&&Te&&Dl.alternate===null&&t(V,Te),M=o(Dl,M,Ie),vs===null?Ee=Dl:vs.sibling=Dl,vs=Dl,Te=is}if(ys.done)return a(V,Te),fs&&Fa(V,Ie),Ee;if(Te===null){for(;!ys.done;Ie++,ys=J.next())ys=ue(V,ys.value,oe),ys!==null&&(M=o(ys,M,Ie),vs===null?Ee=ys:vs.sibling=ys,vs=ys);return fs&&Fa(V,Ie),Ee}for(Te=l(Te);!ys.done;Ie++,ys=J.next())ys=se(Te,V,Ie,ys.value,oe),ys!==null&&(s&&ys.alternate!==null&&Te.delete(ys.key===null?Ie:ys.key),M=o(ys,M,Ie),vs===null?Ee=ys:vs.sibling=ys,vs=ys);return s&&Te.forEach(function(xy){return t(V,xy)}),fs&&Fa(V,Ie),Ee}function ks(V,M,J,oe){if(typeof J=="object"&&J!==null&&J.type===K&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case E:e:{for(var Ee=J.key;M!==null;){if(M.key===Ee){if(Ee=J.type,Ee===K){if(M.tag===7){a(V,M.sibling),oe=i(M,J.props.children),oe.return=V,V=oe;break e}}else if(M.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===O&&Jl(Ee)===M.type){a(V,M.sibling),oe=i(M,J.props),ki(oe,J),oe.return=V,V=oe;break e}a(V,M);break}else t(V,M);M=M.sibling}J.type===K?(oe=Ql(J.props.children,V.mode,oe,J.key),oe.return=V,V=oe):(oe=Vr(J.type,J.key,J.props,null,V.mode,oe),ki(oe,J),oe.return=V,V=oe)}return m(V);case R:e:{for(Ee=J.key;M!==null;){if(M.key===Ee)if(M.tag===4&&M.stateNode.containerInfo===J.containerInfo&&M.stateNode.implementation===J.implementation){a(V,M.sibling),oe=i(M,J.children||[]),oe.return=V,V=oe;break e}else{a(V,M);break}else t(V,M);M=M.sibling}oe=Go(J,V.mode,oe),oe.return=V,V=oe}return m(V);case O:return J=Jl(J),ks(V,M,J,oe)}if(_e(J))return Ce(V,M,J,oe);if(ye(J)){if(Ee=ye(J),typeof Ee!="function")throw Error(d(150));return J=Ee.call(J),De(V,M,J,oe)}if(typeof J.then=="function")return ks(V,M,Zr(J),oe);if(J.$$typeof===H)return ks(V,M,Qr(V,J),oe);Jr(V,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,M!==null&&M.tag===6?(a(V,M.sibling),oe=i(M,J),oe.return=V,V=oe):(a(V,M),oe=qo(J,V.mode,oe),oe.return=V,V=oe),m(V)):a(V,M)}return function(V,M,J,oe){try{Ci=0;var Ee=ks(V,M,J,oe);return An=null,Ee}catch(Te){if(Te===Mn||Te===Xr)throw Te;var vs=qt(29,Te,null,V.mode);return vs.lanes=oe,vs.return=V,vs}finally{}}}var Pl=nh(!0),ih=nh(!1),pl=!1;function Wo(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ed(s,t){s=s.updateQueue,t.updateQueue===s&&(t.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function gl(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function jl(s,t,a){var l=s.updateQueue;if(l===null)return null;if(l=l.shared,(Ns&2)!==0){var i=l.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),l.pending=t,t=Gr(s),Fm(s,null,a),t}return qr(s,l,t,a),Gr(s)}function Ti(s,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,dl(s,a)}}function sd(s,t){var a=s.updateQueue,l=s.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var i=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var m={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?i=o=m:o=o.next=m,a=a.next}while(a!==null);o===null?i=o=t:o=o.next=t}else i=o=t;a={baseState:l.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:l.shared,callbacks:l.callbacks},s.updateQueue=a;return}s=a.lastBaseUpdate,s===null?a.firstBaseUpdate=t:s.next=t,a.lastBaseUpdate=t}var td=!1;function Ei(){if(td){var s=zn;if(s!==null)throw s}}function zi(s,t,a,l){td=!1;var i=s.updateQueue;pl=!1;var o=i.firstBaseUpdate,m=i.lastBaseUpdate,g=i.shared.pending;if(g!==null){i.shared.pending=null;var C=g,I=C.next;C.next=null,m===null?o=I:m.next=I,m=C;var ae=s.alternate;ae!==null&&(ae=ae.updateQueue,g=ae.lastBaseUpdate,g!==m&&(g===null?ae.firstBaseUpdate=I:g.next=I,ae.lastBaseUpdate=C))}if(o!==null){var ue=i.baseState;m=0,ae=I=C=null,g=o;do{var P=g.lane&-536870913,se=P!==g.lane;if(se?(ns&P)===P:(l&P)===P){P!==0&&P===En&&(td=!0),ae!==null&&(ae=ae.next={lane:0,tag:g.tag,payload:g.payload,callback:null,next:null});e:{var Ce=s,De=g;P=t;var ks=a;switch(De.tag){case 1:if(Ce=De.payload,typeof Ce=="function"){ue=Ce.call(ks,ue,P);break e}ue=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=De.payload,P=typeof Ce=="function"?Ce.call(ks,ue,P):Ce,P==null)break e;ue=k({},ue,P);break e;case 2:pl=!0}}P=g.callback,P!==null&&(s.flags|=64,se&&(s.flags|=8192),se=i.callbacks,se===null?i.callbacks=[P]:se.push(P))}else se={lane:P,tag:g.tag,payload:g.payload,callback:g.callback,next:null},ae===null?(I=ae=se,C=ue):ae=ae.next=se,m|=P;if(g=g.next,g===null){if(g=i.shared.pending,g===null)break;se=g,g=se.next,se.next=null,i.lastBaseUpdate=se,i.shared.pending=null}}while(!0);ae===null&&(C=ue),i.baseState=C,i.firstBaseUpdate=I,i.lastBaseUpdate=ae,o===null&&(i.shared.lanes=0),wl|=m,s.lanes=m,s.memoizedState=ue}}function rh(s,t){if(typeof s!="function")throw Error(d(191,s));s.call(t)}function ch(s,t){var a=s.callbacks;if(a!==null)for(s.callbacks=null,s=0;so?o:8;var m=N.T,g={};N.T=g,Nd(s,!1,t,a);try{var C=i(),I=N.S;if(I!==null&&I(g,C),C!==null&&typeof C=="object"&&typeof C.then=="function"){var ae=av(C,l);Di(s,t,ae,Qt(s))}else Di(s,t,l,Qt(s))}catch(ue){Di(s,t,{then:function(){},status:"rejected",reason:ue},Qt())}finally{G.p=o,m!==null&&g.types!==null&&(m.types=g.types),N.T=m}}function ov(){}function vd(s,t,a,l){if(s.tag!==5)throw Error(d(476));var i=qh(s).queue;Hh(s,i,t,q,a===null?ov:function(){return Gh(s),a(l)})}function qh(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:q},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:a},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function Gh(s){var t=qh(s);t.next===null&&(t=s.alternate.memoizedState),Di(s,t.next.queue,{},Qt())}function yd(){return ht(Ji)}function Vh(){return Ks().memoizedState}function Fh(){return Ks().memoizedState}function dv(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var a=Qt();s=gl(a);var l=jl(t,s,a);l!==null&&(Dt(l,t,a),Ti(l,t,a)),t={cache:Zo()},s.payload=t;return}t=t.return}}function uv(s,t,a){var l=Qt();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},ic(s)?Qh(t,a):(a=Bo(s,t,a,l),a!==null&&(Dt(a,s,l),Yh(a,t,l)))}function $h(s,t,a){var l=Qt();Di(s,t,a,l)}function Di(s,t,a,l){var i={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(ic(s))Qh(t,i);else{var o=s.alternate;if(s.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var m=t.lastRenderedState,g=o(m,a);if(i.hasEagerState=!0,i.eagerState=g,Ht(g,m))return qr(s,t,i,0),Es===null&&Hr(),!1}catch{}finally{}if(a=Bo(s,t,i,l),a!==null)return Dt(a,s,l),Yh(a,t,l),!0}return!1}function Nd(s,t,a,l){if(l={lane:2,revertLane:Wd(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ic(s)){if(t)throw Error(d(479))}else t=Bo(s,a,l,2),t!==null&&Dt(t,s,2)}function ic(s){var t=s.alternate;return s===Ke||t!==null&&t===Ke}function Qh(s,t){On=Wr=!0;var a=s.pending;a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t}function Yh(s,t,a){if((a&4194048)!==0){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,dl(s,a)}}var Oi={readContext:ht,use:tc,useCallback:Vs,useContext:Vs,useEffect:Vs,useImperativeHandle:Vs,useLayoutEffect:Vs,useInsertionEffect:Vs,useMemo:Vs,useReducer:Vs,useRef:Vs,useState:Vs,useDebugValue:Vs,useDeferredValue:Vs,useTransition:Vs,useSyncExternalStore:Vs,useId:Vs,useHostTransitionStatus:Vs,useFormState:Vs,useActionState:Vs,useOptimistic:Vs,useMemoCache:Vs,useCacheRefresh:Vs};Oi.useEffectEvent=Vs;var Xh={readContext:ht,use:tc,useCallback:function(s,t){return wt().memoizedState=[s,t===void 0?null:t],s},useContext:ht,useEffect:zh,useImperativeHandle:function(s,t,a){a=a!=null?a.concat([s]):null,lc(4194308,4,Oh.bind(null,t,s),a)},useLayoutEffect:function(s,t){return lc(4194308,4,s,t)},useInsertionEffect:function(s,t){lc(4,2,s,t)},useMemo:function(s,t){var a=wt();t=t===void 0?null:t;var l=s();if(Wl){it(!0);try{s()}finally{it(!1)}}return a.memoizedState=[l,t],l},useReducer:function(s,t,a){var l=wt();if(a!==void 0){var i=a(t);if(Wl){it(!0);try{a(t)}finally{it(!1)}}}else i=t;return l.memoizedState=l.baseState=i,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:i},l.queue=s,s=s.dispatch=uv.bind(null,Ke,s),[l.memoizedState,s]},useRef:function(s){var t=wt();return s={current:s},t.memoizedState=s},useState:function(s){s=xd(s);var t=s.queue,a=$h.bind(null,Ke,t);return t.dispatch=a,[s.memoizedState,a]},useDebugValue:gd,useDeferredValue:function(s,t){var a=wt();return jd(a,s,t)},useTransition:function(){var s=xd(!1);return s=Hh.bind(null,Ke,s.queue,!0,!1),wt().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,a){var l=Ke,i=wt();if(fs){if(a===void 0)throw Error(d(407));a=a()}else{if(a=t(),Es===null)throw Error(d(349));(ns&127)!==0||xh(l,t,a)}i.memoizedState=a;var o={value:a,getSnapshot:t};return i.queue=o,zh(ph.bind(null,l,o,s),[s]),l.flags|=2048,Ln(9,{destroy:void 0},fh.bind(null,l,o,a,t),null),a},useId:function(){var s=wt(),t=Es.identifierPrefix;if(fs){var a=ka,l=Ca;a=(l&~(1<<32-dt(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=ec++,0<\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof l.is=="string"?m.createElement("select",{is:l.is}):m.createElement("select"),l.multiple?o.multiple=!0:l.size&&(o.size=l.size);break;default:o=typeof l.is=="string"?m.createElement(i,{is:l.is}):m.createElement(i)}}o[Ge]=t,o[xs]=l;e:for(m=t.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.tag!==27&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===t)break e;for(;m.sibling===null;){if(m.return===null||m.return===t)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}t.stateNode=o;e:switch(ft(o,i,l),i){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Za(t)}}return Os(t),Rd(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,a),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==l&&Za(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(d(166));if(s=le.current,kn(t)){if(s=t.stateNode,a=t.memoizedProps,l=null,i=mt,i!==null)switch(i.tag){case 27:case 5:l=i.memoizedProps}s[Ge]=t,s=!!(s.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||hf(s.nodeValue,a)),s||xl(t,!0)}else s=Cc(s).createTextNode(l),s[Ge]=t,t.stateNode=s}return Os(t),null;case 31:if(a=t.memoizedState,s===null||s.memoizedState!==null){if(l=kn(t),a!==null){if(s===null){if(!l)throw Error(d(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(d(557));s[Ge]=t}else Yl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Os(t),s=!1}else a=Qo(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=a),s=!0;if(!s)return t.flags&256?(Vt(t),t):(Vt(t),null);if((t.flags&128)!==0)throw Error(d(558))}return Os(t),null;case 13:if(l=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(i=kn(t),l!==null&&l.dehydrated!==null){if(s===null){if(!i)throw Error(d(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(d(317));i[Ge]=t}else Yl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Os(t),i=!1}else i=Qo(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Vt(t),t):(Vt(t),null)}return Vt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,s=s!==null&&s.memoizedState!==null,a&&(l=t.child,i=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(i=l.alternate.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==i&&(l.flags|=2048)),a!==s&&a&&(t.child.flags|=8192),uc(t,t.updateQueue),Os(t),null);case 4:return D(),s===null&&au(t.stateNode.containerInfo),Os(t),null;case 10:return Qa(t.type),Os(t),null;case 19:if(xe(Xs),l=t.memoizedState,l===null)return Os(t),null;if(i=(t.flags&128)!==0,o=l.rendering,o===null)if(i)Li(l,!1);else{if(Fs!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(o=Pr(s),o!==null){for(t.flags|=128,Li(l,!1),s=o.updateQueue,t.updateQueue=s,uc(t,s),t.subtreeFlags=0,s=a,a=t.child;a!==null;)$m(a,s),a=a.sibling;return $(Xs,Xs.current&1|2),fs&&Fa(t,l.treeForkCount),t.child}s=s.sibling}l.tail!==null&&Je()>pc&&(t.flags|=128,i=!0,Li(l,!1),t.lanes=4194304)}else{if(!i)if(s=Pr(o),s!==null){if(t.flags|=128,i=!0,s=s.updateQueue,t.updateQueue=s,uc(t,s),Li(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!fs)return Os(t),null}else 2*Je()-l.renderingStartTime>pc&&a!==536870912&&(t.flags|=128,i=!0,Li(l,!1),t.lanes=4194304);l.isBackwards?(o.sibling=t.child,t.child=o):(s=l.last,s!==null?s.sibling=o:t.child=o,l.last=o)}return l.tail!==null?(s=l.tail,l.rendering=s,l.tail=s.sibling,l.renderingStartTime=Je(),s.sibling=null,a=Xs.current,$(Xs,i?a&1|2:a&1),fs&&Fa(t,l.treeForkCount),s):(Os(t),null);case 22:case 23:return Vt(t),ld(),l=t.memoizedState!==null,s!==null?s.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(Os(t),t.subtreeFlags&6&&(t.flags|=8192)):Os(t),a=t.updateQueue,a!==null&&uc(t,a.retryQueue),a=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),s!==null&&xe(Zl),null;case 24:return a=null,s!==null&&(a=s.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Qa(Is),Os(t),null;case 25:return null;case 30:return null}throw Error(d(156,t.tag))}function pv(s,t){switch(Fo(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return Qa(Is),D(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return we(t),null;case 31:if(t.memoizedState!==null){if(Vt(t),t.alternate===null)throw Error(d(340));Yl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(Vt(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(d(340));Yl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return xe(Xs),null;case 4:return D(),null;case 10:return Qa(t.type),null;case 22:case 23:return Vt(t),ld(),s!==null&&xe(Zl),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return Qa(Is),null;case 25:return null;default:return null}}function gx(s,t){switch(Fo(t),t.tag){case 3:Qa(Is),D();break;case 26:case 27:case 5:we(t);break;case 4:D();break;case 31:t.memoizedState!==null&&Vt(t);break;case 13:Vt(t);break;case 19:xe(Xs);break;case 10:Qa(t.type);break;case 22:case 23:Vt(t),ld(),s!==null&&xe(Zl);break;case 24:Qa(Is)}}function Ui(s,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var i=l.next;a=i;do{if((a.tag&s)===s){l=void 0;var o=a.create,m=a.inst;l=o(),m.destroy=l}a=a.next}while(a!==i)}}catch(g){_s(t,t.return,g)}}function Nl(s,t,a){try{var l=t.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var o=i.next;l=o;do{if((l.tag&s)===s){var m=l.inst,g=m.destroy;if(g!==void 0){m.destroy=void 0,i=t;var C=a,I=g;try{I()}catch(ae){_s(i,C,ae)}}}l=l.next}while(l!==o)}}catch(ae){_s(t,t.return,ae)}}function jx(s){var t=s.updateQueue;if(t!==null){var a=s.stateNode;try{ch(t,a)}catch(l){_s(s,s.return,l)}}}function vx(s,t,a){a.props=en(s.type,s.memoizedProps),a.state=s.memoizedState;try{a.componentWillUnmount()}catch(l){_s(s,t,l)}}function Bi(s,t){try{var a=s.ref;if(a!==null){switch(s.tag){case 26:case 27:case 5:var l=s.stateNode;break;case 30:l=s.stateNode;break;default:l=s.stateNode}typeof a=="function"?s.refCleanup=a(l):a.current=l}}catch(i){_s(s,t,i)}}function Ta(s,t){var a=s.ref,l=s.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(i){_s(s,t,i)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(i){_s(s,t,i)}else a.current=null}function yx(s){var t=s.type,a=s.memoizedProps,l=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(i){_s(s,s.return,i)}}function Ld(s,t,a){try{var l=s.stateNode;Bv(l,s.type,a,t),l[xs]=t}catch(i){_s(s,s.return,i)}}function Nx(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Tl(s.type)||s.tag===4}function Ud(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Nx(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Tl(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Bd(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(s,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(s),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=qa));else if(l!==4&&(l===27&&Tl(s.type)&&(a=s.stateNode,t=null),s=s.child,s!==null))for(Bd(s,t,a),s=s.sibling;s!==null;)Bd(s,t,a),s=s.sibling}function mc(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?a.insertBefore(s,t):a.appendChild(s);else if(l!==4&&(l===27&&Tl(s.type)&&(a=s.stateNode),s=s.child,s!==null))for(mc(s,t,a),s=s.sibling;s!==null;)mc(s,t,a),s=s.sibling}function bx(s){var t=s.stateNode,a=s.memoizedProps;try{for(var l=s.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ft(t,l,a),t[Ge]=s,t[xs]=a}catch(o){_s(s,s.return,o)}}var Ja=!1,et=!1,Hd=!1,wx=typeof WeakSet=="function"?WeakSet:Set,ct=null;function gv(s,t){if(s=s.containerInfo,iu=Dc,s=Rm(s),Ao(s)){if("selectionStart"in s)var a={start:s.selectionStart,end:s.selectionEnd};else e:{a=(a=s.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var i=l.anchorOffset,o=l.focusNode;l=l.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var m=0,g=-1,C=-1,I=0,ae=0,ue=s,P=null;s:for(;;){for(var se;ue!==a||i!==0&&ue.nodeType!==3||(g=m+i),ue!==o||l!==0&&ue.nodeType!==3||(C=m+l),ue.nodeType===3&&(m+=ue.nodeValue.length),(se=ue.firstChild)!==null;)P=ue,ue=se;for(;;){if(ue===s)break s;if(P===a&&++I===i&&(g=m),P===o&&++ae===l&&(C=m),(se=ue.nextSibling)!==null)break;ue=P,P=ue.parentNode}ue=se}a=g===-1||C===-1?null:{start:g,end:C}}else a=null}a=a||{start:0,end:0}}else a=null;for(ru={focusedElem:s,selectionRange:a},Dc=!1,ct=t;ct!==null;)if(t=ct,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,ct=s;else for(;ct!==null;){switch(t=ct,o=t.alternate,s=t.flags,t.tag){case 0:if((s&4)!==0&&(s=t.updateQueue,s=s!==null?s.events:null,s!==null))for(a=0;a title"))),ft(o,l,a),o[Ge]=s,rt(o),l=o;break e;case"link":var m=zf("link","href",i).get(l+(a.href||""));if(m){for(var g=0;gks&&(m=ks,ks=De,De=m);var V=Dm(g,De),M=Dm(g,ks);if(V&&M&&(se.rangeCount!==1||se.anchorNode!==V.node||se.anchorOffset!==V.offset||se.focusNode!==M.node||se.focusOffset!==M.offset)){var J=ue.createRange();J.setStart(V.node,V.offset),se.removeAllRanges(),De>ks?(se.addRange(J),se.extend(M.node,M.offset)):(J.setEnd(M.node,M.offset),se.addRange(J))}}}}for(ue=[],se=g;se=se.parentNode;)se.nodeType===1&&ue.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;ga?32:a,N.T=null,a=Yd,Yd=null;var o=Sl,m=sl;if(at=0,Gn=Sl=null,sl=0,(Ns&6)!==0)throw Error(d(331));var g=Ns;if(Ns|=4,Ox(o.current),Mx(o,o.current,m,a),Ns=g,$i(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot=="function")try{Oe.onPostCommitFiberRoot(Se,o)}catch{}return!0}finally{G.p=i,N.T=l,Px(s,t)}}function ef(s,t,a){t=na(a,t),t=Sd(s.stateNode,t,2),s=jl(s,t,2),s!==null&&(tt(s,2),Ea(s))}function _s(s,t,a){if(s.tag===3)ef(s,s,a);else for(;t!==null;){if(t.tag===3){ef(t,s,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(_l===null||!_l.has(l))){s=na(a,s),a=sx(2),l=jl(t,a,2),l!==null&&(tx(a,l,t,s),tt(l,2),Ea(l));break}}t=t.return}}function Jd(s,t,a){var l=s.pingCache;if(l===null){l=s.pingCache=new yv;var i=new Set;l.set(t,i)}else i=l.get(t),i===void 0&&(i=new Set,l.set(t,i));i.has(a)||(Vd=!0,i.add(a),s=Sv.bind(null,s,t,a),t.then(s,s))}function Sv(s,t,a){var l=s.pingCache;l!==null&&l.delete(t),s.pingedLanes|=s.suspendedLanes&a,s.warmLanes&=~a,Es===s&&(ns&a)===a&&(Fs===4||Fs===3&&(ns&62914560)===ns&&300>Je()-fc?(Ns&2)===0&&Vn(s,0):Fd|=a,qn===ns&&(qn=0)),Ea(s)}function sf(s,t){t===0&&(t=ve()),s=$l(s,t),s!==null&&(tt(s,t),Ea(s))}function Cv(s){var t=s.memoizedState,a=0;t!==null&&(a=t.retryLane),sf(s,a)}function kv(s,t){var a=0;switch(s.tag){case 31:case 13:var l=s.stateNode,i=s.memoizedState;i!==null&&(a=i.retryLane);break;case 19:l=s.stateNode;break;case 22:l=s.stateNode._retryCache;break;default:throw Error(d(314))}l!==null&&l.delete(t),sf(s,a)}function Tv(s,t){return Ue(s,t)}var bc=null,$n=null,Id=!1,wc=!1,Pd=!1,kl=0;function Ea(s){s!==$n&&s.next===null&&($n===null?bc=$n=s:$n=$n.next=s),wc=!0,Id||(Id=!0,zv())}function $i(s,t){if(!Pd&&wc){Pd=!0;do for(var a=!1,l=bc;l!==null;){if(s!==0){var i=l.pendingLanes;if(i===0)var o=0;else{var m=l.suspendedLanes,g=l.pingedLanes;o=(1<<31-dt(42|s)+1)-1,o&=i&~(m&~g),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,nf(l,o))}else o=ns,o=Ba(l,l===Es?o:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(o&3)===0||_a(l,o)||(a=!0,nf(l,o));l=l.next}while(a);Pd=!1}}function Ev(){tf()}function tf(){wc=Id=!1;var s=0;kl!==0&&qv()&&(s=kl);for(var t=Je(),a=null,l=bc;l!==null;){var i=l.next,o=af(l,t);o===0?(l.next=null,a===null?bc=i:a.next=i,i===null&&($n=a)):(a=l,(s!==0||(o&3)!==0)&&(wc=!0)),l=i}at!==0&&at!==5||$i(s),kl!==0&&(kl=0)}function af(s,t){for(var a=s.suspendedLanes,l=s.pingedLanes,i=s.expirationTimes,o=s.pendingLanes&-62914561;0g)break;var ae=C.transferSize,ue=C.initiatorType;ae&&xf(ue)&&(C=C.responseEnd,m+=ae*(C"u"?null:document;function Cf(s,t,a){var l=Qn;if(l&&typeof t=="string"&&t){var i=aa(t);i='link[rel="'+s+'"][href="'+i+'"]',typeof a=="string"&&(i+='[crossorigin="'+a+'"]'),Sf.has(i)||(Sf.add(i),s={rel:s,crossOrigin:a,href:t},l.querySelector(i)===null&&(t=l.createElement("link"),ft(t,"link",s),rt(t),l.head.appendChild(t)))}}function Zv(s){tl.D(s),Cf("dns-prefetch",s,null)}function Jv(s,t){tl.C(s,t),Cf("preconnect",s,t)}function Iv(s,t,a){tl.L(s,t,a);var l=Qn;if(l&&s&&t){var i='link[rel="preload"][as="'+aa(t)+'"]';t==="image"&&a&&a.imageSrcSet?(i+='[imagesrcset="'+aa(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(i+='[imagesizes="'+aa(a.imageSizes)+'"]')):i+='[href="'+aa(s)+'"]';var o=i;switch(t){case"style":o=Yn(s);break;case"script":o=Xn(s)}ua.has(o)||(s=k({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:s,as:t},a),ua.set(o,s),l.querySelector(i)!==null||t==="style"&&l.querySelector(Ki(o))||t==="script"&&l.querySelector(Zi(o))||(t=l.createElement("link"),ft(t,"link",s),rt(t),l.head.appendChild(t)))}}function Pv(s,t){tl.m(s,t);var a=Qn;if(a&&s){var l=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+aa(l)+'"][href="'+aa(s)+'"]',o=i;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=Xn(s)}if(!ua.has(o)&&(s=k({rel:"modulepreload",href:s},t),ua.set(o,s),a.querySelector(i)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Zi(o)))return}l=a.createElement("link"),ft(l,"link",s),rt(l),a.head.appendChild(l)}}}function Wv(s,t,a){tl.S(s,t,a);var l=Qn;if(l&&s){var i=xn(l).hoistableStyles,o=Yn(s);t=t||"default";var m=i.get(o);if(!m){var g={loading:0,preload:null};if(m=l.querySelector(Ki(o)))g.loading=5;else{s=k({rel:"stylesheet",href:s,"data-precedence":t},a),(a=ua.get(o))&&xu(s,a);var C=m=l.createElement("link");rt(C),ft(C,"link",s),C._p=new Promise(function(I,ae){C.onload=I,C.onerror=ae}),C.addEventListener("load",function(){g.loading|=1}),C.addEventListener("error",function(){g.loading|=2}),g.loading|=4,Tc(m,t,l)}m={type:"stylesheet",instance:m,count:1,state:g},i.set(o,m)}}}function ey(s,t){tl.X(s,t);var a=Qn;if(a&&s){var l=xn(a).hoistableScripts,i=Xn(s),o=l.get(i);o||(o=a.querySelector(Zi(i)),o||(s=k({src:s,async:!0},t),(t=ua.get(i))&&fu(s,t),o=a.createElement("script"),rt(o),ft(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(i,o))}}function sy(s,t){tl.M(s,t);var a=Qn;if(a&&s){var l=xn(a).hoistableScripts,i=Xn(s),o=l.get(i);o||(o=a.querySelector(Zi(i)),o||(s=k({src:s,async:!0,type:"module"},t),(t=ua.get(i))&&fu(s,t),o=a.createElement("script"),rt(o),ft(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(i,o))}}function kf(s,t,a,l){var i=(i=le.current)?kc(i):null;if(!i)throw Error(d(446));switch(s){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Yn(a.href),a=xn(i).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){s=Yn(a.href);var o=xn(i).hoistableStyles,m=o.get(s);if(m||(i=i.ownerDocument||i,m={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(s,m),(o=i.querySelector(Ki(s)))&&!o._p&&(m.instance=o,m.state.loading=5),ua.has(s)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ua.set(s,a),o||ty(i,s,a,m.state))),t&&l===null)throw Error(d(528,""));return m}if(t&&l!==null)throw Error(d(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Xn(a),a=xn(i).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(d(444,s))}}function Yn(s){return'href="'+aa(s)+'"'}function Ki(s){return'link[rel="stylesheet"]['+s+"]"}function Tf(s){return k({},s,{"data-precedence":s.precedence,precedence:null})}function ty(s,t,a,l){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=s.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),ft(t,"link",a),rt(t),s.head.appendChild(t))}function Xn(s){return'[src="'+aa(s)+'"]'}function Zi(s){return"script[async]"+s}function Ef(s,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=s.querySelector('style[data-href~="'+aa(a.href)+'"]');if(l)return t.instance=l,rt(l),l;var i=k({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(s.ownerDocument||s).createElement("style"),rt(l),ft(l,"style",i),Tc(l,a.precedence,s),t.instance=l;case"stylesheet":i=Yn(a.href);var o=s.querySelector(Ki(i));if(o)return t.state.loading|=4,t.instance=o,rt(o),o;l=Tf(a),(i=ua.get(i))&&xu(l,i),o=(s.ownerDocument||s).createElement("link"),rt(o);var m=o;return m._p=new Promise(function(g,C){m.onload=g,m.onerror=C}),ft(o,"link",l),t.state.loading|=4,Tc(o,a.precedence,s),t.instance=o;case"script":return o=Xn(a.src),(i=s.querySelector(Zi(o)))?(t.instance=i,rt(i),i):(l=a,(i=ua.get(o))&&(l=k({},a),fu(l,i)),s=s.ownerDocument||s,i=s.createElement("script"),rt(i),ft(i,"link",l),s.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(d(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,Tc(l,a.precedence,s));return t.instance}function Tc(s,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=l.length?l[l.length-1]:null,o=i,m=0;m title"):null)}function ay(s,t,a){if(a===1||t.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return s=t.disabled,typeof t.precedence=="string"&&s==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Af(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function ly(s,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var i=Yn(l.href),o=t.querySelector(Ki(i));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=zc.bind(s),t.then(s,s)),a.state.loading|=4,a.instance=o,rt(o);return}o=t.ownerDocument||t,l=Tf(l),(i=ua.get(i))&&xu(l,i),o=o.createElement("link"),rt(o);var m=o;m._p=new Promise(function(g,C){m.onload=g,m.onerror=C}),ft(o,"link",l),a.instance=o}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(s.count++,a=zc.bind(s),t.addEventListener("load",a),t.addEventListener("error",a))}}var pu=0;function ny(s,t){return s.stylesheets&&s.count===0&&Ac(s,s.stylesheets),0pu?50:800)+t);return s.unsuspend=a,function(){s.unsuspend=null,clearTimeout(l),clearTimeout(i)}}:null}function zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ac(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Mc=null;function Ac(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Mc=new Map,t.forEach(iy,s),Mc=null,zc.call(s))}function iy(s,t){if(!(t.state.loading&4)){var a=Mc.get(s);if(a)var l=a.get(null);else{a=new Map,Mc.set(s,a);for(var i=s.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}return n(),ku.exports=Ub(),ku.exports}var Hb=Bb();function Q(...n){return Sy(Cy(n))}const Fe=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("rounded-xl border bg-card text-card-foreground shadow",n),...r}));Fe.displayName="Card";const gs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("flex flex-col space-y-1.5 p-6",n),...r}));gs.displayName="CardHeader";const js=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("font-semibold leading-none tracking-tight",n),...r}));js.displayName="CardTitle";const Zs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("text-sm text-muted-foreground",n),...r}));Zs.displayName="CardDescription";const bs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("p-6 pt-0",n),...r}));bs.displayName="CardContent";const Sg=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("flex items-center p-6 pt-0",n),...r}));Sg.displayName="CardFooter";const Kt=Ey,Rt=u.forwardRef(({className:n,...r},c)=>e.jsx(bp,{ref:c,className:Q("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n),...r}));Rt.displayName=bp.displayName;const $e=u.forwardRef(({className:n,...r},c)=>e.jsx(wp,{ref:c,className:Q("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",n),...r}));$e.displayName=wp.displayName;const We=u.forwardRef(({className:n,...r},c)=>e.jsx(_p,{ref:c,className:Q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[state=active]:animate-in data-[state=active]:fade-in data-[state=active]:duration-300",n),...r}));We.displayName=_p.displayName;const Pe=u.forwardRef(({className:n,children:r,viewportRef:c,...d},h)=>e.jsxs(Sp,{ref:h,className:Q("relative overflow-hidden",n),...d,children:[e.jsx(zy,{ref:c,className:"h-full w-full rounded-[inherit]",children:r}),e.jsx(Bu,{}),e.jsx(Bu,{orientation:"horizontal"}),e.jsx(My,{})]}));Pe.displayName=Sp.displayName;const Bu=u.forwardRef(({className:n,orientation:r="vertical",...c},d)=>e.jsx(Cp,{ref:d,orientation:r,className:Q("flex touch-none select-none transition-colors",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...c,children:e.jsx(Ay,{className:"relative flex-1 rounded-full bg-border"})}));Bu.displayName=Cp.displayName;function qb({className:n,...r}){return e.jsx("div",{className:Q("animate-pulse rounded-md bg-primary/10",n),...r})}const Sr=u.forwardRef(({className:n,value:r,...c},d)=>e.jsx(kp,{ref:d,className:Q("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",n),...c,children:e.jsx(Dy,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})}));Sr.displayName=kp.displayName;const Gb={light:"",dark:".dark"},Cg=u.createContext(null);function kg(){const n=u.useContext(Cg);if(!n)throw new Error("useChart must be used within a ");return n}const Zn=u.forwardRef(({id:n,className:r,children:c,config:d,...h},x)=>{const f=u.useId(),j=`chart-${n||f.replace(/:/g,"")}`;return e.jsx(Cg.Provider,{value:{config:d},children:e.jsxs("div",{"data-chart":j,ref:x,className:Q("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",r),...h,children:[e.jsx(Vb,{id:j,config:d}),e.jsx(Iy,{children:c})]})})});Zn.displayName="Chart";const Vb=({id:n,config:r})=>{const c=Object.entries(r).filter(([,d])=>d.theme||d.color);return c.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Gb).map(([d,h])=>` +${h} [data-chart=${n}] { +${c.map(([x,f])=>{const j=f.theme?.[d]||f.color;return j?` --color-${x}: ${j};`:null}).join(` +`)} +} +`).join(` +`)}}):null},lr=Py,Jn=u.forwardRef(({active:n,payload:r,className:c,indicator:d="dot",hideLabel:h=!1,hideIndicator:x=!1,label:f,labelFormatter:j,labelClassName:p,formatter:w,color:v,nameKey:k,labelKey:T},E)=>{const{config:R}=kg(),K=u.useMemo(()=>{if(h||!r?.length)return null;const[A]=r,Z=`${T||A?.dataKey||A?.name||"value"}`,H=Hu(R,A,Z),z=!T&&typeof f=="string"?R[f]?.label||f:H?.label;return j?e.jsx("div",{className:Q("font-medium",p),children:j(z,r)}):z?e.jsx("div",{className:Q("font-medium",p),children:z}):null},[f,j,r,h,p,R,T]);if(!n||!r?.length)return null;const U=r.length===1&&d!=="dot";return e.jsxs("div",{ref:E,className:Q("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",c),children:[U?null:K,e.jsx("div",{className:"grid gap-1.5",children:r.filter(A=>A.type!=="none").map((A,Z)=>{const H=`${k||A.name||A.dataKey||"value"}`,z=Hu(R,A,H),B=v||A.payload.fill||A.color;return e.jsx("div",{className:Q("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",d==="dot"&&"items-center"),children:w&&A?.value!==void 0&&A.name?w(A.value,A.name,A,Z,A.payload):e.jsxs(e.Fragment,{children:[z?.icon?e.jsx(z.icon,{}):!x&&e.jsx("div",{className:Q("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":d==="dot","w-1":d==="line","w-0 border-[1.5px] border-dashed bg-transparent":d==="dashed","my-0.5":U&&d==="dashed"}),style:{"--color-bg":B,"--color-border":B}}),e.jsxs("div",{className:Q("flex flex-1 justify-between leading-none",U?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[U?K:null,e.jsx("span",{className:"text-muted-foreground",children:z?.label||A.name})]}),A.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:A.value.toLocaleString()})]})]})},A.dataKey)})})]})});Jn.displayName="ChartTooltip";const Fb=Wy,Tg=u.forwardRef(({className:n,hideIcon:r=!1,payload:c,verticalAlign:d="bottom",nameKey:h},x)=>{const{config:f}=kg();return c?.length?e.jsx("div",{ref:x,className:Q("flex items-center justify-center gap-4",d==="top"?"pb-3":"pt-3",n),children:c.filter(j=>j.type!=="none").map(j=>{const p=`${h||j.dataKey||"value"}`,w=Hu(f,j,p);return e.jsxs("div",{className:Q("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[w?.icon&&!r?e.jsx(w.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:j.color}}),w?.label]},j.value)})}):null});Tg.displayName="ChartLegend";function Hu(n,r,c){if(typeof r!="object"||r===null)return;const d="payload"in r&&typeof r.payload=="object"&&r.payload!==null?r.payload:void 0;let h=c;return c in r&&typeof r[c]=="string"?h=r[c]:d&&c in d&&typeof d[c]=="string"&&(h=d[c]),h in n?n[h]:n[c]}const gr=ai("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),y=u.forwardRef(({className:n,variant:r,size:c,asChild:d=!1,...h},x)=>{const f=d?nN:"button";return e.jsx(f,{className:Q(gr({variant:r,size:c,className:n})),ref:x,...h})});y.displayName="Button";const $b=ai("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ye({className:n,variant:r,...c}){return e.jsx("div",{className:Q($b({variant:r}),n),...c})}const Qb=5,Yb=5e3;let zu=0;function Xb(){return zu=(zu+1)%Number.MAX_SAFE_INTEGER,zu.toString()}const Mu=new Map,ap=n=>{if(Mu.has(n))return;const r=setTimeout(()=>{Mu.delete(n),ur({type:"REMOVE_TOAST",toastId:n})},Yb);Mu.set(n,r)},Kb=(n,r)=>{switch(r.type){case"ADD_TOAST":return{...n,toasts:[r.toast,...n.toasts].slice(0,Qb)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(c=>c.id===r.toast.id?{...c,...r.toast}:c)};case"DISMISS_TOAST":{const{toastId:c}=r;return c?ap(c):n.toasts.forEach(d=>{ap(d.id)}),{...n,toasts:n.toasts.map(d=>d.id===c||c===void 0?{...d,open:!1}:d)}}case"REMOVE_TOAST":return r.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==r.toastId)}}},Zc=[];let Jc={toasts:[]};function ur(n){Jc=Kb(Jc,n),Zc.forEach(r=>{r(Jc)})}function Zb({...n}){const r=Xb(),c=h=>ur({type:"UPDATE_TOAST",toast:{...h,id:r}}),d=()=>ur({type:"DISMISS_TOAST",toastId:r});return ur({type:"ADD_TOAST",toast:{...n,id:r,open:!0,onOpenChange:h=>{h||d()}}}),{id:r,dismiss:d,update:c}}function Hs(){const[n,r]=u.useState(Jc);return u.useEffect(()=>(Zc.push(r),()=>{const c=Zc.indexOf(r);c>-1&&Zc.splice(c,1)}),[n]),{...n,toast:Zb,dismiss:c=>ur({type:"DISMISS_TOAST",toastId:c})}}const Jb=n=>{const r=[];for(let c=0;c{try{E(!0);const q=await qc.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");k({hitokoto:q.data.hitokoto,from:q.data.from||q.data.from_who||"未知"})}catch(q){console.error("获取一言失败:",q),k({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{E(!1)}},[]),z=u.useCallback(async()=>{try{const q=localStorage.getItem("access-token"),ie=await qc.get("/api/webui/system/status",{headers:{Authorization:`Bearer ${q}`}});K(ie.data)}catch(q){console.error("获取机器人状态失败:",q),K(null)}},[]),B=async()=>{if(!U)try{A(!0);const q=localStorage.getItem("access-token");await qc.post("/api/webui/system/restart",{},{headers:{Authorization:`Bearer ${q}`}}),Z({title:"重启中",description:"麦麦正在重启,请稍候..."}),setTimeout(()=>{z(),A(!1)},3e3)}catch(q){console.error("重启失败:",q),Z({title:"重启失败",description:"无法重启麦麦,请检查控制台",variant:"destructive"}),A(!1)}},X=u.useCallback(async()=>{try{const q=localStorage.getItem("access-token"),ie=await qc.get(`/api/webui/statistics/dashboard?hours=${f}`,{headers:{Authorization:`Bearer ${q}`}});r(ie.data),d(!1),x(100)}catch(q){console.error("Failed to fetch dashboard data:",q),d(!1),x(100)}},[f]);if(u.useEffect(()=>{if(!c)return;x(0);const q=setTimeout(()=>x(15),200),ie=setTimeout(()=>x(30),800),_=setTimeout(()=>x(45),2e3),me=setTimeout(()=>x(60),4e3),xe=setTimeout(()=>x(75),6500),$=setTimeout(()=>x(85),9e3),de=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(q),clearTimeout(ie),clearTimeout(_),clearTimeout(me),clearTimeout(xe),clearTimeout($),clearTimeout(de)}},[c]),u.useEffect(()=>{X(),H(),z()},[X,H,z]),u.useEffect(()=>{if(!p)return;const q=setInterval(()=>{X(),z()},3e4);return()=>clearInterval(q)},[p,X,z]),c||!n)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:e.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[e.jsx(pt,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-lg font-medium",children:"加载统计数据中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取麦麦运行数据"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Sr,{value:h,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h,"%"]})]})]})});const{summary:S,model_stats:O=[],hourly_data:te=[],daily_data:he=[],recent_activity:Ne=[]}=n,ye=S??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},pe=q=>{const ie=Math.floor(q/3600),_=Math.floor(q%3600/60);return`${ie}小时${_}分钟`},je=q=>new Date(q).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),_e=Jb(O.length),N=O.map((q,ie)=>({name:q.model_name,value:q.request_count,fill:_e[ie]})),G={requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--chart-3))"}};return e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"实时监控面板"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"麦麦运行状态和统计数据一览"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Kt,{value:f.toString(),onValueChange:q=>j(Number(q)),children:e.jsxs(Rt,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx($e,{value:"24",children:"24小时"}),e.jsx($e,{value:"168",children:"7天"}),e.jsx($e,{value:"720",children:"30天"})]})}),e.jsxs(y,{variant:p?"default":"outline",size:"sm",onClick:()=>w(!p),className:"gap-2",children:[e.jsx(pt,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:X,children:e.jsx(pt,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[T?e.jsx(qb,{className:"h-5 flex-1"}):v?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',v.hitokoto,'" —— ',v.from]}):null,e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:H,disabled:T,children:e.jsx(pt,{className:`h-3.5 w-3.5 ${T?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Fe,{className:"lg:col-span-1",children:[e.jsx(gs,{className:"pb-3",children:e.jsxs(js,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Nr,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(bs,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:R?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Ye,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),"运行中"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),e.jsxs(Ye,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Da,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),R&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",R.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",pe(R.uptime)]})]})]})})]}),e.jsxs(Fe,{className:"lg:col-span-2",children:[e.jsx(gs,{className:"pb-3",children:e.jsxs(js,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(bs,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:B,disabled:U,className:"gap-2",children:[e.jsx(Wc,{className:`h-4 w-4 ${U?"animate-spin":""}`}),U?"重启中...":"重启麦麦"]}),e.jsx(y,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/logs",children:[e.jsx(Aa,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(y,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/plugins",children:[e.jsx(bN,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(y,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/settings",children:[e.jsx(Rl,{className:"h-4 w-4"}),"系统设置"]})})]})})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(wN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:ye.total_requests.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",f<48?f+"小时":Math.floor(f/24)+"天"]})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"总花费"}),e.jsx(_N,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["¥",ye.total_cost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ye.cost_per_hour>0?`¥${ye.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(eo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(ye.total_tokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ye.tokens_per_hour>0?`${(ye.tokens_per_hour/1e3).toFixed(1)}K/小时`:"暂无数据"})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ye.avg_response_time.toFixed(2),"s"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"API平均耗时"})]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(Wn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(bs,{children:e.jsx("div",{className:"text-xl font-bold",children:pe(ye.online_time)})})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-xl font-bold",children:ye.total_messages.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",ye.total_replies.toLocaleString()," 条"]})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(SN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-xl font-bold",children:ye.total_messages>0?`¥${(ye.total_cost/ye.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(Kt,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx($e,{value:"trends",children:"趋势"}),e.jsx($e,{value:"models",children:"模型"}),e.jsx($e,{value:"activity",children:"活动"}),e.jsx($e,{value:"daily",children:"日统计"})]}),e.jsxs(We,{value:"trends",className:"space-y-4",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"请求趋势"}),e.jsxs(Zs,{children:["最近",f,"小时的请求量变化"]})]}),e.jsx(bs,{children:e.jsx(Zn,{config:G,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(eN,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:q=>je(q),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(Jn,{labelFormatter:q=>je(q)})}),e.jsx(sN,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"花费趋势"}),e.jsx(Zs,{children:"API调用成本变化"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:G,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Su,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:q=>je(q),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(Jn,{labelFormatter:q=>je(q)})}),e.jsx(Fc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"Token消耗"}),e.jsx(Zs,{children:"Token使用量变化"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:G,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Su,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:q=>je(q),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(Jn,{labelFormatter:q=>je(q)})}),e.jsx(Fc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(We,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"模型请求分布"}),e.jsxs(Zs,{children:["各模型使用占比 (共 ",O.length," 个模型)"]})]}),e.jsx(bs,{children:e.jsx(Zn,{config:Object.fromEntries(O.map((q,ie)=>[q.model_name,{label:q.model_name,color:_e[ie]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(tN,{children:[e.jsx(lr,{content:e.jsx(Jn,{})}),e.jsx(aN,{data:N,cx:"50%",cy:"50%",labelLine:!1,label:({name:q,percent:ie})=>ie&&ie<.05?"":`${q} ${ie?(ie*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:N.map((q,ie)=>e.jsx(lN,{fill:q.fill},`cell-${ie}`))})]})})})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"模型详细统计"}),e.jsx(Zs,{children:"请求数、花费和性能"})]}),e.jsx(bs,{children:e.jsx(Pe,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:O.map((q,ie)=>e.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:q.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${ie%5+1}))`}})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"请求数:"}),e.jsx("span",{className:"ml-1 font-medium",children:q.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",q.total_cost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[(q.total_tokens/1e3).toFixed(1),"K"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"平均耗时:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[q.avg_response_time.toFixed(2),"s"]})]})]})]},ie))})})})]})]})}),e.jsx(We,{value:"activity",children:e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"最近活动"}),e.jsx(Zs,{children:"最新的API调用记录"})]}),e.jsx(bs,{children:e.jsx(Pe,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:Ne.map((q,ie)=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:q.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:q.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:je(q.timestamp)})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsx("span",{className:"ml-1",children:q.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",q.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[q.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${q.status==="success"?"text-green-600":"text-red-600"}`,children:q.status})]})]})]},ie))})})})]})}),e.jsx(We,{value:"daily",children:e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"每日统计"}),e.jsx(Zs,{children:"最近7天的数据汇总"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:{requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:e.jsxs(Su,{data:he,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:q=>{const ie=new Date(q);return`${ie.getMonth()+1}/${ie.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(Jn,{labelFormatter:q=>new Date(q).toLocaleDateString("zh-CN")})}),e.jsx(Fb,{content:e.jsx(Tg,{})}),e.jsx(Fc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Fc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]})]})})}const Pb={theme:"system",setTheme:()=>null},Eg=u.createContext(Pb),Yu=()=>{const n=u.useContext(Eg);if(n===void 0)throw new Error("useTheme must be used within a ThemeProvider");return n},Wb=(n,r,c)=>{const d=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||d){r(n);return}const h=c.clientX,x=c.clientY,f=Math.hypot(Math.max(h,innerWidth-h),Math.max(x,innerHeight-x));document.startViewTransition(()=>{r(n)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${x}px)`,`circle(${f}px at ${h}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},zg=u.createContext(void 0),Mg=()=>{const n=u.useContext(zg);if(n===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return n},Ve=u.forwardRef(({className:n,...r},c)=>e.jsx(Tp,{className:Q("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...r,ref:c,children:e.jsx(Oy,{className:Q("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ve.displayName=Tp.displayName;const e0=ai("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),b=u.forwardRef(({className:n,...r},c)=>e.jsx(Jp,{ref:c,className:Q(e0(),n),...r}));b.displayName=Jp.displayName;const ce=u.forwardRef(({className:n,type:r,...c},d)=>e.jsx("input",{type:r,className:Q("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:d,...c}));ce.displayName="Input";const s0=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:n=>n.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:n=>/[A-Z]/.test(n)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:n=>/[a-z]/.test(n)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:n=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(n)}];function t0(n){const r=s0.map(d=>({id:d.id,label:d.label,description:d.description,passed:d.validate(n)}));return{isValid:r.every(d=>d.passed),rules:r}}const Xu="0.11.6 Beta",Ku="MaiBot Dashboard",a0=`${Ku} v${Xu}`,l0=(n="v")=>`${n}${Xu}`,Ot={THEME:"maibot-ui-theme",ACCENT_COLOR:"accent-color",ENABLE_ANIMATIONS:"maibot-animations",ENABLE_WAVES_BACKGROUND:"maibot-waves-background",LOG_CACHE_SIZE:"maibot-log-cache-size",LOG_AUTO_SCROLL:"maibot-log-auto-scroll",LOG_FONT_SIZE:"maibot-log-font-size",LOG_LINE_SPACING:"maibot-log-line-spacing",DATA_SYNC_INTERVAL:"maibot-data-sync-interval",WS_RECONNECT_INTERVAL:"maibot-ws-reconnect-interval",WS_MAX_RECONNECT_ATTEMPTS:"maibot-ws-max-reconnect-attempts",COMPLETED_TOURS:"maibot-completed-tours"},za={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function $s(n){const r=Ag(n),c=localStorage.getItem(r);if(c===null)return za[n];const d=za[n];if(typeof d=="boolean")return c==="true";if(typeof d=="number"){const h=parseFloat(c);return isNaN(h)?d:h}return c}function Pn(n,r){const c=Ag(n);localStorage.setItem(c,String(r)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:n,value:r}}))}function n0(){return{theme:$s("theme"),accentColor:$s("accentColor"),enableAnimations:$s("enableAnimations"),enableWavesBackground:$s("enableWavesBackground"),logCacheSize:$s("logCacheSize"),logAutoScroll:$s("logAutoScroll"),logFontSize:$s("logFontSize"),logLineSpacing:$s("logLineSpacing"),dataSyncInterval:$s("dataSyncInterval"),wsReconnectInterval:$s("wsReconnectInterval"),wsMaxReconnectAttempts:$s("wsMaxReconnectAttempts")}}function i0(){const n=n0(),r=localStorage.getItem(Ot.COMPLETED_TOURS),c=r?JSON.parse(r):[];return{...n,completedTours:c}}function r0(n){const r=[],c=[];for(const[d,h]of Object.entries(n)){if(d==="completedTours"){Array.isArray(h)?(localStorage.setItem(Ot.COMPLETED_TOURS,JSON.stringify(h)),r.push("completedTours")):c.push("completedTours");continue}if(d in za){const x=d,f=za[x];if(typeof h==typeof f){if(x==="theme"&&!["light","dark","system"].includes(h)){c.push(d);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(h)){c.push(d);continue}Pn(x,h),r.push(d)}else c.push(d)}else c.push(d)}return{success:r.length>0,imported:r,skipped:c}}function c0(){for(const n of Object.keys(za))Pn(n,za[n]);localStorage.removeItem(Ot.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function o0(){const n=[],r=[],c=[];for(let d=0;dd.size-c.size),{used:n,items:localStorage.length,details:r}}function d0(n){if(n===0)return"0 B";const r=1024,c=["B","KB","MB"],d=Math.floor(Math.log(n)/Math.log(r));return parseFloat((n/Math.pow(r,d)).toFixed(2))+" "+c[d]}function Ag(n){return{theme:Ot.THEME,accentColor:Ot.ACCENT_COLOR,enableAnimations:Ot.ENABLE_ANIMATIONS,enableWavesBackground:Ot.ENABLE_WAVES_BACKGROUND,logCacheSize:Ot.LOG_CACHE_SIZE,logAutoScroll:Ot.LOG_AUTO_SCROLL,logFontSize:Ot.LOG_FONT_SIZE,logLineSpacing:Ot.LOG_LINE_SPACING,dataSyncInterval:Ot.DATA_SYNC_INTERVAL,wsReconnectInterval:Ot.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:Ot.WS_MAX_RECONNECT_ATTEMPTS}[n]}const Ma=u.forwardRef(({className:n,...r},c)=>e.jsxs(Ep,{ref:c,className:Q("relative flex w-full touch-none select-none items-center",n),...r,children:[e.jsx(Ry,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(Ly,{className:"absolute h-full bg-primary"})}),e.jsx(Uy,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Ma.displayName=Ep.displayName;class u0{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return $s("logCacheSize")}getMaxReconnectAttempts(){return $s("wsMaxReconnectAttempts")}getReconnectInterval(){return $s("wsReconnectInterval")}getWebSocketUrl(){{const r=window.location.protocol==="https:"?"wss:":"ws:",c=window.location.host;return`${r}//${c}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const r=this.getWebSocketUrl();try{this.ws=new WebSocket(r),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=c=>{try{if(c.data==="pong")return;const d=JSON.parse(c.data);this.notifyLog(d)}catch(d){console.error("解析日志消息失败:",d)}},this.ws.onerror=c=>{console.error("❌ WebSocket 错误:",c),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(c){console.error("创建 WebSocket 连接失败:",c),this.attemptReconnect()}}attemptReconnect(){const r=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=r)return;this.reconnectAttempts+=1;const c=this.getReconnectInterval(),d=Math.min(c*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},d)}startHeartbeat(){this.heartbeatInterval=window.setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},3e4)}stopHeartbeat(){this.heartbeatInterval!==null&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.reconnectTimeout!==null&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.stopHeartbeat(),this.ws&&(this.ws.close(),this.ws=null),this.isConnected=!1,this.reconnectAttempts=0}onLog(r){return this.logCallbacks.add(r),()=>this.logCallbacks.delete(r)}onConnectionChange(r){return this.connectionCallbacks.add(r),r(this.isConnected),()=>this.connectionCallbacks.delete(r)}notifyLog(r){if(!this.logCache.some(d=>d.id===r.id)){this.logCache.push(r);const d=this.getMaxCacheSize();this.logCache.length>d&&(this.logCache=this.logCache.slice(-d)),this.logCallbacks.forEach(h=>{try{h(r)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(r){this.connectionCallbacks.forEach(c=>{try{c(r)}catch(d){console.error("连接状态回调执行失败:",d)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const an=new u0;typeof window<"u"&&an.connect();const Rs=rN,ni=cN,m0=iN,Zu=Wp,Dg=u.forwardRef(({className:n,...r},c)=>e.jsx(Ip,{ref:c,className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r}));Dg.displayName=Ip.displayName;const zs=u.forwardRef(({className:n,children:r,preventOutsideClose:c=!1,...d},h)=>e.jsxs(m0,{children:[e.jsx(Dg,{}),e.jsxs(Pp,{ref:h,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),onPointerDownOutside:c?x=>x.preventDefault():void 0,onInteractOutside:c?x=>x.preventDefault():void 0,...d,children:[r,e.jsxs(Wp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(li,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zs.displayName=Pp.displayName;const Ms=({className:n,...r})=>e.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});Ms.displayName="DialogHeader";const Js=({className:n,...r})=>e.jsx("div",{className:Q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Js.displayName="DialogFooter";const As=u.forwardRef(({className:n,...r},c)=>e.jsx(eg,{ref:c,className:Q("text-lg font-semibold leading-none tracking-tight",n),...r}));As.displayName=eg.displayName;const Ys=u.forwardRef(({className:n,...r},c)=>e.jsx(sg,{ref:c,className:Q("text-sm text-muted-foreground",n),...r}));Ys.displayName=sg.displayName;const ps=Hy,Qs=qy,h0=By,Og=u.forwardRef(({className:n,...r},c)=>e.jsx(zp,{className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r,ref:c}));Og.displayName=zp.displayName;const rs=u.forwardRef(({className:n,...r},c)=>e.jsxs(h0,{children:[e.jsx(Og,{}),e.jsx(Mp,{ref:c,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...r})]}));rs.displayName=Mp.displayName;const cs=({className:n,...r})=>e.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",n),...r});cs.displayName="AlertDialogHeader";const os=({className:n,...r})=>e.jsx("div",{className:Q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});os.displayName="AlertDialogFooter";const ds=u.forwardRef(({className:n,...r},c)=>e.jsx(Ap,{ref:c,className:Q("text-lg font-semibold",n),...r}));ds.displayName=Ap.displayName;const us=u.forwardRef(({className:n,...r},c)=>e.jsx(Dp,{ref:c,className:Q("text-sm text-muted-foreground",n),...r}));us.displayName=Dp.displayName;const ms=u.forwardRef(({className:n,...r},c)=>e.jsx(Op,{ref:c,className:Q(gr(),n),...r}));ms.displayName=Op.displayName;const hs=u.forwardRef(({className:n,...r},c)=>e.jsx(Rp,{ref:c,className:Q(gr({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));hs.displayName=Rp.displayName;function x0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"系统设置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理您的应用偏好设置"})]})}),e.jsxs(Kt,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs($e,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(gg,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs($e,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(CN,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs($e,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Rl,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs($e,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Xt,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(Pe,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(We,{value:"appearance",className:"mt-0",children:e.jsx(f0,{})}),e.jsx(We,{value:"security",className:"mt-0",children:e.jsx(p0,{})}),e.jsx(We,{value:"other",className:"mt-0",children:e.jsx(g0,{})}),e.jsx(We,{value:"about",className:"mt-0",children:e.jsx(j0,{})})]})]})]})}function np(n){const r=document.documentElement,d={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[n];if(d)r.style.setProperty("--primary",d.hsl),d.gradient?(r.style.setProperty("--primary-gradient",d.gradient),r.classList.add("has-gradient")):(r.style.removeProperty("--primary-gradient"),r.classList.remove("has-gradient"));else if(n.startsWith("#")){const h=x=>{x=x.replace("#","");const f=parseInt(x.substring(0,2),16)/255,j=parseInt(x.substring(2,4),16)/255,p=parseInt(x.substring(4,6),16)/255,w=Math.max(f,j,p),v=Math.min(f,j,p);let k=0,T=0;const E=(w+v)/2;if(w!==v){const R=w-v;switch(T=E>.5?R/(2-w-v):R/(w+v),w){case f:k=((j-p)/R+(jlocalStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const w=localStorage.getItem("accent-color")||"blue";np(w)},[]);const p=w=>{j(w),localStorage.setItem("accent-color",w),np(w)};return e.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题模式"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(Au,{value:"light",current:n,onChange:r,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Au,{value:"dark",current:n,onChange:r,label:"深色",description:"始终使用深色主题"}),e.jsx(Au,{value:"system",current:n,onChange:r,label:"跟随系统",description:"根据系统设置自动切换"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题色"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"单色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(ma,{value:"blue",current:f,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(ma,{value:"purple",current:f,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(ma,{value:"green",current:f,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(ma,{value:"orange",current:f,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(ma,{value:"pink",current:f,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(ma,{value:"red",current:f,onChange:p,label:"红色",colorClass:"bg-red-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"渐变色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(ma,{value:"gradient-sunset",current:f,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(ma,{value:"gradient-ocean",current:f,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(ma,{value:"gradient-forest",current:f,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(ma,{value:"gradient-aurora",current:f,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(ma,{value:"gradient-fire",current:f,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(ma,{value:"gradient-twilight",current:f,onChange:p,label:"暮光",colorClass:"bg-gradient-to-r from-indigo-500 to-purple-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"自定义颜色"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{type:"color",value:f.startsWith("#")?f:"#3b82f6",onChange:w=>p(w.target.value),className:"h-10 sm:h-12 w-full rounded-lg border-2 border-border cursor-pointer",title:"选择自定义颜色"})}),e.jsx("div",{className:"flex-1",children:e.jsx(ce,{type:"text",value:f,onChange:w=>p(w.target.value),placeholder:"#3b82f6",className:"font-mono text-sm"})})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-2",children:"点击色块选择颜色,或手动输入 HEX 颜色代码"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"动画效果"}),e.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[e.jsx("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Ve,{id:"animations",checked:c,onCheckedChange:d})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Ve,{id:"waves-background",checked:h,onCheckedChange:x})]})})]})]})]})}function p0(){const n=Jt(),[r,c]=u.useState(""),[d,h]=u.useState(""),[x,f]=u.useState(!1),[j,p]=u.useState(!1),[w,v]=u.useState(!1),[k,T]=u.useState(!1),[E,R]=u.useState(!1),[K,U]=u.useState(!1),[A,Z]=u.useState(""),[H,z]=u.useState(!1),{toast:B}=Hs(),X=u.useMemo(()=>t0(d),[d]),S=async pe=>{if(!r){B({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(pe),R(!0),B({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>R(!1),2e3)}catch{B({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},O=async()=>{if(!d.trim()){B({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!X.isValid){const pe=X.rules.filter(je=>!je.passed).map(je=>je.label).join(", ");B({title:"格式错误",description:`Token 不符合要求: ${pe}`,variant:"destructive"});return}v(!0);try{const pe=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:d.trim()})}),je=await pe.json();pe.ok&&je.success?(h(""),c(d.trim()),B({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{n({to:"/auth"})},1500)):B({title:"更新失败",description:je.message||"无法更新 Token",variant:"destructive"})}catch(pe){console.error("更新 Token 错误:",pe),B({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{v(!1)}},te=async()=>{T(!0);try{const pe=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),je=await pe.json();pe.ok&&je.success?(c(je.token),Z(je.token),U(!0),z(!1),B({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):B({title:"生成失败",description:je.message||"无法生成新 Token",variant:"destructive"})}catch(pe){console.error("生成 Token 错误:",pe),B({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{T(!1)}},he=async()=>{try{await navigator.clipboard.writeText(A),z(!0),B({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{B({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},Ne=()=>{U(!1),setTimeout(()=>{Z(""),z(!1)},300),setTimeout(()=>{n({to:"/auth"})},500)},ye=pe=>{pe||Ne()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Rs,{open:K,onOpenChange:ye,children:e.jsxs(zs,{className:"sm:max-w-md",children:[e.jsxs(Ms,{children:[e.jsxs(As,{className:"flex items-center gap-2",children:[e.jsx(ba,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Ys,{children:"这是您的新 Token,请立即保存。关闭此窗口后将跳转到登录页面。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-4",children:[e.jsx(b,{className:"text-xs text-muted-foreground mb-2 block",children:"您的新 Token (64位安全令牌)"}),e.jsx("div",{className:"font-mono text-sm break-all select-all bg-background p-3 rounded border",children:A})]}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ba,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"重要提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"此 Token 仅显示一次,关闭后无法再查看"}),e.jsx("li",{children:"请立即复制并保存到安全的位置"}),e.jsx("li",{children:"关闭窗口后将自动跳转到登录页面"}),e.jsx("li",{children:"请使用新 Token 重新登录系统"})]})]})]})})]}),e.jsxs(Js,{className:"gap-2 sm:gap-0",children:[e.jsx(y,{variant:"outline",onClick:he,className:"gap-2",children:H?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(so,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(y,{onClick:Ne,children:"我已保存,关闭"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"当前 Access Token"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"current-token",className:"text-sm",children:"您的访问令牌"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ce,{id:"current-token",type:x?"text":"password",value:r||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{r?f(!x):B({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(y,{variant:"outline",size:"icon",onClick:()=>S(r),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!r,children:E?e.jsx(fa,{className:"h-4 w-4 text-green-500"}):e.jsx(so,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{variant:"outline",disabled:k,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(pt,{className:Q("h-4 w-4",k&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重新生成 Token"}),e.jsx(us,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:te,children:"确认生成"})]})]})]})]})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"请妥善保管您的 Access Token,不要泄露给他人"})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"自定义 Access Token"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"new-token",type:j?"text":"password",value:d,onChange:pe=>h(pe.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!j),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:j?"隐藏":"显示",children:j?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),d&&e.jsxs("div",{className:"mt-3 space-y-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Token 安全要求:"}),e.jsx("div",{className:"space-y-1.5",children:X.rules.map(pe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[pe.passed?e.jsx(pa,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(jg,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:Q(pe.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:pe.label})]},pe.id))}),X.isValid&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(fa,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(y,{onClick:O,disabled:w||!X.isValid||!d,className:"w-full sm:w-auto",children:w?"更新中...":"更新自定义 Token"})]})]}),e.jsxs("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm sm:text-base font-semibold text-yellow-900 dark:text-yellow-200 mb-2",children:"安全提示"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-yellow-800 dark:text-yellow-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"重新生成 Token 会创建系统随机生成的 64 位安全令牌"}),e.jsx("li",{children:"自定义 Token 必须满足所有安全要求才能使用"}),e.jsx("li",{children:"更新 Token 后,旧的 Token 将立即失效"}),e.jsx("li",{children:"请在安全的环境下查看和复制 Token"}),e.jsx("li",{children:"如果怀疑 Token 泄露,请立即重新生成或更新"}),e.jsx("li",{children:"建议使用系统生成的 Token 以获得最高安全性"})]})]})]})}function g0(){const n=Jt(),{toast:r}=Hs(),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(()=>$s("logCacheSize")),[p,w]=u.useState(()=>$s("wsReconnectInterval")),[v,k]=u.useState(()=>$s("wsMaxReconnectAttempts")),[T,E]=u.useState(()=>$s("dataSyncInterval")),[R,K]=u.useState(()=>lp()),[U,A]=u.useState(!1),[Z,H]=u.useState(!1),z=u.useRef(null);if(h)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const B=()=>{K(lp())},X=N=>{const G=N[0];j(G),Pn("logCacheSize",G)},S=N=>{const G=N[0];w(G),Pn("wsReconnectInterval",G)},O=N=>{const G=N[0];k(G),Pn("wsMaxReconnectAttempts",G)},te=N=>{const G=N[0];E(G),Pn("dataSyncInterval",G)},he=()=>{an.clearLogs(),r({title:"日志已清除",description:"日志缓存已清空"})},Ne=()=>{const N=o0();B(),r({title:"缓存已清除",description:`已清除 ${N.clearedKeys.length} 项缓存数据`})},ye=()=>{A(!0);try{const N=i0(),G=JSON.stringify(N,null,2),q=new Blob([G],{type:"application/json"}),ie=URL.createObjectURL(q),_=document.createElement("a");_.href=ie,_.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(ie),r({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(N){console.error("导出设置失败:",N),r({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{A(!1)}},pe=N=>{const G=N.target.files?.[0];if(!G)return;H(!0);const q=new FileReader;q.onload=ie=>{try{const _=ie.target?.result,me=JSON.parse(_),xe=r0(me);xe.success?(j($s("logCacheSize")),w($s("wsReconnectInterval")),k($s("wsMaxReconnectAttempts")),E($s("dataSyncInterval")),B(),r({title:"导入成功",description:`成功导入 ${xe.imported.length} 项设置${xe.skipped.length>0?`,跳过 ${xe.skipped.length} 项`:""}`}),(xe.imported.includes("theme")||xe.imported.includes("accentColor"))&&r({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):r({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(_){console.error("导入设置失败:",_),r({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{H(!1),z.current&&(z.current.value="")}},q.readAsText(G)},je=()=>{c0(),j(za.logCacheSize),w(za.wsReconnectInterval),k(za.wsMaxReconnectAttempts),E(za.dataSyncInterval),B(),r({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},_e=async()=>{d(!0);try{const N=localStorage.getItem("access-token"),G=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${N}`}}),q=await G.json();G.ok&&q.success?(r({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{n({to:"/setup"})},1e3)):r({title:"重置失败",description:q.message||"无法重置配置状态",variant:"destructive"})}catch(N){console.error("重置配置状态错误:",N),r({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{d(!1)}};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(eo,{className:"h-5 w-5"}),"性能与存储"]}),e.jsxs("div",{className:"space-y-4 sm:space-y-5",children:[e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(kN,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:B,className:"h-7 px-2",children:e.jsx(pt,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:d0(R.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[R.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f," 条"]})]}),e.jsx(Ma,{value:[f],onValueChange:X,min:100,max:5e3,step:100,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制日志查看器最多缓存的日志条数,较大的值会占用更多内存"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[T," 秒"]})]}),e.jsx(Ma,{value:[T],onValueChange:te,min:10,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制首页统计数据的自动刷新间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[p/1e3," 秒"]})]}),e.jsx(Ma,{value:[p],onValueChange:S,min:1e3,max:1e4,step:500,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"日志 WebSocket 连接断开后的重连基础间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[v," 次"]})]}),e.jsx(Ma,{value:[v],onValueChange:O,min:3,max:30,step:1,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"连接失败后的最大重连尝试次数"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:he,className:"gap-2",children:[e.jsx(es,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(es,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认清除本地缓存"}),e.jsx(us,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:Ne,children:"确认清除"})]})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(nl,{className:"h-5 w-5"}),"导入/导出设置"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"导出当前的界面设置以便备份,或从之前导出的文件中恢复设置。"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(y,{variant:"outline",onClick:ye,disabled:U,className:"gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),U?"导出中...":"导出设置"]}),e.jsx("input",{ref:z,type:"file",accept:".json",onChange:pe,className:"hidden"}),e.jsxs(y,{variant:"outline",onClick:()=>z.current?.click(),disabled:Z,className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),Z?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Wc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重置所有设置"}),e.jsx(us,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:je,children:"确认重置"})]})]})]})})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"配置向导"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"重新进行初次配置向导,可以帮助您重新设置系统的基础配置。"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{variant:"outline",disabled:c,className:"gap-2",children:[e.jsx(Wc,{className:Q("h-4 w-4",c&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重新配置"}),e.jsx(us,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:_e,children:"确认重置"})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dashed border-yellow-500/50 bg-yellow-500/5 p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(ba,{className:"h-5 w-5 text-yellow-500"}),"开发者工具"]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"以下功能仅供开发调试使用,可能会导致页面崩溃或异常。"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{variant:"destructive",className:"gap-2",children:[e.jsx(ba,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认触发错误"}),e.jsx(us,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function j0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"rounded-lg border-2 border-primary/30 bg-gradient-to-r from-primary/5 to-primary/10 p-4 sm:p-6",children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-primary/10 p-2 sm:p-3",children:e.jsx("svg",{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-2",children:"开源项目"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mb-3",children:"本项目在 GitHub 开源,欢迎 Star ⭐ 支持!"}),e.jsxs("a",{href:"https://github.com/Mai-with-u/MaiBot-Dashboard",target:"_blank",rel:"noopener noreferrer",className:Q("inline-flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground font-medium text-sm","hover:bg-primary/90 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"前往 GitHub",e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:["关于 ",Ku]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Xu]}),e.jsx("p",{children:"麦麦(MaiBot)的现代化 Web 管理界面"})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"作者"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"MaiBot 核心"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Mai-with-u"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"WebUI"}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:["Mai-with-u ",e.jsx("a",{href:"https://github.com/DrSmoothl",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"@MotricSeven"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"技术栈"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"前端框架"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"React 19.2.0"}),e.jsx("li",{children:"TypeScript 5.7.2"}),e.jsx("li",{children:"Vite 6.0.7"}),e.jsx("li",{children:"TanStack Router 1.94.2"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"UI 组件"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"shadcn/ui"}),e.jsx("li",{children:"Radix UI"}),e.jsx("li",{children:"Tailwind CSS 3.4.17"}),e.jsx("li",{children:"Lucide Icons"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"后端"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Python 3.12+"}),e.jsx("li",{children:"FastAPI"}),e.jsx("li",{children:"Uvicorn"}),e.jsx("li",{children:"WebSocket"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"构建工具"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Bun / npm"}),e.jsx("li",{children:"ESLint 9.17.0"}),e.jsx("li",{children:"PostCSS"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源库感谢"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mb-3",children:"本项目使用了以下优秀的开源库,感谢他们的贡献:"}),e.jsx(Pe,{className:"h-[300px] sm:h-[400px]",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"UI 框架与组件"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(qs,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(qs,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(qs,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(qs,{name:"Lucide React",description:"精美的图标库",license:"ISC"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"路由与状态管理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(qs,{name:"Zustand",description:"轻量级状态管理",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"表单处理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(qs,{name:"Zod",description:"TypeScript 优先的 schema 验证",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"工具库"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(qs,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(qs,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(qs,{name:"date-fns",description:"现代化日期处理库",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"动画效果"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(qs,{name:"vaul",description:"抽屉组件动画",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"后端框架"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(qs,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(qs,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(qs,{name:"python-multipart",description:"文件上传支持",license:"Apache-2.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"开发工具"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(qs,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(qs,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(qs,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(qs,{name:"PostCSS",description:"CSS 转换工具",license:"MIT"})]})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源许可"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:"rounded-md bg-primary/10 px-2 py-1",children:e.jsx("span",{className:"text-xs sm:text-sm font-bold text-primary",children:"GPLv3"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm sm:text-base font-semibold text-foreground mb-1",children:"MaiBot WebUI"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目采用 GNU General Public License v3.0 开源许可证。 您可以自由地使用、修改和分发本软件,但必须保持相同的开源许可。"})]})]})}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目依赖的所有开源库均遵循各自的开源许可证(MIT、Apache-2.0、BSD 等)。 感谢所有开源贡献者的无私奉献。"})]})]})]})}function qs({name:n,description:r,license:c}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border bg-muted/30 p-2.5 sm:p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:n}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:r})]}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary flex-shrink-0",children:c})]})}function Au({value:n,current:r,onChange:c,label:d,description:h}){const x=r===n;return e.jsxs("button",{onClick:()=>c(n),className:Q("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:d}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:h})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[n==="light"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-300"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-400"})]}),n==="dark"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-900"})]}),n==="system"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-200 to-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-300 to-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-400 to-slate-900"})]})]})]})}function ma({value:n,current:r,onChange:c,label:d,colorClass:h}){const x=r===n;return e.jsxs("button",{onClick:()=>c(n),className:Q("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:Q("h-8 w-8 sm:h-10 sm:w-10 rounded-full",h)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:d})]})]})}class v0{grad3;p;perm;constructor(r=0){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.p=[];for(let c=0;c<256;c++)this.p[c]=Math.floor(Math.random()*256);this.perm=[];for(let c=0;c<512;c++)this.perm[c]=this.p[c&255]}dot(r,c,d){return r[0]*c+r[1]*d}mix(r,c,d){return(1-d)*r+d*c}fade(r){return r*r*r*(r*(r*6-15)+10)}perlin2(r,c){const d=Math.floor(r)&255,h=Math.floor(c)&255;r-=Math.floor(r),c-=Math.floor(c);const x=this.fade(r),f=this.fade(c),j=this.perm[d]+h,p=this.perm[j],w=this.perm[j+1],v=this.perm[d+1]+h,k=this.perm[v],T=this.perm[v+1];return this.mix(this.mix(this.dot(this.grad3[p%12],r,c),this.dot(this.grad3[k%12],r-1,c),x),this.mix(this.dot(this.grad3[w%12],r,c-1),this.dot(this.grad3[T%12],r-1,c-1),x),f)}}function ip(){const n=u.useRef(null),r=u.useRef(null),c=u.useRef(void 0),d=u.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new v0(Math.random()),bounding:null});return u.useEffect(()=>{const h=r.current,x=n.current;if(!h||!x)return;const f=d.current,j=()=>{const K=h.getBoundingClientRect();f.bounding=K,x.style.width=`${K.width}px`,x.style.height=`${K.height}px`},p=()=>{if(!f.bounding)return;const{width:K,height:U}=f.bounding;f.lines=[],f.paths.forEach(te=>te.remove()),f.paths=[];const A=10,Z=32,H=K+200,z=U+30,B=Math.ceil(H/A),X=Math.ceil(z/Z),S=(K-A*B)/2,O=(U-Z*X)/2;for(let te=0;te<=B;te++){const he=[];for(let ye=0;ye<=X;ye++){const pe={x:S+A*te,y:O+Z*ye,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};he.push(pe)}const Ne=document.createElementNS("http://www.w3.org/2000/svg","path");x.appendChild(Ne),f.paths.push(Ne),f.lines.push(he)}},w=K=>{const{lines:U,mouse:A,noise:Z}=f;U.forEach(H=>{H.forEach(z=>{const B=Z.perlin2((z.x+K*.0125)*.002,(z.y+K*.005)*.0015)*12;z.wave.x=Math.cos(B)*32,z.wave.y=Math.sin(B)*16;const X=z.x-A.sx,S=z.y-A.sy,O=Math.hypot(X,S),te=Math.max(175,A.vs);if(O{const A={x:K.x+K.wave.x+(U?K.cursor.x:0),y:K.y+K.wave.y+(U?K.cursor.y:0)};return A.x=Math.round(A.x*10)/10,A.y=Math.round(A.y*10)/10,A},k=()=>{const{lines:K,paths:U}=f;K.forEach((A,Z)=>{let H=v(A[0],!1),z=`M ${H.x} ${H.y}`;A.forEach((B,X)=>{const S=X===A.length-1;H=v(B,!S),z+=`L ${H.x} ${H.y}`}),U[Z].setAttribute("d",z)})},T=K=>{const{mouse:U}=f;U.sx+=(U.x-U.sx)*.1,U.sy+=(U.y-U.sy)*.1;const A=U.x-U.lx,Z=U.y-U.ly,H=Math.hypot(A,Z);U.v=H,U.vs+=(H-U.vs)*.1,U.vs=Math.min(100,U.vs),U.lx=U.x,U.ly=U.y,U.a=Math.atan2(Z,A),h&&(h.style.setProperty("--x",`${U.sx}px`),h.style.setProperty("--y",`${U.sy}px`)),w(K),k(),c.current=requestAnimationFrame(T)},E=K=>{if(!f.bounding)return;const{mouse:U}=f;U.x=K.pageX-f.bounding.left,U.y=K.pageY-f.bounding.top+window.scrollY,U.set||(U.sx=U.x,U.sy=U.y,U.lx=U.x,U.ly=U.y,U.set=!0)},R=()=>{j(),p()};return j(),p(),window.addEventListener("resize",R),window.addEventListener("mousemove",E),c.current=requestAnimationFrame(T),()=>{window.removeEventListener("resize",R),window.removeEventListener("mousemove",E),c.current&&cancelAnimationFrame(c.current)}},[]),e.jsxs("div",{ref:r,className:"waves-background",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"},children:[e.jsx("div",{className:"waves-cursor",style:{position:"absolute",top:0,left:0,width:"0.5rem",height:"0.5rem",background:"hsl(var(--primary) / 0.3)",borderRadius:"50%",transform:"translate3d(calc(var(--x, -0.5rem) - 50%), calc(var(--y, 50%) - 50%), 0)",willChange:"transform",pointerEvents:"none"}}),e.jsx("svg",{ref:n,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:` + path { + fill: none; + stroke: hsl(var(--primary) / 0.20); + stroke-width: 1px; + } + `})})]})}async function ke(n,r){const c={...r,credentials:"include",headers:{"Content-Type":"application/json",...r?.headers}},d=await fetch(n,c);if(d.status===401)throw window.location.href="/auth",new Error("认证失败,请重新登录");return d}function Ts(){return{"Content-Type":"application/json"}}async function y0(){try{await fetch("/api/webui/auth/logout",{method:"POST",credentials:"include"})}catch(n){console.error("登出请求失败:",n)}window.location.href="/auth"}async function Ju(){try{return(await(await fetch("/api/webui/auth/check",{method:"GET",credentials:"include"})).json()).authenticated===!0}catch{return!1}}function N0(){const[n,r]=u.useState(""),[c,d]=u.useState(!1),[h,x]=u.useState(""),[f,j]=u.useState(!0),p=Jt(),{enableWavesBackground:w,setEnableWavesBackground:v}=Mg(),{theme:k,setTheme:T}=Yu();u.useEffect(()=>{(async()=>{try{await Ju()&&p({to:"/"})}catch{}finally{j(!1)}})()},[p]);const R=k==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":k,K=()=>{T(R==="dark"?"light":"dark")},U=async A=>{if(A.preventDefault(),x(""),!n.trim()){x("请输入 Access Token");return}d(!0);try{const Z=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:n.trim()})}),H=await Z.json();Z.ok&&H.valid?H.is_first_setup?p({to:"/setup"}):p({to:"/"}):x(H.message||"Token 验证失败,请检查后重试")}catch(Z){console.error("Token 验证错误:",Z),x("连接服务器失败,请检查网络连接")}finally{d(!1)}};return f?e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[w&&e.jsx(ip,{}),e.jsx("div",{className:"text-muted-foreground",children:"正在检查登录状态..."})]}):e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[w&&e.jsx(ip,{}),e.jsxs(Fe,{className:"relative z-10 w-full max-w-md shadow-2xl backdrop-blur-xl bg-card/80 border-border/50",children:[e.jsx("button",{onClick:K,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:R==="dark"?"切换到浅色模式":"切换到深色模式",children:R==="dark"?e.jsx(Ou,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(Ru,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(gs,{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx(Yf,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(js,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(Zs,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(bs,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(vg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(ce,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:n,onChange:A=>r(A.target.value),className:Q("pl-10",h&&"border-red-500 focus-visible:ring-red-500"),disabled:c,autoFocus:!0,autoComplete:"off"})]})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-red-50 p-3 text-sm text-red-600 dark:bg-red-950/50 dark:text-red-400",children:[e.jsx(Da,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:h})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:c,children:c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"验证中..."]}):"验证并进入"}),e.jsxs(Rs,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-primary hover:text-primary/80 transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(ro,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token,我该去哪里获得 Token?"]})}),e.jsxs(zs,{className:"sm:max-w-md",children:[e.jsxs(Ms,{children:[e.jsxs(As,{className:"flex items-center gap-2",children:[e.jsx(Yf,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx(Ys,{children:"Access Token 是访问 MaiBot WebUI 的唯一凭证,请按以下方式获取"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(TN,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式一:查看启动日志"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在 MaiBot 启动时,控制台会显示 WebUI Access Token。"}),e.jsxs("div",{className:"rounded bg-background p-2 font-mono text-xs",children:[e.jsx("p",{className:"text-muted-foreground",children:"🔑 WebUI Access Token: abc123..."}),e.jsx("p",{className:"text-muted-foreground",children:"💡 请使用此 Token 登录 WebUI"})]})]})]})}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Aa,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式二:查看配置文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Token 保存在项目根目录的配置文件中:"}),e.jsx("div",{className:"rounded bg-background p-2 font-mono text-xs break-all",children:e.jsx("code",{className:"text-primary",children:"data/webui.json"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["打开此文件,复制 ",e.jsx("code",{className:"px-1 py-0.5 bg-background rounded",children:"access_token"})," 字段的值"]})]})]})}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"安全提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"请妥善保管您的 Token,不要泄露给他人"}),e.jsx("li",{children:"如需重置 Token,请在登录后前往系统设置"})]})]})]})})]})]})]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-muted-foreground hover:text-foreground transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(ln,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsxs(ds,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(us,{children:"背景动画可能会在低性能设备上造成卡顿。关闭动画可以显著提升界面流畅度。"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭动画后,背景将变为纯色,但不影响任何功能的使用。您可以随时在系统设置中重新开启动画。"})}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>v(!1),children:"关闭动画"})]})]})]})]})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 text-center text-xs text-muted-foreground",children:e.jsx("p",{children:a0})})]})}const Bs=u.forwardRef(({className:n,...r},c)=>e.jsx("textarea",{className:Q("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:c,...r}));Bs.displayName="Textarea";const jr=u.forwardRef(({className:n,orientation:r="horizontal",decorative:c=!0,...d},h)=>e.jsx(Lp,{ref:h,decorative:c,orientation:r,className:Q("shrink-0 bg-border",r==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",n),...d}));jr.displayName=Lp.displayName;function b0({config:n,onChange:r}){const c=h=>{h.trim()&&!n.alias_names.includes(h.trim())&&r({...n,alias_names:[...n.alias_names,h.trim()]})},d=h=>{r({...n,alias_names:n.alias_names.filter((x,f)=>f!==h)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(ce,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:n.qq_account||"",onChange:h=>r({...n,qq_account:Number(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(ce,{id:"nickname",placeholder:"请输入机器人的昵称",value:n.nickname,onChange:h=>r({...n,nickname:h.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:n.alias_names.map((h,x)=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[h,e.jsx("button",{type:"button",onClick:()=>d(x),className:"ml-1 hover:text-destructive",children:e.jsx(li,{className:"h-3 w-3"})})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:h=>{h.key==="Enter"&&(c(h.target.value),h.target.value="")}}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>{const h=document.getElementById("alias_input");h&&(c(h.value),h.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function w0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(Bs,{id:"personality",placeholder:"描述机器人的人格特质和身份特征(建议120字以内)",value:n.personality,onChange:c=>r({...n,personality:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:是一个女大学生,现在在读大二,会刷贴吧"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(Bs,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:n.reply_style,onChange:c=>r({...n,reply_style:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:回复平淡一些,简短一些,说中文,参考贴吧、知乎和微博的回复风格"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(Bs,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:n.interest,onChange:c=>r({...n,interest:c.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(jr,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(Bs,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:n.plan_style,onChange:c=>r({...n,plan_style:c.target.value}),rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在群聊中如何行动,例如回复频率、条件等"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(Bs,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:n.private_plan_style,onChange:c=>r({...n,private_plan_style:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function _0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(n.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ce,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:n.emoji_chance,onChange:c=>r({...n,emoji_chance:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人发送表情包的概率"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",max:"200",value:n.max_reg_num,onChange:c=>r({...n,max_reg_num:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人最多保存的表情包数量"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(Ve,{id:"do_replace",checked:n.do_replace,onCheckedChange:c=>r({...n,do_replace:c})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",max:"120",value:n.check_interval,onChange:c=>r({...n,check_interval:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(Ve,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:c=>r({...n,steal_emoji:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(Ve,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:c=>r({...n,content_filtration:c})})]}),n.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:n.filtration_prompt,onChange:c=>r({...n,filtration_prompt:c.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function S0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(Ve,{id:"enable_tool",checked:n.enable_tool,onCheckedChange:c=>r({...n,enable_tool:c})})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"enable_mood",children:"启用情绪系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"让机器人具有情绪变化能力"})]}),e.jsx(Ve,{id:"enable_mood",checked:n.enable_mood,onCheckedChange:c=>r({...n,enable_mood:c})})]}),n.enable_mood&&e.jsxs("div",{className:"ml-6 space-y-6 border-l-2 border-primary/20 pl-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"mood_update_threshold",children:"情绪更新阈值"}),e.jsx(ce,{id:"mood_update_threshold",type:"number",min:"0.1",max:"10",step:"0.1",value:n.mood_update_threshold||1,onChange:c=>r({...n,mood_update_threshold:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"值越高,情绪更新越慢"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"emotion_style",children:"情感特征"}),e.jsx(Bs,{id:"emotion_style",placeholder:"描述情绪的变化情况,例如:情绪较为稳定,但遭遇特定事件时起伏较大",value:n.emotion_style||"",onChange:c=>r({...n,emotion_style:c.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响机器人的情绪变化方式"})]})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(Ve,{id:"all_global",checked:n.all_global,onCheckedChange:c=>r({...n,all_global:c})})]})]})}function C0({config:n,onChange:r}){const[c,d]=u.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("svg",{className:"h-5 w-5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-1",children:"关于硅基流动 (SiliconFlow)"}),e.jsx("p",{className:"text-blue-700 dark:text-blue-300 mb-2",children:"硅基流动提供了完整的模型覆盖,包括 DeepSeek V3、Qwen、视觉模型、语音识别和嵌入模型。 只需一个 API Key 即可使用麦麦的所有功能!"}),e.jsxs("a",{href:"https://cloud.siliconflow.cn",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:["前往硅基流动获取 API Key",e.jsx(dr,{className:"h-3 w-3"})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"siliconflow_api_key",children:"SiliconFlow API Key *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"siliconflow_api_key",type:c?"text":"password",placeholder:"sk-...",value:n.api_key,onChange:h=>r({api_key:h.target.value}),className:"font-mono pr-10"}),e.jsx(y,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>d(!c),children:c?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"请输入您的硅基流动 API 密钥。获取后,麦麦将自动配置所有必需的模型。"})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium",children:"将自动配置以下模型:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"DeepSeek V3 - 主要对话和工具模型"}),e.jsx("li",{children:"Qwen3 30B - 高频小任务和工具调用"}),e.jsx("li",{children:"Qwen3 VL 30B - 图像识别"}),e.jsx("li",{children:"SenseVoice - 语音识别"}),e.jsx("li",{children:"BGE-M3 - 文本嵌入"}),e.jsx("li",{children:"知识库相关模型 (LPMM)"})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 p-4",children:e.jsxs("p",{className:"text-sm text-amber-900 dark:text-amber-100",children:[e.jsx("span",{className:"font-medium",children:"💡 提示:"}),'完成向导后,您可以在"系统设置 → 模型配置"中添加更多 API 提供商和模型。']})})]})}async function k0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:Ts()});if(!n.ok)throw new Error("读取Bot配置失败");const c=(await n.json()).config.bot||{};return{qq_account:c.qq_account||0,nickname:c.nickname||"",alias_names:c.alias_names||[]}}async function T0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:Ts()});if(!n.ok)throw new Error("读取人格配置失败");const c=(await n.json()).config.personality||{};return{personality:c.personality||"",reply_style:c.reply_style||"",interest:c.interest||"",plan_style:c.plan_style||"",private_plan_style:c.private_plan_style||""}}async function E0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:Ts()});if(!n.ok)throw new Error("读取表情包配置失败");const c=(await n.json()).config.emoji||{};return{emoji_chance:c.emoji_chance??.4,max_reg_num:c.max_reg_num??40,do_replace:c.do_replace??!0,check_interval:c.check_interval??10,steal_emoji:c.steal_emoji??!0,content_filtration:c.content_filtration??!1,filtration_prompt:c.filtration_prompt||""}}async function z0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:Ts()});if(!n.ok)throw new Error("读取其他配置失败");const c=(await n.json()).config,d=c.tool||{},h=c.mood||{},x=c.jargon||{};return{enable_tool:d.enable_tool??!0,enable_mood:h.enable_mood??!1,mood_update_threshold:h.mood_update_threshold,emotion_style:h.emotion_style,all_global:x.all_global??!0}}async function M0(){const n=await ke("/api/webui/config/model",{method:"GET",headers:Ts()});if(!n.ok)throw new Error("读取模型配置失败");return{api_key:((await n.json()).config.api_providers||[]).find(x=>x.name==="SiliconFlow")?.api_key||""}}async function A0(n){const r=await ke("/api/webui/config/bot/section/bot",{method:"POST",headers:Ts(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存Bot基础配置失败")}return await r.json()}async function D0(n){const r=await ke("/api/webui/config/bot/section/personality",{method:"POST",headers:Ts(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存人格配置失败")}return await r.json()}async function O0(n){const r=await ke("/api/webui/config/bot/section/emoji",{method:"POST",headers:Ts(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存表情包配置失败")}return await r.json()}async function R0(n){const r=[];r.push(ke("/api/webui/config/bot/section/tool",{method:"POST",headers:Ts(),body:JSON.stringify({enable_tool:n.enable_tool})})),r.push(ke("/api/webui/config/bot/section/jargon",{method:"POST",headers:Ts(),body:JSON.stringify({all_global:n.all_global})}));const c={enable_mood:n.enable_mood};n.enable_mood&&(c.mood_update_threshold=n.mood_update_threshold||1,c.emotion_style=n.emotion_style||""),r.push(ke("/api/webui/config/bot/section/mood",{method:"POST",headers:Ts(),body:JSON.stringify(c)}));const d=await Promise.all(r);for(const h of d)if(!h.ok){const x=await h.json();throw new Error(x.detail||"保存其他配置失败")}return{success:!0}}async function L0(n){const r=await ke("/api/webui/config/model",{method:"GET",headers:Ts()});if(!r.ok)throw new Error("读取模型配置失败");const d=(await r.json()).config,h=d.api_providers||[],x=h.findIndex(p=>p.name==="SiliconFlow");x>=0?h[x]={...h[x],api_key:n.api_key}:h.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:n.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const f={...d,api_providers:h},j=await ke("/api/webui/config/model",{method:"POST",headers:Ts(),body:JSON.stringify(f)});if(!j.ok){const p=await j.json();throw new Error(p.detail||"保存模型配置失败")}return await j.json()}async function rp(){const n=localStorage.getItem("access-token"),r=await ke("/api/webui/setup/complete",{method:"POST",headers:{Authorization:`Bearer ${n}`}});if(!r.ok){const c=await r.json();throw new Error(c.message||"标记配置完成失败")}return await r.json()}async function co(){const n=await ke("/api/webui/system/restart",{method:"POST",headers:Ts()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"重启失败")}return await n.json()}async function U0(){const n=await ke("/api/webui/system/status",{method:"GET",headers:Ts()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取状态失败")}return await n.json()}function B0(){const n=Jt(),{toast:r}=Hs(),[c,d]=u.useState(0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[p,w]=u.useState(!0),[v,k]=u.useState({qq_account:0,nickname:"",alias_names:[]}),[T,E]=u.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 +2.如果相同的内容已经被执行,请不要重复执行 +3.请控制你的发言频率,不要太过频繁的发言 +4.如果有人对你感到厌烦,请减少回复 +5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 +2.如果相同的内容已经被执行,请不要重复执行 +3.某句话如果已经被回复过,不要重复回复`}),[R,K]=u.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[U,A]=u.useState({enable_tool:!0,enable_mood:!1,mood_update_threshold:1,emotion_style:"情绪较为稳定,但遇遇特定事件的时候起伏较大",all_global:!0}),[Z,H]=u.useState({api_key:""}),[z,B]=u.useState(!1),[X,S]=u.useState(""),O=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:ir},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:to},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:$u},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:Rl},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:vg}],te=(c+1)/O.length*100;u.useEffect(()=>{(async()=>{try{w(!0);const[G,q,ie,_,me]=await Promise.all([k0(),T0(),E0(),z0(),M0()]);k(G),E(q),K(ie),A(_),H(me)}catch(G){r({title:"加载配置失败",description:G instanceof Error?G.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{w(!1)}})()},[r]);const he=async()=>{j(!0);try{switch(c){case 0:await A0(v);break;case 1:await D0(T);break;case 2:await O0(R);break;case 3:await R0(U);break;case 4:await L0(Z);break}return r({title:"保存成功",description:`${O[c].title}配置已保存`}),!0}catch(N){return r({title:"保存失败",description:N instanceof Error?N.message:"未知错误",variant:"destructive"}),!1}finally{j(!1)}},Ne=async()=>{await he()&&c{c>0&&d(c-1)},pe=async()=>{x(!0),B(!0);try{if(S("正在保存API配置..."),!await he()){x(!1),B(!1);return}S("正在完成初始化..."),await rp(),S("正在重启麦麦..."),await co(),r({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),S("等待麦麦重启完成...");const G=60;let q=0,ie=!1;for(;qsetTimeout(_,1e3));try{(await U0()).running&&(ie=!0,S("重启成功!正在跳转..."))}catch{q++}}if(!ie)throw new Error("重启超时,请手动检查麦麦状态");setTimeout(()=>{n({to:"/"})},1e3)}catch(N){B(!1),r({title:"配置失败",description:N instanceof Error?N.message:"未知错误",variant:"destructive"})}finally{x(!1)}},je=async()=>{try{await rp(),n({to:"/"})}catch(N){r({title:"跳过失败",description:N instanceof Error?N.message:"未知错误",variant:"destructive"})}},_e=()=>{switch(c){case 0:return e.jsx(b0,{config:v,onChange:k});case 1:return e.jsx(w0,{config:T,onChange:E});case 2:return e.jsx(_0,{config:R,onChange:K});case 3:return e.jsx(S0,{config:U,onChange:A});case 4:return e.jsx(C0,{config:Z,onChange:H});default:return null}};return e.jsxs("div",{className:"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-gradient-to-br from-primary/5 via-background to-secondary/5 p-4 md:p-6",children:[z&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:e.jsxs("div",{className:"mx-auto flex max-w-md flex-col items-center space-y-6 rounded-lg border bg-card p-8 text-center shadow-lg",children:[e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(vt,{className:"h-10 w-10 animate-spin text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground",children:X})]}),e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full w-full animate-pulse bg-primary",style:{animation:"pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请稍候,这可能需要一分钟..."})]})}),e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute left-1/4 top-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-primary/5 blur-3xl"}),e.jsx("div",{className:"absolute right-1/4 bottom-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-secondary/5 blur-3xl"})]}),p?e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center",children:e.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),e.jsx("p",{className:"text-lg font-medium",children:"加载配置中..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"正在读取现有配置"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-10 w-full max-w-4xl",children:[e.jsxs("div",{className:"mb-6 md:mb-8 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 md:h-16 md:w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx(EN,{className:"h-6 w-6 md:h-8 md:w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsx("h1",{className:"mb-2 text-2xl md:text-3xl font-bold",children:"首次配置向导"}),e.jsxs("p",{className:"text-sm md:text-base text-muted-foreground",children:["让我们一起完成 ",Ku," 的初始配置"]})]}),e.jsxs("div",{className:"mb-6 md:mb-8",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs md:text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["步骤 ",c+1," / ",O.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(te),"%"]})]}),e.jsx(Sr,{value:te,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:O.map((N,G)=>{const q=N.icon;return e.jsxs("div",{className:Q("flex flex-1 flex-col items-center gap-1 md:gap-2",Gn({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(xr,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(y,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx(ti,{className:"h-4 w-4"}),"返回上一页"]})]}),e.jsx("div",{className:"mt-12 pt-8 border-t border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"如果您认为这是一个错误,请联系系统管理员"})})]})})}const He=xN,qe=fN,Re=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs(tg,{ref:d,className:Q("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n),...c,children:[r,e.jsx(oN,{asChild:!0,children:e.jsx(Ll,{className:"h-4 w-4 opacity-50"})})]}));Re.displayName=tg.displayName;const Lg=u.forwardRef(({className:n,...r},c)=>e.jsx(ag,{ref:c,className:Q("flex cursor-default items-center justify-center py-1",n),...r,children:e.jsx(fr,{className:"h-4 w-4"})}));Lg.displayName=ag.displayName;const Ug=u.forwardRef(({className:n,...r},c)=>e.jsx(lg,{ref:c,className:Q("flex cursor-default items-center justify-center py-1",n),...r,children:e.jsx(Ll,{className:"h-4 w-4"})}));Ug.displayName=lg.displayName;const Le=u.forwardRef(({className:n,children:r,position:c="popper",...d},h)=>e.jsx(dN,{children:e.jsxs(ng,{ref:h,className:Q("relative z-[100] max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-hidden rounded-md border border-border bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",c==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:c,...d,children:[e.jsx(Lg,{}),e.jsx(uN,{className:Q("p-1",c==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e.jsx(Ug,{})]})}));Le.displayName=ng.displayName;const H0=u.forwardRef(({className:n,...r},c)=>e.jsx(ig,{ref:c,className:Q("px-2 py-1.5 text-sm font-semibold",n),...r}));H0.displayName=ig.displayName;const ne=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs(rg,{ref:d,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-2 pl-2 pr-8 text-sm outline-none bg-white dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 focus:bg-gray-100 dark:focus:bg-gray-800 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...c,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(mN,{children:e.jsx(fa,{className:"h-4 w-4"})})}),e.jsx(hN,{children:r})]}));ne.displayName=rg.displayName;const q0=u.forwardRef(({className:n,...r},c)=>e.jsx(cg,{ref:c,className:Q("-mx-1 my-1 h-px bg-muted",n),...r}));q0.displayName=cg.displayName;const Oa=Vy,Ra=Fy,wa=u.forwardRef(({className:n,align:r="center",sideOffset:c=4,...d},h)=>e.jsx(Gy,{children:e.jsx(Up,{ref:h,align:r,sideOffset:c,className:Q("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",n),...d})}));wa.displayName=Up.displayName;const Ul="/api/webui/config";async function cp(){const r=await(await ke(`${Ul}/bot`)).json();if(!r.success)throw new Error("获取配置数据失败");return r.config}async function ei(){const r=await(await ke(`${Ul}/model`)).json();if(!r.success)throw new Error("获取模型配置数据失败");return r.config}async function op(n){const c=await(await ke(`${Ul}/bot`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function G0(){const r=await(await ke(`${Ul}/bot/raw`)).json();if(!r.success)throw new Error("获取配置源代码失败");return r.content}async function V0(n){const c=await(await ke(`${Ul}/bot/raw`,{method:"POST",body:JSON.stringify({raw_content:n})})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function io(n){const c=await(await ke(`${Ul}/model`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function F0(n,r){const d=await(await ke(`${Ul}/bot/section/${n}`,{method:"POST",body:JSON.stringify(r)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function qu(n,r){const d=await(await ke(`${Ul}/model/section/${n}`,{method:"POST",body:JSON.stringify(r)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function $0(n,r="openai",c="/models"){const d=new URLSearchParams({provider_name:n,parser:r,endpoint:c}),h=await ke(`/api/webui/models/list?${d}`);if(!h.ok){const f=await h.json().catch(()=>({}));throw new Error(f.detail||`获取模型列表失败 (${h.status})`)}const x=await h.json();if(!x.success)throw new Error("获取模型列表失败");return x.models}async function Q0(n){const r=new URLSearchParams({provider_name:n}),c=await ke(`/api/webui/models/test-connection-by-name?${r}`,{method:"POST"});if(!c.ok){const d=await c.json().catch(()=>({}));throw new Error(d.detail||`测试连接失败 (${c.status})`)}return await c.json()}const Y0=ai("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),ha=u.forwardRef(({className:n,variant:r,...c},d)=>e.jsx("div",{ref:d,role:"alert",className:Q(Y0({variant:r}),n),...c}));ha.displayName="Alert";const X0=u.forwardRef(({className:n,...r},c)=>e.jsx("h5",{ref:c,className:Q("mb-1 font-medium leading-none tracking-tight",n),...r}));X0.displayName="AlertTitle";const xa=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:Q("text-sm [&_p]:leading-relaxed",n),...r}));xa.displayName="AlertDescription";function Iu({onRestartComplete:n,onRestartFailed:r}){const[c,d]=u.useState(0),[h,x]=u.useState("restarting"),[f,j]=u.useState(0),[p,w]=u.useState(0);u.useEffect(()=>{const T=setInterval(()=>{d(K=>K>=90?K:K+1)},200),E=setInterval(()=>{j(K=>K+1)},1e3),R=setTimeout(()=>{x("checking"),v()},3e3);return()=>{clearInterval(T),clearInterval(E),clearTimeout(R)}},[]);const v=()=>{const E=async()=>{try{if(w(K=>K+1),(await fetch("/api/webui/system/status",{method:"GET",headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(3e3)})).ok)d(100),x("success"),setTimeout(()=>{n?.()},1500);else throw new Error("Status check failed")}catch{p<60?setTimeout(E,2e3):(x("failed"),r?.())}};E()},k=T=>{const E=Math.floor(T/60),R=T%60;return`${E}:${R.toString().padStart(2,"0")}`};return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[h==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"请稍候,麦麦正在重启中..."})]}),h==="checking"&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"检查服务状态"}),e.jsxs("p",{className:"text-muted-foreground text-center",children:["等待服务恢复... (尝试 ",p,"/60)"]})]}),h==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(pa,{className:"h-16 w-16 text-green-500"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启成功"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"正在跳转到登录页面..."})]}),h==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx(Da,{className:"h-16 w-16 text-destructive"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启超时"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"服务未能在预期时间内恢复,请手动检查或刷新页面"})]})]}),h!=="failed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Sr,{value:c,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[c,"%"]}),e.jsxs("span",{children:["已用时: ",k(f)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[h==="restarting"&&"🔄 配置已保存,正在重启主程序...",h==="checking"&&"⏳ 正在等待服务恢复,请勿关闭页面...",h==="success"&&"✅ 配置已生效,服务运行正常",h==="failed"&&"⚠️ 如果长时间无响应,请尝试手动重启"]})}),e.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/50 rounded-lg p-4",children:e.jsxs("p",{className:"text-sm text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"⚠️ 重要提示:"})," 由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。如需结束程序,请使用脚本目录下的进程管理脚本。"]})}),h==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"刷新页面"}),e.jsx("button",{onClick:()=>{x("checking"),w(0),v()},className:"flex-1 px-4 py-2 bg-secondary text-secondary-foreground rounded-md hover:bg-secondary/90",children:"重试检测"})]})]})})}const K0={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(n,r){let c;if(!r.inString&&(c=n.match(/^('''|"""|'|")/))&&(r.stringType=c[0],r.inString=!0),n.sol()&&!r.inString&&r.inArray===0&&(r.lhs=!0),r.inString){for(;r.inString;)if(n.match(r.stringType))r.inString=!1;else if(n.peek()==="\\")n.next(),n.next();else{if(n.eol())break;n.match(/^.[^\\\"\']*/)}return r.lhs?"property":"string"}else{if(r.inArray&&n.peek()==="]")return n.next(),r.inArray--,"bracket";if(r.lhs&&n.peek()==="["&&n.skipTo("]"))return n.next(),n.peek()==="]"&&n.next(),"atom";if(n.peek()==="#")return n.skipToEnd(),"comment";if(n.eatSpace())return null;if(r.lhs&&n.eatWhile(function(d){return d!="="&&d!=" "}))return"property";if(r.lhs&&n.peek()==="=")return n.next(),r.lhs=!1,null;if(!r.lhs&&n.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!r.lhs&&(n.match("true")||n.match("false")))return"atom";if(!r.lhs&&n.peek()==="[")return r.inArray++,n.next(),"bracket";if(!r.lhs&&n.match(/^\-?\d+(?:\.\d+)?/))return"number";n.eatSpace()||n.next()}return null},languageData:{commentTokens:{line:"#"}}},Z0={python:[tb()],json:[ab(),lb()],toml:[sb.define(K0)],text:[]};function J0({value:n,onChange:r,language:c="text",readOnly:d=!1,height:h="400px",minHeight:x,maxHeight:f,placeholder:j,theme:p="dark",className:w=""}){const[v,k]=u.useState(!1);if(u.useEffect(()=>{k(!0)},[]),!v)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${w}`,style:{height:h,minHeight:x,maxHeight:f}});const T=[...Z0[c]||[],If.lineWrapping];return d&&T.push(If.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border ${w}`,children:e.jsx(nb,{value:n,height:h,minHeight:x,maxHeight:f,theme:p==="dark"?ib:void 0,extensions:T,onChange:r,placeholder:j,basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,foldGutter:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,syntaxHighlighting:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0}})})}function I0(){const[n,r]=u.useState(!0),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[p,w]=u.useState(!1),[v,k]=u.useState(!1),[T,E]=u.useState("visual"),[R,K]=u.useState(""),[U,A]=u.useState(!1),{toast:Z}=Hs(),[H,z]=u.useState(null),[B,X]=u.useState(null),[S,O]=u.useState(null),[te,he]=u.useState(null),[Ne,ye]=u.useState(null),[pe,je]=u.useState(null),[_e,N]=u.useState(null),[G,q]=u.useState(null),[ie,_]=u.useState(null),[me,xe]=u.useState(null),[$,de]=u.useState(null),[ge,le]=u.useState(null),[L,F]=u.useState(null),[D,ee]=u.useState(null),[we,ze]=u.useState(null),[ss,Ze]=u.useState(null),[Ls,Gs]=u.useState(null),[re,be]=u.useState(null),Xe=u.useRef(null),Ue=u.useRef(!0),st=u.useRef({}),It=u.useCallback(async()=>{try{const Se=await G0();K(Se),A(!1)}catch(Se){Z({variant:"destructive",title:"加载失败",description:Se instanceof Error?Se.message:"加载源代码失败"})}},[Z]),bt=u.useCallback(async()=>{try{r(!0);const Se=await cp();st.current=Se,z(Se.bot),X(Se.personality);const Oe=Se.chat;Oe.talk_value_rules||(Oe.talk_value_rules=[]),O(Oe),he(Se.expression),ye(Se.emoji),je(Se.memory),N(Se.tool),q(Se.mood),_(Se.voice),xe(Se.lpmm_knowledge),de(Se.keyword_reaction),le(Se.response_post_process),F(Se.chinese_typo),ee(Se.response_splitter),ze(Se.log),Ze(Se.debug),Gs(Se.maim_message),be(Se.telemetry),j(!1),Ue.current=!1,await It()}catch(Se){console.error("加载配置失败:",Se),Z({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{r(!1)}},[Z,It]);u.useEffect(()=>{bt()},[bt]);const Je=u.useCallback(async(Se,Oe)=>{if(!Ue.current)try{x(!0),await F0(Se,Oe),j(!1)}catch(it){console.error(`自动保存 ${Se} 失败:`,it),j(!0)}finally{x(!1)}},[]),Be=u.useCallback((Se,Oe)=>{Ue.current||(j(!0),Xe.current&&clearTimeout(Xe.current),Xe.current=setTimeout(()=>{Je(Se,Oe)},2e3))},[Je]);u.useEffect(()=>{H&&!Ue.current&&Be("bot",H)},[H,Be]),u.useEffect(()=>{B&&!Ue.current&&Be("personality",B)},[B,Be]),u.useEffect(()=>{S&&!Ue.current&&Be("chat",S)},[S,Be]),u.useEffect(()=>{te&&!Ue.current&&Be("expression",te)},[te,Be]),u.useEffect(()=>{Ne&&!Ue.current&&Be("emoji",Ne)},[Ne,Be]),u.useEffect(()=>{pe&&!Ue.current&&Be("memory",pe)},[pe,Be]),u.useEffect(()=>{_e&&!Ue.current&&Be("tool",_e)},[_e,Be]),u.useEffect(()=>{G&&!Ue.current&&Be("mood",G)},[G,Be]),u.useEffect(()=>{ie&&!Ue.current&&Be("voice",ie)},[ie,Be]),u.useEffect(()=>{me&&!Ue.current&&Be("lpmm_knowledge",me)},[me,Be]),u.useEffect(()=>{$&&!Ue.current&&Be("keyword_reaction",$)},[$,Be]),u.useEffect(()=>{ge&&!Ue.current&&Be("response_post_process",ge)},[ge,Be]),u.useEffect(()=>{L&&!Ue.current&&Be("chinese_typo",L)},[L,Be]),u.useEffect(()=>{D&&!Ue.current&&Be("response_splitter",D)},[D,Be]),u.useEffect(()=>{we&&!Ue.current&&Be("log",we)},[we,Be]),u.useEffect(()=>{ss&&!Ue.current&&Be("debug",ss)},[ss,Be]),u.useEffect(()=>{Ls&&!Ue.current&&Be("maim_message",Ls)},[Ls,Be]),u.useEffect(()=>{re&&!Ue.current&&Be("telemetry",re)},[re,Be]);const jt=async()=>{try{d(!0),await V0(R),j(!1),A(!1),Z({title:"保存成功",description:"配置已保存"}),await bt()}catch(Se){A(!0),Z({variant:"destructive",title:"保存失败",description:Se instanceof Error?Se.message:"保存配置失败"})}finally{d(!1)}},nt=async Se=>{if(f){Z({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(E(Se),Se==="source")await It();else try{const Oe=await cp();st.current=Oe,z(Oe.bot),X(Oe.personality);const it=Oe.chat;it.talk_value_rules||(it.talk_value_rules=[]),O(it),he(Oe.expression),ye(Oe.emoji),je(Oe.memory),N(Oe.tool),q(Oe.mood),_(Oe.voice),xe(Oe.lpmm_knowledge),de(Oe.keyword_reaction),le(Oe.response_post_process),F(Oe.chinese_typo),ee(Oe.response_splitter),ze(Oe.log),Ze(Oe.debug),Gs(Oe.maim_message),be(Oe.telemetry),j(!1)}catch(Oe){console.error("加载配置失败:",Oe),Z({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},St=async()=>{try{d(!0),Xe.current&&clearTimeout(Xe.current);const Se={...st.current,bot:H,personality:B,chat:S,expression:te,emoji:Ne,memory:pe,tool:_e,mood:G,voice:ie,lpmm_knowledge:me,keyword_reaction:$,response_post_process:ge,chinese_typo:L,response_splitter:D,log:we,debug:ss,maim_message:Ls,telemetry:re};await op(Se),j(!1),Z({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(Se){console.error("保存配置失败:",Se),Z({title:"保存失败",description:Se.message,variant:"destructive"})}finally{d(!1)}},Ct=async()=>{try{w(!0),co().catch(()=>{}),k(!0)}catch(Se){console.error("重启失败:",Se),k(!1),Z({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),w(!1)}},rl=async()=>{try{d(!0),Xe.current&&clearTimeout(Xe.current);const Se={...st.current,bot:H,personality:B,chat:S,expression:te,emoji:Ne,memory:pe,tool:_e,mood:G,voice:ie,lpmm_knowledge:me,keyword_reaction:$,response_post_process:ge,chinese_typo:L,response_splitter:D,log:we,debug:ss,maim_message:Ls,telemetry:re};await op(Se),j(!1),Z({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(Oe=>setTimeout(Oe,500)),await Ct()}catch(Se){console.error("保存失败:",Se),Z({title:"保存失败",description:Se.message,variant:"destructive"})}finally{d(!1)}},cl=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},ol=()=>{k(!1),w(!1),Z({title:"重启失败",description:"服务器未能在预期时间内恢复,请手动检查",variant:"destructive"})};return n?e.jsx(Pe,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦主程序配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的核心功能和行为设置"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto items-center",children:[e.jsx(Kt,{value:T,onValueChange:Se=>nt(Se),className:"w-auto",children:e.jsxs(Rt,{className:"h-9",children:[e.jsxs($e,{value:"visual",className:"text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(AN,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"可视化"]}),e.jsxs($e,{value:"source",className:"text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(DN,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码"]})]})}),e.jsxs(y,{onClick:T==="visual"?St:jt,disabled:c||h||!f||p,size:"sm",variant:"outline",className:"flex-1 sm:flex-none",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),c?"保存中...":h?"自动保存中...":f?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{disabled:c||h||p,size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),p?"重启中...":f?"保存并重启":"重启麦麦"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重启麦麦?"}),e.jsx(us,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:f?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ha,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(xa,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Rs,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(zs,{className:"max-w-2xl",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx(Ys,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx($e,{value:"windows",children:"Windows"}),e.jsx($e,{value:"macos",children:"macOS"}),e.jsx($e,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:['在"进程"或"详细信息"标签页中找到 ',e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:'右键点击并选择"结束任务"'})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"}),' 打开 Spotlight,搜索"活动监视器"']}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Js,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:f?rl:Ct,children:f?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ha,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(xa,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),T==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ha,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(xa,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在后端验证格式,只有格式完全正确才能保存。",U&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(J0,{value:R,onChange:Se=>{K(Se),j(!0),U&&A(!1)},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),T==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(Kt,{defaultValue:"bot",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs(Rt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5 lg:grid-cols-10",children:[e.jsx($e,{value:"bot",className:"flex-shrink-0",children:"基本信息"}),e.jsx($e,{value:"personality",className:"flex-shrink-0",children:"人格"}),e.jsx($e,{value:"chat",className:"flex-shrink-0",children:"聊天"}),e.jsx($e,{value:"expression",className:"flex-shrink-0",children:"表达"}),e.jsx($e,{value:"features",className:"flex-shrink-0",children:"功能"}),e.jsx($e,{value:"processing",className:"flex-shrink-0",children:"处理"}),e.jsx($e,{value:"mood",className:"flex-shrink-0",children:"情绪"}),e.jsx($e,{value:"voice",className:"flex-shrink-0",children:"语音"}),e.jsx($e,{value:"lpmm",className:"flex-shrink-0",children:"知识库"}),e.jsx($e,{value:"other",className:"flex-shrink-0",children:"其他"})]})}),e.jsx(We,{value:"bot",className:"space-y-4",children:H&&e.jsx(P0,{config:H,onChange:z})}),e.jsx(We,{value:"personality",className:"space-y-4",children:B&&e.jsx(W0,{config:B,onChange:X})}),e.jsx(We,{value:"chat",className:"space-y-4",children:S&&e.jsx(ew,{config:S,onChange:O})}),e.jsx(We,{value:"expression",className:"space-y-4",children:te&&e.jsx(tw,{config:te,onChange:he})}),e.jsx(We,{value:"features",className:"space-y-4",children:Ne&&pe&&_e&&e.jsx(aw,{emojiConfig:Ne,memoryConfig:pe,toolConfig:_e,onEmojiChange:ye,onMemoryChange:je,onToolChange:N})}),e.jsx(We,{value:"processing",className:"space-y-4",children:$&&ge&&L&&D&&e.jsx(lw,{keywordReactionConfig:$,responsePostProcessConfig:ge,chineseTypoConfig:L,responseSplitterConfig:D,onKeywordReactionChange:de,onResponsePostProcessChange:le,onChineseTypoChange:F,onResponseSplitterChange:ee})}),e.jsx(We,{value:"mood",className:"space-y-4",children:G&&e.jsx(nw,{config:G,onChange:q})}),e.jsx(We,{value:"voice",className:"space-y-4",children:ie&&e.jsx(iw,{config:ie,onChange:_})}),e.jsx(We,{value:"lpmm",className:"space-y-4",children:me&&e.jsx(rw,{config:me,onChange:xe})}),e.jsxs(We,{value:"other",className:"space-y-4",children:[we&&e.jsx(cw,{config:we,onChange:ze}),ss&&e.jsx(ow,{config:ss,onChange:Ze}),Ls&&e.jsx(dw,{config:Ls,onChange:Gs}),re&&e.jsx(uw,{config:re,onChange:be})]})]})}),v&&e.jsx(Iu,{onRestartComplete:cl,onRestartFailed:ol})]})})}function P0({config:n,onChange:r}){const c=()=>{r({...n,platforms:[...n.platforms,""]})},d=p=>{r({...n,platforms:n.platforms.filter((w,v)=>v!==p)})},h=(p,w)=>{const v=[...n.platforms];v[p]=w,r({...n,platforms:v})},x=()=>{r({...n,alias_names:[...n.alias_names,""]})},f=p=>{r({...n,alias_names:n.alias_names.filter((w,v)=>v!==p)})},j=(p,w)=>{const v=[...n.alias_names];v[p]=w,r({...n,alias_names:v})};return e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"基本信息"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"platform",children:"平台"}),e.jsx(ce,{id:"platform",value:n.platform,onChange:p=>r({...n,platform:p.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ce,{id:"qq_account",value:n.qq_account,onChange:p=>r({...n,qq_account:p.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:n.nickname,onChange:p=>r({...n,nickname:p.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"其他平台账号"}),e.jsxs(y,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.platforms.map((p,w)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:p,onChange:v=>h(w,v.target.value),placeholder:"wx:114514"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除平台账号 "',p||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d(w),children:"删除"})]})]})]})]},w)),n.platforms.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"别名"}),e.jsxs(y,{onClick:x,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.alias_names.map((p,w)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:p,onChange:v=>j(w,v.target.value),placeholder:"小麦"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除别名 "',p||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>f(w),children:"删除"})]})]})]})]},w)),n.alias_names.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无别名"})]})]})]})]})})}function W0({config:n,onChange:r}){const c=()=>{r({...n,states:[...n.states,""]})},d=x=>{r({...n,states:n.states.filter((f,j)=>j!==x)})},h=(x,f)=>{const j=[...n.states];j[x]=f,r({...n,states:j})};return e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"人格设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"personality",children:"人格特质"}),e.jsx(Bs,{id:"personality",value:n.personality,onChange:x=>r({...n,personality:x.target.value}),placeholder:"描述人格特质和身份特征(建议120字以内)",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"建议120字以内,描述人格特质和身份特征"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(Bs,{id:"reply_style",value:n.reply_style,onChange:x=>r({...n,reply_style:x.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"interest",children:"兴趣"}),e.jsx(Bs,{id:"interest",value:n.interest,onChange:x=>r({...n,interest:x.target.value}),placeholder:"会影响麦麦对什么话题进行回复",rows:2})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(Bs,{id:"plan_style",value:n.plan_style,onChange:x=>r({...n,plan_style:x.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(Bs,{id:"visual_style",value:n.visual_style,onChange:x=>r({...n,visual_style:x.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(Bs,{id:"private_plan_style",value:n.private_plan_style,onChange:x=>r({...n,private_plan_style:x.target.value}),placeholder:"私聊的说话规则和行为风格",rows:4})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"状态列表(人格多样性)"}),e.jsxs(y,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加状态"]})]}),e.jsx("div",{className:"space-y-2",children:n.states.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Bs,{value:x,onChange:j=>h(f,j.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsx(us,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d(f),children:"删除"})]})]})]})]},f))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"state_probability",children:"状态替换概率"}),e.jsx(ce,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:n.state_probability,onChange:x=>r({...n,state_probability:parseFloat(x.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时替换 personality 的概率(0.0-1.0)"})]})]})]})})}function ew({config:n,onChange:r}){const c=()=>{r({...n,talk_value_rules:[...n.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},d=j=>{r({...n,talk_value_rules:n.talk_value_rules.filter((p,w)=>w!==j)})},h=(j,p,w)=>{const v=[...n.talk_value_rules];v[j]={...v[j],[p]:w},r({...n,talk_value_rules:v})},x=({value:j,onChange:p})=>{const[w,v]=u.useState("00"),[k,T]=u.useState("00"),[E,R]=u.useState("23"),[K,U]=u.useState("59");u.useEffect(()=>{const Z=j.split("-");if(Z.length===2){const[H,z]=Z,[B,X]=H.split(":"),[S,O]=z.split(":");B&&v(B.padStart(2,"0")),X&&T(X.padStart(2,"0")),S&&R(S.padStart(2,"0")),O&&U(O.padStart(2,"0"))}},[j]);const A=(Z,H,z,B)=>{const X=`${Z}:${H}-${z}:${B}`;p(X)};return e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"}),j||"选择时间段"]})}),e.jsx(wa,{className:"w-80",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"开始时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"小时"}),e.jsxs(He,{value:w,onValueChange:Z=>{v(Z),A(Z,k,E,K)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:Array.from({length:24},(Z,H)=>H).map(Z=>e.jsx(ne,{value:Z.toString().padStart(2,"0"),children:Z.toString().padStart(2,"0")},Z))})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"分钟"}),e.jsxs(He,{value:k,onValueChange:Z=>{T(Z),A(w,Z,E,K)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:Array.from({length:60},(Z,H)=>H).map(Z=>e.jsx(ne,{value:Z.toString().padStart(2,"0"),children:Z.toString().padStart(2,"0")},Z))})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"结束时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"小时"}),e.jsxs(He,{value:E,onValueChange:Z=>{R(Z),A(w,k,Z,K)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:Array.from({length:24},(Z,H)=>H).map(Z=>e.jsx(ne,{value:Z.toString().padStart(2,"0"),children:Z.toString().padStart(2,"0")},Z))})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"分钟"}),e.jsxs(He,{value:K,onValueChange:Z=>{U(Z),A(w,k,E,Z)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:Array.from({length:60},(Z,H)=>H).map(Z=>e.jsx(ne,{value:Z.toString().padStart(2,"0"),children:Z.toString().padStart(2,"0")},Z))})]})]})]})]})]})})]})},f=({rule:j})=>{const p=`{ target = "${j.target}", time = "${j.time}", value = ${j.value.toFixed(1)} }`;return e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(wa,{className:"w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"聊天设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(ce,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:n.talk_value,onChange:j=>r({...n,talk_value:parseFloat(j.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越小越沉默,范围 0-1"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"mentioned_bot_reply",checked:n.mentioned_bot_reply,onCheckedChange:j=>r({...n,mentioned_bot_reply:j})}),e.jsx(b,{htmlFor:"mentioned_bot_reply",className:"cursor-pointer",children:"启用提及必回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(ce,{id:"max_context_size",type:"number",min:"1",value:n.max_context_size,onChange:j=>r({...n,max_context_size:parseInt(j.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ce,{id:"planner_smooth",type:"number",step:"1",min:"0",value:n.planner_smooth,onChange:j=>r({...n,planner_smooth:parseFloat(j.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-5,0 为关闭"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_talk_value_rules",checked:n.enable_talk_value_rules,onCheckedChange:j=>r({...n,enable_talk_value_rules:j})}),e.jsx(b,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"include_planner_reasoning",checked:n.include_planner_reasoning,onCheckedChange:j=>r({...n,include_planner_reasoning:j})}),e.jsx(b,{htmlFor:"include_planner_reasoning",className:"cursor-pointer",children:"将 planner 推理加入 replyer"})]})]})]}),n.enable_talk_value_rules&&e.jsxs("div",{className:"border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"动态发言频率规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"按时段或聊天流ID调整发言频率,优先匹配具体聊天,再匹配全局规则"})]}),e.jsxs(y,{onClick:c,size:"sm",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),n.talk_value_rules&&n.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:n.talk_value_rules.map((j,p)=>e.jsxs("div",{className:"rounded-lg border p-4 bg-muted/50 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["规则 #",p+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{rule:j}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"sm",children:e.jsx(es,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除规则 #",p+1," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d(p),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(He,{value:j.target===""?"global":"specific",onValueChange:w=>{w==="global"?h(p,"target",""):h(p,"target","qq::group")},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"global",children:"全局配置"}),e.jsx(ne,{value:"specific",children:"详细配置"})]})]})]}),j.target!==""&&(()=>{const w=j.target.split(":"),v=w[0]||"qq",k=w[1]||"",T=w[2]||"group";return e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"平台"}),e.jsxs(He,{value:v,onValueChange:E=>{h(p,"target",`${E}:${k}:${T}`)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"qq",children:"QQ"}),e.jsx(ne,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:k,onChange:E=>{h(p,"target",`${v}:${E.target.value}:${T}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"类型"}),e.jsxs(He,{value:T,onValueChange:E=>{h(p,"target",`${v}:${k}:${E}`)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"group",children:"群组(group)"}),e.jsx(ne,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",j.target||"(未设置)"]})]})})(),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(x,{value:j.time,onChange:w=>h(p,"time",w)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持跨夜区间,例如 23:00-02:00"})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:`rule-value-${p}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(ce,{id:`rule-value-${p}`,type:"number",step:"0.01",min:"0.01",max:"1",value:j.value,onChange:w=>{const v=parseFloat(w.target.value);isNaN(v)||h(p,"value",Math.max(.01,Math.min(1,v)))},className:"w-20 h-8 text-xs"})]}),e.jsx(Ma,{value:[j.value],onValueChange:w=>h(p,"value",w[0]),min:.01,max:1,step:.01,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.01 (极少发言)"}),e.jsx("span",{children:"0.5"}),e.jsx("span",{children:"1.0 (正常)"})]})]})]})]},p))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:'暂无规则,点击"添加规则"按钮创建'})}),e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsx("h5",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"📝 规则说明"}),e.jsxs("ul",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 为空"}),":全局规则,对所有聊天生效"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 指定"}),":仅对特定聊天流生效(格式:platform:id:type)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"优先级"}),":先匹配具体聊天流规则,再匹配全局规则"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"时间支持跨夜"}),":例如 23:00-02:00 表示晚上11点到次日凌晨2点"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"数值范围"}),":建议 0-1,0 表示完全沉默,1 表示正常发言"]})]})]})]})]})}function sw({member:n,groupIndex:r,memberIndex:c,availableChatIds:d,onUpdate:h,onRemove:x}){const f=d.includes(n)||n==="*",[j,p]=u.useState(!f);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:j?e.jsxs(e.Fragment,{children:[e.jsx(ce,{value:n,onChange:w=>h(r,c,w.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),d.length>0&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>p(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(He,{value:n,onValueChange:w=>h(r,c,w),children:[e.jsx(Re,{className:"flex-1",children:e.jsx(qe,{placeholder:"选择聊天流"})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"*",children:"* (全局共享)"}),d.map((w,v)=>e.jsx(ne,{value:w,children:w},v))]})]}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>p(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除组成员 "',n||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>x(r,c),children:"删除"})]})]})]})]})}function tw({config:n,onChange:r}){const c=()=>{r({...n,learning_list:[...n.learning_list,["","enable","enable","1.0"]]})},d=k=>{r({...n,learning_list:n.learning_list.filter((T,E)=>E!==k)})},h=(k,T,E)=>{const R=[...n.learning_list];R[k][T]=E,r({...n,learning_list:R})},x=({rule:k})=>{const T=`["${k[0]}", "${k[1]}", "${k[2]}", "${k[3]}"]`;return e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(wa,{className:"w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:T}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},f=()=>{r({...n,expression_groups:[...n.expression_groups,[]]})},j=k=>{r({...n,expression_groups:n.expression_groups.filter((T,E)=>E!==k)})},p=k=>{const T=[...n.expression_groups];T[k]=[...T[k],""],r({...n,expression_groups:T})},w=(k,T)=>{const E=[...n.expression_groups];E[k]=E[k].filter((R,K)=>K!==T),r({...n,expression_groups:E})},v=(k,T,E)=>{const R=[...n.expression_groups];R[k][T]=E,r({...n,expression_groups:R})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达学习配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置麦麦如何学习和使用表达方式"})]}),e.jsxs(y,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.learning_list.map((k,T)=>{const E=n.learning_list.some((H,z)=>z!==T&&H[0]===""),R=k[0]==="",K=k[0].split(":"),U=K[0]||"qq",A=K[1]||"",Z=K[2]||"group";return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["规则 ",T+1," ",R&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{rule:k}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除学习规则 ",T+1," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d(T),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(He,{value:R?"global":"specific",onValueChange:H=>{H==="global"?h(T,0,""):h(T,0,"qq::group")},disabled:E&&!R,children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"global",children:"全局配置"}),e.jsx(ne,{value:"specific",disabled:E&&!R,children:"详细配置"})]})]}),E&&!R&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!R&&e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"平台"}),e.jsxs(He,{value:U,onValueChange:H=>{h(T,0,`${H}:${A}:${Z}`)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"qq",children:"QQ"}),e.jsx(ne,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:A,onChange:H=>{h(T,0,`${U}:${H.target.value}:${Z}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"类型"}),e.jsxs(He,{value:Z,onValueChange:H=>{h(T,0,`${U}:${A}:${H}`)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"group",children:"群组(group)"}),e.jsx(ne,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",k[0]||"(未设置)"]})]}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(Ve,{checked:k[1]==="enable",onCheckedChange:H=>h(T,1,H?"enable":"disable")})]})}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(Ve,{checked:k[2]==="enable",onCheckedChange:H=>h(T,2,H?"enable":"disable")})]})}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-xs font-medium",children:"学习强度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"5",value:k[3],onChange:H=>{const z=parseFloat(H.target.value);isNaN(z)||h(T,3,Math.max(0,Math.min(5,z)).toFixed(1))},className:"w-20 h-8 text-xs"})]}),e.jsx(Ma,{value:[parseFloat(k[3])||1],onValueChange:H=>h(T,3,H[0].toFixed(1)),min:0,max:5,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0 (不学习)"}),e.jsx("span",{children:"2.5"}),e.jsx("span",{children:"5.0 (快速学习)"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响学习频率,最短学习间隔 = 300/学习强度(秒)"})]})]})]},T)}),n.learning_list.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无学习规则,点击"添加规则"开始配置'})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达反思配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置麦麦主动向管理员询问表达方式是否合适的功能"})]}),e.jsx(Ve,{checked:n.reflect,onCheckedChange:k=>r({...n,reflect:k})})]}),n.reflect&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("span",{className:"text-sm font-medium",children:"反思操作员"})}),e.jsx("div",{className:"space-y-4",children:(()=>{const T=(n.reflect_operator_id||"").split(":"),E=T[0]||"qq",R=T[1]||"",K=T[2]||"private";return e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"平台"}),e.jsxs(He,{value:E,onValueChange:U=>{r({...n,reflect_operator_id:`${U}:${R}:${K}`})},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"qq",children:"QQ"}),e.jsx(ne,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"用户/群 ID"}),e.jsx(ce,{value:R,onChange:U=>{r({...n,reflect_operator_id:`${E}:${U.target.value}:${K}`})},placeholder:"输入 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"类型"}),e.jsxs(He,{value:K,onValueChange:U=>{r({...n,reflect_operator_id:`${E}:${R}:${U}`})},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"private",children:"私聊(private)"}),e.jsx(ne,{value:"group",children:"群组(group)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前操作员 ID:",n.reflect_operator_id||"(未设置)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会向此操作员询问表达方式是否合适"})]})})()})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"允许反思的聊天流"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"只有在此列表中的聊天流才会提出问题并跟踪。如果列表为空,则所有聊天流都可以进行表达反思"})]}),e.jsxs(y,{onClick:()=>{r({...n,allow_reflect:[...n.allow_reflect||[],"qq::group"]})},size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加聊天流"]})]}),e.jsxs("div",{className:"space-y-2",children:[(n.allow_reflect||[]).map((k,T)=>{const E=k.split(":"),R=E[0]||"qq",K=E[1]||"",U=E[2]||"group";return e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsxs(He,{value:R,onValueChange:A=>{const Z=[...n.allow_reflect];Z[T]=`${A}:${K}:${U}`,r({...n,allow_reflect:Z})},children:[e.jsx(Re,{className:"w-24",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"qq",children:"QQ"}),e.jsx(ne,{value:"wx",children:"微信"})]})]}),e.jsx(ce,{value:K,onChange:A=>{const Z=[...n.allow_reflect];Z[T]=`${R}:${A.target.value}:${U}`,r({...n,allow_reflect:Z})},placeholder:"ID",className:"flex-1 font-mono text-sm"}),e.jsxs(He,{value:U,onValueChange:A=>{const Z=[...n.allow_reflect];Z[T]=`${R}:${K}:${A}`,r({...n,allow_reflect:Z})},children:[e.jsx(Re,{className:"w-32",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"group",children:"群组"}),e.jsx(ne,{value:"private",children:"私聊"})]})]}),e.jsx(y,{onClick:()=>{r({...n,allow_reflect:n.allow_reflect.filter((A,Z)=>Z!==T)})},size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})]},T)}),(!n.allow_reflect||n.allow_reflect.length===0)&&e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"列表为空,所有聊天流都可以进行表达反思"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达共享组配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置不同聊天流之间如何共享学到的表达方式"})]}),e.jsxs(y,{onClick:f,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.expression_groups.map((k,T)=>{const E=n.learning_list.map(R=>R[0]).filter(R=>R!=="");return e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["共享组 ",T+1,k.length===1&&k[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{onClick:()=>p(T),size:"sm",variant:"outline",children:e.jsx(ot,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除共享组 ",T+1," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>j(T),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:k.map((R,K)=>e.jsx(sw,{member:R,groupIndex:T,memberIndex:K,availableChatIds:E,onUpdate:v,onRemove:w},`${T}-${K}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},T)}),n.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})}function aw({emojiConfig:n,memoryConfig:r,toolConfig:c,onEmojiChange:d,onMemoryChange:h,onToolChange:x}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"工具设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_tool",checked:c.enable_tool,onCheckedChange:f=>x({...c,enable_tool:f})}),e.jsx(b,{htmlFor:"enable_tool",className:"cursor-pointer",children:"启用工具系统"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"允许麦麦使用各种工具来增强功能"})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"记忆设置"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(ce,{id:"max_agent_iterations",type:"number",min:"1",value:r.max_agent_iterations,onChange:f=>h({...r,max_agent_iterations:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1(不深入思考)"})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"表情包设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsx(ce,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:n.emoji_chance,onChange:f=>d({...n,emoji_chance:parseFloat(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"范围 0-1,越大越容易发送表情包"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",value:n.max_reg_num,onChange:f=>d({...n,max_reg_num:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦最多可以注册的表情包数量"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",value:n.check_interval,onChange:f=>d({...n,check_interval:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包(注册、破损、删除)的时间间隔"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"do_replace",checked:n.do_replace,onCheckedChange:f=>d({...n,do_replace:f})}),e.jsx(b,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:f=>d({...n,steal_emoji:f})}),e.jsx(b,{htmlFor:"steal_emoji",className:"cursor-pointer",children:"偷取表情包"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"允许麦麦将看到的表情包据为己有"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:f=>d({...n,content_filtration:f})}),e.jsx(b,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),n.content_filtration&&e.jsxs("div",{className:"grid gap-2 pl-6 border-l-2 border-primary/20",children:[e.jsx(b,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",value:n.filtration_prompt,onChange:f=>d({...n,filtration_prompt:f.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}function lw({keywordReactionConfig:n,responsePostProcessConfig:r,chineseTypoConfig:c,responseSplitterConfig:d,onKeywordReactionChange:h,onResponsePostProcessChange:x,onChineseTypoChange:f,onResponseSplitterChange:j}){const p=()=>{h({...n,regex_rules:[...n.regex_rules,{regex:[""],reaction:""}]})},w=z=>{h({...n,regex_rules:n.regex_rules.filter((B,X)=>X!==z)})},v=(z,B,X)=>{const S=[...n.regex_rules];B==="regex"&&typeof X=="string"?S[z]={...S[z],regex:[X]}:B==="reaction"&&typeof X=="string"&&(S[z]={...S[z],reaction:X}),h({...n,regex_rules:S})},k=({regex:z,reaction:B,onRegexChange:X,onReactionChange:S})=>{const[O,te]=u.useState(!1),[he,Ne]=u.useState(""),[ye,pe]=u.useState(null),[je,_e]=u.useState(""),[N,G]=u.useState({}),[q,ie]=u.useState(""),_=u.useRef(null),[me,xe]=u.useState("build"),$=L=>L.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),de=(L,F=0)=>{const D=_.current;if(!D)return;const ee=D.selectionStart||0,we=D.selectionEnd||0,ze=z.substring(0,ee)+L+z.substring(we);X(ze),setTimeout(()=>{const ss=ee+L.length+F;D.setSelectionRange(ss,ss),D.focus()},0)};u.useEffect(()=>{if(!z||!he){pe(null),G({}),ie(B),_e("");return}try{const L=$(z),F=new RegExp(L,"g"),D=he.match(F);pe(D),_e("");const we=new RegExp(L).exec(he);if(we&&we.groups){G(we.groups);let ze=B;Object.entries(we.groups).forEach(([ss,Ze])=>{ze=ze.replace(new RegExp(`\\[${ss}\\]`,"g"),Ze||"")}),ie(ze)}else G({}),ie(B)}catch(L){_e(L.message),pe(null),G({}),ie(B)}},[z,he,B]);const ge=()=>{if(!he||!ye||ye.length===0)return e.jsx("span",{className:"text-muted-foreground",children:he||"请输入测试文本"});try{const L=$(z),F=new RegExp(L,"g");let D=0;const ee=[];let we;for(;(we=F.exec(he))!==null;)we.index>D&&ee.push(e.jsx("span",{children:he.substring(D,we.index)},`text-${D}`)),ee.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:we[0]},`match-${we.index}`)),D=we.index+we[0].length;return D)",desc:"Python风格命名捕获组",moveCursor:-1},{label:"非捕获组",pattern:"(?:)",desc:"分组但不保存匹配结果",moveCursor:-1}]},{category:"字符类",items:[{label:"字符集",pattern:"[]",desc:"匹配括号内的任意字符",moveCursor:-1},{label:"排除字符",pattern:"[^]",desc:"匹配不在括号内的字符",moveCursor:-1},{label:"范围",pattern:"[a-z]",desc:"匹配a到z的字符"},{label:"中文字符",pattern:"[\\u4e00-\\u9fa5]",desc:"匹配中文汉字"}]},{category:"常用模板",items:[{label:"捕获词语",pattern:"(?P\\S+)",desc:"捕获一个词语"},{label:"捕获句子",pattern:"(?P.+)",desc:"捕获整个句子"},{label:"捕获数字",pattern:"(?P\\d+)",desc:"捕获一个或多个数字"},{label:"可选词语",pattern:"(?:词语1|词语2)",desc:"匹配多个可选项之一"}]}];return e.jsxs(Rs,{open:O,onOpenChange:te,children:[e.jsx(ni,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",children:[e.jsx(ao,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(zs,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"正则表达式编辑器"}),e.jsx(Ys,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(Pe,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(Kt,{value:me,onValueChange:L=>xe(L),className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2",children:[e.jsx($e,{value:"build",children:"🔧 构建器"}),e.jsx($e,{value:"test",children:"🧪 测试器"})]}),e.jsxs(We,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ce,{ref:_,value:z,onChange:L=>X(L.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(Bs,{value:B,onChange:L=>S(L.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[le.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:L.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:L.items.map(F=>e.jsx(y,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>de(F.pattern,F.moveCursor||0),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("span",{className:"text-xs font-medium",children:F.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:F.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:F.desc})]})},F.label))})]},L.category)),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:"完整示例模板"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("^(?P\\S{1,20})是这样的$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:["^(?P\\S","{1,20}",")是这样的$"]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「某事物是这样的」并捕获事物名称"})]})}),e.jsx(y,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「我没要求你做某事」并捕获具体行为"})]})}),e.jsx(y,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("(?P.+?)(?:是|为什么|怎么)"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?P.+?)(?:是|为什么|怎么)"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"捕获问题主题词"})]})})]})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 使用提示"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"点击输入框设置光标位置,然后点击按钮插入模式"}),e.jsxs("li",{children:["命名捕获组格式:",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"(?P<名称>模式)"})]}),e.jsxs("li",{children:["在 reaction 中使用 ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"[名称]"})," 引用捕获的内容"]}),e.jsx("li",{children:"切换到测试器标签页验证正则表达式效果"})]})]})]}),e.jsxs(We,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:z||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(Bs,{id:"test-text",value:he,onChange:L=>Ne(L.target.value),placeholder:`在此输入要测试的文本... +例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),je&&e.jsxs("div",{className:"rounded-md bg-destructive/10 border border-destructive/20 p-3",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:"正则表达式错误"}),e.jsx("p",{className:"text-xs text-destructive/80 mt-1",children:je})]}),!je&&he&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:ye&&ye.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsxs("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["匹配成功 (",ye.length," 处)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-400"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"无匹配"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(Pe,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:ge()})})]}),Object.keys(N).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(Pe,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(N).map(([L,F])=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"font-mono font-semibold text-primary min-w-[80px]",children:["[",L,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:F})]},L))})})]}),Object.keys(N).length>0&&B&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(Pe,{className:"h-48 rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3",children:e.jsx("div",{className:"text-sm break-words",children:q})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"reaction 中的 [name] 已被替换为对应的捕获组值"})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 测试说明"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"匹配的文本会以黄色背景高亮显示"}),e.jsx("li",{children:"命名捕获组的值会显示在下方列表中"}),e.jsx("li",{children:"Reaction 替换预览显示最终生成的反应内容"}),e.jsx("li",{children:"如需修改正则,切换回构建器标签页"})]})]})]})]})})]})]})},T=()=>{h({...n,keyword_rules:[...n.keyword_rules,{keywords:[],reaction:""}]})},E=z=>{h({...n,keyword_rules:n.keyword_rules.filter((B,X)=>X!==z)})},R=(z,B,X)=>{const S=[...n.keyword_rules];typeof X=="string"&&(S[z]={...S[z],reaction:X}),h({...n,keyword_rules:S})},K=z=>{const B=[...n.keyword_rules];B[z]={...B[z],keywords:[...B[z].keywords||[],""]},h({...n,keyword_rules:B})},U=(z,B)=>{const X=[...n.keyword_rules];X[z]={...X[z],keywords:(X[z].keywords||[]).filter((S,O)=>O!==B)},h({...n,keyword_rules:X})},A=(z,B,X)=>{const S=[...n.keyword_rules],O=[...S[z].keywords||[]];O[B]=X,S[z]={...S[z],keywords:O},h({...n,keyword_rules:S})},Z=({rule:z})=>{const B=`{ regex = [${(z.regex||[]).map(X=>`"${X}"`).join(", ")}], reaction = "${z.reaction}" }`;return e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(wa,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(Pe,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:B})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},H=({rule:z})=>{const B=`[[keyword_reaction.keyword_rules]] +keywords = [${(z.keywords||[]).map(X=>`"${X}"`).join(", ")}] +reaction = "${z.reaction}"`;return e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(wa,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(Pe,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:B})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"关键词反应配置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置触发特定反应的关键词和正则表达式规则"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"正则表达式规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用正则表达式匹配消息内容"})]}),e.jsxs(y,{onClick:p,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.regex_rules.map((z,B)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["正则规则 ",B+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{regex:z.regex&&z.regex[0]||"",reaction:z.reaction,onRegexChange:X=>v(B,"regex",X),onReactionChange:X=>v(B,"reaction",X)}),e.jsx(Z,{rule:z}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除正则规则 ",B+1," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>w(B),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"正则表达式(Python 语法)"}),e.jsx(ce,{value:z.regex&&z.regex[0]||"",onChange:X=>v(B,"regex",X.target.value),placeholder:"例如:^(?P\\\\S{1,20})是这样的$ (点击正则编辑器按钮可视化构建)",className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'支持命名捕获组 (?Ppattern),可在 reaction 中使用 [name] 引用。点击"正则编辑器"可视化构建和测试!'})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Bs,{value:z.reaction,onChange:X=>v(B,"reaction",X.target.value),placeholder:`触发后麦麦的反应... +可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},B)),n.regex_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无正则规则,点击"添加正则规则"开始配置'})]})]}),e.jsxs("div",{className:"space-y-4 border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"关键词规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用关键词列表匹配消息内容"})]}),e.jsxs(y,{onClick:T,size:"sm",variant:"outline",children:[e.jsx(ot,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.keyword_rules.map((z,B)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["关键词规则 ",B+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{rule:z}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除关键词规则 ",B+1," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>E(B),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(y,{onClick:()=>K(B),size:"sm",variant:"ghost",children:[e.jsx(ot,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(z.keywords||[]).map((X,S)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:X,onChange:O=>A(B,S,O.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(y,{onClick:()=>U(B,S),size:"sm",variant:"ghost",children:e.jsx(es,{className:"h-4 w-4"})})]},S)),(!z.keywords||z.keywords.length===0)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:'暂无关键词,点击"添加关键词"开始配置'})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Bs,{value:z.reaction,onChange:X=>R(B,"reaction",X.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},B)),n.keyword_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无关键词规则,点击"添加关键词规则"开始配置'})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"回复后处理配置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_response_post_process",checked:r.enable_response_post_process,onCheckedChange:z=>x({...r,enable_response_post_process:z})}),e.jsx(b,{htmlFor:"enable_response_post_process",className:"cursor-pointer",children:"启用回复后处理"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"包括错别字生成器和回复分割器"})]}),r.enable_response_post_process&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(Ve,{id:"enable_chinese_typo",checked:c.enable,onCheckedChange:z=>f({...c,enable:z})}),e.jsx(b,{htmlFor:"enable_chinese_typo",className:"cursor-pointer font-semibold",children:"中文错别字生成器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"为回复添加随机错别字,让麦麦的回复更自然"}),c.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"error_rate",className:"text-xs font-medium",children:"单字替换概率"}),e.jsx(ce,{id:"error_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.error_rate,onChange:z=>f({...c,error_rate:parseFloat(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(ce,{id:"min_freq",type:"number",min:"0",value:c.min_freq,onChange:z=>f({...c,min_freq:parseInt(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"tone_error_rate",className:"text-xs font-medium",children:"声调错误概率"}),e.jsx(ce,{id:"tone_error_rate",type:"number",step:"0.01",min:"0",max:"1",value:c.tone_error_rate,onChange:z=>f({...c,tone_error_rate:parseFloat(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"word_replace_rate",className:"text-xs font-medium",children:"整词替换概率"}),e.jsx(ce,{id:"word_replace_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.word_replace_rate,onChange:z=>f({...c,word_replace_rate:parseFloat(z.target.value)})})]})]})]})}),e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(Ve,{id:"enable_response_splitter",checked:d.enable,onCheckedChange:z=>j({...d,enable:z})}),e.jsx(b,{htmlFor:"enable_response_splitter",className:"cursor-pointer font-semibold",children:"回复分割器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"控制回复的长度和句子数量"}),d.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(ce,{id:"max_length",type:"number",min:"1",value:d.max_length,onChange:z=>j({...d,max_length:parseInt(z.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(ce,{id:"max_sentence_num",type:"number",min:"1",value:d.max_sentence_num,onChange:z=>j({...d,max_sentence_num:parseInt(z.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大句子数量"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_kaomoji_protection",checked:d.enable_kaomoji_protection,onCheckedChange:z=>j({...d,enable_kaomoji_protection:z})}),e.jsx(b,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_overflow_return_all",checked:d.enable_overflow_return_all,onCheckedChange:z=>j({...d,enable_overflow_return_all:z})}),e.jsx(b,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}function nw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"情绪设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:n.enable_mood,onCheckedChange:c=>r({...n,enable_mood:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用情绪系统"})]}),n.enable_mood&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"情绪更新阈值"}),e.jsx(ce,{type:"number",min:"1",value:n.mood_update_threshold,onChange:c=>r({...n,mood_update_threshold:parseInt(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越高,更新越慢"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"情感特征"}),e.jsx(Bs,{value:n.emotion_style,onChange:c=>r({...n,emotion_style:c.target.value}),placeholder:"影响情绪的变化情况",rows:2})]})]})]})]})}function iw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"语音设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:n.enable_asr,onCheckedChange:c=>r({...n,enable_asr:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用语音识别"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后麦麦可以识别语音消息,需要配置语音识别模型"})]})}function rw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:n.enable,onCheckedChange:c=>r({...n,enable:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),n.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"LPMM 模式"}),e.jsxs(He,{value:n.lpmm_mode,onValueChange:c=>r({...n,lpmm_mode:c}),children:[e.jsx(Re,{children:e.jsx(qe,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"classic",children:"经典模式"}),e.jsx(ne,{value:"agent",children:"Agent 模式"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"同义词搜索 TopK"}),e.jsx(ce,{type:"number",min:"1",value:n.rag_synonym_search_top_k,onChange:c=>r({...n,rag_synonym_search_top_k:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"同义词阈值"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:n.rag_synonym_threshold,onChange:c=>r({...n,rag_synonym_threshold:parseFloat(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"实体提取线程数"}),e.jsx(ce,{type:"number",min:"1",value:n.info_extraction_workers,onChange:c=>r({...n,info_extraction_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"嵌入向量维度"}),e.jsx(ce,{type:"number",min:"1",value:n.embedding_dimension,onChange:c=>r({...n,embedding_dimension:parseInt(c.target.value)})})]})]})]})]})]})}function cw({config:n,onChange:r}){const[c,d]=u.useState(""),[h,x]=u.useState("WARNING"),f=()=>{c&&!n.suppress_libraries.includes(c)&&(r({...n,suppress_libraries:[...n.suppress_libraries,c]}),d(""))},j=E=>{r({...n,suppress_libraries:n.suppress_libraries.filter(R=>R!==E)})},p=()=>{c&&!n.library_log_levels[c]&&(r({...n,library_log_levels:{...n.library_log_levels,[c]:h}}),d(""),x("WARNING"))},w=E=>{const R={...n.library_log_levels};delete R[E],r({...n,library_log_levels:R})},v=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],k=["FULL","compact","lite"],T=["none","title","full"];return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"日志配置"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日期格式"}),e.jsx(ce,{value:n.date_style,onChange:E=>r({...n,date_style:E.target.value}),placeholder:"例如: m-d H:i:s"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"m=月, d=日, H=时, i=分, s=秒"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日志级别样式"}),e.jsxs(He,{value:n.log_level_style,onValueChange:E=>r({...n,log_level_style:E}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:k.map(E=>e.jsx(ne,{value:E,children:E},E))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日志文本颜色"}),e.jsxs(He,{value:n.color_text,onValueChange:E=>r({...n,color_text:E}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:T.map(E=>e.jsx(ne,{value:E,children:E},E))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"全局日志级别"}),e.jsxs(He,{value:n.log_level,onValueChange:E=>r({...n,log_level:E}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:v.map(E=>e.jsx(ne,{value:E,children:E},E))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"控制台日志级别"}),e.jsxs(He,{value:n.console_log_level,onValueChange:E=>r({...n,console_log_level:E}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:v.map(E=>e.jsx(ne,{value:E,children:E},E))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"文件日志级别"}),e.jsxs(He,{value:n.file_log_level,onValueChange:E=>r({...n,file_log_level:E}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsx(Le,{children:v.map(E=>e.jsx(ne,{value:E,children:E},E))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:E=>d(E.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),f())}}),e.jsx(y,{onClick:f,size:"sm",className:"flex-shrink-0",children:e.jsx(ot,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.suppress_libraries.map(E=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-3 py-1 rounded-md",children:[e.jsx("span",{className:"text-sm",children:E}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>j(E),children:e.jsx(es,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},E))})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:E=>d(E.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(He,{value:h,onValueChange:x,children:[e.jsx(Re,{className:"w-32",children:e.jsx(qe,{})}),e.jsx(Le,{children:v.map(E=>e.jsx(ne,{value:E,children:E},E))})]}),e.jsx(y,{onClick:p,size:"sm",children:e.jsx(ot,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.library_log_levels).map(([E,R])=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-medium",children:E}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:R}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>w(E),children:e.jsx(es,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},E))})]})]})}function ow({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"调试配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(Ve,{checked:n.show_prompt,onCheckedChange:c=>r({...n,show_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(Ve,{checked:n.show_replyer_prompt,onCheckedChange:c=>r({...n,show_replyer_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(Ve,{checked:n.show_replyer_reasoning,onCheckedChange:c=>r({...n,show_replyer_reasoning:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(Ve,{checked:n.show_jargon_prompt,onCheckedChange:c=>r({...n,show_jargon_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示记忆检索 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示记忆检索相关的提示词"})]}),e.jsx(Ve,{checked:n.show_memory_prompt,onCheckedChange:c=>r({...n,show_memory_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Planner Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 Planner 的提示词和原始返回结果"})]}),e.jsx(Ve,{checked:n.show_planner_prompt,onCheckedChange:c=>r({...n,show_planner_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 LPMM 相关文段"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 LPMM 知识库找到的相关文段日志"})]}),e.jsx(Ve,{checked:n.show_lpmm_paragraph,onCheckedChange:c=>r({...n,show_lpmm_paragraph:c})})]})]})]})}function dw({config:n,onChange:r}){const[c,d]=u.useState(""),h=()=>{c&&!n.auth_token.includes(c)&&(r({...n,auth_token:[...n.auth_token,c]}),d(""))},x=f=>{r({...n,auth_token:n.auth_token.filter((j,p)=>p!==f)})};return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"MaimMessage 服务配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"启用自定义服务器"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否使用自定义的 MaimMessage 服务器"})]}),e.jsx(Ve,{checked:n.use_custom,onCheckedChange:f=>r({...n,use_custom:f})})]}),n.use_custom&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"主机地址"}),e.jsx(ce,{value:n.host,onChange:f=>r({...n,host:f.target.value}),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"端口号"}),e.jsx(ce,{type:"number",value:n.port,onChange:f=>r({...n,port:parseInt(f.target.value)}),placeholder:"8090"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"连接模式"}),e.jsxs(He,{value:n.mode,onValueChange:f=>r({...n,mode:f}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"ws",children:"WebSocket (ws)"}),e.jsx(ne,{value:"tcp",children:"TCP"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:n.use_wss,onCheckedChange:f=>r({...n,use_wss:f}),disabled:n.mode!=="ws"}),e.jsx(b,{children:"使用 WSS 安全连接"})]})]}),n.use_wss&&n.mode==="ws"&&e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"SSL 证书文件路径"}),e.jsx(ce,{value:n.cert_file,onChange:f=>r({...n,cert_file:f.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"SSL 密钥文件路径"}),e.jsx(ce,{value:n.key_file,onChange:f=>r({...n,key_file:f.target.value}),placeholder:"key.pem"})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"认证令牌"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"用于 API 验证,为空则不启用验证"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:f=>d(f.target.value),placeholder:"输入认证令牌",onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}}),e.jsx(y,{onClick:h,size:"sm",children:e.jsx(ot,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:n.auth_token.map((f,j)=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-mono",children:f}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>x(j),children:e.jsx(es,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},j))})]})]})}function uw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"统计信息"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(Ve,{checked:n.enable,onCheckedChange:c=>r({...n,enable:c})})]})]})}const ii=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:c,className:Q("w-full caption-bottom text-sm",n),...r})}));ii.displayName="Table";const ri=u.forwardRef(({className:n,...r},c)=>e.jsx("thead",{ref:c,className:Q("[&_tr]:border-b",n),...r}));ri.displayName="TableHeader";const ci=u.forwardRef(({className:n,...r},c)=>e.jsx("tbody",{ref:c,className:Q("[&_tr:last-child]:border-0",n),...r}));ci.displayName="TableBody";const mw=u.forwardRef(({className:n,...r},c)=>e.jsx("tfoot",{ref:c,className:Q("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n),...r}));mw.displayName="TableFooter";const gt=u.forwardRef(({className:n,...r},c)=>e.jsx("tr",{ref:c,className:Q("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n),...r}));gt.displayName="TableRow";const ls=u.forwardRef(({className:n,...r},c)=>e.jsx("th",{ref:c,className:Q("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...r}));ls.displayName="TableHead";const Qe=u.forwardRef(({className:n,...r},c)=>e.jsx("td",{ref:c,className:Q("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...r}));Qe.displayName="TableCell";const hw=u.forwardRef(({className:n,...r},c)=>e.jsx("caption",{ref:c,className:Q("mt-4 text-sm text-muted-foreground",n),...r}));hw.displayName="TableCaption";const oo=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt,{ref:c,className:Q("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...r}));oo.displayName=Lt.displayName;const uo=u.forwardRef(({className:n,...r},c)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(_t,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Lt.Input,{ref:c,className:Q("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",n),...r})]}));uo.displayName=Lt.Input.displayName;const mo=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.List,{ref:c,className:Q("max-h-[300px] overflow-y-auto overflow-x-hidden",n),...r}));mo.displayName=Lt.List.displayName;const ho=u.forwardRef((n,r)=>e.jsx(Lt.Empty,{ref:r,className:"py-6 text-center text-sm",...n}));ho.displayName=Lt.Empty.displayName;const vr=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Group,{ref:c,className:Q("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",n),...r}));vr.displayName=Lt.Group.displayName;const xw=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Separator,{ref:c,className:Q("-mx-1 h-px bg-border",n),...r}));xw.displayName=Lt.Separator.displayName;const yr=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Item,{ref:c,className:Q("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n),...r}));yr.displayName=Lt.Item.displayName;const yt=u.forwardRef(({className:n,...r},c)=>e.jsx(og,{ref:c,className:Q("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...r,children:e.jsx(pN,{className:Q("grid place-content-center text-current"),children:e.jsx(fa,{className:"h-4 w-4"})})}));yt.displayName=og.displayName;const Bg=u.createContext(null),Hg="maibot-completed-tours";function fw(){try{const n=localStorage.getItem(Hg);return n?new Set(JSON.parse(n)):new Set}catch{return new Set}}function dp(n){localStorage.setItem(Hg,JSON.stringify([...n]))}function pw({children:n}){const[r,c]=u.useState({activeTourId:null,stepIndex:0,isRunning:!1}),d=u.useRef(new Map),[,h]=u.useState(0),[x,f]=u.useState(fw),j=u.useCallback((H,z)=>{d.current.set(H,z),h(B=>B+1)},[]),p=u.useCallback(H=>{d.current.delete(H),c(z=>z.activeTourId===H?{...z,activeTourId:null,isRunning:!1,stepIndex:0}:z)},[]),w=u.useCallback((H,z=0)=>{d.current.has(H)&&c({activeTourId:H,stepIndex:z,isRunning:!0})},[]),v=u.useCallback(()=>{c(H=>({...H,isRunning:!1}))},[]),k=u.useCallback(H=>{c(z=>({...z,stepIndex:H}))},[]),T=u.useCallback(()=>{c(H=>({...H,stepIndex:H.stepIndex+1}))},[]),E=u.useCallback(()=>{c(H=>({...H,stepIndex:Math.max(0,H.stepIndex-1)}))},[]),R=u.useCallback(()=>r.activeTourId?d.current.get(r.activeTourId)||[]:[],[r.activeTourId]),K=u.useCallback(H=>{f(z=>{const B=new Set(z);return B.add(H),dp(B),B})},[]),U=u.useCallback(H=>{const{action:z,index:B,status:X,type:S}=H,O=["finished","skipped"];if(z==="close"){c(te=>({...te,isRunning:!1,stepIndex:0}));return}O.includes(X)?c(te=>(X==="finished"&&te.activeTourId&&setTimeout(()=>K(te.activeTourId),0),{...te,isRunning:!1,stepIndex:0})):S==="step:after"&&(z==="next"?c(te=>({...te,stepIndex:B+1})):z==="prev"&&c(te=>({...te,stepIndex:B-1})))},[K]),A=u.useCallback(H=>x.has(H),[x]),Z=u.useCallback(H=>{f(z=>{const B=new Set(z);return B.delete(H),dp(B),B})},[]);return e.jsx(Bg.Provider,{value:{state:r,tours:d.current,registerTour:j,unregisterTour:p,startTour:w,stopTour:v,goToStep:k,nextStep:T,prevStep:E,getCurrentSteps:R,handleJoyrideCallback:U,isTourCompleted:A,markTourCompleted:K,resetTourCompleted:Z},children:n})}function Pu(){const n=u.useContext(Bg);if(!n)throw new Error("useTour must be used within a TourProvider");return n}const gw={options:{zIndex:1e4,primaryColor:"hsl(var(--primary))",textColor:"hsl(var(--foreground))",backgroundColor:"hsl(var(--background))",arrowColor:"hsl(var(--background))",overlayColor:"rgba(0, 0, 0, 0.5)"},tooltip:{borderRadius:"var(--radius)",padding:"1rem"},tooltipContainer:{textAlign:"left"},tooltipTitle:{fontSize:"1rem",fontWeight:600,marginBottom:"0.5rem"},tooltipContent:{fontSize:"0.875rem",padding:"0.5rem 0"},buttonNext:{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))",borderRadius:"calc(var(--radius) - 2px)",fontSize:"0.875rem",padding:"0.5rem 1rem"},buttonBack:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem",marginRight:"0.5rem"},buttonSkip:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem"},buttonClose:{color:"hsl(var(--muted-foreground))"},spotlight:{borderRadius:"var(--radius)"}},jw={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function vw(){const{state:n,getCurrentSteps:r,handleJoyrideCallback:c}=Pu(),d=r(),[h,x]=u.useState(!1),f=u.useRef(n.stepIndex),j=u.useRef(null);u.useEffect(()=>{f.current!==n.stepIndex&&(x(!1),f.current=n.stepIndex)},[n.stepIndex]),u.useEffect(()=>{if(!n.isRunning||d.length===0){x(!1);return}const v=d[n.stepIndex];if(!v){x(!1);return}const k=v.target;if(k==="body"){x(!0);return}x(!1);const T=setTimeout(()=>{const E=()=>{const A=document.querySelector(k);if(A){const Z=A.getBoundingClientRect();if(Z.width>0&&Z.height>0)return!0}return!1};if(E()){setTimeout(()=>x(!0),100);return}const R=setInterval(()=>{E()&&(clearInterval(R),setTimeout(()=>x(!0),100))},100),K=setTimeout(()=>{clearInterval(R),x(!0)},5e3),U=()=>{clearInterval(R),clearTimeout(K)};j.current=U},150);return()=>{clearTimeout(T),j.current&&(j.current(),j.current=null)}},[n.isRunning,n.stepIndex,d]);const p=u.useRef(null);if(u.useEffect(()=>{let v=document.getElementById("tour-portal-container");return v||(v=document.createElement("div"),v.id="tour-portal-container",v.style.cssText="position: fixed; top: 0; left: 0; z-index: 99999; pointer-events: none;",document.body.appendChild(v)),p.current=v,()=>{}},[]),!n.isRunning||d.length===0||!h)return null;const w=e.jsx(rb,{steps:d,stepIndex:n.stepIndex,run:n.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:c,styles:gw,locale:jw,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${n.stepIndex}`);return p.current?fy.createPortal(w,p.current):w}const ll="model-assignment-tour",qg=[{target:"body",content:"本引导旨在帮助你配置模型提供商和对应的模型,并为麦麦的各个组件分配合适的模型。",placement:"center",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="sidebar-model-provider"]',content:'第一步,你需要配置模型提供商。模型提供商决定了你要使用谁家的模型,无论是单一厂商(如 DeepSeek),还是模型平台(如 Siliconflow),都可以在这里进行配置。点击"下一步"进入配置页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-provider-button"]',content:'点击"添加提供商"按钮,开始配置你的模型提供商。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="provider-dialog"]',content:"在这里,你可以选择你想要配置的模型提供商,填写相关信息后保存即可。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-name-input"]',content:"这里的名称是你为这个模型提供商起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-apikey-input"]',content:"这里需要填写你从模型提供商那里获取的 API 密钥,用于验证和调用模型服务。对于不同的提供商,获取 API 密钥的方式可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-url-input"]',content:"这里需要填写模型提供商的 API 访问地址,确保填写正确以便系统能够连接到模型服务。对于不同的提供商,API 地址可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-template-select"]',content:"当然,如果你不知道如何填写这些信息,很多模型提供商在这里都提供了预设的模板供你选择,选择对应的模板后,相关信息会自动填充。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-save-button"]',content:"填写完所有信息后,点击保存按钮,模型提供商就配置完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-cancel-button"]',content:"因为这次咱们什么都没有填写,所以点击取消按钮退出吧。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="sidebar-model-management"]',content:'配置好模型提供商后,接下来我们需要为麦麦添加模型并分配功能。点击"下一步"进入模型管理页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-model-button"]',content:'在为麦麦的组件分配模型之前,首先需要添加你想要分配的模型,点击"添加模型"按钮开始添加。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="model-dialog"]',content:"在这里,你可以选择你之前配置好的模型提供商,然后选择对应的模型来添加。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-name-input"]',content:"这里的模型名称是你为这个模型起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-provider-select"]',content:"在这里选择你之前配置好的模型提供商,这样系统才能知道你要添加哪个提供商的模型。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-identifier-input"]',content:"这里需要填写你想要添加的模型的标识符,不同的模型提供商可能有不同的标识符格式,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-save-button"]',content:"填写完所有信息后,点击保存按钮,模型就添加完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-cancel-button"]',content:"当然,因为这次咱们什么都没有填写,所以直接点击取消按钮退出吧,等你准备好了再来添加模型。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="tasks-tab-trigger"]',content:'最后一步,添加好模型后,切换到"为模型分配功能"标签页,为麦麦的各个组件分配合适的模型。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="task-model-select"]',content:"在这里,你可以为每个组件选择一个或多个合适的模型,选择完成后配置会自动保存。恭喜你完成了模型配置的学习!",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1}],Gg={0:"/config/model",1:"/config/model",2:"/config/modelProvider",3:"/config/modelProvider",4:"/config/modelProvider",5:"/config/modelProvider",6:"/config/modelProvider",7:"/config/modelProvider",8:"/config/modelProvider",9:"/config/modelProvider",10:"/config/modelProvider",11:"/config/model",12:"/config/model",13:"/config/model",14:"/config/model",15:"/config/model",16:"/config/model",17:"/config/model",18:"/config/model",19:"/config/model"},rr=[{id:"siliconflow",name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",client_type:"openai",display_name:"硅基流动 (SiliconFlow)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"deepseek",name:"DeepSeek",base_url:"https://api.deepseek.com",client_type:"openai",display_name:"DeepSeek",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"rinkoai",name:"RinkoAI",base_url:"https://rinkoai.com/v1",client_type:"openai",display_name:"RinkoAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"zhipu",name:"ZhipuAI",base_url:"https://open.bigmodel.cn/api/paas/v4",client_type:"openai",display_name:"智谱 AI (ZhipuAI / GLM)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"moonshot",name:"Moonshot",base_url:"https://api.moonshot.cn/v1",client_type:"openai",display_name:"月之暗面 (Moonshot / Kimi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"doubao",name:"Doubao",base_url:"https://ark.cn-beijing.volces.com/api/v3",client_type:"openai",display_name:"字节豆包 (Doubao)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"alibaba",name:"Alibaba",base_url:"https://dashscope.aliyuncs.com/compatible-mode/v1",client_type:"openai",display_name:"阿里云百炼 (Alibaba Qwen)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"baichuan",name:"Baichuan",base_url:"https://api.baichuan-ai.com/v1",client_type:"openai",display_name:"百川智能 (Baichuan)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"minimax",name:"MiniMax",base_url:"https://api.minimax.chat/v1",client_type:"openai",display_name:"MiniMax (海螺 AI)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"stepfun",name:"StepFun",base_url:"https://api.stepfun.com/v1",client_type:"openai",display_name:"阶跃星辰 (StepFun)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"lingyi",name:"Lingyi",base_url:"https://api.lingyiwanwu.com/v1",client_type:"openai",display_name:"零一万物 (Lingyi / Yi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"openai",name:"OpenAI",base_url:"https://api.openai.com/v1",client_type:"openai",display_name:"OpenAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"xai",name:"xAI",base_url:"https://api.x.ai/v1",client_type:"openai",display_name:"xAI (Grok)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"anthropic",name:"Anthropic",base_url:"https://api.anthropic.com/v1",client_type:"openai",display_name:"Anthropic (Claude)"},{id:"gemini",name:"Gemini",base_url:"https://generativelanguage.googleapis.com/v1beta",client_type:"gemini",display_name:"Google Gemini",modelFetcher:{endpoint:"/models",parser:"gemini"}},{id:"cohere",name:"Cohere",base_url:"https://api.cohere.ai/v1",client_type:"openai",display_name:"Cohere"},{id:"groq",name:"Groq",base_url:"https://api.groq.com/openai/v1",client_type:"openai",display_name:"Groq",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"together",name:"Together AI",base_url:"https://api.together.xyz/v1",client_type:"openai",display_name:"Together AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"fireworks",name:"Fireworks",base_url:"https://api.fireworks.ai/inference/v1",client_type:"openai",display_name:"Fireworks AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"mistral",name:"Mistral",base_url:"https://api.mistral.ai/v1",client_type:"openai",display_name:"Mistral AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"perplexity",name:"Perplexity",base_url:"https://api.perplexity.ai",client_type:"openai",display_name:"Perplexity AI"},{id:"custom",name:"",base_url:"",client_type:"openai",display_name:"自定义"}];function up(n){return n?n.replace(/\/+$/,"").toLowerCase():""}function yw(n){if(!n)return null;const r=up(n);return rr.find(c=>c.id!=="custom"&&up(c.base_url)===r)||null}function Nw(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[p,w]=u.useState(!1),[v,k]=u.useState(!1),[T,E]=u.useState(!1),[R,K]=u.useState(!1),[U,A]=u.useState(null),[Z,H]=u.useState(null),[z,B]=u.useState("custom"),[X,S]=u.useState(!1),[O,te]=u.useState(!1),[he,Ne]=u.useState(null),[ye,pe]=u.useState(!1),[je,_e]=u.useState(""),[N,G]=u.useState(new Set),[q,ie]=u.useState(!1),[_,me]=u.useState(1),[xe,$]=u.useState(20),[de,ge]=u.useState(""),[le,L]=u.useState({}),[F,D]=u.useState(new Set),[ee,we]=u.useState(new Map),{toast:ze}=Hs(),ss=Jt(),{state:Ze,goToStep:Ls,registerTour:Gs}=Pu(),re=u.useRef(null),be=u.useRef(!0);u.useEffect(()=>{Gs(ll,qg)},[Gs]),u.useEffect(()=>{if(Ze.activeTourId===ll&&Ze.isRunning){const W=Gg[Ze.stepIndex];W&&!window.location.pathname.endsWith(W.replace("/config/",""))&&ss({to:W})}},[Ze.stepIndex,Ze.activeTourId,Ze.isRunning,ss]);const Xe=u.useRef(Ze.stepIndex);u.useEffect(()=>{if(Ze.activeTourId===ll&&Ze.isRunning){const W=Xe.current,ve=Ze.stepIndex;W>=3&&W<=9&&ve<3&&K(!1),W>=10&&ve>=3&&ve<=9&&(L({}),B("custom"),A({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),H(null),pe(!1),K(!0)),Xe.current=ve}},[Ze.stepIndex,Ze.activeTourId,Ze.isRunning]),u.useEffect(()=>{if(Ze.activeTourId!==ll||!Ze.isRunning)return;const W=ve=>{const Me=ve.target,tt=Ze.stepIndex;tt===2&&Me.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Ls(3),300):tt===9&&Me.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>Ls(10),300)};return document.addEventListener("click",W,!0),()=>document.removeEventListener("click",W,!0)},[Ze,Ls]),u.useEffect(()=>{Ue()},[]);const Ue=async()=>{try{d(!0);const W=await ei();r(W.api_providers||[]),w(!1),be.current=!1}catch(W){console.error("加载配置失败:",W)}finally{d(!1)}},st=async()=>{try{k(!0),co().catch(()=>{}),E(!0)}catch(W){console.error("重启失败:",W),E(!1),ze({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),k(!1)}},It=async()=>{try{x(!0),re.current&&clearTimeout(re.current);const W=await ei();W.api_providers=n,await io(W),w(!1),ze({title:"保存成功",description:"正在重启麦麦..."}),await st()}catch(W){console.error("保存配置失败:",W),ze({title:"保存失败",description:W.message,variant:"destructive"}),x(!1)}},bt=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Je=()=>{E(!1),k(!1),ze({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},Be=u.useCallback(async W=>{if(!be.current)try{j(!0),await qu("api_providers",W),w(!1)}catch(ve){console.error("自动保存失败:",ve),w(!0)}finally{j(!1)}},[]);u.useEffect(()=>{if(!be.current)return w(!0),re.current&&clearTimeout(re.current),re.current=setTimeout(()=>{Be(n)},2e3),()=>{re.current&&clearTimeout(re.current)}},[n,Be]);const jt=async()=>{try{x(!0),re.current&&clearTimeout(re.current);const W=await ei();W.api_providers=n,await io(W),w(!1),ze({title:"保存成功",description:"模型提供商配置已保存"})}catch(W){console.error("保存配置失败:",W),ze({title:"保存失败",description:W.message,variant:"destructive"})}finally{x(!1)}},nt=(W,ve)=>{if(L({}),W){const Me=rr.find(tt=>tt.base_url===W.base_url&&tt.client_type===W.client_type);B(Me?.id||"custom"),A(W)}else B("custom"),A({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});H(ve),pe(!1),K(!0)},St=W=>{B(W),S(!1);const ve=rr.find(Me=>Me.id===W);ve&&ve.id!=="custom"?A(Me=>({...Me,name:ve.name,base_url:ve.base_url,client_type:ve.client_type})):ve?.id==="custom"&&A(Me=>({...Me,name:"",base_url:"",client_type:"openai"}))},Ct=u.useMemo(()=>z!=="custom",[z]),rl=async()=>{if(U?.api_key)try{await navigator.clipboard.writeText(U.api_key),ze({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{ze({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},cl=()=>{if(!U)return;const W={};if(U.name?.trim()||(W.name="请输入提供商名称"),U.base_url?.trim()||(W.base_url="请输入基础 URL"),U.api_key?.trim()||(W.api_key="请输入 API Key"),Object.keys(W).length>0){L(W);return}L({});const ve={...U,max_retry:U.max_retry??2,timeout:U.timeout??30,retry_interval:U.retry_interval??10};if(Z!==null){const Me=[...n];Me[Z]=ve,r(Me)}else r([...n,ve]);K(!1),A(null),H(null)},ol=W=>{if(!W&&U){const ve={...U,max_retry:U.max_retry??2,timeout:U.timeout??30,retry_interval:U.retry_interval??10};A(ve)}K(W)},Se=W=>{Ne(W),te(!0)},Oe=()=>{if(he!==null){const W=n.filter((ve,Me)=>Me!==he);r(W),ze({title:"删除成功",description:"提供商已从列表中移除"})}te(!1),Ne(null)},it=W=>{const ve=new Set(N);ve.has(W)?ve.delete(W):ve.add(W),G(ve)},dt=()=>{if(N.size===ut.length)G(new Set);else{const W=ut.map((ve,Me)=>n.findIndex(tt=>tt===ut[Me]));G(new Set(W))}},di=()=>{if(N.size===0){ze({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}ie(!0)},on=()=>{const W=n.filter((ve,Me)=>!N.has(Me));r(W),G(new Set),ie(!1),ze({title:"批量删除成功",description:`已删除 ${N.size} 个提供商`})},ut=n.filter(W=>{if(!je)return!0;const ve=je.toLowerCase();return W.name.toLowerCase().includes(ve)||W.base_url.toLowerCase().includes(ve)||W.client_type.toLowerCase().includes(ve)}),Pt=Math.ceil(ut.length/xe),Wt=ut.slice((_-1)*xe,_*xe),Ua=()=>{const W=parseInt(de);W>=1&&W<=Pt&&(me(W),ge(""))},Ut=async W=>{D(ve=>new Set(ve).add(W));try{const ve=await Q0(W);we(Me=>new Map(Me).set(W,ve)),ve.network_ok?ve.api_key_valid===!0?ze({title:"连接正常",description:`${W} 网络连接正常,API Key 有效 (${ve.latency_ms}ms)`}):ve.api_key_valid===!1?ze({title:"连接正常但 Key 无效",description:`${W} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):ze({title:"网络连接正常",description:`${W} 可以访问 (${ve.latency_ms}ms)`}):ze({title:"连接失败",description:ve.error||"无法连接到提供商",variant:"destructive"})}catch(ve){ze({title:"测试失败",description:ve.message,variant:"destructive"})}finally{D(ve=>{const Me=new Set(ve);return Me.delete(W),Me})}},Ba=async()=>{for(const W of n)await Ut(W.name)},_a=W=>{const ve=F.has(W),Me=ee.get(W);return ve?e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(vt,{className:"h-3 w-3 animate-spin"}),"测试中"]}):Me?Me.network_ok?Me.api_key_valid===!0?e.jsxs(Ye,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(pa,{className:"h-3 w-3"}),"正常"]}):Me.api_key_valid===!1?e.jsxs(Ye,{variant:"destructive",className:"gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(Ye,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(pa,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(Ye,{variant:"destructive",className:"gap-1",children:[e.jsx(jg,{className:"h-3 w-3"}),"离线"]}):null};return c?e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})}):e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"AI模型厂商配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理 AI 模型厂商的 API 配置"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[N.size>0&&e.jsxs(y,{onClick:di,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(es,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",N.size,")"]}),e.jsxs(y,{onClick:Ba,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:n.length===0||F.size>0,children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),F.size>0?`测试中 (${F.size})`:"测试全部"]}),e.jsxs(y,{onClick:()=>nt(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(ot,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(y,{onClick:jt,disabled:h||f||!p||v,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),h?"保存中...":f?"自动保存中...":p?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{disabled:h||f||v,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),v?"重启中...":p?"保存并重启":"重启麦麦"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重启麦麦?"}),e.jsx(us,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:p?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ha,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(xa,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Rs,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(zs,{className:"max-w-2xl",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx(Ys,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx($e,{value:"windows",children:"Windows"}),e.jsx($e,{value:"macos",children:"macOS"}),e.jsx($e,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:["在“进程”或“详细信息”标签页中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:"右键点击并选择“结束任务”"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"})," 打开 Spotlight,搜索“活动监视器”"]}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Js,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:p?It:st,children:p?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ha,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(xa,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Pe,{className:"h-[calc(100vh-260px)]",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索提供商名称、URL 或类型...",value:je,onChange:W=>_e(W.target.value),className:"pl-9"})]}),je&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",ut.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:ut.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:je?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):Wt.map((W,ve)=>{const Me=n.findIndex(tt=>tt===W);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-base truncate",children:W.name}),_a(W.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:W.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>Ut(W.name),disabled:F.has(W.name),title:"测试连接",children:F.has(W.name)?e.jsx(vt,{className:"h-4 w-4 animate-spin"}):e.jsx(ln,{className:"h-4 w-4"})}),e.jsx(y,{variant:"default",size:"sm",onClick:()=>nt(W,Me),children:e.jsx(nn,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(y,{size:"sm",onClick:()=>Se(Me),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(es,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"客户端类型"}),e.jsx("p",{className:"font-medium",children:W.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:W.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:W.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:W.retry_interval})]})]})]},ve)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(gt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:N.size===ut.length&&ut.length>0,onCheckedChange:dt})}),e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"基础URL"}),e.jsx(ls,{children:"客户端类型"}),e.jsx(ls,{className:"text-right",children:"最大重试"}),e.jsx(ls,{className:"text-right",children:"超时(秒)"}),e.jsx(ls,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:Wt.length===0?e.jsx(gt,{children:e.jsx(Qe,{colSpan:9,className:"text-center text-muted-foreground py-8",children:je?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):Wt.map((W,ve)=>{const Me=n.findIndex(tt=>tt===W);return e.jsxs(gt,{children:[e.jsx(Qe,{children:e.jsx(yt,{checked:N.has(Me),onCheckedChange:()=>it(Me)})}),e.jsx(Qe,{children:_a(W.name)||e.jsx(Ye,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Qe,{className:"font-medium",children:W.name}),e.jsx(Qe,{className:"max-w-xs truncate",title:W.base_url,children:W.base_url}),e.jsx(Qe,{children:W.client_type}),e.jsx(Qe,{className:"text-right",children:W.max_retry}),e.jsx(Qe,{className:"text-right",children:W.timeout}),e.jsx(Qe,{className:"text-right",children:W.retry_interval}),e.jsx(Qe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>Ut(W.name),disabled:F.has(W.name),title:"测试连接",children:F.has(W.name)?e.jsx(vt,{className:"h-4 w-4 animate-spin"}):e.jsx(ln,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"default",size:"sm",onClick:()=>nt(W,Me),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(y,{size:"sm",onClick:()=>Se(Me),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(es,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},ve)})})]})})}),ut.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(He,{value:xe.toString(),onValueChange:W=>{$(parseInt(W)),me(1),G(new Set)},children:[e.jsx(Re,{id:"page-size-provider",className:"w-20",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"10",children:"10"}),e.jsx(ne,{value:"20",children:"20"}),e.jsx(ne,{value:"50",children:"50"}),e.jsx(ne,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(_-1)*xe+1," 到"," ",Math.min(_*xe,ut.length)," 条,共 ",ut.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>me(1),disabled:_===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>me(W=>Math.max(1,W-1)),disabled:_===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:de,onChange:W=>ge(W.target.value),onKeyDown:W=>W.key==="Enter"&&Ua(),placeholder:_.toString(),className:"w-16 h-8 text-center",min:1,max:Pt}),e.jsx(y,{variant:"outline",size:"sm",onClick:Ua,disabled:!de,className:"h-8",children:"跳转"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>me(W=>W+1),disabled:_>=Pt,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>me(Pt),disabled:_>=Pt,className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]}),e.jsx(Rs,{open:R,onOpenChange:ol,children:e.jsxs(zs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:Ze.isRunning,children:[e.jsxs(Ms,{children:[e.jsx(As,{children:Z!==null?"编辑提供商":"添加提供商"}),e.jsx(Ys,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:W=>{W.preventDefault(),cl()},autoComplete:"off",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"provider-template-select",children:[e.jsx(b,{htmlFor:"template",children:"提供商模板"}),e.jsxs(Oa,{open:X,onOpenChange:S,children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",role:"combobox","aria-expanded":X,className:"w-full justify-between",children:[z?rr.find(W=>W.id===z)?.display_name:"选择提供商模板...",e.jsx(Qu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(wa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索提供商模板..."}),e.jsx(Pe,{className:"h-[300px]",children:e.jsxs(mo,{className:"max-h-none overflow-visible",children:[e.jsx(ho,{children:"未找到匹配的模板"}),e.jsx(vr,{children:rr.map(W=>e.jsxs(yr,{value:W.display_name,onSelect:()=>St(W.id),children:[e.jsx(fa,{className:`mr-2 h-4 w-4 ${z===W.id?"opacity-100":"opacity-0"}`}),W.display_name]},W.id))})]})})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"选择预设模板可自动填充 URL 和客户端类型,支持搜索"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-name-input",children:[e.jsx(b,{htmlFor:"name",className:le.name?"text-destructive":"",children:"名称 *"}),e.jsx(ce,{id:"name",value:U?.name||"",onChange:W=>{A(ve=>ve?{...ve,name:W.target.value}:null),le.name&&L(ve=>({...ve,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:le.name?"border-destructive focus-visible:ring-destructive":""}),le.name&&e.jsx("p",{className:"text-xs text-destructive",children:le.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsx(b,{htmlFor:"base_url",className:le.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(ce,{id:"base_url",value:U?.base_url||"",onChange:W=>{A(ve=>ve?{...ve,base_url:W.target.value}:null),le.base_url&&L(ve=>({...ve,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:Ct,className:`${Ct?"bg-muted cursor-not-allowed":""} ${le.base_url?"border-destructive focus-visible:ring-destructive":""}`}),le.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:le.base_url}),Ct&&!le.base_url&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时 URL 不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-apikey-input",children:[e.jsx(b,{htmlFor:"api_key",className:le.api_key?"text-destructive":"",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"api_key",type:ye?"text":"password",value:U?.api_key||"",onChange:W=>{A(ve=>ve?{...ve,api_key:W.target.value}:null),le.api_key&&L(ve=>({...ve,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${le.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(y,{type:"button",variant:"outline",size:"icon",onClick:()=>pe(!ye),title:ye?"隐藏密钥":"显示密钥",children:ye?e.jsx(mr,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})}),e.jsx(y,{type:"button",variant:"outline",size:"icon",onClick:rl,title:"复制密钥",children:e.jsx(so,{className:"h-4 w-4"})})]}),le.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:le.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs(He,{value:U?.client_type||"openai",onValueChange:W=>A(ve=>ve?{...ve,client_type:W}:null),disabled:Ct,children:[e.jsx(Re,{id:"client_type",className:Ct?"bg-muted cursor-not-allowed":"",children:e.jsx(qe,{placeholder:"选择客户端类型"})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"openai",children:"OpenAI"}),e.jsx(ne,{value:"gemini",children:"Gemini"})]})]}),Ct&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时客户端类型不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(ce,{id:"max_retry",type:"number",min:"0",value:U?.max_retry??"",onChange:W=>{const ve=W.target.value===""?null:parseInt(W.target.value);A(Me=>Me?{...Me,max_retry:ve}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(ce,{id:"timeout",type:"number",min:"1",value:U?.timeout??"",onChange:W=>{const ve=W.target.value===""?null:parseInt(W.target.value);A(Me=>Me?{...Me,timeout:ve}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(ce,{id:"retry_interval",type:"number",min:"1",value:U?.retry_interval??"",onChange:W=>{const ve=W.target.value===""?null:parseInt(W.target.value);A(Me=>Me?{...Me,retry_interval:ve}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(Js,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>K(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(y,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(ps,{open:O,onOpenChange:te,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除提供商 "',he!==null?n[he]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:Oe,children:"删除"})]})]})}),e.jsx(ps,{open:q,onOpenChange:ie,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认批量删除"}),e.jsxs(us,{children:["确定要删除选中的 ",N.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:on,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),T&&e.jsx(Iu,{onRestartComplete:bt,onRestartFailed:Je})]})}function bw({value:n,label:r,onRemove:c}){const{attributes:d,listeners:h,setNodeRef:x,transform:f,transition:j,isDragging:p}=jb({id:n}),w={transform:vb.Transform.toString(f),transition:j,opacity:p?.5:1};return e.jsx("div",{ref:x,style:w,className:Q("inline-flex items-center gap-1",p&&"shadow-lg"),children:e.jsxs(Ye,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...d,...h,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(ON,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:r}),e.jsx(li,{className:"ml-1 h-3 w-3 cursor-pointer hover:text-destructive",strokeWidth:2,fill:"none",onClick:v=>{v.stopPropagation(),c(n)}})]})})}function ww({options:n,selected:r,onChange:c,placeholder:d="选择选项...",emptyText:h="未找到选项",className:x}){const[f,j]=u.useState(!1),p=ob(Pf(gb,{activationConstraint:{distance:8}}),Pf(pb,{coordinateGetter:fb})),w=T=>{r.includes(T)?c(r.filter(E=>E!==T)):c([...r,T])},v=T=>{c(r.filter(E=>E!==T))},k=T=>{const{active:E,over:R}=T;if(R&&E.id!==R.id){const K=r.indexOf(E.id),U=r.indexOf(R.id);c(xb(r,K,U))}};return e.jsxs(Oa,{open:f,onOpenChange:j,children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",role:"combobox","aria-expanded":f,className:Q("w-full justify-between min-h-10 h-auto",x),children:[e.jsx(db,{sensors:p,collisionDetection:ub,onDragEnd:k,children:e.jsx(mb,{items:r,strategy:hb,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:r.length===0?e.jsx("span",{className:"text-muted-foreground",children:d}):r.map(T=>{const E=n.find(R=>R.value===T);return e.jsx(bw,{value:T,label:E?.label||T,onRemove:v},T)})})})}),e.jsx(Qu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(wa,{className:"w-full p-0",align:"start",children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索...",className:"h-9"}),e.jsxs(mo,{children:[e.jsx(ho,{children:h}),e.jsx(vr,{children:n.map(T=>{const E=r.includes(T.value);return e.jsxs(yr,{value:T.value,onSelect:()=>w(T.value),children:[e.jsx("div",{className:Q("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",E?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(fa,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:T.label})]},T.value)})})]})]})})]})}const mp=new Map,_w=300*1e3;function Sw(){const[n,r]=u.useState([]),[c,d]=u.useState([]),[h,x]=u.useState([]),[f,j]=u.useState([]),[p,w]=u.useState(null),[v,k]=u.useState(!0),[T,E]=u.useState(!1),[R,K]=u.useState(!1),[U,A]=u.useState(!1),[Z,H]=u.useState(!1),[z,B]=u.useState(!1),[X,S]=u.useState(!1),[O,te]=u.useState(null),[he,Ne]=u.useState(null),[ye,pe]=u.useState(!1),[je,_e]=u.useState(null),[N,G]=u.useState(""),[q,ie]=u.useState(new Set),[_,me]=u.useState(!1),[xe,$]=u.useState(1),[de,ge]=u.useState(20),[le,L]=u.useState(""),[F,D]=u.useState([]),[ee,we]=u.useState(!1),[ze,ss]=u.useState(null),[Ze,Ls]=u.useState(!1),[Gs,re]=u.useState(null),[be,Xe]=u.useState({}),{toast:Ue}=Hs(),st=Jt(),{registerTour:It,startTour:bt,state:Je,goToStep:Be}=Pu(),jt=u.useRef(null),nt=u.useRef(null),St=u.useRef(!0);u.useEffect(()=>{It(ll,qg)},[It]),u.useEffect(()=>{if(Je.activeTourId===ll&&Je.isRunning){const Y=Gg[Je.stepIndex];Y&&!window.location.pathname.endsWith(Y.replace("/config/",""))&&st({to:Y})}},[Je.stepIndex,Je.activeTourId,Je.isRunning,st]);const Ct=u.useRef(Je.stepIndex);u.useEffect(()=>{if(Je.activeTourId===ll&&Je.isRunning){const Y=Ct.current,fe=Je.stepIndex;Y>=12&&Y<=17&&fe<12&&S(!1),Ct.current=fe}},[Je.stepIndex,Je.activeTourId,Je.isRunning]),u.useEffect(()=>{if(Je.activeTourId!==ll||!Je.isRunning)return;const Y=fe=>{const Ae=fe.target,Ge=Je.stepIndex;Ge===2&&Ae.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Be(3),300):Ge===9&&Ae.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>Be(10),300):Ge===11&&Ae.closest('[data-tour="add-model-button"]')?setTimeout(()=>Be(12),300):Ge===17&&Ae.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>Be(18),300):Ge===18&&Ae.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>Be(19),300)};return document.addEventListener("click",Y,!0),()=>document.removeEventListener("click",Y,!0)},[Je,Be]);const rl=()=>{bt(ll)};u.useEffect(()=>{cl()},[]);const cl=async()=>{try{k(!0);const Y=await ei(),fe=Y.models||[];r(fe),j(fe.map(Ge=>Ge.name));const Ae=Y.api_providers||[];d(Ae.map(Ge=>Ge.name)),x(Ae),w(Y.model_task_config||null),A(!1),St.current=!1}catch(Y){console.error("加载配置失败:",Y)}finally{k(!1)}},ol=u.useCallback(Y=>h.find(fe=>fe.name===Y),[h]),Se=u.useCallback(async(Y,fe=!1)=>{const Ae=ol(Y);if(!Ae?.base_url){D([]),re(null),ss('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!Ae.api_key){D([]),re(null),ss('该提供商未配置 API Key,请先在"模型提供商配置"中填写');return}const Ge=yw(Ae.base_url);if(re(Ge),!Ge?.modelFetcher){D([]),ss(null);return}const xs=`${Y}:${Ae.base_url}`,ea=mp.get(xs);if(!fe&&ea&&Date.now()-ea.timestamp<_w){D(ea.models),ss(null);return}we(!0),ss(null);try{const sa=await $0(Y,Ge.modelFetcher.parser,Ge.modelFetcher.endpoint);D(sa),mp.set(xs,{models:sa,timestamp:Date.now()})}catch(sa){console.error("获取模型列表失败:",sa);const Sa=sa.message||"获取模型列表失败";Sa.includes("无效")||Sa.includes("过期")||Sa.includes("API Key")?ss('API Key 无效或已过期,请检查"模型提供商配置"中的密钥'):Sa.includes("权限")?ss("没有权限获取模型列表,请检查 API Key 权限"):Sa.includes("timeout")||Sa.includes("超时")?ss("请求超时,请检查网络连接后重试"):Sa.includes("不支持")?ss("该提供商不支持自动获取模型列表,请手动输入"):ss(Sa),D([])}finally{we(!1)}},[ol]);u.useEffect(()=>{X&&O?.api_provider&&Se(O.api_provider)},[X,O?.api_provider,Se]);const Oe=async()=>{try{H(!0),co().catch(()=>{}),B(!0)}catch(Y){console.error("重启失败:",Y),B(!1),Ue({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),H(!1)}},it=async()=>{try{E(!0),jt.current&&clearTimeout(jt.current),nt.current&&clearTimeout(nt.current);const Y=await ei();Y.models=n,Y.model_task_config=p,await io(Y),A(!1),Ue({title:"保存成功",description:"正在重启麦麦..."}),await Oe()}catch(Y){console.error("保存配置失败:",Y),Ue({title:"保存失败",description:Y.message,variant:"destructive"}),E(!1)}},dt=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},di=()=>{B(!1),H(!1),Ue({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},on=u.useCallback(async Y=>{if(!St.current)try{K(!0),await qu("models",Y),A(!1)}catch(fe){console.error("自动保存模型列表失败:",fe),A(!0)}finally{K(!1)}},[]),ut=u.useCallback(async Y=>{if(!St.current)try{K(!0),await qu("model_task_config",Y),A(!1)}catch(fe){console.error("自动保存任务配置失败:",fe),A(!0)}finally{K(!1)}},[]);u.useEffect(()=>{if(!St.current)return A(!0),jt.current&&clearTimeout(jt.current),jt.current=setTimeout(()=>{on(n)},2e3),()=>{jt.current&&clearTimeout(jt.current)}},[n,on]),u.useEffect(()=>{if(!(St.current||!p))return A(!0),nt.current&&clearTimeout(nt.current),nt.current=setTimeout(()=>{ut(p)},2e3),()=>{nt.current&&clearTimeout(nt.current)}},[p,ut]);const Pt=async()=>{try{E(!0),jt.current&&clearTimeout(jt.current),nt.current&&clearTimeout(nt.current);const Y=await ei();Y.models=n,Y.model_task_config=p,await io(Y),A(!1),Ue({title:"保存成功",description:"模型配置已保存"}),await cl()}catch(Y){console.error("保存配置失败:",Y),Ue({title:"保存失败",description:Y.message,variant:"destructive"})}finally{E(!1)}},Wt=(Y,fe)=>{Xe({}),te(Y||{model_identifier:"",name:"",api_provider:c[0]||"",price_in:0,price_out:0,force_stream_mode:!1,extra_params:{}}),Ne(fe),S(!0)},Ua=()=>{if(!O)return;const Y={};if(O.name?.trim()||(Y.name="请输入模型名称"),O.api_provider?.trim()||(Y.api_provider="请选择 API 提供商"),O.model_identifier?.trim()||(Y.model_identifier="请输入模型标识符"),Object.keys(Y).length>0){Xe(Y);return}Xe({});const fe={...O,price_in:O.price_in??0,price_out:O.price_out??0};let Ae,Ge=null;if(he!==null?(Ge=n[he].name,Ae=[...n],Ae[he]=fe):Ae=[...n,fe],r(Ae),j(Ae.map(xs=>xs.name)),Ge&&Ge!==fe.name&&p){const xs=ea=>ea.map(sa=>sa===Ge?fe.name:sa);w({...p,utils:{...p.utils,model_list:xs(p.utils?.model_list||[])},utils_small:{...p.utils_small,model_list:xs(p.utils_small?.model_list||[])},tool_use:{...p.tool_use,model_list:xs(p.tool_use?.model_list||[])},replyer:{...p.replyer,model_list:xs(p.replyer?.model_list||[])},planner:{...p.planner,model_list:xs(p.planner?.model_list||[])},vlm:{...p.vlm,model_list:xs(p.vlm?.model_list||[])},voice:{...p.voice,model_list:xs(p.voice?.model_list||[])},embedding:{...p.embedding,model_list:xs(p.embedding?.model_list||[])},lpmm_entity_extract:{...p.lpmm_entity_extract,model_list:xs(p.lpmm_entity_extract?.model_list||[])},lpmm_rdf_build:{...p.lpmm_rdf_build,model_list:xs(p.lpmm_rdf_build?.model_list||[])},lpmm_qa:{...p.lpmm_qa,model_list:xs(p.lpmm_qa?.model_list||[])}})}S(!1),te(null),Ne(null)},Ut=Y=>{if(!Y&&O){const fe={...O,price_in:O.price_in??0,price_out:O.price_out??0};te(fe)}S(Y)},Ba=Y=>{_e(Y),pe(!0)},_a=()=>{if(je!==null){const Y=n.filter((fe,Ae)=>Ae!==je);r(Y),j(Y.map(fe=>fe.name)),Ue({title:"删除成功",description:"模型已从列表中移除"})}pe(!1),_e(null)},W=Y=>{const fe=new Set(q);fe.has(Y)?fe.delete(Y):fe.add(Y),ie(fe)},ve=()=>{if(q.size===kt.length)ie(new Set);else{const Y=kt.map((fe,Ae)=>n.findIndex(Ge=>Ge===kt[Ae]));ie(new Set(Y))}},Me=()=>{if(q.size===0){Ue({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}me(!0)},tt=()=>{const Y=n.filter((fe,Ae)=>!q.has(Ae));r(Y),j(Y.map(fe=>fe.name)),ie(new Set),me(!1),Ue({title:"批量删除成功",description:`已删除 ${q.size} 个模型`})},Bt=(Y,fe,Ae)=>{p&&w({...p,[Y]:{...p[Y],[fe]:Ae}})},kt=n.filter(Y=>{if(!N)return!0;const fe=N.toLowerCase();return Y.name.toLowerCase().includes(fe)||Y.model_identifier.toLowerCase().includes(fe)||Y.api_provider.toLowerCase().includes(fe)}),dl=Math.ceil(kt.length/de),Hl=kt.slice((xe-1)*de,xe*de),dn=()=>{const Y=parseInt(le);Y>=1&&Y<=dl&&($(Y),L(""))},un=Y=>p?[p.utils?.model_list||[],p.utils_small?.model_list||[],p.tool_use?.model_list||[],p.replyer?.model_list||[],p.planner?.model_list||[],p.vlm?.model_list||[],p.voice?.model_list||[],p.embedding?.model_list||[],p.lpmm_entity_extract?.model_list||[],p.lpmm_rdf_build?.model_list||[],p.lpmm_qa?.model_list||[]].some(Ae=>Ae.includes(Y)):!1;return v?e.jsx(Pe,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"模型管理与分配"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"添加模型并为模型分配功能"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(y,{onClick:Pt,disabled:T||R||!U||Z,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),T?"保存中...":R?"自动保存中...":U?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(y,{disabled:T||R||Z,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),Z?"重启中...":U?"保存并重启":"重启麦麦"]})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认重启麦麦?"}),e.jsx(us,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:U?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ha,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(xa,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Rs,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(zs,{className:"max-w-2xl",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx(Ys,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx($e,{value:"windows",children:"Windows"}),e.jsx($e,{value:"macos",children:"macOS"}),e.jsx($e,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:['在"进程"或"详细信息"标签页中找到 ',e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:'右键点击并选择"结束任务"'})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"}),' 打开 Spotlight,搜索"活动监视器"']}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Js,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:U?it:Oe,children:U?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ha,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(xa,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(ha,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:rl,children:[e.jsx(RN,{className:"h-4 w-4 text-primary"}),e.jsxs(xa,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:"新手引导:"}),"不知道如何配置模型?点击这里开始学习如何为麦麦的组件分配模型。"]}),e.jsx(y,{variant:"outline",size:"sm",className:"ml-4 shrink-0",children:"开始引导"})]})]}),e.jsxs(Kt,{defaultValue:"models",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx($e,{value:"models",children:"添加模型"}),e.jsx($e,{value:"tasks","data-tour":"tasks-tab-trigger",children:"为模型分配功能"})]}),e.jsxs(We,{value:"models",className:"space-y-4 mt-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置可用的模型列表"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[q.size>0&&e.jsxs(y,{onClick:Me,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(es,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",q.size,")"]}),e.jsxs(y,{onClick:()=>Wt(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(ot,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加模型"]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索模型名称、标识符或提供商...",value:N,onChange:Y=>G(Y.target.value),className:"pl-9"})]}),N&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",kt.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Hl.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:N?"未找到匹配的模型":"暂无模型配置"}):Hl.map((Y,fe)=>{const Ae=n.findIndex(xs=>xs===Y),Ge=un(Y.name);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-base",children:Y.name}),e.jsx(Ye,{variant:Ge?"default":"secondary",className:Ge?"bg-green-600 hover:bg-green-700":"",children:Ge?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:Y.model_identifier,children:Y.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(y,{variant:"default",size:"sm",onClick:()=>Wt(Y,Ae),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(y,{size:"sm",onClick:()=>Ba(Ae),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(es,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"提供商"}),e.jsx("p",{className:"font-medium",children:Y.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"强制流式"}),e.jsx("p",{className:"font-medium",children:Y.force_stream_mode?"是":"否"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输入价格"}),e.jsxs("p",{className:"font-medium",children:["¥",Y.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",Y.price_out,"/M"]})]})]})]},fe)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(gt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:q.size===kt.length&&kt.length>0,onCheckedChange:ve})}),e.jsx(ls,{className:"w-24",children:"使用状态"}),e.jsx(ls,{children:"模型名称"}),e.jsx(ls,{children:"模型标识符"}),e.jsx(ls,{children:"提供商"}),e.jsx(ls,{className:"text-right",children:"输入价格"}),e.jsx(ls,{className:"text-right",children:"输出价格"}),e.jsx(ls,{className:"text-center",children:"强制流式"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:Hl.length===0?e.jsx(gt,{children:e.jsx(Qe,{colSpan:9,className:"text-center text-muted-foreground py-8",children:N?"未找到匹配的模型":"暂无模型配置"})}):Hl.map((Y,fe)=>{const Ae=n.findIndex(xs=>xs===Y),Ge=un(Y.name);return e.jsxs(gt,{children:[e.jsx(Qe,{children:e.jsx(yt,{checked:q.has(Ae),onCheckedChange:()=>W(Ae)})}),e.jsx(Qe,{children:e.jsx(Ye,{variant:Ge?"default":"secondary",className:Ge?"bg-green-600 hover:bg-green-700":"",children:Ge?"已使用":"未使用"})}),e.jsx(Qe,{className:"font-medium",children:Y.name}),e.jsx(Qe,{className:"max-w-xs truncate",title:Y.model_identifier,children:Y.model_identifier}),e.jsx(Qe,{children:Y.api_provider}),e.jsxs(Qe,{className:"text-right",children:["¥",Y.price_in,"/M"]}),e.jsxs(Qe,{className:"text-right",children:["¥",Y.price_out,"/M"]}),e.jsx(Qe,{className:"text-center",children:Y.force_stream_mode?"是":"否"}),e.jsx(Qe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(y,{variant:"default",size:"sm",onClick:()=>Wt(Y,Ae),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(y,{size:"sm",onClick:()=>Ba(Ae),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(es,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},fe)})})]})})}),kt.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(He,{value:de.toString(),onValueChange:Y=>{ge(parseInt(Y)),$(1),ie(new Set)},children:[e.jsx(Re,{id:"page-size-model",className:"w-20",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"10",children:"10"}),e.jsx(ne,{value:"20",children:"20"}),e.jsx(ne,{value:"50",children:"50"}),e.jsx(ne,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(xe-1)*de+1," 到"," ",Math.min(xe*de,kt.length)," 条,共 ",kt.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>$(1),disabled:xe===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>$(Y=>Math.max(1,Y-1)),disabled:xe===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:le,onChange:Y=>L(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&dn(),placeholder:xe.toString(),className:"w-16 h-8 text-center",min:1,max:dl}),e.jsx(y,{variant:"outline",size:"sm",onClick:dn,disabled:!le,className:"h-8",children:"跳转"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>$(Y=>Y+1),disabled:xe>=dl,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>$(dl),disabled:xe>=dl,className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]}),e.jsxs(We,{value:"tasks",className:"space-y-6 mt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"为不同的任务配置使用的模型和参数"}),p&&e.jsxs("div",{className:"grid gap-4 sm:gap-6",children:[e.jsx(ya,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:p.utils,modelNames:f,onChange:(Y,fe)=>Bt("utils",Y,fe),dataTour:"task-model-select"}),e.jsx(ya,{title:"组件小模型 (utils_small)",description:"消耗量较大的组件,建议使用速度较快的小模型",taskConfig:p.utils_small,modelNames:f,onChange:(Y,fe)=>Bt("utils_small",Y,fe)}),e.jsx(ya,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:p.tool_use,modelNames:f,onChange:(Y,fe)=>Bt("tool_use",Y,fe)}),e.jsx(ya,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:p.replyer,modelNames:f,onChange:(Y,fe)=>Bt("replyer",Y,fe)}),e.jsx(ya,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:p.planner,modelNames:f,onChange:(Y,fe)=>Bt("planner",Y,fe)}),e.jsx(ya,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:p.vlm,modelNames:f,onChange:(Y,fe)=>Bt("vlm",Y,fe),hideTemperature:!0}),e.jsx(ya,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:p.voice,modelNames:f,onChange:(Y,fe)=>Bt("voice",Y,fe),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(ya,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:p.embedding,modelNames:f,onChange:(Y,fe)=>Bt("embedding",Y,fe),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(ya,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:p.lpmm_entity_extract,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_entity_extract",Y,fe)}),e.jsx(ya,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:p.lpmm_rdf_build,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_rdf_build",Y,fe)}),e.jsx(ya,{title:"问答模型 (lpmm_qa)",description:"知识库问答",taskConfig:p.lpmm_qa,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_qa",Y,fe)})]})]})]})]}),e.jsx(Rs,{open:X,onOpenChange:Ut,children:e.jsxs(zs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Je.isRunning,children:[e.jsxs(Ms,{children:[e.jsx(As,{children:he!==null?"编辑模型":"添加模型"}),e.jsx(Ys,{children:"配置模型的基本信息和参数"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"model-name-input",children:[e.jsx(b,{htmlFor:"model_name",className:be.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ce,{id:"model_name",value:O?.name||"",onChange:Y=>{te(fe=>fe?{...fe,name:Y.target.value}:null),be.name&&Xe(fe=>({...fe,name:void 0}))},placeholder:"例如: qwen3-30b",className:be.name?"border-destructive focus-visible:ring-destructive":""}),be.name?e.jsx("p",{className:"text-xs text-destructive",children:be.name}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于在任务配置中引用此模型"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-provider-select",children:[e.jsx(b,{htmlFor:"api_provider",className:be.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs(He,{value:O?.api_provider||"",onValueChange:Y=>{te(fe=>fe?{...fe,api_provider:Y}:null),D([]),ss(null),be.api_provider&&Xe(fe=>({...fe,api_provider:void 0}))},children:[e.jsx(Re,{id:"api_provider",className:be.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx(qe,{placeholder:"选择提供商"})}),e.jsx(Le,{children:c.map(Y=>e.jsx(ne,{value:Y,children:Y},Y))})]}),be.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:be.api_provider})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-identifier-input",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:"model_identifier",className:be.model_identifier?"text-destructive":"",children:"模型标识符 *"}),Gs?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{variant:"secondary",className:"text-xs",children:Gs.display_name}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>O?.api_provider&&Se(O.api_provider,!0),disabled:ee,children:ee?e.jsx(vt,{className:"h-3 w-3 animate-spin"}):e.jsx(pt,{className:"h-3 w-3"})})]})]}),Gs?.modelFetcher?e.jsxs(Oa,{open:Ze,onOpenChange:Ls,children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",role:"combobox","aria-expanded":Ze,className:"w-full justify-between font-normal",disabled:ee||!!ze,children:[ee?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(vt,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):ze?e.jsx("span",{className:"text-muted-foreground text-sm",children:"点击下方输入框手动填写"}):O?.model_identifier?e.jsx("span",{className:"truncate",children:O.model_identifier}):e.jsx("span",{className:"text-muted-foreground",children:"搜索或选择模型..."}),e.jsx(Qu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(wa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索模型..."}),e.jsx(Pe,{className:"h-[300px]",children:e.jsxs(mo,{className:"max-h-none overflow-visible",children:[e.jsx(ho,{children:ze?e.jsxs("div",{className:"py-4 px-2 text-center space-y-2",children:[e.jsx("p",{className:"text-sm text-destructive",children:ze}),!ze.includes("API Key")&&e.jsx(y,{variant:"link",size:"sm",onClick:()=>O?.api_provider&&Se(O.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(vr,{heading:"可用模型",children:F.map(Y=>e.jsxs(yr,{value:Y.id,onSelect:()=>{te(fe=>fe?{...fe,model_identifier:Y.id}:null),Ls(!1)},children:[e.jsx(fa,{className:`mr-2 h-4 w-4 ${O?.model_identifier===Y.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:Y.id}),Y.name!==Y.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Y.name})]})]},Y.id))}),e.jsx(vr,{heading:"手动输入",children:e.jsxs(yr,{value:"__manual_input__",onSelect:()=>{Ls(!1)},children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ce,{id:"model_identifier",value:O?.model_identifier||"",onChange:Y=>{te(fe=>fe?{...fe,model_identifier:Y.target.value}:null),be.model_identifier&&Xe(fe=>({...fe,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:be.model_identifier?"border-destructive focus-visible:ring-destructive":""}),be.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:be.model_identifier}),ze&&Gs?.modelFetcher&&!be.model_identifier&&e.jsxs(ha,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsx(xa,{className:"text-xs",children:ze})]}),Gs?.modelFetcher&&e.jsx(ce,{value:O?.model_identifier||"",onChange:Y=>{te(fe=>fe?{...fe,model_identifier:Y.target.value}:null),be.model_identifier&&Xe(fe=>({...fe,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${be.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!be.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:ze?'请手动输入模型标识符,或前往"模型提供商配置"检查 API Key':Gs?.modelFetcher?`已识别为 ${Gs.display_name},支持自动获取模型列表`:"API 提供商提供的模型 ID"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(ce,{id:"price_in",type:"number",step:"0.1",min:"0",value:O?.price_in??"",onChange:Y=>{const fe=Y.target.value===""?null:parseFloat(Y.target.value);te(Ae=>Ae?{...Ae,price_in:fe}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ce,{id:"price_out",type:"number",step:"0.1",min:"0",value:O?.price_out??"",onChange:Y=>{const fe=Y.target.value===""?null:parseFloat(Y.target.value);te(Ae=>Ae?{...Ae,price_out:fe}:null)},placeholder:"默认: 0"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"force_stream_mode",checked:O?.force_stream_mode||!1,onCheckedChange:Y=>te(fe=>fe?{...fe,force_stream_mode:Y}:null)}),e.jsx(b,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>S(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(y,{onClick:Ua,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(ps,{open:ye,onOpenChange:pe,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除模型 "',je!==null?n[je]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:_a,children:"删除"})]})]})}),e.jsx(ps,{open:_,onOpenChange:me,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认批量删除"}),e.jsxs(us,{children:["确定要删除选中的 ",q.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:tt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),z&&e.jsx(Iu,{onRestartComplete:dt,onRestartFailed:di})]})})}function ya({title:n,description:r,taskConfig:c,modelNames:d,onChange:h,hideTemperature:x=!1,hideMaxTokens:f=!1,dataTour:j}){const p=w=>{h("model_list",w)};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-base sm:text-lg",children:n}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:r})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":j,children:[e.jsx(b,{children:"模型列表"}),e.jsx(ww,{options:d.map(w=>({label:w,value:w})),selected:c.model_list||[],onChange:p,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!x&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"温度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:c.temperature??.3,onChange:w=>{const v=parseFloat(w.target.value);!isNaN(v)&&v>=0&&v<=1&&h("temperature",v)},className:"w-20 h-8 text-sm"})]}),e.jsx(Ma,{value:[c.temperature??.3],onValueChange:w=>h("temperature",w[0]),min:0,max:1,step:.1,className:"w-full"})]}),!f&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"最大 Token"}),e.jsx(ce,{type:"number",step:"1",min:"1",value:c.max_tokens??1024,onChange:w=>h("max_tokens",parseInt(w.target.value))})]})]})]})]})}const xo="/api/webui/config";async function Cw(){const r=await(await ke(`${xo}/adapter-config/path`)).json();return!r.success||!r.path?null:{path:r.path,lastModified:r.lastModified}}async function hp(n){const c=await(await ke(`${xo}/adapter-config/path`,{method:"POST",headers:Ts(),body:JSON.stringify({path:n})})).json();if(!c.success)throw new Error(c.message||"保存路径失败")}async function xp(n){const c=await(await ke(`${xo}/adapter-config?path=${encodeURIComponent(n)}`)).json();if(!c.success)throw new Error("读取配置文件失败");return c.content}async function fp(n,r){const d=await(await ke(`${xo}/adapter-config`,{method:"POST",headers:Ts(),body:JSON.stringify({path:n,content:r})})).json();if(!d.success)throw new Error(d.message||"保存配置失败")}const Yt={inner:{version:"0.1.2"},nickname:{nickname:""},napcat_server:{host:"localhost",port:8095,token:"",heartbeat_interval:30},maibot_server:{host:"localhost",port:8e3},chat:{group_list_type:"whitelist",group_list:[],private_list_type:"whitelist",private_list:[],ban_user_id:[],ban_qq_bot:!1,enable_poke:!0},voice:{use_tts:!1},debug:{level:"INFO"}},Du={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:rn},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:LN}};function kw(){const[n,r]=u.useState("upload"),[c,d]=u.useState(null),[h,x]=u.useState(""),[f,j]=u.useState(""),[p,w]=u.useState("oneclick"),[v,k]=u.useState(""),[T,E]=u.useState(!1),[R,K]=u.useState(!1),[U,A]=u.useState(!1),[Z,H]=u.useState(!1),[z,B]=u.useState(null),X=u.useRef(null),{toast:S}=Hs(),O=u.useRef(null),te=L=>{if(!L.trim())return{valid:!1,error:"路径不能为空"};if(!L.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const F=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,D=/^(\/|~\/).+\.toml$/i,ee=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,we=F.test(L),ze=D.test(L),ss=ee.test(L);return!we&&!ze&&!ss?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(L)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}},he=L=>{if(j(L),L.trim()){const F=te(L);k(F.error)}else k("")},Ne=u.useCallback(async L=>{const F=Du[L];K(!0);try{const D=await xp(F.path),ee=xe(D);d(ee),w(L),j(F.path),await hp(F.path),S({title:"加载成功",description:`已从${F.name}预设加载配置`})}catch(D){console.error("加载预设配置失败:",D),S({title:"加载失败",description:D instanceof Error?D.message:"无法读取预设配置文件",variant:"destructive"})}finally{K(!1)}},[S]),ye=u.useCallback(async L=>{const F=te(L);if(!F.valid){k(F.error),S({title:"路径无效",description:F.error,variant:"destructive"});return}k(""),K(!0);try{const D=await xp(L),ee=xe(D);d(ee),j(L),await hp(L),S({title:"加载成功",description:"已从配置文件加载"})}catch(D){console.error("加载配置失败:",D),S({title:"加载失败",description:D instanceof Error?D.message:"无法读取配置文件",variant:"destructive"})}finally{K(!1)}},[S]);u.useEffect(()=>{(async()=>{try{const F=await Cw();if(F&&F.path){j(F.path);const D=Object.entries(Du).find(([,ee])=>ee.path===F.path);D?(r("preset"),w(D[0]),await Ne(D[0])):(r("path"),await ye(F.path))}}catch(F){console.error("加载保存的路径失败:",F)}})()},[ye,Ne]);const pe=u.useCallback(L=>{n!=="path"&&n!=="preset"||!f||(O.current&&clearTimeout(O.current),O.current=setTimeout(async()=>{E(!0);try{const F=$(L);await fp(f,F),S({title:"自动保存成功",description:"配置已保存到文件"})}catch(F){console.error("自动保存失败:",F),S({title:"自动保存失败",description:F instanceof Error?F.message:"保存配置失败",variant:"destructive"})}finally{E(!1)}},1e3))},[n,f,S]),je=async()=>{if(!c||!f)return;const L=te(f);if(!L.valid){S({title:"保存失败",description:L.error,variant:"destructive"});return}E(!0);try{const F=$(c);await fp(f,F),S({title:"保存成功",description:"配置已保存到文件"})}catch(F){console.error("保存失败:",F),S({title:"保存失败",description:F instanceof Error?F.message:"保存配置失败",variant:"destructive"})}finally{E(!1)}},_e=async()=>{f&&await ye(f)},N=L=>{if(L!==n){if(c){B(L),A(!0);return}G(L)}},G=L=>{d(null),x(""),k(""),r(L),L==="preset"&&Ne("oneclick"),S({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[L]})},q=()=>{z&&(G(z),B(null)),A(!1)},ie=()=>{if(c){H(!0);return}_()},_=()=>{j(""),d(null),k(""),S({title:"已清空",description:"路径和配置已清空"})},me=()=>{_(),H(!1)},xe=L=>{const F=JSON.parse(JSON.stringify(Yt)),D=L.split(` +`);let ee="";for(const we of D){const ze=we.trim();if(!ze||ze.startsWith("#"))continue;const ss=ze.match(/^\[(\w+)\]/);if(ss){ee=ss[1];continue}const Ze=ze.match(/^(\w+)\s*=\s*(.+)$/);if(Ze&&ee){const[,Ls,Gs]=Ze;let re=Gs.trim();const be=re.match(/^("[^"]*")/);if(be)re=be[1];else{const Ue=re.indexOf("#");Ue!==-1&&(re=re.substring(0,Ue).trim())}let Xe;if(re==="true")Xe=!0;else if(re==="false")Xe=!1;else if(re.startsWith("[")&&re.endsWith("]")){const Ue=re.slice(1,-1).trim();if(Ue){const st=Ue.split(",").map(bt=>{const Je=bt.trim();return isNaN(Number(Je))?Je.replace(/"/g,""):Number(Je)}),It=typeof st[0];Xe=st.every(bt=>typeof bt===It)?st:st.filter(bt=>typeof bt=="number")}else Xe=[]}else re.startsWith('"')&&re.endsWith('"')?Xe=re.slice(1,-1):isNaN(Number(re))?Xe=re.replace(/"/g,""):Xe=Number(re);if(ee in F){const Ue=F[ee];Ue[Ls]=Xe}}}return F},$=L=>{const F=[],D=(ee,we)=>ee===""||ee===null||ee===void 0?we:ee;return F.push("[inner]"),F.push(`version = "${D(L.inner.version,Yt.inner.version)}" # 版本号`),F.push("# 请勿修改版本号,除非你知道自己在做什么"),F.push(""),F.push("[nickname] # 现在没用"),F.push(`nickname = "${D(L.nickname.nickname,Yt.nickname.nickname)}"`),F.push(""),F.push("[napcat_server] # Napcat连接的ws服务设置"),F.push(`host = "${D(L.napcat_server.host,Yt.napcat_server.host)}" # Napcat设定的主机地址`),F.push(`port = ${D(L.napcat_server.port||0,Yt.napcat_server.port)} # Napcat设定的端口`),F.push(`token = "${D(L.napcat_server.token,Yt.napcat_server.token)}" # Napcat设定的访问令牌,若无则留空`),F.push(`heartbeat_interval = ${D(L.napcat_server.heartbeat_interval||0,Yt.napcat_server.heartbeat_interval)} # 与Napcat设置的心跳相同(按秒计)`),F.push(""),F.push("[maibot_server] # 连接麦麦的ws服务设置"),F.push(`host = "${D(L.maibot_server.host,Yt.maibot_server.host)}" # 麦麦在.env文件中设置的主机地址,即HOST字段`),F.push(`port = ${D(L.maibot_server.port||0,Yt.maibot_server.port)} # 麦麦在.env文件中设置的端口,即PORT字段`),F.push(""),F.push("[chat] # 黑白名单功能"),F.push(`group_list_type = "${D(L.chat.group_list_type,Yt.chat.group_list_type)}" # 群组名单类型,可选为:whitelist, blacklist`),F.push(`group_list = [${L.chat.group_list.join(", ")}] # 群组名单`),F.push("# 当group_list_type为whitelist时,只有群组名单中的群组可以聊天"),F.push("# 当group_list_type为blacklist时,群组名单中的任何群组无法聊天"),F.push(`private_list_type = "${D(L.chat.private_list_type,Yt.chat.private_list_type)}" # 私聊名单类型,可选为:whitelist, blacklist`),F.push(`private_list = [${L.chat.private_list.join(", ")}] # 私聊名单`),F.push("# 当private_list_type为whitelist时,只有私聊名单中的用户可以聊天"),F.push("# 当private_list_type为blacklist时,私聊名单中的任何用户无法聊天"),F.push(`ban_user_id = [${L.chat.ban_user_id.join(", ")}] # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`),F.push(`ban_qq_bot = ${L.chat.ban_qq_bot} # 是否屏蔽QQ官方机器人`),F.push(`enable_poke = ${L.chat.enable_poke} # 是否启用戳一戳功能`),F.push(""),F.push("[voice] # 发送语音设置"),F.push(`use_tts = ${L.voice.use_tts} # 是否使用tts语音(请确保你配置了tts并有对应的adapter)`),F.push(""),F.push("[debug]"),F.push(`level = "${D(L.debug.level,Yt.debug.level)}" # 日志等级(DEBUG, INFO, WARNING, ERROR, CRITICAL)`),F.join(` +`)},de=L=>{const F=L.target.files?.[0];if(!F)return;const D=new FileReader;D.onload=ee=>{try{const we=ee.target?.result,ze=xe(we);d(ze),x(F.name),S({title:"上传成功",description:`已加载配置文件:${F.name}`})}catch(we){console.error("解析配置文件失败:",we),S({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},D.readAsText(F)},ge=()=>{if(!c)return;const L=$(c),F=new Blob([L],{type:"text/plain;charset=utf-8"}),D=URL.createObjectURL(F),ee=document.createElement("a");ee.href=D,ee.download=h||"config.toml",document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(D),S({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},le=()=>{d(JSON.parse(JSON.stringify(Yt))),x("config.toml"),S({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦适配器配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的 QQ 适配器的配置文件"})]})}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg border border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400",children:[e.jsx(Da,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"工作模式"}),e.jsx(Zs,{children:"选择配置文件的管理方式"})]}),e.jsxs(bs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 md:gap-4",children:[e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>N("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(rn,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"预设模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"使用预设的部署配置"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>N("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(hr,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"上传文件模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"上传配置文件,编辑后下载并手动覆盖"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>N("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(UN,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"指定路径模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"指定配置文件路径,自动加载和保存"})]})]})})]}),n==="preset"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsx(b,{className:"text-sm md:text-base",children:"选择部署方式"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(Du).map(([L,F])=>{const D=F.icon,ee=p===L;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${ee?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{w(L),Ne(L)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(D,{className:"h-5 w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-semibold text-sm",children:F.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:F.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:F.path})]})]})},L)})})]}),n==="path"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"config-path",className:"text-sm md:text-base",children:"配置文件路径"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(ce,{id:"config-path",value:f,onChange:L=>he(L.target.value),placeholder:"例: C:\\Adapter\\config.toml",className:`text-sm ${v?"border-destructive":""}`}),v&&e.jsx("p",{className:"text-xs text-destructive",children:v})]}),e.jsx(y,{onClick:()=>ye(f),disabled:R||!f||!!v,className:"w-full sm:w-auto",children:R?e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"h-4 w-4 animate-spin mr-2"}),e.jsx("span",{className:"sm:hidden",children:"加载中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:"加载配置"}),e.jsx("span",{className:"hidden sm:inline",children:"加载"})]})})]})]}),e.jsxs("details",{className:"rounded-lg bg-muted/50 p-3 group",children:[e.jsxs("summary",{className:"text-xs font-medium cursor-pointer select-none list-none flex items-center justify-between",children:[e.jsx("span",{children:"路径格式说明"}),e.jsx("svg",{className:"h-4 w-4 transition-transform group-open:rotate-180",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsxs("div",{className:"mt-2 space-y-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Windows"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"C:\\Adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"D:\\MaiBot\\adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"\\\\server\\share\\config.toml"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Linux"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"/opt/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"/home/user/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"~/adapter/config.toml"})]})]}),e.jsx("p",{className:"pt-1 border-t text-[10px] md:text-xs",children:"💡 配置会自动保存到指定文件,修改后 1 秒自动保存"})]})]})]})]})]}),e.jsxs(ha,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsx(xa,{children:n==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",T&&" (正在保存...)"]}):n==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",T&&" (正在保存...)"]})})]}),n==="upload"&&!c&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:X,type:"file",accept:".toml",className:"hidden",onChange:de}),e.jsxs(y,{onClick:()=>X.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(hr,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(y,{onClick:le,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Aa,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),n==="upload"&&c&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(y,{onClick:ge,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(nl,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(n==="preset"||n==="path")&&c&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(y,{onClick:je,size:"sm",disabled:T||!!v,className:"w-full sm:w-auto",children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),T?"保存中...":"立即保存"]}),e.jsxs(y,{onClick:_e,size:"sm",variant:"outline",disabled:R,className:"w-full sm:w-auto",children:[e.jsx(pt,{className:`mr-2 h-4 w-4 ${R?"animate-spin":""}`}),"刷新"]}),n==="path"&&e.jsxs(y,{onClick:ie,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(es,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),c?e.jsxs(Kt,{defaultValue:"napcat",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs(Rt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5",children:[e.jsxs($e,{value:"napcat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"Napcat 连接"}),e.jsx("span",{className:"sm:hidden",children:"Napcat"})]}),e.jsxs($e,{value:"maibot",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"麦麦连接"}),e.jsx("span",{className:"sm:hidden",children:"麦麦"})]}),e.jsxs($e,{value:"chat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"聊天控制"}),e.jsx("span",{className:"sm:hidden",children:"聊天"})]}),e.jsxs($e,{value:"voice",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"语音设置"}),e.jsx("span",{className:"sm:hidden",children:"语音"})]}),e.jsx($e,{value:"debug",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:"调试"})]})}),e.jsx(We,{value:"napcat",className:"space-y-4",children:e.jsx(Tw,{config:c,onChange:L=>{d(L),pe(L)}})}),e.jsx(We,{value:"maibot",className:"space-y-4",children:e.jsx(Ew,{config:c,onChange:L=>{d(L),pe(L)}})}),e.jsx(We,{value:"chat",className:"space-y-4",children:e.jsx(zw,{config:c,onChange:L=>{d(L),pe(L)}})}),e.jsx(We,{value:"voice",className:"space-y-4",children:e.jsx(Mw,{config:c,onChange:L=>{d(L),pe(L)}})}),e.jsx(We,{value:"debug",className:"space-y-4",children:e.jsx(Aw,{config:c,onChange:L=>{d(L),pe(L)}})})]}):e.jsx("div",{className:"rounded-lg border bg-card p-6 md:p-12",children:e.jsxs("div",{className:"text-center space-y-3 md:space-y-4",children:[e.jsx(Aa,{className:"h-12 w-12 md:h-16 md:w-16 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold",children:"尚未加载配置"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-2 px-4",children:n==="preset"?"请选择预设的部署方式":n==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(ps,{open:U,onOpenChange:A,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认切换模式"}),e.jsxs(us,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(os,{children:[e.jsx(hs,{onClick:()=>{A(!1),B(null)},children:"取消"}),e.jsx(ms,{onClick:q,children:"确认切换"})]})]})}),e.jsx(ps,{open:Z,onOpenChange:H,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认清空路径"}),e.jsxs(us,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(os,{children:[e.jsx(hs,{onClick:()=>H(!1),children:"取消"}),e.jsx(ms,{onClick:me,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function Tw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"Napcat WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"napcat-host",value:n.napcat_server.host,onChange:c=>r({...n,napcat_server:{...n.napcat_server,host:c.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的主机地址"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"napcat-port",type:"number",value:n.napcat_server.port||"",onChange:c=>r({...n,napcat_server:{...n.napcat_server,port:c.target.value?parseInt(c.target.value):0}}),placeholder:"8095",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的端口(留空使用默认值 8095)"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-token",className:"text-sm md:text-base",children:"访问令牌(Token)"}),e.jsx(ce,{id:"napcat-token",type:"password",value:n.napcat_server.token,onChange:c=>r({...n,napcat_server:{...n.napcat_server,token:c.target.value}}),placeholder:"留空表示无需令牌",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的访问令牌,若无则留空"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-heartbeat",className:"text-sm md:text-base",children:"心跳间隔(秒)"}),e.jsx(ce,{id:"napcat-heartbeat",type:"number",value:n.napcat_server.heartbeat_interval||"",onChange:c=>r({...n,napcat_server:{...n.napcat_server,heartbeat_interval:c.target.value?parseInt(c.target.value):0}}),placeholder:"30",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"与 Napcat 设置的心跳间隔保持一致(留空使用默认值 30)"})]})]})]})})}function Ew({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"麦麦 WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"maibot-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"maibot-host",value:n.maibot_server.host,onChange:c=>r({...n,maibot_server:{...n.maibot_server,host:c.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 HOST 字段"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"maibot-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"maibot-port",type:"number",value:n.maibot_server.port||"",onChange:c=>r({...n,maibot_server:{...n.maibot_server,port:c.target.value?parseInt(c.target.value):0}}),placeholder:"8000",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 PORT 字段(留空使用默认值 8000)"})]})]})]})})}function zw({config:n,onChange:r}){const c=x=>{const f={...n};x==="group"?f.chat.group_list=[...f.chat.group_list,0]:x==="private"?f.chat.private_list=[...f.chat.private_list,0]:f.chat.ban_user_id=[...f.chat.ban_user_id,0],r(f)},d=(x,f)=>{const j={...n};x==="group"?j.chat.group_list=j.chat.group_list.filter((p,w)=>w!==f):x==="private"?j.chat.private_list=j.chat.private_list.filter((p,w)=>w!==f):j.chat.ban_user_id=j.chat.ban_user_id.filter((p,w)=>w!==f),r(j)},h=(x,f,j)=>{const p={...n};x==="group"?p.chat.group_list[f]=j:x==="private"?p.chat.private_list[f]=j:p.chat.ban_user_id[f]=j,r(p)};return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"聊天黑白名单功能"}),e.jsxs("div",{className:"grid gap-4 md:gap-6",children:[e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"群组名单类型"}),e.jsxs(He,{value:n.chat.group_list_type,onValueChange:x=>r({...n,chat:{...n.chat,group_list_type:x}}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(ne,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(b,{className:"text-sm md:text-base",children:"群组列表"}),e.jsxs(y,{onClick:()=>c("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Aa,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),n.chat.group_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("group",f,parseInt(j.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除群号 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d("group",f),children:"删除"})]})]})]})]},f)),n.chat.group_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无群组"})]})]}),e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"私聊名单类型"}),e.jsxs(He,{value:n.chat.private_list_type,onValueChange:x=>r({...n,chat:{...n.chat,private_list_type:x}}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(ne,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(b,{className:"text-sm md:text-base",children:"私聊列表"}),e.jsxs(y,{onClick:()=>c("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Aa,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.private_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("private",f,parseInt(j.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d("private",f),children:"删除"})]})]})]})]},f)),n.chat.private_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无用户"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"全局禁止名单"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"名单中的用户无法进行任何聊天"})]}),e.jsxs(y,{onClick:()=>c("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Aa,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.ban_user_id.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("ban",f,parseInt(j.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(y,{size:"icon",variant:"outline",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:["确定要从全局禁止名单中删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>d("ban",f),children:"删除"})]})]})]})]},f)),n.chat.ban_user_id.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无禁止用户"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"屏蔽QQ官方机器人"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否屏蔽来自QQ官方机器人的消息"})]}),e.jsx(Ve,{checked:n.chat.ban_qq_bot,onCheckedChange:x=>r({...n,chat:{...n.chat,ban_qq_bot:x}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"启用戳一戳功能"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否响应戳一戳消息"})]}),e.jsx(Ve,{checked:n.chat.enable_poke,onCheckedChange:x=>r({...n,chat:{...n.chat,enable_poke:x}})})]})]})]})})}function Mw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"发送语音设置"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"使用 TTS 语音"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"请确保已配置 TTS 并有对应的适配器"})]}),e.jsx(Ve,{checked:n.voice.use_tts,onCheckedChange:c=>r({...n,voice:{use_tts:c}})})]})]})})}function Aw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"调试设置"}),e.jsx("div",{className:"grid gap-3 md:gap-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"日志等级"}),e.jsxs(He,{value:n.debug.level,onValueChange:c=>r({...n,debug:{level:c}}),children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"DEBUG",children:"DEBUG(调试)"}),e.jsx(ne,{value:"INFO",children:"INFO(信息)"}),e.jsx(ne,{value:"WARNING",children:"WARNING(警告)"}),e.jsx(ne,{value:"ERROR",children:"ERROR(错误)"}),e.jsx(ne,{value:"CRITICAL",children:"CRITICAL(严重)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const Dw=["defaultChecked","defaultValue","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML","accessKey","className","contentEditable","contextMenu","dir","draggable","hidden","id","lang","placeholder","slot","spellCheck","style","tabIndex","title","translate","radioGroup","role","about","datatype","inlist","prefix","property","resource","typeof","vocab","autoCapitalize","autoCorrect","autoSave","color","itemProp","itemScope","itemType","itemID","itemRef","results","security","unselectable","inputMode","is","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],Ow=/^(aria-|data-)/,Vg=n=>Object.fromEntries(Object.entries(n).filter(([r])=>Ow.test(r)||Dw.includes(r)));function Rw(n,r){const c=Vg(n);return Object.keys(n).some(d=>!Object.hasOwn(c,d)&&n[d]!==r[d])}class Lw extends u.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(r){if(r.uppy!==this.props.uppy)this.uninstallPlugin(r),this.installPlugin();else if(Rw(this.props,r)){const{uppy:c,...d}={...this.props,target:this.container};this.plugin.setOptions(d)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:r,...c}={id:"Dashboard",...this.props,inline:!0,target:this.container};r.use(yb,c),this.plugin=r.getPlugin(c.id)}uninstallPlugin(r=this.props){const{uppy:c}=r;c.removePlugin(this.plugin)}render(){return u.createElement("div",{className:"uppy-Container",ref:r=>{this.container=r},...Vg(this.props)})}}function Uw({content:n,className:r=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${r}`,children:e.jsx(bb,{remarkPlugins:[_b,Sb],rehypePlugins:[wb],components:{code({inline:c,className:d,children:h,...x}){return c?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...x,children:h}):e.jsx("code",{className:`${d} block bg-muted p-4 rounded-lg overflow-x-auto`,...x,children:h})},table({children:c,...d}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...d,children:c})})},th({children:c,...d}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...d,children:c})},td({children:c,...d}){return e.jsx("td",{className:"border border-border px-4 py-2",...d,children:c})},a({children:c,...d}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...d,children:c})},blockquote({children:c,...d}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...d,children:c})},h1({children:c,...d}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...d,children:c})},h2({children:c,...d}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...d,children:c})},h3({children:c,...d}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...d,children:c})},h4({children:c,...d}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...d,children:c})},ul({children:c,...d}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...d,children:c})},ol({children:c,...d}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...d,children:c})},p({children:c,...d}){return e.jsx("p",{className:"my-2 leading-relaxed",...d,children:c})},hr({...c}){return e.jsx("hr",{className:"my-4 border-border",...c})}},children:n})})}function Bw({children:n,className:r}){return e.jsx(Uw,{content:n,className:r})}const La="/api/webui/emoji";async function Hw(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.is_registered!==void 0&&r.append("is_registered",n.is_registered.toString()),n.is_banned!==void 0&&r.append("is_banned",n.is_banned.toString()),n.format&&r.append("format",n.format),n.sort_by&&r.append("sort_by",n.sort_by),n.sort_order&&r.append("sort_order",n.sort_order);const c=await ke(`${La}/list?${r}`,{});if(!c.ok)throw new Error(`获取表情包列表失败: ${c.statusText}`);return c.json()}async function qw(n){const r=await ke(`${La}/${n}`,{});if(!r.ok)throw new Error(`获取表情包详情失败: ${r.statusText}`);return r.json()}async function Gw(n,r){const c=await ke(`${La}/${n}`,{method:"PATCH",body:JSON.stringify(r)});if(!c.ok)throw new Error(`更新表情包失败: ${c.statusText}`);return c.json()}async function Vw(n){const r=await ke(`${La}/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`删除表情包失败: ${r.statusText}`);return r.json()}async function Fw(){const n=await ke(`${La}/stats/summary`,{});if(!n.ok)throw new Error(`获取统计数据失败: ${n.statusText}`);return n.json()}async function $w(n){const r=await ke(`${La}/${n}/register`,{method:"POST"});if(!r.ok)throw new Error(`注册表情包失败: ${r.statusText}`);return r.json()}async function Qw(n){const r=await ke(`${La}/${n}/ban`,{method:"POST"});if(!r.ok)throw new Error(`封禁表情包失败: ${r.statusText}`);return r.json()}function Fg(n){return`${La}/${n}/thumbnail`}async function Yw(n){const r=await ke(`${La}/batch/delete`,{method:"POST",body:JSON.stringify({emoji_ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除失败")}return r.json()}function Xw(){return`${La}/upload`}function Kw(){const[n,r]=u.useState([]),[c,d]=u.useState(null),[h,x]=u.useState(!1),[f,j]=u.useState(1),[p,w]=u.useState(0),[v,k]=u.useState(20),[T,E]=u.useState("all"),[R,K]=u.useState("all"),[U,A]=u.useState("all"),[Z,H]=u.useState("usage_count"),[z,B]=u.useState("desc"),[X,S]=u.useState(null),[O,te]=u.useState(!1),[he,Ne]=u.useState(!1),[ye,pe]=u.useState(!1),[je,_e]=u.useState(new Set),[N,G]=u.useState(!1),[q,ie]=u.useState(""),[_,me]=u.useState("medium"),[xe,$]=u.useState(!1),{toast:de}=Hs(),ge=u.useCallback(async()=>{try{x(!0);const re=await Hw({page:f,page_size:v,is_registered:T==="all"?void 0:T==="registered",is_banned:R==="all"?void 0:R==="banned",format:U==="all"?void 0:U,sort_by:Z,sort_order:z});r(re.data),w(re.total)}catch(re){const be=re instanceof Error?re.message:"加载表情包列表失败";de({title:"错误",description:be,variant:"destructive"})}finally{x(!1)}},[f,v,T,R,U,Z,z,de]),le=async()=>{try{const re=await Fw();d(re.data)}catch(re){console.error("加载统计数据失败:",re)}};u.useEffect(()=>{ge()},[ge]),u.useEffect(()=>{le()},[]);const L=async re=>{try{const be=await qw(re.id);S(be.data),te(!0)}catch(be){const Xe=be instanceof Error?be.message:"加载详情失败";de({title:"错误",description:Xe,variant:"destructive"})}},F=re=>{S(re),Ne(!0)},D=re=>{S(re),pe(!0)},ee=async()=>{if(X)try{await Vw(X.id),de({title:"成功",description:"表情包已删除"}),pe(!1),S(null),ge(),le()}catch(re){const be=re instanceof Error?re.message:"删除失败";de({title:"错误",description:be,variant:"destructive"})}},we=async re=>{try{await $w(re.id),de({title:"成功",description:"表情包已注册"}),ge(),le()}catch(be){const Xe=be instanceof Error?be.message:"注册失败";de({title:"错误",description:Xe,variant:"destructive"})}},ze=async re=>{try{await Qw(re.id),de({title:"成功",description:"表情包已封禁"}),ge(),le()}catch(be){const Xe=be instanceof Error?be.message:"封禁失败";de({title:"错误",description:Xe,variant:"destructive"})}},ss=re=>{const be=new Set(je);be.has(re)?be.delete(re):be.add(re),_e(be)},Ze=async()=>{try{const re=await Yw(Array.from(je));de({title:"批量删除完成",description:re.message}),_e(new Set),G(!1),ge(),le()}catch(re){de({title:"批量删除失败",description:re instanceof Error?re.message:"批量删除失败",variant:"destructive"})}},Ls=()=>{const re=parseInt(q),be=Math.ceil(p/v);re>=1&&re<=be?(j(re),ie("")):de({title:"无效的页码",description:`请输入1-${be}之间的页码`,variant:"destructive"})},Gs=c?.formats?Object.keys(c.formats):[];return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"表情包管理"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理麦麦的表情包资源"})]}),e.jsxs(y,{onClick:()=>$(!0),className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(Pe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[c&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Fe,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"总数"}),e.jsx(js,{className:"text-2xl",children:c.total})]})}),e.jsx(Fe,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"已注册"}),e.jsx(js,{className:"text-2xl text-green-600",children:c.registered})]})}),e.jsx(Fe,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"已封禁"}),e.jsx(js,{className:"text-2xl text-red-600",children:c.banned})]})}),e.jsx(Fe,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"未注册"}),e.jsx(js,{className:"text-2xl text-gray-600",children:c.unregistered})]})})]}),e.jsxs(Fe,{children:[e.jsx(gs,{children:e.jsxs(js,{className:"flex items-center gap-2",children:[e.jsx(Lu,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(bs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"排序方式"}),e.jsxs(He,{value:`${Z}-${z}`,onValueChange:re=>{const[be,Xe]=re.split("-");H(be),B(Xe),j(1)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(ne,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(ne,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(ne,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(ne,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(ne,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(ne,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(ne,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"注册状态"}),e.jsxs(He,{value:T,onValueChange:re=>{E(re),j(1)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部"}),e.jsx(ne,{value:"registered",children:"已注册"}),e.jsx(ne,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"封禁状态"}),e.jsxs(He,{value:R,onValueChange:re=>{K(re),j(1)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部"}),e.jsx(ne,{value:"banned",children:"已封禁"}),e.jsx(ne,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"格式"}),e.jsxs(He,{value:U,onValueChange:re=>{A(re),j(1)},children:[e.jsx(Re,{children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部"}),Gs.map(re=>e.jsxs(ne,{value:re,children:[re.toUpperCase()," (",c?.formats[re],")"]},re))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[je.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",je.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs(He,{value:_,onValueChange:re=>me(re),children:[e.jsx(Re,{className:"w-24",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"small",children:"小"}),e.jsx(ne,{value:"medium",children:"中"}),e.jsx(ne,{value:"large",children:"大"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(He,{value:v.toString(),onValueChange:re=>{k(parseInt(re)),j(1),_e(new Set)},children:[e.jsx(Re,{id:"emoji-page-size",className:"w-20",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"20",children:"20"}),e.jsx(ne,{value:"40",children:"40"}),e.jsx(ne,{value:"60",children:"60"}),e.jsx(ne,{value:"100",children:"100"})]})]}),je.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>_e(new Set),children:"取消选择"}),e.jsxs(y,{variant:"destructive",size:"sm",onClick:()=>G(!0),children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(y,{variant:"outline",size:"sm",onClick:ge,disabled:h,children:[e.jsx(pt,{className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"表情包列表"}),e.jsxs(Zs,{children:["共 ",p," 个表情包,当前第 ",f," 页"]})]}),e.jsxs(bs,{children:[n.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${_==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":_==="medium"?"grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8":"grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5"}`,children:n.map(re=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${je.has(re.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>ss(re.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${je.has(re.id)?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:e.jsx("div",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center ${je.has(re.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:je.has(re.id)&&e.jsx(pa,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[re.is_registered&&e.jsx(Ye,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),re.is_banned&&e.jsx(Ye,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"已封禁"})]}),e.jsx("div",{className:`aspect-square bg-muted flex items-center justify-center overflow-hidden ${_==="small"?"p-1":_==="medium"?"p-2":"p-3"}`,children:e.jsx("img",{src:Fg(re.id),alt:"表情包",className:"w-full h-full object-contain",loading:"lazy",onError:be=>{const Xe=be.target;Xe.style.display="none";const Ue=Xe.parentElement;Ue&&(Ue.innerHTML='')}})}),e.jsxs("div",{className:`border-t bg-card ${_==="small"?"p-1":"p-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 text-xs text-muted-foreground mb-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1 py-0",children:re.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[re.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${_==="small"?"flex-wrap":""}`,children:[e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:be=>{be.stopPropagation(),F(re)},title:"编辑",children:e.jsx(pr,{className:"h-3 w-3"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:be=>{be.stopPropagation(),L(re)},title:"详情",children:e.jsx(Xt,{className:"h-3 w-3"})}),!re.is_registered&&e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:be=>{be.stopPropagation(),we(re)},title:"注册",children:e.jsx(pa,{className:"h-3 w-3"})}),!re.is_banned&&e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:be=>{be.stopPropagation(),ze(re)},title:"封禁",children:e.jsx(BN,{className:"h-3 w-3"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:be=>{be.stopPropagation(),D(re)},title:"删除",children:e.jsx(es,{className:"h-3 w-3"})})]})]})]},re.id))}),p>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["显示 ",(f-1)*v+1," 到"," ",Math.min(f*v,p)," 条,共 ",p," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(re=>Math.max(1,re-1)),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:q,onChange:re=>ie(re.target.value),onKeyDown:re=>re.key==="Enter"&&Ls(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(p/v)}),e.jsx(y,{variant:"outline",size:"sm",onClick:Ls,disabled:!q,className:"h-8",children:"跳转"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(re=>re+1),disabled:f>=Math.ceil(p/v),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(p/v)),disabled:f>=Math.ceil(p/v),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(Zw,{emoji:X,open:O,onOpenChange:te}),e.jsx(Jw,{emoji:X,open:he,onOpenChange:Ne,onSuccess:()=>{ge(),le()}}),e.jsx(Iw,{open:xe,onOpenChange:$,onSuccess:()=>{ge(),le()}})]})}),e.jsx(ps,{open:N,onOpenChange:G,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认批量删除"}),e.jsxs(us,{children:["你确定要删除选中的 ",je.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:Ze,children:"确认删除"})]})]})}),e.jsx(Rs,{open:ye,onOpenChange:pe,children:e.jsxs(zs,{children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"确认删除"}),e.jsx(Ys,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>pe(!1),children:"取消"}),e.jsx(y,{variant:"destructive",onClick:ee,children:"删除"})]})]})})]})}function Zw({emoji:n,open:r,onOpenChange:c}){if(!n)return null;const d=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(Ms,{children:e.jsx(As,{children:"表情包详情"})}),e.jsx(Pe,{className:"max-h-[calc(90vh-8rem)] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-32 h-32 bg-muted rounded-lg flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:Fg(n.id),alt:n.description||"表情包",className:"w-full h-full object-cover",onError:h=>{const x=h.target;x.style.display="none";const f=x.parentElement;f&&(f.innerHTML='')}})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:n.id})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ye,{variant:"outline",children:n.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.full_path})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"描述"}),n.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(Bw,{className:"prose-sm",children:n.description})}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"-"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"情绪"}),e.jsx("div",{className:"mt-1",children:n.emotion?e.jsx("span",{className:"text-sm",children:n.emotion}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[n.is_registered&&e.jsx(Ye,{variant:"default",className:"bg-green-600",children:"已注册"}),n.is_banned&&e.jsx(Ye,{variant:"destructive",children:"已封禁"}),!n.is_registered&&!n.is_banned&&e.jsx(Ye,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:n.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.record_time)})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.last_used_time)})]})]})})]})})}function Jw({emoji:n,open:r,onOpenChange:c,onSuccess:d}){const[h,x]=u.useState(""),[f,j]=u.useState(!1),[p,w]=u.useState(!1),[v,k]=u.useState(!1),{toast:T}=Hs();u.useEffect(()=>{n&&(x(n.emotion||""),j(n.is_registered),w(n.is_banned))},[n]);const E=async()=>{if(n)try{k(!0);const R=h.split(/[,,]/).map(K=>K.trim()).filter(Boolean).join(",");await Gw(n.id,{emotion:R||void 0,is_registered:f,is_banned:p}),T({title:"成功",description:"表情包信息已更新"}),c(!1),d()}catch(R){const K=R instanceof Error?R.message:"保存失败";T({title:"错误",description:K,variant:"destructive"})}finally{k(!1)}};return n?e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"编辑表情包"}),e.jsx(Ys,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(b,{children:"情绪"}),e.jsx(Bs,{value:h,onChange:R=>x(R.target.value),placeholder:"输入情绪描述...",rows:2,className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入情绪相关的文本描述"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"is_registered",checked:f,onCheckedChange:R=>{R===!0?(j(!0),w(!1)):j(!1)}}),e.jsx(b,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"is_banned",checked:p,onCheckedChange:R=>{R===!0?(w(!0),j(!1)):w(!1)}}),e.jsx(b,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(y,{onClick:E,disabled:v,children:v?"保存中...":"保存"})]})]})}):null}function Iw({open:n,onOpenChange:r,onSuccess:c}){const[d,h]=u.useState("select"),[x,f]=u.useState([]),[j,p]=u.useState(null),[w,v]=u.useState(!1),{toast:k}=Hs(),T=u.useMemo(()=>new Nb({id:"emoji-uploader",autoProceed:!1,restrictions:{maxFileSize:10485760,allowedFileTypes:["image/jpeg","image/png","image/gif","image/webp"],maxNumberOfFiles:20},locale:{pluralize:()=>0,strings:{addMoreFiles:"添加更多文件",addingMoreFiles:"正在添加更多文件",allowedFileTypes:"允许的文件类型:%{types}",cancel:"取消",closeModal:"关闭",complete:"完成",connectedToInternet:"已连接到互联网",copyLink:"复制链接",copyLinkToClipboardFallback:"复制下方链接",copyLinkToClipboardSuccess:"链接已复制到剪贴板",dashboardTitle:"选择文件",dashboardWindowTitle:"文件选择窗口(按 ESC 关闭)",done:"完成",dropHereOr:"拖放文件到这里或 %{browse}",dropHint:"将文件拖放到此处",dropPasteFiles:"将文件拖放到这里或 %{browseFiles}",dropPasteFolders:"将文件拖放到这里或 %{browseFolders}",dropPasteBoth:"将文件拖放到这里,%{browseFiles} 或 %{browseFolders}",dropPasteImportFiles:"将文件拖放到这里,%{browseFiles} 或从以下位置导入:",dropPasteImportFolders:"将文件拖放到这里,%{browseFolders} 或从以下位置导入:",dropPasteImportBoth:"将文件拖放到这里,%{browseFiles},%{browseFolders} 或从以下位置导入:",editFile:"编辑文件",editing:"正在编辑 %{file}",emptyFolderAdded:"未从空文件夹添加文件",exceedsSize:"%{file} 超过了最大允许大小 %{size}",failedToUpload:"上传 %{file} 失败",fileSource:"文件来源:%{name}",filesUploadedOfTotal:{0:"已上传 %{complete} / %{smart_count} 个文件",1:"已上传 %{complete} / %{smart_count} 个文件"},filter:"筛选",finishEditingFile:"完成编辑文件",folderAdded:{0:"已从 %{folder} 添加 %{smart_count} 个文件",1:"已从 %{folder} 添加 %{smart_count} 个文件"},generatingThumbnails:"正在生成缩略图...",import:"导入",importFiles:"从以下位置导入文件:",importFrom:"从 %{name} 导入",loading:"加载中...",logOut:"登出",myDevice:"我的设备",noFilesFound:"这里没有文件或文件夹",noInternetConnection:"无网络连接",openFolderNamed:"打开文件夹 %{name}",pause:"暂停",pauseUpload:"暂停上传",paused:"已暂停",poweredBy:"技术支持:%{uppy}",processingXFiles:{0:"正在处理 %{smart_count} 个文件",1:"正在处理 %{smart_count} 个文件"},recording:"录制中",removeFile:"移除文件",resetFilter:"重置筛选",resume:"继续",resumeUpload:"继续上传",retry:"重试",retryUpload:"重试上传",save:"保存",saveChanges:"保存更改",selectFileNamed:"选择文件 %{name}",selectX:{0:"选择 %{smart_count}",1:"选择 %{smart_count}"},smile:"笑一个!",startRecording:"开始录制视频",stopRecording:"停止录制视频",takePicture:"拍照",timedOut:"上传已停滞 %{seconds} 秒,正在中止。",upload:"下一步",uploadComplete:"上传完成",uploadFailed:"上传失败",uploadPaused:"上传已暂停",uploadXFiles:{0:"下一步(%{smart_count} 个文件)",1:"下一步(%{smart_count} 个文件)"},uploadXNewFiles:{0:"下一步(+%{smart_count} 个文件)",1:"下一步(+%{smart_count} 个文件)"},uploading:"正在上传",uploadingXFiles:{0:"正在上传 %{smart_count} 个文件",1:"正在上传 %{smart_count} 个文件"},xFilesSelected:{0:"已选择 %{smart_count} 个文件",1:"已选择 %{smart_count} 个文件"},xMoreFilesAdded:{0:"又添加了 %{smart_count} 个文件",1:"又添加了 %{smart_count} 个文件"},xTimeLeft:"剩余 %{time}",youCanOnlyUploadFileTypes:"您只能上传:%{types}",youCanOnlyUploadX:{0:"您只能上传 %{smart_count} 个文件",1:"您只能上传 %{smart_count} 个文件"},youHaveToAtLeastSelectX:{0:"您至少需要选择 %{smart_count} 个文件",1:"您至少需要选择 %{smart_count} 个文件"},browseFiles:"浏览文件",browseFolders:"浏览文件夹",cancelUpload:"取消上传",addMore:"添加更多",back:"返回",editFileWithFilename:"编辑文件 %{file}"}}}),[]);u.useEffect(()=>{const X=()=>{const S=T.getFiles();if(S.length===0)return;const O=S.map(te=>({id:te.id,name:te.name,previewUrl:te.preview||URL.createObjectURL(te.data),emotion:"",description:"",isRegistered:!0,file:te.data}));f(O),S.length===1?(p(O[0].id),h("edit-single")):h("edit-multiple")};return T.on("upload",X),()=>{T.off("upload",X)}},[T]),u.useEffect(()=>{n||(T.cancelAll(),h("select"),f([]),p(null),v(!1))},[n,T]);const E=u.useCallback((X,S)=>{f(O=>O.map(te=>te.id===X?{...te,...S}:te))},[]),R=u.useCallback(X=>X.emotion.trim().length>0,[]),K=u.useMemo(()=>x.length>0&&x.every(R),[x,R]),U=u.useMemo(()=>x.find(X=>X.id===j)||null,[x,j]),A=u.useCallback(()=>{(d==="edit-single"||d==="edit-multiple")&&(h("select"),f([]),p(null))},[d]),Z=u.useCallback(async()=>{if(!K){k({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}v(!0);const X=localStorage.getItem("access-token")||"";let S=0,O=0;try{for(const te of x){const he=new FormData;he.append("file",te.file),he.append("emotion",te.emotion),he.append("description",te.description),he.append("is_registered",te.isRegistered.toString());try{(await fetch(Xw(),{method:"POST",headers:{Authorization:`Bearer ${X}`},body:he})).ok?S++:O++}catch{O++}}O===0?(k({title:"上传成功",description:`成功上传 ${S} 个表情包`}),r(!1),c()):(k({title:"部分上传失败",description:`成功 ${S} 个,失败 ${O} 个`,variant:"destructive"}),c())}finally{v(!1)}},[K,x,k,r,c]),H=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(Lw,{uppy:T,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),z=()=>{const X=x[0];return X?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:A,children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"编辑表情包信息"})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"w-32 h-32 rounded-lg border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:X.previewUrl,alt:X.name,className:"max-w-full max-h-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate max-w-32",children:X.name})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"single-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"single-emotion",value:X.emotion,onChange:S=>E(X.id,{emotion:S.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:X.emotion.trim()?"":"border-destructive"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于情感匹配,多个标签用逗号分隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"single-description",children:"描述"}),e.jsx(ce,{id:"single-description",value:X.description,onChange:S=>E(X.id,{description:S.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"single-is-registered",checked:X.isRegistered,onCheckedChange:S=>E(X.id,{isRegistered:S===!0})}),e.jsx(b,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(Js,{children:e.jsx(y,{onClick:Z,disabled:!K||w,children:w?"上传中...":"上传"})})]}):null},B=()=>{const X=x.filter(R).length,S=x.length;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:A,children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",X,"/",S," 已完成)"]})]}),e.jsx(Ye,{variant:K?"default":"secondary",children:K?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Pe,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:x.map(O=>{const te=R(O),he=j===O.id;return e.jsxs("div",{onClick:()=>p(O.id),className:` + flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all + ${he?"ring-2 ring-primary":""} + ${te?"border-green-500 bg-green-50 dark:bg-green-950/20":"border-border hover:border-muted-foreground/50"} + `,children:[e.jsx("div",{className:"w-12 h-12 rounded border overflow-hidden bg-muted flex-shrink-0 flex items-center justify-center",children:e.jsx("img",{src:O.previewUrl,alt:O.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:O.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:O.emotion||"未填写情感标签"})]}),te?e.jsx(pa,{className:"h-5 w-5 text-green-500 flex-shrink-0"}):e.jsx("div",{className:"h-5 w-5 rounded-full border-2 border-muted-foreground/30 flex-shrink-0"})]},O.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:U?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:U.previewUrl,alt:U.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:U.name}),R(U)&&e.jsxs(Ye,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),"已完成"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"multi-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"multi-emotion",value:U.emotion,onChange:O=>E(U.id,{emotion:O.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:U.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"multi-description",children:"描述"}),e.jsx(ce,{id:"multi-description",value:U.description,onChange:O=>E(U.id,{description:O.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"multi-is-registered",checked:U.isRegistered,onCheckedChange:O=>E(U.id,{isRegistered:O===!0})}),e.jsx(b,{htmlFor:"multi-is-registered",className:"cursor-pointer text-sm",children:"上传后立即注册"})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(HN,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(Js,{children:e.jsx(y,{onClick:Z,disabled:!K||w,children:w?"上传中...":`上传全部 (${S})`})})]})};return e.jsx(Rs,{open:n,onOpenChange:r,children:e.jsxs(zs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(Ms,{children:[e.jsxs(As,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),d==="select"&&"上传表情包 - 选择文件",d==="edit-single"&&"上传表情包 - 填写信息",d==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs(Ys,{children:[d==="select"&&"支持 JPG、PNG、GIF、WebP 格式,单个文件最大 10MB,可同时上传多个文件",d==="edit-single"&&"请填写表情包的情感标签(必填)和描述",d==="edit-multiple"&&"点击左侧卡片编辑每个表情包的信息,情感标签为必填项"]})]}),e.jsxs("div",{className:"overflow-y-auto pr-1",children:[d==="select"&&H(),d==="edit-single"&&z(),d==="edit-multiple"&&B()]})]})})}const Bl="/api/webui/expression";async function Pw(){const n=await ke(`${Bl}/chats`,{});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取聊天列表失败")}return n.json()}async function Ww(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.chat_id&&r.append("chat_id",n.chat_id);const c=await ke(`${Bl}/list?${r}`,{});if(!c.ok){const d=await c.json();throw new Error(d.detail||"获取表达方式列表失败")}return c.json()}async function e1(n){const r=await ke(`${Bl}/${n}`,{});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取表达方式详情失败")}return r.json()}async function s1(n){const r=await ke(`${Bl}/`,{method:"POST",body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"创建表达方式失败")}return r.json()}async function t1(n,r){const c=await ke(`${Bl}/${n}`,{method:"PATCH",body:JSON.stringify(r)});if(!c.ok){const d=await c.json();throw new Error(d.detail||"更新表达方式失败")}return c.json()}async function a1(n){const r=await ke(`${Bl}/${n}`,{method:"DELETE"});if(!r.ok){const c=await r.json();throw new Error(c.detail||"删除表达方式失败")}return r.json()}async function l1(n){const r=await ke(`${Bl}/batch/delete`,{method:"POST",body:JSON.stringify({ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除表达方式失败")}return r.json()}async function n1(){const n=await ke(`${Bl}/stats/summary`,{});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取统计数据失败")}return n.json()}function i1(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(0),[f,j]=u.useState(1),[p,w]=u.useState(20),[v,k]=u.useState(""),[T,E]=u.useState(null),[R,K]=u.useState(!1),[U,A]=u.useState(!1),[Z,H]=u.useState(!1),[z,B]=u.useState(null),[X,S]=u.useState(new Set),[O,te]=u.useState(!1),[he,Ne]=u.useState(""),[ye,pe]=u.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[je,_e]=u.useState([]),[N,G]=u.useState(new Map),{toast:q}=Hs(),ie=async()=>{try{d(!0);const ee=await Ww({page:f,page_size:p,search:v||void 0});r(ee.data),x(ee.total)}catch(ee){q({title:"加载失败",description:ee instanceof Error?ee.message:"无法加载表达方式",variant:"destructive"})}finally{d(!1)}},_=async()=>{try{const ee=await n1();ee?.data&&pe(ee.data)}catch(ee){console.error("加载统计数据失败:",ee)}},me=async()=>{try{const ee=await Pw();if(ee?.data){_e(ee.data);const we=new Map;ee.data.forEach(ze=>{we.set(ze.chat_id,ze.chat_name)}),G(we)}}catch(ee){console.error("加载聊天列表失败:",ee)}},xe=ee=>N.get(ee)||ee;u.useEffect(()=>{ie(),_(),me()},[f,p,v]);const $=async ee=>{try{const we=await e1(ee.id);E(we.data),K(!0)}catch(we){q({title:"加载详情失败",description:we instanceof Error?we.message:"无法加载表达方式详情",variant:"destructive"})}},de=ee=>{E(ee),A(!0)},ge=async ee=>{try{await a1(ee.id),q({title:"删除成功",description:`已删除表达方式: ${ee.situation}`}),B(null),ie(),_()}catch(we){q({title:"删除失败",description:we instanceof Error?we.message:"无法删除表达方式",variant:"destructive"})}},le=ee=>{const we=new Set(X);we.has(ee)?we.delete(ee):we.add(ee),S(we)},L=()=>{X.size===n.length&&n.length>0?S(new Set):S(new Set(n.map(ee=>ee.id)))},F=async()=>{try{await l1(Array.from(X)),q({title:"批量删除成功",description:`已删除 ${X.size} 个表达方式`}),S(new Set),te(!1),ie(),_()}catch(ee){q({title:"批量删除失败",description:ee instanceof Error?ee.message:"无法批量删除表达方式",variant:"destructive"})}},D=()=>{const ee=parseInt(he),we=Math.ceil(h/p);ee>=1&&ee<=we?(j(ee),Ne("")):q({title:"无效的页码",description:`请输入1-${we}之间的页码`,variant:"destructive"})};return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(si,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs(y,{onClick:()=>H(!0),className:"gap-2",children:[e.jsx(ot,{className:"h-4 w-4"}),"新增表达方式"]})]})}),e.jsx(Pe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:ye.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"近7天新增"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:ye.recent_7days})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-blue-600",children:ye.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx(b,{htmlFor:"search",children:"搜索"}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2 mt-1.5",children:e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(_t,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索情境、风格或上下文...",value:v,onChange:ee=>k(ee.target.value),className:"pl-9"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:X.size>0&&e.jsxs("span",{children:["已选择 ",X.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(He,{value:p.toString(),onValueChange:ee=>{w(parseInt(ee)),j(1),S(new Set)},children:[e.jsx(Re,{id:"page-size",className:"w-20",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"10",children:"10"}),e.jsx(ne,{value:"20",children:"20"}),e.jsx(ne,{value:"50",children:"50"}),e.jsx(ne,{value:"100",children:"100"})]})]}),X.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>S(new Set),children:"取消选择"}),e.jsxs(y,{variant:"destructive",size:"sm",onClick:()=>te(!0),children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(gt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:X.size===n.length&&n.length>0,onCheckedChange:L})}),e.jsx(ls,{children:"情境"}),e.jsx(ls,{children:"风格"}),e.jsx(ls,{children:"聊天"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c?e.jsx(gt,{children:e.jsx(Qe,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(gt,{children:e.jsx(Qe,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(ee=>e.jsxs(gt,{children:[e.jsx(Qe,{children:e.jsx(yt,{checked:X.has(ee.id),onCheckedChange:()=>le(ee.id)})}),e.jsx(Qe,{className:"font-medium max-w-xs truncate",children:ee.situation}),e.jsx(Qe,{className:"max-w-xs truncate",children:ee.style}),e.jsx(Qe,{className:"max-w-[200px] truncate",title:xe(ee.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:xe(ee.chat_id)})}),e.jsx(Qe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(y,{variant:"default",size:"sm",onClick:()=>de(ee),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(ee),title:"查看详情",children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsxs(y,{size:"sm",onClick:()=>B(ee),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},ee.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:c?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(ee=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(yt,{checked:X.has(ee.id),onCheckedChange:()=>le(ee.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"情境"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-2 w-full break-all",title:ee.situation,children:ee.situation})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"风格"}),e.jsx("p",{className:"text-sm line-clamp-2 w-full break-all",title:ee.style,children:ee.style})]})]})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"聊天"}),e.jsx("p",{className:"text-sm truncate",title:xe(ee.chat_id),style:{wordBreak:"keep-all"},children:xe(ee.chat_id)})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>de(ee),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>$(ee),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(Zt,{className:"h-3 w-3"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>B(ee),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(es,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},ee.id))}),h>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",h," 条记录,第 ",f," / ",Math.ceil(h/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(f-1),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:he,onChange:ee=>Ne(ee.target.value),onKeyDown:ee=>ee.key==="Enter"&&D(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(h/p)}),e.jsx(y,{variant:"outline",size:"sm",onClick:D,disabled:!he,className:"h-8",children:"跳转"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(f+1),disabled:f>=Math.ceil(h/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(h/p)),disabled:f>=Math.ceil(h/p),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(r1,{expression:T,open:R,onOpenChange:K,chatNameMap:N}),e.jsx(c1,{open:Z,onOpenChange:H,chatList:je,onSuccess:()=>{ie(),_(),H(!1)}}),e.jsx(o1,{expression:T,open:U,onOpenChange:A,chatList:je,onSuccess:()=>{ie(),_(),A(!1)}}),e.jsx(ps,{open:!!z,onOpenChange:()=>B(null),children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除表达方式 "',z?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>z&&ge(z),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(d1,{open:O,onOpenChange:te,onConfirm:F,count:X.size})]})}function r1({expression:n,open:r,onOpenChange:c,chatNameMap:d}){if(!n)return null;const h=f=>f?new Date(f*1e3).toLocaleString("zh-CN"):"-",x=f=>d.get(f)||f;return e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"表达方式详情"}),e.jsx(Ys,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(nr,{label:"情境",value:n.situation}),e.jsx(nr,{label:"风格",value:n.style}),e.jsx(nr,{label:"聊天",value:x(n.chat_id)}),e.jsx(nr,{icon:Uu,label:"记录ID",value:n.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(nr,{icon:Wn,label:"创建时间",value:h(n.create_date)})})]}),e.jsx(Js,{children:e.jsx(y,{onClick:()=>c(!1),children:"关闭"})})]})})}function nr({icon:n,label:r,value:c,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),r]}),e.jsx("div",{className:Q("text-sm",d&&"font-mono",!c&&"text-muted-foreground"),children:c||"-"})]})}function c1({open:n,onOpenChange:r,chatList:c,onSuccess:d}){const[h,x]=u.useState({situation:"",style:"",chat_id:""}),[f,j]=u.useState(!1),{toast:p}=Hs(),w=async()=>{if(!h.situation||!h.style||!h.chat_id){p({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{j(!0),await s1(h),p({title:"创建成功",description:"表达方式已创建"}),x({situation:"",style:"",chat_id:""}),d()}catch(v){p({title:"创建失败",description:v instanceof Error?v.message:"无法创建表达方式",variant:"destructive"})}finally{j(!1)}};return e.jsx(Rs,{open:n,onOpenChange:r,children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"新增表达方式"}),e.jsx(Ys,{children:"创建新的表达方式记录"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"situation",value:h.situation,onChange:v=>x({...h,situation:v.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"style",value:h.style,onChange:v=>x({...h,style:v.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(He,{value:h.chat_id,onValueChange:v=>x({...h,chat_id:v}),children:[e.jsx(Re,{children:e.jsx(qe,{placeholder:"选择关联的聊天"})}),e.jsx(Le,{children:c.map(v=>e.jsx(ne,{value:v.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[v.chat_name,v.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},v.chat_id))})]})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(y,{onClick:w,disabled:f,children:f?"创建中...":"创建"})]})]})})}function o1({expression:n,open:r,onOpenChange:c,chatList:d,onSuccess:h}){const[x,f]=u.useState({}),[j,p]=u.useState(!1),{toast:w}=Hs();u.useEffect(()=>{n&&f({situation:n.situation,style:n.style,chat_id:n.chat_id})},[n]);const v=async()=>{if(n)try{p(!0),await t1(n.id,x),w({title:"保存成功",description:"表达方式已更新"}),h()}catch(k){w({title:"保存失败",description:k instanceof Error?k.message:"无法更新表达方式",variant:"destructive"})}finally{p(!1)}};return n?e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"编辑表达方式"}),e.jsx(Ys,{children:"修改表达方式的信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_situation",children:"情境"}),e.jsx(ce,{id:"edit_situation",value:x.situation||"",onChange:k=>f({...x,situation:k.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_style",children:"风格"}),e.jsx(ce,{id:"edit_style",value:x.style||"",onChange:k=>f({...x,style:k.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(He,{value:x.chat_id||"",onValueChange:k=>f({...x,chat_id:k}),children:[e.jsx(Re,{children:e.jsx(qe,{placeholder:"选择关联的聊天"})}),e.jsx(Le,{children:d.map(k=>e.jsx(ne,{value:k.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[k.chat_name,k.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},k.chat_id))})]})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(y,{onClick:v,disabled:j,children:j?"保存中...":"保存"})]})]})}):null}function d1({open:n,onOpenChange:r,onConfirm:c,count:d}){return e.jsx(ps,{open:n,onOpenChange:r,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认批量删除"}),e.jsxs(us,{children:["您即将删除 ",d," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const oi="/api/webui/person";async function u1(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.is_known!==void 0&&r.append("is_known",n.is_known.toString()),n.platform&&r.append("platform",n.platform);const c=await ke(`${oi}/list?${r}`,{headers:Ts()});if(!c.ok){const d=await c.json();throw new Error(d.detail||"获取人物列表失败")}return c.json()}async function m1(n){const r=await ke(`${oi}/${n}`,{headers:Ts()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取人物详情失败")}return r.json()}async function h1(n,r){const c=await ke(`${oi}/${n}`,{method:"PATCH",headers:Ts(),body:JSON.stringify(r)});if(!c.ok){const d=await c.json();throw new Error(d.detail||"更新人物信息失败")}return c.json()}async function x1(n){const r=await ke(`${oi}/${n}`,{method:"DELETE",headers:Ts()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"删除人物信息失败")}return r.json()}async function f1(){const n=await ke(`${oi}/stats/summary`,{headers:Ts()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取统计数据失败")}return n.json()}async function p1(n){const r=await ke(`${oi}/batch/delete`,{method:"POST",headers:Ts(),body:JSON.stringify({person_ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除失败")}return r.json()}function g1(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(0),[f,j]=u.useState(1),[p,w]=u.useState(20),[v,k]=u.useState(""),[T,E]=u.useState(void 0),[R,K]=u.useState(void 0),[U,A]=u.useState(null),[Z,H]=u.useState(!1),[z,B]=u.useState(!1),[X,S]=u.useState(null),[O,te]=u.useState({total:0,known:0,unknown:0,platforms:{}}),[he,Ne]=u.useState(new Set),[ye,pe]=u.useState(!1),[je,_e]=u.useState(""),{toast:N}=Hs(),G=async()=>{try{d(!0);const D=await u1({page:f,page_size:p,search:v||void 0,is_known:T,platform:R});r(D.data),x(D.total)}catch(D){N({title:"加载失败",description:D instanceof Error?D.message:"无法加载人物信息",variant:"destructive"})}finally{d(!1)}},q=async()=>{try{const D=await f1();D?.data&&te(D.data)}catch(D){console.error("加载统计数据失败:",D)}};u.useEffect(()=>{G(),q()},[f,p,v,T,R]);const ie=async D=>{try{const ee=await m1(D.person_id);A(ee.data),H(!0)}catch(ee){N({title:"加载详情失败",description:ee instanceof Error?ee.message:"无法加载人物详情",variant:"destructive"})}},_=D=>{A(D),B(!0)},me=async D=>{try{await x1(D.person_id),N({title:"删除成功",description:`已删除人物信息: ${D.person_name||D.nickname||D.user_id}`}),S(null),G(),q()}catch(ee){N({title:"删除失败",description:ee instanceof Error?ee.message:"无法删除人物信息",variant:"destructive"})}},xe=u.useMemo(()=>Object.keys(O.platforms),[O.platforms]),$=D=>{const ee=new Set(he);ee.has(D)?ee.delete(D):ee.add(D),Ne(ee)},de=()=>{he.size===n.length&&n.length>0?Ne(new Set):Ne(new Set(n.map(D=>D.person_id)))},ge=()=>{if(he.size===0){N({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}pe(!0)},le=async()=>{try{const D=await p1(Array.from(he));N({title:"批量删除完成",description:D.message}),Ne(new Set),pe(!1),G(),q()}catch(D){N({title:"批量删除失败",description:D instanceof Error?D.message:"批量删除失败",variant:"destructive"})}},L=()=>{const D=parseInt(je),ee=Math.ceil(h/p);D>=1&&D<=ee?(j(D),_e("")):N({title:"无效的页码",description:`请输入1-${ee}之间的页码`,variant:"destructive"})},F=D=>D?new Date(D*1e3).toLocaleString("zh-CN"):"-";return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(qN,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(Pe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总人数"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:O.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"已认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:O.known})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"未认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-muted-foreground",children:O.unknown})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(b,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(_t,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:v,onChange:D=>k(D.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(He,{value:T===void 0?"all":T.toString(),onValueChange:D=>{E(D==="all"?void 0:D==="true"),j(1)},children:[e.jsx(Re,{id:"filter-known",className:"mt-1.5",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部"}),e.jsx(ne,{value:"true",children:"已认识"}),e.jsx(ne,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(He,{value:R||"all",onValueChange:D=>{K(D==="all"?void 0:D),j(1)},children:[e.jsx(Re,{id:"filter-platform",className:"mt-1.5",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部平台"}),xe.map(D=>e.jsxs(ne,{value:D,children:[D," (",O.platforms[D],")"]},D))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:he.size>0&&e.jsxs("span",{children:["已选择 ",he.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(He,{value:p.toString(),onValueChange:D=>{w(parseInt(D)),j(1),Ne(new Set)},children:[e.jsx(Re,{id:"page-size",className:"w-20",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"10",children:"10"}),e.jsx(ne,{value:"20",children:"20"}),e.jsx(ne,{value:"50",children:"50"}),e.jsx(ne,{value:"100",children:"100"})]})]}),he.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>Ne(new Set),children:"取消选择"}),e.jsxs(y,{variant:"destructive",size:"sm",onClick:ge,children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(gt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:n.length>0&&he.size===n.length,onCheckedChange:de,"aria-label":"全选"})}),e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"昵称"}),e.jsx(ls,{children:"平台"}),e.jsx(ls,{children:"用户ID"}),e.jsx(ls,{children:"最后更新"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c?e.jsx(gt,{children:e.jsx(Qe,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(gt,{children:e.jsx(Qe,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(D=>e.jsxs(gt,{children:[e.jsx(Qe,{children:e.jsx(yt,{checked:he.has(D.person_id),onCheckedChange:()=>$(D.person_id),"aria-label":`选择 ${D.person_name||D.nickname||D.user_id}`})}),e.jsx(Qe,{children:e.jsx("div",{className:Q("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",D.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:D.is_known?"已认识":"未认识"})}),e.jsx(Qe,{className:"font-medium",children:D.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Qe,{children:D.nickname||"-"}),e.jsx(Qe,{children:D.platform}),e.jsx(Qe,{className:"font-mono text-sm",children:D.user_id}),e.jsx(Qe,{className:"text-sm text-muted-foreground",children:F(D.last_know)}),e.jsx(Qe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(y,{variant:"default",size:"sm",onClick:()=>ie(D),children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(y,{variant:"default",size:"sm",onClick:()=>_(D),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(y,{size:"sm",onClick:()=>S(D),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},D.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:c?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(D=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(yt,{checked:he.has(D.person_id),onCheckedChange:()=>$(D.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:Q("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",D.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:D.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:D.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),D.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",D.nickname]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"平台"}),e.jsx("p",{className:"font-medium text-xs",children:D.platform})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"用户ID"}),e.jsx("p",{className:"font-mono text-xs truncate",title:D.user_id,children:D.user_id})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"最后更新"}),e.jsx("p",{className:"text-xs",children:F(D.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>ie(D),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>_(D),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>S(D),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(es,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},D.id))}),h>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",h," 条记录,第 ",f," / ",Math.ceil(h/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(f-1),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:je,onChange:D=>_e(D.target.value),onKeyDown:D=>D.key==="Enter"&&L(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(h/p)}),e.jsx(y,{variant:"outline",size:"sm",onClick:L,disabled:!je,className:"h-8",children:"跳转"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>j(f+1),disabled:f>=Math.ceil(h/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(h/p)),disabled:f>=Math.ceil(h/p),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(j1,{person:U,open:Z,onOpenChange:H}),e.jsx(v1,{person:U,open:z,onOpenChange:B,onSuccess:()=>{G(),q(),B(!1)}}),e.jsx(ps,{open:!!X,onOpenChange:()=>S(null),children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认删除"}),e.jsxs(us,{children:['确定要删除人物信息 "',X?.person_name||X?.nickname||X?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:()=>X&&me(X),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(ps,{open:ye,onOpenChange:pe,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"确认批量删除"}),e.jsxs(us,{children:["确定要删除选中的 ",he.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(os,{children:[e.jsx(hs,{children:"取消"}),e.jsx(ms,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function j1({person:n,open:r,onOpenChange:c}){if(!n)return null;const d=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"人物详情"}),e.jsxs(Ys,{children:["查看 ",n.person_name||n.nickname||n.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(al,{icon:to,label:"人物名称",value:n.person_name}),e.jsx(al,{icon:si,label:"昵称",value:n.nickname}),e.jsx(al,{icon:Uu,label:"用户ID",value:n.user_id,mono:!0}),e.jsx(al,{icon:Uu,label:"人物ID",value:n.person_id,mono:!0}),e.jsx(al,{label:"平台",value:n.platform}),e.jsx(al,{label:"状态",value:n.is_known?"已认识":"未认识"})]}),n.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:n.name_reason})]}),n.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:n.memory_points})]}),n.group_nick_name&&n.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:n.group_nick_name.map((h,x)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:h.group_nick_name})]},x))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(al,{icon:Wn,label:"认识时间",value:d(n.know_times)}),e.jsx(al,{icon:Wn,label:"首次记录",value:d(n.know_since)}),e.jsx(al,{icon:Wn,label:"最后更新",value:d(n.last_know)})]})]}),e.jsx(Js,{children:e.jsx(y,{onClick:()=>c(!1),children:"关闭"})})]})})}function al({icon:n,label:r,value:c,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),r]}),e.jsx("div",{className:Q("text-sm",d&&"font-mono",!c&&"text-muted-foreground"),children:c||"-"})]})}function v1({person:n,open:r,onOpenChange:c,onSuccess:d}){const[h,x]=u.useState({}),[f,j]=u.useState(!1),{toast:p}=Hs();u.useEffect(()=>{n&&x({person_name:n.person_name||"",name_reason:n.name_reason||"",nickname:n.nickname||"",memory_points:n.memory_points||"",is_known:n.is_known})},[n]);const w=async()=>{if(n)try{j(!0),await h1(n.person_id,h),p({title:"保存成功",description:"人物信息已更新"}),d()}catch(v){p({title:"保存失败",description:v instanceof Error?v.message:"无法更新人物信息",variant:"destructive"})}finally{j(!1)}};return n?e.jsx(Rs,{open:r,onOpenChange:c,children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"编辑人物信息"}),e.jsxs(Ys,{children:["修改 ",n.person_name||n.nickname||n.user_id," 的信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"person_name",children:"人物名称"}),e.jsx(ce,{id:"person_name",value:h.person_name||"",onChange:v=>x({...h,person_name:v.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:h.nickname||"",onChange:v=>x({...h,nickname:v.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(Bs,{id:"name_reason",value:h.name_reason||"",onChange:v=>x({...h,name_reason:v.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"memory_points",children:"个人印象"}),e.jsx(Bs,{id:"memory_points",value:h.memory_points||"",onChange:v=>x({...h,memory_points:v.target.value}),placeholder:"对这个人的印象和记忆点...",rows:4})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(b,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(Ve,{id:"is_known",checked:h.is_known,onCheckedChange:v=>x({...h,is_known:v})})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(y,{onClick:w,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}var y1=Cb();const pp=_y(y1),Wu="/api/webui";async function N1(n=100,r="all"){const c=`${Wu}/knowledge/graph?limit=${n}&node_type=${r}`,d=await fetch(c);if(!d.ok)throw new Error(`获取知识图谱失败: ${d.status}`);return d.json()}async function b1(){const n=await fetch(`${Wu}/knowledge/stats`);if(!n.ok)throw new Error("获取知识图谱统计信息失败");return n.json()}async function w1(n){const r=await fetch(`${Wu}/knowledge/search?query=${encodeURIComponent(n)}`);if(!r.ok)throw new Error("搜索知识节点失败");return r.json()}const $g=u.memo(({data:n})=>e.jsxs("div",{className:"px-4 py-2 shadow-md rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700 min-w-[120px]",children:[e.jsx(lo,{type:"target",position:no.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:n.content,children:n.label}),e.jsx(lo,{type:"source",position:no.Bottom})]}));$g.displayName="EntityNode";const Qg=u.memo(({data:n})=>e.jsxs("div",{className:"px-3 py-2 shadow-md rounded-md bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700 min-w-[100px]",children:[e.jsx(lo,{type:"target",position:no.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:n.content,children:n.label}),e.jsx(lo,{type:"source",position:no.Bottom})]}));Qg.displayName="ParagraphNode";const _1={entity:$g,paragraph:Qg};function S1(n,r){const c=new pp.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const d=[],h=[];return n.forEach(x=>{c.setNode(x.id,{width:150,height:50})}),r.forEach(x=>{c.setEdge(x.source,x.target)}),pp.layout(c),n.forEach(x=>{const f=c.node(x.id);d.push({id:x.id,type:x.type,position:{x:f.x-75,y:f.y-25},data:{label:x.content.slice(0,20)+(x.content.length>20?"...":""),content:x.content}})}),r.forEach((x,f)=>{const j={id:`edge-${f}`,source:x.source,target:x.target,animated:n.length<=200&&x.weight>5,style:{strokeWidth:Math.min(x.weight/2,5),opacity:.6}};x.weight>10&&n.length<100&&(j.label=`${x.weight.toFixed(0)}`),h.push(j)}),{nodes:d,edges:h}}function C1(){const n=Jt(),[r,c]=u.useState(!1),[d,h]=u.useState(null),[x,f]=u.useState(""),[j,p]=u.useState("all"),[w,v]=u.useState(50),[k,T]=u.useState("50"),[E,R]=u.useState(!1),[K,U]=u.useState(!0),[A,Z]=u.useState(!1),[H,z]=u.useState(!1),[B,X,S]=kb([]),[O,te,he]=Tb([]),[Ne,ye]=u.useState(0),[pe,je]=u.useState(null),[_e,N]=u.useState(null),{toast:G}=Hs(),q=u.useCallback(le=>le.type==="entity"?"#6366f1":le.type==="paragraph"?"#10b981":"#6b7280",[]),ie=u.useCallback(async(le=!1)=>{try{if(!le&&w>200){z(!0);return}c(!0);const[L,F]=await Promise.all([N1(w,j),b1()]);if(h(F),L.nodes.length===0){G({title:"提示",description:"知识库为空,请先导入知识数据"}),X([]),te([]);return}const{nodes:D,edges:ee}=S1(L.nodes,L.edges);X(D),te(ee),ye(D.length),F&&F.total_nodes>w&&G({title:"提示",description:`知识图谱包含 ${F.total_nodes} 个节点,当前显示 ${D.length} 个`}),G({title:"加载成功",description:`已加载 ${D.length} 个节点,${ee.length} 条边`})}catch(L){console.error("加载知识图谱失败:",L),G({title:"加载失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}finally{c(!1)}},[w,j,G]),_=u.useCallback(async()=>{if(!x.trim()){G({title:"提示",description:"请输入搜索关键词"});return}try{const le=await w1(x);if(le.length===0){G({title:"未找到",description:"没有找到匹配的节点"});return}const L=new Set(le.map(F=>F.id));X(F=>F.map(D=>({...D,style:{...D.style,opacity:L.has(D.id)?1:.3,filter:L.has(D.id)?"brightness(1.2)":"brightness(0.8)"}}))),G({title:"搜索完成",description:`找到 ${le.length} 个匹配节点`})}catch(le){console.error("搜索失败:",le),G({title:"搜索失败",description:le instanceof Error?le.message:"未知错误",variant:"destructive"})}},[x,G]),me=u.useCallback(()=>{X(le=>le.map(L=>({...L,style:{...L.style,opacity:1,filter:"brightness(1)"}})))},[]),xe=u.useCallback(()=>{U(!1),Z(!0),ie()},[ie]),$=u.useCallback(()=>{z(!1),setTimeout(()=>{ie(!0)},0)},[ie]),de=u.useCallback((le,L)=>{B.find(D=>D.id===L.id)&&je({id:L.id,type:L.type,content:L.data.content})},[B]);u.useEffect(()=>{K||A&&ie()},[w,j,K,A]);const ge=u.useCallback((le,L)=>{const F=B.find(we=>we.id===L.source),D=B.find(we=>we.id===L.target),ee=O.find(we=>we.id===L.id);F&&D&&ee&&N({source:{id:F.id,type:F.type,content:F.data.content},target:{id:D.id,type:D.type,content:D.data.content},edge:{source:L.source,target:L.target,weight:parseFloat(L.label||"0")}})},[B,O]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦知识库图谱"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"可视化知识实体与关系网络"})]}),d&&e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(eo,{className:"h-3 w-3"}),"节点: ",d.total_nodes]}),e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(yg,{className:"h-3 w-3"}),"边: ",d.total_edges]}),e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Xt,{className:"h-3 w-3"}),"实体: ",d.entity_nodes]}),e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Aa,{className:"h-3 w-3"}),"段落: ",d.paragraph_nodes]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mt-4",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(ce,{placeholder:"搜索节点内容...",value:x,onChange:le=>f(le.target.value),onKeyDown:le=>le.key==="Enter"&&_(),className:"flex-1"}),e.jsx(y,{onClick:_,size:"sm",children:e.jsx(_t,{className:"h-4 w-4"})}),e.jsx(y,{onClick:me,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(He,{value:j,onValueChange:le=>p(le),children:[e.jsx(Re,{className:"w-[120px]",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部节点"}),e.jsx(ne,{value:"entity",children:"仅实体"}),e.jsx(ne,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs(He,{value:w===1e4?"all":E?"custom":w.toString(),onValueChange:le=>{le==="custom"?(R(!0),T(w.toString())):le==="all"?(R(!1),v(1e4)):(R(!1),v(Number(le)))},children:[e.jsx(Re,{className:"w-[120px]",children:e.jsx(qe,{})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"50",children:"50 节点"}),e.jsx(ne,{value:"100",children:"100 节点"}),e.jsx(ne,{value:"200",children:"200 节点"}),e.jsx(ne,{value:"500",children:"500 节点"}),e.jsx(ne,{value:"1000",children:"1000 节点"}),e.jsx(ne,{value:"all",children:"全部 (最多10000)"}),e.jsx(ne,{value:"custom",children:"自定义..."})]})]}),E&&e.jsx(ce,{type:"number",min:"50",value:k,onChange:le=>T(le.target.value),onBlur:()=>{const le=parseInt(k);!isNaN(le)&&le>=50?v(le):(T("50"),v(50))},onKeyDown:le=>{if(le.key==="Enter"){const L=parseInt(k);!isNaN(L)&&L>=50?v(L):(T("50"),v(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(y,{onClick:()=>ie(),variant:"outline",size:"sm",disabled:r,children:e.jsx(pt,{className:Q("h-4 w-4",r&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:r?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pt,{className:"h-8 w-8 animate-spin mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"加载知识图谱中..."})]})}):B.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(eo,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"知识库为空"}),e.jsx("p",{className:"text-muted-foreground",children:"请先导入知识数据"})]})}):e.jsxs(Eb,{nodes:B,edges:O,onNodesChange:S,onEdgesChange:he,onNodeClick:de,onEdgeClick:ge,nodeTypes:_1,fitView:!0,minZoom:.05,maxZoom:1.5,defaultViewport:{x:0,y:0,zoom:.5},elevateNodesOnSelect:Ne<=500,nodesDraggable:Ne<=1e3,attributionPosition:"bottom-left",children:[e.jsx(zb,{variant:Mb.Dots,gap:12,size:1}),e.jsx(Ab,{}),Ne<=500&&e.jsx(Db,{nodeColor:q,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(Ob,{position:"top-right",className:"bg-background/95 backdrop-blur-sm rounded-lg border p-3 shadow-lg",children:[e.jsx("div",{className:"text-sm font-semibold mb-2",children:"图例"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700"}),e.jsx("span",{children:"实体节点"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700"}),e.jsx("span",{children:"段落节点"})]}),Ne>200&&e.jsxs("div",{className:"mt-2 pt-2 border-t text-yellow-600 dark:text-yellow-500",children:[e.jsx("div",{className:"font-semibold",children:"性能模式"}),e.jsx("div",{children:"已禁用动画"}),Ne>500&&e.jsx("div",{children:"已禁用缩略图"})]})]})]})]})}),e.jsx(Rs,{open:!!pe,onOpenChange:le=>!le&&je(null),children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(Ms,{children:e.jsx(As,{children:"节点详情"})}),pe&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"类型"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ye,{variant:pe.type==="entity"?"default":"secondary",children:pe.type==="entity"?"🏷️ 实体":"📄 段落"})})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),e.jsx("code",{className:"mt-1 block p-2 bg-muted rounded text-xs break-all",children:pe.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(Pe,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:pe.content})})]})]})]})}),e.jsx(Rs,{open:!!_e,onOpenChange:le=>!le&&N(null),children:e.jsxs(zs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ms,{children:e.jsx(As,{children:"边详情"})}),_e&&e.jsx(Pe,{className:"flex-1 pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-blue-50 dark:bg-blue-950 rounded border-2 border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"源节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:_e.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[_e.source.id.slice(0,40),"..."]})]}),e.jsx("div",{className:"text-2xl text-muted-foreground flex-shrink-0",children:"→"}),e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-green-50 dark:bg-green-950 rounded border-2 border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"目标节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:_e.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[_e.target.id.slice(0,40),"..."]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"权重"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ye,{variant:"outline",className:"text-base font-mono",children:_e.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(ps,{open:K,onOpenChange:U,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"加载知识图谱"}),e.jsxs(us,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(os,{children:[e.jsx(hs,{onClick:()=>n({to:"/"}),children:"取消 (返回首页)"}),e.jsx(ms,{onClick:xe,children:"确认加载"})]})]})}),e.jsx(ps,{open:H,onOpenChange:z,children:e.jsxs(rs,{children:[e.jsxs(cs,{children:[e.jsx(ds,{children:"⚠️ 节点数量较多"}),e.jsx(us,{asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["您正在尝试加载 ",e.jsx("strong",{className:"text-orange-600",children:w>=1e4?"全部 (最多10000个)":w})," 个节点。"]}),e.jsx("p",{className:"mt-4",children:"节点数量过多可能导致:"}),e.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[e.jsx("li",{children:"页面加载时间较长"}),e.jsx("li",{children:"浏览器卡顿或崩溃"}),e.jsx("li",{children:"系统资源占用过高"})]}),e.jsx("p",{className:"mt-4",children:"建议先选择较少的节点数量 (50-200 个)。"})]})})]}),e.jsxs(os,{children:[e.jsx(hs,{onClick:()=>{z(!1),w>200&&(v(50),R(!1))},children:"取消"}),e.jsx(ms,{onClick:$,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function gp({className:n,classNames:r,showOutsideDays:c=!0,captionLayout:d="label",buttonVariant:h="ghost",formatters:x,components:f,...j}){const p=_g();return e.jsx(cb,{showOutsideDays:c,className:Q("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,n),captionLayout:d,formatters:{formatMonthDropdown:w=>w.toLocaleString("default",{month:"short"}),...x},classNames:{root:Q("w-fit",p.root),months:Q("relative flex flex-col gap-4 md:flex-row",p.months),month:Q("flex w-full flex-col gap-4",p.month),nav:Q("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",p.nav),button_previous:Q(gr({variant:h}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_previous),button_next:Q(gr({variant:h}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_next),month_caption:Q("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",p.month_caption),dropdowns:Q("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",p.dropdowns),dropdown_root:Q("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",p.dropdown_root),dropdown:Q("bg-popover absolute inset-0 opacity-0",p.dropdown),caption_label:Q("select-none font-medium",d==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",p.caption_label),table:"w-full border-collapse",weekdays:Q("flex",p.weekdays),weekday:Q("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",p.weekday),week:Q("mt-2 flex w-full",p.week),week_number_header:Q("w-[--cell-size] select-none",p.week_number_header),week_number:Q("text-muted-foreground select-none text-[0.8rem]",p.week_number),day:Q("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",p.day),range_start:Q("bg-accent rounded-l-md",p.range_start),range_middle:Q("rounded-none",p.range_middle),range_end:Q("bg-accent rounded-r-md",p.range_end),today:Q("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",p.today),outside:Q("text-muted-foreground aria-selected:text-muted-foreground",p.outside),disabled:Q("text-muted-foreground opacity-50",p.disabled),hidden:Q("invisible",p.hidden),...r},components:{Root:({className:w,rootRef:v,...k})=>e.jsx("div",{"data-slot":"calendar",ref:v,className:Q(w),...k}),Chevron:({className:w,orientation:v,...k})=>v==="left"?e.jsx(cn,{className:Q("size-4",w),...k}):v==="right"?e.jsx(il,{className:Q("size-4",w),...k}):e.jsx(Ll,{className:Q("size-4",w),...k}),DayButton:k1,WeekNumber:({children:w,...v})=>e.jsx("td",{...v,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:w})}),...f},...j})}function k1({className:n,day:r,modifiers:c,...d}){const h=_g(),x=u.useRef(null);return u.useEffect(()=>{c.focused&&x.current?.focus()},[c.focused]),e.jsx(y,{ref:x,variant:"ghost",size:"icon","data-day":r.date.toLocaleDateString(),"data-selected-single":c.selected&&!c.range_start&&!c.range_end&&!c.range_middle,"data-range-start":c.range_start,"data-range-end":c.range_end,"data-range-middle":c.range_middle,className:Q("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",h.day,n),...d})}const T1={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},E1=(n,r,c)=>{let d;const h=T1[n];return typeof h=="string"?d=h:r===1?d=h.one:d=h.other.replace("{{count}}",String(r)),c?.addSuffix?c.comparison&&c.comparison>0?d+"内":d+"前":d},z1={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},M1={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},A1={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},D1={date:wu({formats:z1,defaultWidth:"full"}),time:wu({formats:M1,defaultWidth:"full"}),dateTime:wu({formats:A1,defaultWidth:"full"})};function jp(n,r,c){const d="eeee p";return ky(n,r,c)?d:n.getTime()>r.getTime()?"'下个'"+d:"'上个'"+d}const O1={lastWeek:jp,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:jp,other:"PP p"},R1=(n,r,c,d)=>{const h=O1[n];return typeof h=="function"?h(r,c,d):h},L1={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},U1={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},B1={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},H1={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},q1={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},G1={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},V1=(n,r)=>{const c=Number(n);switch(r?.unit){case"date":return c.toString()+"日";case"hour":return c.toString()+"时";case"minute":return c.toString()+"分";case"second":return c.toString()+"秒";default:return"第 "+c.toString()}},F1={ordinalNumber:V1,era:er({values:L1,defaultWidth:"wide"}),quarter:er({values:U1,defaultWidth:"wide",argumentCallback:n=>n-1}),month:er({values:B1,defaultWidth:"wide"}),day:er({values:H1,defaultWidth:"wide"}),dayPeriod:er({values:q1,defaultWidth:"wide",formattingValues:G1,defaultFormattingWidth:"wide"})},$1=/^(第\s*)?\d+(日|时|分|秒)?/i,Q1=/\d+/i,Y1={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},X1={any:[/^(前)/i,/^(公元)/i]},K1={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Z1={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},J1={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},I1={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},P1={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},W1={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},e2={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},s2={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},t2={ordinalNumber:Ty({matchPattern:$1,parsePattern:Q1,valueCallback:n=>parseInt(n,10)}),era:sr({matchPatterns:Y1,defaultMatchWidth:"wide",parsePatterns:X1,defaultParseWidth:"any"}),quarter:sr({matchPatterns:K1,defaultMatchWidth:"wide",parsePatterns:Z1,defaultParseWidth:"any",valueCallback:n=>n+1}),month:sr({matchPatterns:J1,defaultMatchWidth:"wide",parsePatterns:I1,defaultParseWidth:"any"}),day:sr({matchPatterns:P1,defaultMatchWidth:"wide",parsePatterns:W1,defaultParseWidth:"any"}),dayPeriod:sr({matchPatterns:e2,defaultMatchWidth:"any",parsePatterns:s2,defaultParseWidth:"any"})},$c={code:"zh-CN",formatDistance:E1,formatLong:D1,formatRelative:R1,localize:F1,match:t2,options:{weekStartsOn:1,firstWeekContainsDate:4}},Qc={xs:{label:"小",rowHeight:28,class:"text-[10px] sm:text-xs"},sm:{label:"中",rowHeight:36,class:"text-xs sm:text-sm"},base:{label:"大",rowHeight:44,class:"text-sm sm:text-base"}};function a2(){const[n,r]=u.useState([]),[c,d]=u.useState(""),[h,x]=u.useState("all"),[f,j]=u.useState("all"),[p,w]=u.useState(void 0),[v,k]=u.useState(void 0),[T,E]=u.useState(!0),[R,K]=u.useState(!1),[U,A]=u.useState("xs"),[Z,H]=u.useState(4),z=u.useRef(null);u.useEffect(()=>{const N=an.getAllLogs();r(N);const G=an.onLog(()=>{r(an.getAllLogs())}),q=an.onConnectionChange(ie=>{K(ie)});return()=>{G(),q()}},[]);const B=u.useMemo(()=>{const N=new Set(n.map(G=>G.module).filter(G=>G&&G.trim()!==""));return Array.from(N).sort()},[n]),X=N=>{switch(N){case"DEBUG":return"text-muted-foreground";case"INFO":return"text-blue-500 dark:text-blue-400";case"WARNING":return"text-yellow-600 dark:text-yellow-500";case"ERROR":return"text-red-600 dark:text-red-500";case"CRITICAL":return"text-red-700 dark:text-red-400 font-bold";default:return"text-foreground"}},S=N=>{switch(N){case"DEBUG":return"bg-gray-800/30 dark:bg-gray-800/50";case"INFO":return"bg-blue-900/20 dark:bg-blue-500/20";case"WARNING":return"bg-yellow-900/20 dark:bg-yellow-500/20";case"ERROR":return"bg-red-900/20 dark:bg-red-500/20";case"CRITICAL":return"bg-red-900/30 dark:bg-red-600/30";default:return"bg-gray-800/20 dark:bg-gray-800/30"}},O=()=>{window.location.reload()},te=()=>{an.clearLogs(),r([])},he=()=>{const N=pe.map(_=>`${_.timestamp} [${_.level.padEnd(8)}] [${_.module}] ${_.message}`).join(` +`),G=new Blob([N],{type:"text/plain;charset=utf-8"}),q=URL.createObjectURL(G),ie=document.createElement("a");ie.href=q,ie.download=`logs-${_u(new Date,"yyyy-MM-dd-HHmmss")}.txt`,ie.click(),URL.revokeObjectURL(q)},Ne=()=>{E(!T)},ye=()=>{w(void 0),k(void 0)},pe=u.useMemo(()=>n.filter(N=>{const G=c===""||N.message.toLowerCase().includes(c.toLowerCase())||N.module.toLowerCase().includes(c.toLowerCase()),q=h==="all"||N.level===h,ie=f==="all"||N.module===f;let _=!0;if(p||v){const me=new Date(N.timestamp);if(p){const xe=new Date(p);xe.setHours(0,0,0,0),_=_&&me>=xe}if(v){const xe=new Date(v);xe.setHours(23,59,59,999),_=_&&me<=xe}}return G&&q&&ie&&_}),[n,c,h,f,p,v]),je=Qc[U].rowHeight+Z,_e=py({count:pe.length,getScrollElement:()=>z.current,estimateSize:()=>je,overscan:15});return u.useEffect(()=>{T&&pe.length>0&&_e.scrollToIndex(pe.length-1,{align:"end",behavior:"auto"})},[pe.length,T,_e]),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 space-y-4 p-3 sm:p-4 lg:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Q("h-2.5 w-2.5 sm:h-3 sm:w-3 rounded-full",R?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:R?"已连接":"未连接"})]})]}),e.jsx(Fe,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索日志...",value:c,onChange:N=>d(N.target.value),className:"pl-9 h-9 text-sm"})]}),e.jsxs(He,{value:h,onValueChange:x,children:[e.jsxs(Re,{className:"w-full sm:w-[140px] lg:w-[180px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx(qe,{placeholder:"级别"})]}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部级别"}),e.jsx(ne,{value:"DEBUG",children:"DEBUG"}),e.jsx(ne,{value:"INFO",children:"INFO"}),e.jsx(ne,{value:"WARNING",children:"WARNING"}),e.jsx(ne,{value:"ERROR",children:"ERROR"}),e.jsx(ne,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(He,{value:f,onValueChange:j,children:[e.jsxs(Re,{className:"w-full sm:w-[160px] lg:w-[200px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx(qe,{placeholder:"模块"})]}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部模块"}),B.map(N=>e.jsx(ne,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",className:Q("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!p&&"text-muted-foreground"),children:[e.jsx(Xf,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:p?_u(p,"PPP",{locale:$c}):"开始日期"})]})}),e.jsx(wa,{className:"w-auto p-0",align:"start",children:e.jsx(gp,{mode:"single",selected:p,onSelect:w,initialFocus:!0,locale:$c})})]}),e.jsxs(Oa,{children:[e.jsx(Ra,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",className:Q("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!v&&"text-muted-foreground"),children:[e.jsx(Xf,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:v?_u(v,"PPP",{locale:$c}):"结束日期"})]})}),e.jsx(wa,{className:"w-auto p-0",align:"start",children:e.jsx(gp,{mode:"single",selected:v,onSelect:k,initialFocus:!0,locale:$c})})]}),(p||v)&&e.jsxs(y,{variant:"outline",size:"sm",onClick:ye,className:"w-full sm:w-auto h-9",children:[e.jsx(li,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline text-sm",children:"清除时间筛选"}),e.jsx("span",{className:"sm:hidden text-sm",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(y,{variant:T?"default":"outline",size:"sm",onClick:Ne,className:"flex-1 sm:flex-none h-9",children:[T?e.jsx(GN,{className:"h-4 w-4"}):e.jsx(VN,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:T?"自动滚动":"已暂停"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:O,className:"flex-1 sm:flex-none h-9",children:[e.jsx(pt,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"刷新"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:te,className:"flex-1 sm:flex-none h-9",children:[e.jsx(es,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"清空"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:he,className:"flex-1 sm:flex-none h-9",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"导出"})]})]}),e.jsx("div",{className:"flex-1 hidden sm:block"}),e.jsxs("div",{className:"text-xs sm:text-sm text-muted-foreground flex items-center justify-center sm:justify-end",children:[e.jsxs("span",{className:"font-mono",children:[pe.length," / ",n.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-6 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(FN,{className:"h-4 w-4"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys(Qc).map(N=>e.jsx(y,{variant:U===N?"default":"outline",size:"sm",onClick:()=>A(N),className:"h-7 px-3 text-xs",children:Qc[N].label},N))})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 max-w-xs",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"行距"}),e.jsx(Ma,{value:[Z],onValueChange:([N])=>H(N),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-8",children:[Z,"px"]})]})]})]})})]}),e.jsx("div",{className:"flex-1 min-h-0 px-3 sm:px-4 lg:px-6 pb-3 sm:pb-4 lg:pb-6",children:e.jsx(Fe,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900 h-full",children:e.jsx(Pe,{viewportRef:z,className:"h-full",children:e.jsx("div",{className:Q("p-2 sm:p-3 font-mono relative",Qc[U].class),style:{height:`${_e.getTotalSize()}px`},children:pe.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-sm",children:"暂无日志数据"}):_e.getVirtualItems().map(N=>{const G=pe[N.index];return e.jsxs("div",{"data-index":N.index,ref:_e.measureElement,className:Q("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors group",S(G.level)),style:{transform:`translateY(${N.start}px)`,paddingTop:`${Z/2}px`,paddingBottom:`${Z/2}px`},children:[e.jsxs("div",{className:"flex flex-col gap-0.5 sm:hidden",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600",children:G.timestamp}),e.jsxs("span",{className:Q("font-semibold",X(G.level)),children:["[",G.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate",children:G.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words",children:G.message})]}),e.jsxs("div",{className:"hidden sm:flex gap-2 items-start",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600 flex-shrink-0 w-[130px] lg:w-[160px]",children:G.timestamp}),e.jsxs("span",{className:Q("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",X(G.level)),children:["[",G.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:G.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:G.message})]})]},N.key)})})})})})]})}const l2="Mai-with-u",n2="plugin-repo",i2="main",r2="plugin_details.json";async function c2(){try{const n=await ke("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:l2,repo:n2,branch:i2,file_path:r2})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=await n.json();if(!r.success||!r.data)throw new Error(r.error||"获取插件列表失败");return JSON.parse(r.data).filter(h=>!h?.id||!h?.manifest?(console.warn("跳过无效插件数据:",h),!1):!h.manifest.name||!h.manifest.version?(console.warn("跳过缺少必需字段的插件:",h.id),!1):!0).map(h=>({id:h.id,manifest:{manifest_version:h.manifest.manifest_version||1,name:h.manifest.name,version:h.manifest.version,description:h.manifest.description||"",author:h.manifest.author||{name:"Unknown"},license:h.manifest.license||"Unknown",host_application:h.manifest.host_application||{min_version:"0.0.0"},homepage_url:h.manifest.homepage_url,repository_url:h.manifest.repository_url,keywords:h.manifest.keywords||[],categories:h.manifest.categories||[],default_locale:h.manifest.default_locale||"zh-CN",locales_path:h.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(n){throw console.error("Failed to fetch plugin list:",n),n}}async function o2(){try{const n=await ke("/api/webui/plugins/git-status");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to check Git status:",n),{installed:!1,error:"无法检测 Git 安装状态"}}}async function d2(){try{const n=await ke("/api/webui/plugins/version");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to get Maimai version:",n),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function u2(n,r,c){const d=n.split(".").map(j=>parseInt(j)||0),h=d[0]||0,x=d[1]||0,f=d[2]||0;if(c.version_majorparseInt(k)||0),p=j[0]||0,w=j[1]||0,v=j[2]||0;if(c.version_major>p||c.version_major===p&&c.version_minor>w||c.version_major===p&&c.version_minor===w&&c.version_patch>v)return!1}return!0}function m2(n,r){const c=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host,h=new WebSocket(`${c}//${d}/api/webui/ws/plugin-progress`);return h.onopen=()=>{console.log("Plugin progress WebSocket connected");const x=setInterval(()=>{h.readyState===WebSocket.OPEN?h.send("ping"):clearInterval(x)},3e4)},h.onmessage=x=>{try{if(x.data==="pong")return;const f=JSON.parse(x.data);n(f)}catch(f){console.error("Failed to parse progress data:",f)}},h.onerror=x=>{console.error("Plugin progress WebSocket error:",x),r?.(x)},h.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},h}async function cr(){try{const n=await ke("/api/webui/plugins/installed",{headers:Ts()});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=await n.json();if(!r.success)throw new Error(r.message||"获取已安装插件列表失败");return r.plugins||[]}catch(n){return console.error("Failed to get installed plugins:",n),[]}}function Yc(n,r){return r.some(c=>c.id===n)}function Xc(n,r){const c=r.find(d=>d.id===n);if(c)return c.manifest?.version||c.version}async function h2(n,r,c="main"){const d=await ke("/api/webui/plugins/install",{method:"POST",body:JSON.stringify({plugin_id:n,repository_url:r,branch:c})});if(!d.ok){const h=await d.json();throw new Error(h.detail||"安装失败")}return await d.json()}async function x2(n){const r=await ke("/api/webui/plugins/uninstall",{method:"POST",body:JSON.stringify({plugin_id:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"卸载失败")}return await r.json()}async function f2(n,r,c="main"){const d=await ke("/api/webui/plugins/update",{method:"POST",body:JSON.stringify({plugin_id:n,repository_url:r,branch:c})});if(!d.ok){const h=await d.json();throw new Error(h.detail||"更新失败")}return await d.json()}async function p2(n){const r=await ke(`/api/webui/plugins/config/${n}/schema`,{headers:Ts()});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取配置 Schema 失败")}const c=await r.json();if(!c.success)throw new Error(c.message||"获取配置 Schema 失败");return c.schema}async function g2(n){const r=await ke(`/api/webui/plugins/config/${n}`,{headers:Ts()});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取配置失败")}const c=await r.json();if(!c.success)throw new Error(c.message||"获取配置失败");return c.config}async function j2(n,r){const c=await ke(`/api/webui/plugins/config/${n}`,{method:"PUT",body:JSON.stringify({config:r})});if(!c.ok){const d=await c.json();throw new Error(d.detail||"保存配置失败")}return await c.json()}async function v2(n){const r=await ke(`/api/webui/plugins/config/${n}/reset`,{method:"POST",headers:Ts()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"重置配置失败")}return await r.json()}async function y2(n){const r=await ke(`/api/webui/plugins/config/${n}/toggle`,{method:"POST",headers:Ts()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"切换状态失败")}return await r.json()}const Cr="https://maibot-plugin-stats.maibot-webui.workers.dev";async function Yg(n){try{const r=await fetch(`${Cr}/stats/${n}`);return r.ok?await r.json():(console.error("Failed to fetch plugin stats:",r.statusText),null)}catch(r){return console.error("Error fetching plugin stats:",r),null}}async function N2(n,r){try{const c=r||em(),d=await fetch(`${Cr}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:c})}),h=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...h}:{success:!1,error:h.error||"点赞失败"}}catch(c){return console.error("Error liking plugin:",c),{success:!1,error:"网络错误"}}}async function b2(n,r){try{const c=r||em(),d=await fetch(`${Cr}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:c})}),h=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...h}:{success:!1,error:h.error||"点踩失败"}}catch(c){return console.error("Error disliking plugin:",c),{success:!1,error:"网络错误"}}}async function w2(n,r,c,d){if(r<1||r>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const h=d||em(),x=await fetch(`${Cr}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,rating:r,comment:c,user_id:h})}),f=await x.json();return x.status===429?{success:!1,error:"每天最多评分 3 次"}:x.ok?{success:!0,...f}:{success:!1,error:f.error||"评分失败"}}catch(h){return console.error("Error rating plugin:",h),{success:!1,error:"网络错误"}}}async function _2(n){try{const r=await fetch(`${Cr}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n})}),c=await r.json();return r.status===429?(console.warn("Download recording rate limited"),{success:!0}):r.ok?{success:!0,...c}:(console.error("Failed to record download:",c.error),{success:!1,error:c.error})}catch(r){return console.error("Error recording download:",r),{success:!1,error:"网络错误"}}}function S2(){const n=navigator,r=[navigator.userAgent,navigator.language,navigator.languages?.join(",")||"",navigator.platform,navigator.hardwareConcurrency||0,screen.width,screen.height,screen.colorDepth,screen.pixelDepth,new Date().getTimezoneOffset(),Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.maxTouchPoints||0,n.deviceMemory||0].join("|");let c=0;for(let d=0;d{x(!0);const A=await Yg(n);A&&d(A),x(!1)};u.useEffect(()=>{E()},[n]);const R=async()=>{const A=await N2(n);A.success?(T({title:"已点赞",description:"感谢你的支持!"}),E()):T({title:"点赞失败",description:A.error||"未知错误",variant:"destructive"})},K=async()=>{const A=await b2(n);A.success?(T({title:"已反馈",description:"感谢你的反馈!"}),E()):T({title:"操作失败",description:A.error||"未知错误",variant:"destructive"})},U=async()=>{if(f===0){T({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const A=await w2(n,f,p||void 0);A.success?(T({title:"评分成功",description:"感谢你的评价!"}),k(!1),j(0),w(""),E()):T({title:"评分失败",description:A.error||"未知错误",variant:"destructive"})};return h?e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):c?r?e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",title:`下载量: ${c.downloads.toLocaleString()}`,children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:c.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`评分: ${c.rating.toFixed(1)} (${c.rating_count} 条评价)`,children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:c.rating.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`点赞数: ${c.likes}`,children:[e.jsx(Cu,{className:"h-4 w-4"}),e.jsx("span",{children:c.likes})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(nl,{className:"h-5 w-5 text-muted-foreground mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.downloads.toLocaleString()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"下载量"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Ol,{className:"h-5 w-5 text-yellow-400 mb-1 fill-yellow-400"}),e.jsx("span",{className:"text-2xl font-bold",children:c.rating.toFixed(1)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.rating_count," 条评价"]})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Cu,{className:"h-5 w-5 text-green-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.likes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点赞"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Kf,{className:"h-5 w-5 text-red-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.dislikes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点踩"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(Cu,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:K,children:[e.jsx(Kf,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Rs,{open:v,onOpenChange:k,children:[e.jsx(ni,{asChild:!0,children:e.jsxs(y,{variant:"default",size:"sm",children:[e.jsx(Ol,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(zs,{children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"为插件评分"}),e.jsx(Ys,{children:"分享你的使用体验,帮助其他用户"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex gap-2",children:[1,2,3,4,5].map(A=>e.jsx("button",{onClick:()=>j(A),className:"focus:outline-none",children:e.jsx(Ol,{className:`h-8 w-8 transition-colors ${A<=f?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-300"}`})},A))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f===0&&"点击星星进行评分",f===1&&"很差",f===2&&"一般",f===3&&"还行",f===4&&"不错",f===5&&"非常好"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"评论(可选)"}),e.jsx(Bs,{value:p,onChange:A=>w(A.target.value),placeholder:"分享你的使用体验...",rows:4,maxLength:500}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 text-right",children:[p.length," / 500"]})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsx(y,{onClick:U,disabled:f===0,children:"提交评分"})]})]})]})]}),c.recent_ratings&&c.recent_ratings.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"最近评价"}),e.jsx("div",{className:"space-y-3",children:c.recent_ratings.map((A,Z)=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(H=>e.jsx(Ol,{className:`h-3 w-3 ${H<=A.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},H))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(A.created_at).toLocaleDateString()})]}),A.comment&&e.jsx("p",{className:"text-sm text-muted-foreground",children:A.comment})]},Z))})]})]}):null}const vp={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function k2(){const n=Jt(),[r,c]=u.useState(null),[d,h]=u.useState(""),[x,f]=u.useState("all"),[j,p]=u.useState("all"),[w,v]=u.useState(!0),[k,T]=u.useState([]),[E,R]=u.useState(!0),[K,U]=u.useState(null),[A,Z]=u.useState(null),[H,z]=u.useState(null),[B,X]=u.useState(null),[,S]=u.useState([]),[O,te]=u.useState({}),{toast:he}=Hs(),Ne=async _=>{const me=_.map(async de=>{try{const ge=await Yg(de.id);return{id:de.id,stats:ge}}catch(ge){return console.warn(`Failed to load stats for ${de.id}:`,ge),{id:de.id,stats:null}}}),xe=await Promise.all(me),$={};xe.forEach(({id:de,stats:ge})=>{ge&&($[de]=ge)}),te($)};u.useEffect(()=>{let _=null,me=!1;return(async()=>{if(_=m2($=>{me||(z($),$.stage==="success"?setTimeout(()=>{me||z(null)},2e3):$.stage==="error"&&(R(!1),U($.error||"加载失败")))},$=>{console.error("WebSocket error:",$),me||he({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise($=>{if(!_){$();return}const de=()=>{_&&_.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),$()):_&&_.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),$()):setTimeout(de,100)};de()}),!me){const $=await o2();Z($),$.installed||he({title:"Git 未安装",description:$.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!me){const $=await d2();X($)}if(!me)try{R(!0),U(null);const $=await c2();if(!me){const de=await cr();S(de);const ge=$.map(le=>{const L=Yc(le.id,de),F=Xc(le.id,de);return{...le,installed:L,installed_version:F}});for(const le of de)!ge.some(F=>F.id===le.id)&&le.manifest&&ge.push({id:le.id,manifest:{manifest_version:le.manifest.manifest_version||1,name:le.manifest.name,version:le.manifest.version,description:le.manifest.description||"",author:le.manifest.author,license:le.manifest.license||"Unknown",host_application:le.manifest.host_application,homepage_url:le.manifest.homepage_url,repository_url:le.manifest.repository_url,keywords:le.manifest.keywords||[],categories:le.manifest.categories||[],default_locale:le.manifest.default_locale||"zh-CN",locales_path:le.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:le.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});T(ge),Ne(ge)}}catch($){if(!me){const de=$ instanceof Error?$.message:"加载插件列表失败";U(de),he({title:"加载失败",description:de,variant:"destructive"})}}finally{me||R(!1)}})(),()=>{me=!0,_&&_.close()}},[he]);const ye=_=>{if(!_.installed&&B&&!pe(_))return e.jsxs(Ye,{variant:"destructive",className:"gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),"不兼容"]});if(_.installed){const me=_.installed_version?.trim(),xe=_.manifest.version?.trim();if(me!==xe){const $=me?.split(".").map(Number)||[0,0,0],de=xe?.split(".").map(Number)||[0,0,0];for(let ge=0;ge<3;ge++){if((de[ge]||0)>($[ge]||0))return e.jsxs(Ye,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Da,{className:"h-3 w-3"}),"可更新"]});if((de[ge]||0)<($[ge]||0))break}}return e.jsxs(Ye,{variant:"default",className:"gap-1",children:[e.jsx(pa,{className:"h-3 w-3"}),"已安装"]})}return null},pe=_=>!B||!_.manifest?.host_application?!0:u2(_.manifest.host_application.min_version,_.manifest.host_application.max_version,B),je=_=>{if(!_.installed||!_.installed_version||!_.manifest?.version)return!1;const me=_.installed_version.trim(),xe=_.manifest.version.trim();if(me===xe)return!1;const $=me.split(".").map(Number),de=xe.split(".").map(Number);for(let ge=0;ge<3;ge++){if((de[ge]||0)>($[ge]||0))return!0;if((de[ge]||0)<($[ge]||0))return!1}return!1},_e=k.filter(_=>{if(!_.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",_.id),!1;const me=d===""||_.manifest.name?.toLowerCase().includes(d.toLowerCase())||_.manifest.description?.toLowerCase().includes(d.toLowerCase())||_.manifest.keywords&&_.manifest.keywords.some(ge=>ge.toLowerCase().includes(d.toLowerCase())),xe=x==="all"||_.manifest.categories&&_.manifest.categories.includes(x);let $=!0;j==="installed"?$=_.installed===!0:j==="updates"&&($=_.installed===!0&&je(_));const de=!w||!B||pe(_);return me&&xe&&$&&de}),N=()=>{c(null)},G=async _=>{if(!A?.installed){he({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(B&&!pe(_)){he({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}try{await h2(_.id,_.manifest.repository_url||"","main"),_2(_.id).catch(xe=>{console.warn("Failed to record download:",xe)}),he({title:"安装成功",description:`${_.manifest.name} 已成功安装`});const me=await cr();S(me),T(xe=>xe.map($=>{if($.id===_.id){const de=Yc($.id,me),ge=Xc($.id,me);return{...$,installed:de,installed_version:ge}}return $}))}catch(me){he({title:"安装失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}},q=async _=>{try{await x2(_.id),he({title:"卸载成功",description:`${_.manifest.name} 已成功卸载`});const me=await cr();S(me),T(xe=>xe.map($=>{if($.id===_.id){const de=Yc($.id,me),ge=Xc($.id,me);return{...$,installed:de,installed_version:ge}}return $}))}catch(me){he({title:"卸载失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}},ie=async _=>{if(!A?.installed){he({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const me=await f2(_.id,_.manifest.repository_url||"","main");he({title:"更新成功",description:`${_.manifest.name} 已从 ${me.old_version} 更新到 ${me.new_version}`});const xe=await cr();S(xe),T($=>$.map(de=>{if(de.id===_.id){const ge=Yc(de.id,xe),le=Xc(de.id,xe);return{...de,installed:ge,installed_version:le}}return de}))}catch(me){he({title:"更新失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}};return e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件市场"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"浏览和管理麦麦的插件"})]}),e.jsxs(y,{onClick:()=>n({to:"/plugin-mirrors"}),children:[e.jsx($N,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]}),A&&!A.installed&&e.jsxs(Fe,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(gs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(js,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(Zs,{className:"text-orange-800 dark:text-orange-200",children:A.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(bs,{children:e.jsxs("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:["您可以从 ",e.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",className:"underline font-medium",children:"git-scm.com"})," 下载并安装 Git。 安装完成后,请重启麦麦应用。"]})})]}),e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:d,onChange:_=>h(_.target.value),className:"pl-9"})]}),e.jsxs(He,{value:x,onValueChange:f,children:[e.jsx(Re,{className:"w-full sm:w-[200px]",children:e.jsx(qe,{placeholder:"选择分类"})}),e.jsxs(Le,{children:[e.jsx(ne,{value:"all",children:"全部分类"}),e.jsx(ne,{value:"Group Management",children:"群组管理"}),e.jsx(ne,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(ne,{value:"Utility Tools",children:"实用工具"}),e.jsx(ne,{value:"Content Generation",children:"内容生成"}),e.jsx(ne,{value:"Multimedia",children:"多媒体"}),e.jsx(ne,{value:"External Integration",children:"外部集成"}),e.jsx(ne,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(ne,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"compatible-only",checked:w,onCheckedChange:_=>v(_===!0)}),e.jsx("label",{htmlFor:"compatible-only",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:"只显示兼容当前版本的插件"})]})]})}),e.jsx(Kt,{value:j,onValueChange:p,className:"w-full",children:e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsxs($e,{value:"all",children:["全部插件 (",k.filter(_=>{if(!_.manifest)return!1;const me=d===""||_.manifest.name?.toLowerCase().includes(d.toLowerCase())||_.manifest.description?.toLowerCase().includes(d.toLowerCase())||_.manifest.keywords&&_.manifest.keywords.some(de=>de.toLowerCase().includes(d.toLowerCase())),xe=x==="all"||_.manifest.categories&&_.manifest.categories.includes(x),$=!w||!B||pe(_);return me&&xe&&$}).length,")"]}),e.jsxs($e,{value:"installed",children:["已安装 (",k.filter(_=>{if(!_.manifest)return!1;const me=d===""||_.manifest.name?.toLowerCase().includes(d.toLowerCase())||_.manifest.description?.toLowerCase().includes(d.toLowerCase())||_.manifest.keywords&&_.manifest.keywords.some(de=>de.toLowerCase().includes(d.toLowerCase())),xe=x==="all"||_.manifest.categories&&_.manifest.categories.includes(x),$=!w||!B||pe(_);return _.installed&&me&&xe&&$}).length,")"]}),e.jsxs($e,{value:"updates",children:["可更新 (",k.filter(_=>{if(!_.manifest)return!1;const me=d===""||_.manifest.name?.toLowerCase().includes(d.toLowerCase())||_.manifest.description?.toLowerCase().includes(d.toLowerCase())||_.manifest.keywords&&_.manifest.keywords.some(de=>de.toLowerCase().includes(d.toLowerCase())),xe=x==="all"||_.manifest.categories&&_.manifest.categories.includes(x),$=!w||!B||pe(_);return _.installed&&je(_)&&me&&xe&&$}).length,")"]})]})}),H&&H.stage==="loading"&&e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vt,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm font-medium",children:[H.operation==="fetch"&&"加载插件列表",H.operation==="install"&&`安装插件${H.plugin_id?`: ${H.plugin_id}`:""}`,H.operation==="uninstall"&&`卸载插件${H.plugin_id?`: ${H.plugin_id}`:""}`,H.operation==="update"&&`更新插件${H.plugin_id?`: ${H.plugin_id}`:""}`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[H.progress,"%"]})]}),e.jsx(Sr,{value:H.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:H.message}),H.operation==="fetch"&&H.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",H.loaded_plugins," / ",H.total_plugins," 个插件"]})]})}),H&&H.stage==="error"&&H.error&&e.jsx(Fe,{className:"border-destructive bg-destructive/10",children:e.jsx(gs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(js,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(Zs,{className:"text-destructive/80",children:H.error})]})]})})}),E?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):K?e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ba,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:K}),e.jsx(y,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):_e.length===0?e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(_t,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未找到插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d||x!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:_e.map(_=>e.jsxs(Fe,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(gs,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(js,{className:"text-xl",children:_.manifest?.name||_.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[_.manifest?.categories&&_.manifest.categories[0]&&e.jsx(Ye,{variant:"secondary",className:"text-xs whitespace-nowrap",children:vp[_.manifest.categories[0]]||_.manifest.categories[0]}),ye(_)]})]}),e.jsx(Zs,{className:"line-clamp-2",children:_.manifest?.description||"无描述"})]}),e.jsx(bs,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:(O[_.id]?.downloads??_.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(O[_.id]?.rating??_.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[_.manifest?.keywords&&_.manifest.keywords.slice(0,3).map(me=>e.jsx(Ye,{variant:"outline",className:"text-xs",children:me},me)),_.manifest?.keywords&&_.manifest.keywords.length>3&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:["+",_.manifest.keywords.length-3]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground pt-2 border-t space-y-1",children:[e.jsxs("div",{children:["v",_.manifest?.version||"unknown"," · ",_.manifest?.author?.name||"Unknown"]}),_.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[_.manifest.host_application.min_version,_.manifest.host_application.max_version?` - ${_.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(Sg,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>c(_),children:"查看详情"}),_.installed?je(_)?e.jsxs(y,{size:"sm",disabled:!A?.installed,title:A?.installed?void 0:"Git 未安装",onClick:()=>ie(_),children:[e.jsx(pt,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(y,{variant:"destructive",size:"sm",disabled:!A?.installed,title:A?.installed?void 0:"Git 未安装",onClick:()=>q(_),children:[e.jsx(es,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(y,{size:"sm",disabled:!A?.installed||H?.operation==="install"||B!==null&&!pe(_),title:A?.installed?B!==null&&!pe(_)?`不兼容当前版本 (需要 ${_.manifest?.host_application?.min_version||"未知"}${_.manifest?.host_application?.max_version?` - ${_.manifest.host_application.max_version}`:"+"},当前 ${B?.version})`:void 0:"Git 未安装",onClick:()=>G(_),children:[e.jsx(nl,{className:"h-4 w-4 mr-1"}),H?.operation==="install"&&H?.plugin_id===_.id?"安装中...":"安装"]})]})})]},_.id))}),e.jsx(Rs,{open:r!==null,onOpenChange:N,children:r&&r.manifest&&e.jsx(zs,{className:"max-w-2xl max-h-[80vh] p-0 flex flex-col",children:e.jsx(Pe,{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsx(Ms,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(As,{className:"text-2xl",children:r.manifest.name}),e.jsxs(Ys,{children:["作者: ",r.manifest.author?.name||"Unknown",r.manifest.author?.url&&e.jsx("a",{href:r.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-primary hover:underline",children:e.jsx(dr,{className:"h-3 w-3 inline"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[r.manifest.categories&&r.manifest.categories[0]&&e.jsx(Ye,{variant:"secondary",children:vp[r.manifest.categories[0]]||r.manifest.categories[0]}),ye(r)]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(C2,{pluginId:r.id}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["v",r.manifest?.version||"unknown"]}),r.installed&&r.installed_version&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["已安装: v",r.installed_version]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"下载量"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(O[r.id]?.downloads??r.downloads??0).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"评分"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(O[r.id]?.rating??r.rating??0).toFixed(1)," (",O[r.id]?.rating_count??r.review_count??0,")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"许可证"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.manifest.license||"Unknown"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"支持版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.manifest.host_application?.min_version||"未知",r.manifest.host_application?.max_version?` - ${r.manifest.host_application.max_version}`:" - 最新版本"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"关键词"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.manifest.keywords&&r.manifest.keywords.map(_=>e.jsx(Ye,{variant:"outline",children:_},_))})]}),r.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"详细说明"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:r.detailed_description})]}),!r.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"说明"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.manifest.description||"无描述"})]}),e.jsxs("div",{className:"space-y-2",children:[r.manifest.homepage_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"主页: "}),e.jsx("a",{href:r.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:r.manifest.homepage_url})]}),r.manifest.repository_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"仓库: "}),e.jsx("a",{href:r.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:r.manifest.repository_url})]})]})]}),e.jsxs(Js,{children:[r.manifest.homepage_url&&e.jsxs(y,{onClick:()=>window.open(r.manifest.homepage_url,"_blank"),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"访问主页"]}),r.manifest.repository_url&&e.jsxs(y,{variant:"outline",onClick:()=>window.open(r.manifest.repository_url,"_blank"),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"查看仓库"]})]})]})})})})]})})}const Gu=$y,Vu=Qy,Fu=Yy;function T2({field:n,value:r,onChange:c}){const[d,h]=u.useState(!1);switch(n.ui_type){case"switch":return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:n.label}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]}),e.jsx(Ve,{checked:!!r,onCheckedChange:c,disabled:n.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(ce,{type:"number",value:r??n.default,onChange:x=>c(parseFloat(x.target.value)||0),min:n.min,max:n.max,step:n.step??1,placeholder:n.placeholder,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"slider":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:n.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:r??n.default})]}),e.jsx(Ma,{value:[r??n.default],onValueChange:x=>c(x[0]),min:n.min??0,max:n.max??100,step:n.step??1,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsxs(He,{value:String(r??n.default),onValueChange:c,disabled:n.disabled,children:[e.jsx(Re,{children:e.jsx(qe,{placeholder:n.placeholder??"请选择"})}),e.jsx(Le,{children:n.choices?.map(x=>e.jsx(ne,{value:String(x),children:String(x)},String(x)))})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(Bs,{value:r??n.default,onChange:x=>c(x.target.value),placeholder:n.placeholder,rows:n.rows??3,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{type:d?"text":"password",value:r??"",onChange:x=>c(x.target.value),placeholder:n.placeholder,disabled:n.disabled,className:"pr-10"}),e.jsx(y,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>h(!d),children:d?e.jsx(mr,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(ce,{type:"text",value:r??n.default??"",onChange:x=>c(x.target.value),placeholder:n.placeholder,maxLength:n.max_length,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]})}}function yp({section:n,config:r,onChange:c}){const[d,h]=u.useState(!n.collapsed),x=Object.entries(n.fields).filter(([,f])=>!f.hidden).sort(([,f],[,j])=>f.order-j.order);return e.jsx(Gu,{open:d,onOpenChange:h,children:e.jsxs(Fe,{children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(gs,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsx(Ll,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(il,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(js,{className:"text-lg",children:n.title})]}),e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[x.length," 项"]})]}),n.description&&e.jsx(Zs,{className:"ml-6",children:n.description})]})}),e.jsx(Fu,{children:e.jsx(bs,{className:"space-y-4 pt-0",children:x.map(([f,j])=>e.jsx(T2,{field:j,value:r[n.name]?.[f],onChange:p=>c(n.name,f,p),sectionName:n.name},f))})})]})})}function E2({plugin:n,onBack:r}){const{toast:c}=Hs(),[d,h]=u.useState(null),[x,f]=u.useState({}),[j,p]=u.useState({}),[w,v]=u.useState(!0),[k,T]=u.useState(!1),[E,R]=u.useState(!1),[K,U]=u.useState(!1),A=u.useCallback(async()=>{v(!0);try{const[O,te]=await Promise.all([p2(n.id),g2(n.id)]);h(O),f(te),p(JSON.parse(JSON.stringify(te)))}catch(O){c({title:"加载配置失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}finally{v(!1)}},[n.id,c]);u.useEffect(()=>{A()},[A]),u.useEffect(()=>{R(JSON.stringify(x)!==JSON.stringify(j))},[x,j]);const Z=(O,te,he)=>{f(Ne=>({...Ne,[O]:{...Ne[O]||{},[te]:he}}))},H=async()=>{T(!0);try{await j2(n.id,x),p(JSON.parse(JSON.stringify(x))),c({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(O){c({title:"保存失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}finally{T(!1)}},z=async()=>{try{await v2(n.id),c({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),U(!1),A()}catch(O){c({title:"重置失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},B=async()=>{try{const O=await y2(n.id);c({title:O.message,description:O.note}),A()}catch(O){c({title:"切换状态失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}};if(w)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!d)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 space-y-4",children:[e.jsx(Da,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(y,{onClick:r,variant:"outline",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"返回"]})]});const X=Object.values(d.sections).sort((O,te)=>O.order-te.order),S=x.plugin?.enabled!==!1;return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(y,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:d.plugin_info.name||n.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ye,{variant:S?"default":"secondary",children:S?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",d.plugin_info.version||n.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:B,children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),S?"禁用":"启用"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>U(!0),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(y,{size:"sm",onClick:H,disabled:!E||k,children:[k?e.jsx(vt,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),E&&e.jsx(Fe,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(bs,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xt,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),d.layout.type==="tabs"&&d.layout.tabs.length>0?e.jsxs(Kt,{defaultValue:d.layout.tabs[0]?.id,children:[e.jsx(Rt,{children:d.layout.tabs.map(O=>e.jsxs($e,{value:O.id,children:[O.title,O.badge&&e.jsx(Ye,{variant:"secondary",className:"ml-2 text-xs",children:O.badge})]},O.id))}),d.layout.tabs.map(O=>e.jsx(We,{value:O.id,className:"space-y-4 mt-4",children:O.sections.map(te=>{const he=d.sections[te];return he?e.jsx(yp,{section:he,config:x,onChange:Z},te):null})},O.id))]}):e.jsx("div",{className:"space-y-4",children:X.map(O=>e.jsx(yp,{section:O,config:x,onChange:Z},O.name))}),e.jsx(Rs,{open:K,onOpenChange:U,children:e.jsxs(zs,{children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"确认重置配置"}),e.jsx(Ys,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>U(!1),children:"取消"}),e.jsx(y,{variant:"destructive",onClick:z,children:"确认重置"})]})]})})]})}function z2(){const{toast:n}=Hs(),[r,c]=u.useState([]),[d,h]=u.useState(!0),[x,f]=u.useState(""),[j,p]=u.useState(null),w=async()=>{h(!0);try{const E=await cr();c(E)}catch(E){n({title:"加载插件列表失败",description:E instanceof Error?E.message:"未知错误",variant:"destructive"})}finally{h(!1)}};u.useEffect(()=>{w()},[]);const v=r.filter(E=>{const R=x.toLowerCase();return E.id.toLowerCase().includes(R)||E.manifest.name.toLowerCase().includes(R)||E.manifest.description?.toLowerCase().includes(R)}),k=r.length,T=0;return j?e.jsx(Pe,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(E2,{plugin:j,onBack:()=>p(null)})})}):e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理和配置已安装的插件"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:w,children:[e.jsx(pt,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"刷新"]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d?"正在加载...":"个插件"})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已启用"}),e.jsx(pa,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Da,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:T}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:x,onChange:E=>f(E.target.value),className:"pl-9"})]}),e.jsxs(Fe,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"已安装的插件"}),e.jsx(Zs,{children:"点击插件查看和编辑配置"})]}),e.jsx(bs,{children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):v.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(rn,{className:"h-16 w-16 text-muted-foreground/50"}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-lg font-medium text-muted-foreground",children:x?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:v.map(E=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>p(E),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(rn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium truncate",children:E.manifest.name}),e.jsxs(Ye,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",E.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:E.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(y,{variant:"ghost",size:"sm",children:e.jsx(Rl,{className:"h-4 w-4"})}),e.jsx(il,{className:"h-4 w-4 text-muted-foreground"})]})]},E.id))})})]})]})})}function M2(){const n=Jt(),{toast:r}=Hs(),[c,d]=u.useState([]),[h,x]=u.useState(!0),[f,j]=u.useState(null),[p,w]=u.useState(null),[v,k]=u.useState(!1),[T,E]=u.useState(!1),[R,K]=u.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),U=u.useCallback(async()=>{try{x(!0),j(null);const S=localStorage.getItem("access-token"),O=await fetch("/api/webui/plugins/mirrors",{headers:{Authorization:`Bearer ${S}`}});if(!O.ok)throw new Error("获取镜像源列表失败");const te=await O.json();d(te.mirrors||[])}catch(S){const O=S instanceof Error?S.message:"加载镜像源失败";j(O),r({title:"加载失败",description:O,variant:"destructive"})}finally{x(!1)}},[r]);u.useEffect(()=>{U()},[U]);const A=async()=>{try{const S=localStorage.getItem("access-token"),O=await fetch("/api/webui/plugins/mirrors",{method:"POST",headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},body:JSON.stringify(R)});if(!O.ok){const te=await O.json();throw new Error(te.detail||"添加镜像源失败")}r({title:"添加成功",description:"镜像源已添加"}),k(!1),K({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),U()}catch(S){r({title:"添加失败",description:S instanceof Error?S.message:"未知错误",variant:"destructive"})}},Z=async()=>{if(p)try{const S=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${p.id}`,{method:"PUT",headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},body:JSON.stringify({name:R.name,raw_prefix:R.raw_prefix,clone_prefix:R.clone_prefix,enabled:R.enabled,priority:R.priority})})).ok)throw new Error("更新镜像源失败");r({title:"更新成功",description:"镜像源已更新"}),E(!1),w(null),U()}catch(S){r({title:"更新失败",description:S instanceof Error?S.message:"未知错误",variant:"destructive"})}},H=async S=>{if(confirm("确定要删除这个镜像源吗?"))try{const O=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${S}`,{method:"DELETE",headers:{Authorization:`Bearer ${O}`}})).ok)throw new Error("删除镜像源失败");r({title:"删除成功",description:"镜像源已删除"}),U()}catch(O){r({title:"删除失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},z=async S=>{try{const O=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${S.id}`,{method:"PUT",headers:{Authorization:`Bearer ${O}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:!S.enabled})})).ok)throw new Error("更新状态失败");U()}catch(O){r({title:"更新失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},B=S=>{w(S),K({id:S.id,name:S.name,raw_prefix:S.raw_prefix,clone_prefix:S.clone_prefix,enabled:S.enabled,priority:S.priority}),E(!0)},X=async(S,O)=>{const te=O==="up"?S.priority-1:S.priority+1;if(!(te<1))try{const he=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${S.id}`,{method:"PUT",headers:{Authorization:`Bearer ${he}`,"Content-Type":"application/json"},body:JSON.stringify({priority:te})})).ok)throw new Error("更新优先级失败");U()}catch(he){r({title:"更新失败",description:he instanceof Error?he.message:"未知错误",variant:"destructive"})}};return e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>n({to:"/plugins"}),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"镜像源配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 Git 克隆和文件下载的镜像源"})]})]}),e.jsxs(y,{onClick:()=>k(!0),children:[e.jsx(ot,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),h?e.jsx(Fe,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-primary"})})}):f?e.jsx(Fe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ba,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),e.jsx(y,{onClick:U,children:"重新加载"})]})}):e.jsxs(Fe,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(gt,{children:[e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"ID"}),e.jsx(ls,{children:"优先级"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c.map(S=>e.jsxs(gt,{children:[e.jsx(Qe,{children:e.jsx(Ve,{checked:S.enabled,onCheckedChange:()=>z(S)})}),e.jsx(Qe,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:S.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",S.raw_prefix]})]})}),e.jsx(Qe,{children:e.jsx(Ye,{variant:"outline",children:S.id})}),e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:S.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>X(S,"up"),disabled:S.priority===1,children:e.jsx(fr,{className:"h-3 w-3"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>X(S,"down"),children:e.jsx(Ll,{className:"h-3 w-3"})})]})]})}),e.jsx(Qe,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>B(S),children:e.jsx(nn,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>H(S.id),children:e.jsx(es,{className:"h-4 w-4 text-destructive"})})]})})]},S.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:c.map(S=>e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:S.name}),S.enabled&&e.jsx(Ye,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(Ye,{variant:"outline",className:"mt-1 text-xs",children:S.id})]}),e.jsx(Ve,{checked:S.enabled,onCheckedChange:()=>z(S)})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Raw: "}),e.jsx("span",{className:"break-all",children:S.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:S.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(y,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>B(S),children:[e.jsx(nn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>X(S,"up"),disabled:S.priority===1,children:e.jsx(fr,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>X(S,"down"),children:e.jsx(Ll,{className:"h-4 w-4"})}),e.jsx(y,{variant:"destructive",size:"sm",onClick:()=>H(S.id),children:e.jsx(es,{className:"h-4 w-4"})})]})]})},S.id))})]}),e.jsx(Rs,{open:v,onOpenChange:k,children:e.jsxs(zs,{className:"max-w-lg",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"添加镜像源"}),e.jsx(Ys,{children:"添加新的 Git 镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(ce,{id:"add-id",placeholder:"例如: my-mirror",value:R.id,onChange:S=>K({...R,id:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ce,{id:"add-name",placeholder:"例如: 我的镜像源",value:R.name,onChange:S=>K({...R,name:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"add-raw",placeholder:"https://example.com/raw",value:R.raw_prefix,onChange:S=>K({...R,raw_prefix:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"add-clone",placeholder:"https://example.com/clone",value:R.clone_prefix,onChange:S=>K({...R,clone_prefix:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ce,{id:"add-priority",type:"number",min:"1",value:R.priority,onChange:S=>K({...R,priority:parseInt(S.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"add-enabled",checked:R.enabled,onCheckedChange:S=>K({...R,enabled:S})}),e.jsx(b,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsx(y,{onClick:A,children:"添加"})]})]})}),e.jsx(Rs,{open:T,onOpenChange:E,children:e.jsxs(zs,{className:"max-w-lg",children:[e.jsxs(Ms,{children:[e.jsx(As,{children:"编辑镜像源"}),e.jsx(Ys,{children:"修改镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"镜像源 ID"}),e.jsx(ce,{value:R.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ce,{id:"edit-name",value:R.name,onChange:S=>K({...R,name:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"edit-raw",value:R.raw_prefix,onChange:S=>K({...R,raw_prefix:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"edit-clone",value:R.clone_prefix,onChange:S=>K({...R,clone_prefix:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ce,{id:"edit-priority",type:"number",min:"1",value:R.priority,onChange:S=>K({...R,priority:parseInt(S.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"edit-enabled",checked:R.enabled,onCheckedChange:S=>K({...R,enabled:S})}),e.jsx(b,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(Js,{children:[e.jsx(y,{variant:"outline",onClick:()=>E(!1),children:"取消"}),e.jsx(y,{onClick:Z,children:"保存"})]})]})})]})})}const Ic=u.forwardRef(({className:n,...r},c)=>e.jsx(Bp,{ref:c,className:Q("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",n),...r}));Ic.displayName=Bp.displayName;const A2=u.forwardRef(({className:n,...r},c)=>e.jsx(Hp,{ref:c,className:Q("aspect-square h-full w-full",n),...r}));A2.displayName=Hp.displayName;const Pc=u.forwardRef(({className:n,...r},c)=>e.jsx(qp,{ref:c,className:Q("flex h-full w-full items-center justify-center rounded-full bg-muted",n),...r}));Pc.displayName=qp.displayName;function D2(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function O2(){const n="maibot_webui_user_id";let r=localStorage.getItem(n);return r||(r=D2(),localStorage.setItem(n,r)),r}function R2(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function L2(n){localStorage.setItem("maibot_webui_user_name",n)}function U2(){const[n,r]=u.useState([]),[c,d]=u.useState(""),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[p,w]=u.useState(!1),[v,k]=u.useState(!0),[T,E]=u.useState(R2()),[R,K]=u.useState(!1),[U,A]=u.useState(""),[Z,H]=u.useState({}),z=u.useRef(O2()),B=u.useRef(null),X=u.useRef(null),S=u.useRef(null),O=u.useRef(0),te=u.useRef(new Set),{toast:he}=Hs(),Ne=$=>(O.current+=1,`${$}-${Date.now()}-${O.current}-${Math.random().toString(36).substr(2,9)}`),ye=u.useCallback(()=>{X.current?.scrollIntoView({behavior:"smooth"})},[]);u.useEffect(()=>{ye()},[n,ye]);const pe=u.useCallback(async()=>{k(!0);try{const $=`/api/chat/history?user_id=${z.current}&limit=50`;console.log("[Chat] 正在加载历史消息:",$);const de=await fetch($);if(console.log("[Chat] 历史消息响应状态:",de.status,de.statusText),console.log("[Chat] 响应 Content-Type:",de.headers.get("content-type")),de.ok){const ge=await de.text();console.log("[Chat] 响应内容前100字符:",ge.substring(0,100));try{const le=JSON.parse(ge);if(console.log("[Chat] 解析后的数据:",le),le.messages&&le.messages.length>0){const L=le.messages.map(F=>({id:F.id,type:F.type,content:F.content,timestamp:F.timestamp,sender:{name:F.sender_name||(F.is_bot?"麦麦":"WebUI用户"),user_id:F.user_id,is_bot:F.is_bot}}));r(L),console.log("[Chat] 已加载历史消息数量:",L.length),L.forEach(F=>{if(F.type==="bot"){const D=`bot-${F.content}-${Math.floor(F.timestamp*1e3)}`;te.current.add(D)}})}else console.log("[Chat] 没有历史消息")}catch(le){console.error("[Chat] JSON 解析失败:",le),console.error("[Chat] 原始响应内容:",ge)}}else{console.error("[Chat] 响应失败:",de.status);const ge=await de.text();console.error("[Chat] 错误响应内容:",ge.substring(0,200))}}catch($){console.error("[Chat] 加载历史消息失败:",$)}finally{k(!1)}},[]),je=u.useCallback(()=>{if(B.current?.readyState===WebSocket.OPEN||B.current?.readyState===WebSocket.CONNECTING){console.log("WebSocket 已存在,跳过连接");return}j(!0);const de=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/chat/ws?user_id=${encodeURIComponent(z.current)}&user_name=${encodeURIComponent(T)}`;console.log("正在连接 WebSocket:",de);try{const ge=new WebSocket(de);B.current=ge,ge.onopen=()=>{x(!0),j(!1),console.log("WebSocket 已连接")},ge.onmessage=le=>{try{const L=JSON.parse(le.data);switch(L.type){case"session_info":H({session_id:L.session_id,user_id:L.user_id,user_name:L.user_name,bot_name:L.bot_name});break;case"system":r(F=>[...F,{id:Ne("sys"),type:"system",content:L.content||"",timestamp:L.timestamp||Date.now()/1e3}]);break;case"user_message":r(F=>[...F,{id:L.message_id||Ne("user"),type:"user",content:L.content||"",timestamp:L.timestamp||Date.now()/1e3,sender:L.sender}]);break;case"bot_message":{w(!1);const F=`bot-${L.content}-${Math.floor((L.timestamp||0)*1e3)}`;if(te.current.has(F)){console.log("跳过重复的机器人消息");break}if(te.current.add(F),te.current.size>100){const D=te.current.values().next().value;D&&te.current.delete(D)}r(D=>[...D,{id:Ne("bot"),type:"bot",content:L.content||"",timestamp:L.timestamp||Date.now()/1e3,sender:L.sender}]);break}case"typing":w(L.is_typing||!1);break;case"error":r(F=>[...F,{id:Ne("error"),type:"error",content:L.content||"发生错误",timestamp:L.timestamp||Date.now()/1e3}]),he({title:"错误",description:L.content,variant:"destructive"});break;case"pong":break;default:console.log("未知消息类型:",L.type)}}catch(L){console.error("解析消息失败:",L)}},ge.onclose=()=>{x(!1),j(!1),B.current=null,console.log("WebSocket 已断开"),S.current&&clearTimeout(S.current),S.current=window.setTimeout(()=>{_e.current||je()},5e3)},ge.onerror=le=>{console.error("WebSocket 错误:",le),j(!1)}}catch(ge){console.error("创建 WebSocket 失败:",ge),j(!1)}},[he,T]),_e=u.useRef(!1);u.useEffect(()=>{_e.current=!1,pe();const $=setTimeout(()=>{_e.current||je()},100),de=setInterval(()=>{B.current?.readyState===WebSocket.OPEN&&B.current.send(JSON.stringify({type:"ping"}))},3e4);return()=>{_e.current=!0,clearTimeout($),clearInterval(de),S.current&&(clearTimeout(S.current),S.current=null),B.current&&(B.current.close(),B.current=null)}},[je,pe]);const N=u.useCallback(()=>{!c.trim()||!B.current||B.current.readyState!==WebSocket.OPEN||(B.current.send(JSON.stringify({type:"message",content:c.trim(),user_name:T})),d(""))},[c,T]),G=$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),N())},q=()=>{A(T),K(!0)},ie=()=>{const $=U.trim()||"WebUI用户";E($),L2($),K(!1),B.current?.readyState===WebSocket.OPEN&&B.current.send(JSON.stringify({type:"update_nickname",user_name:$}))},_=()=>{A(""),K(!1)},me=$=>new Date($*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),xe=()=>{B.current&&B.current.close(),je()};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"shrink-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0",children:[e.jsx(Ic,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(Pc,{className:"bg-primary/10 text-primary",children:e.jsx(ir,{className:"h-4 w-4 sm:h-5 sm:w-5"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-base sm:text-lg font-semibold truncate",children:Z.bot_name||"麦麦"}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:h?e.jsxs(e.Fragment,{children:[e.jsx(QN,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"已连接"})]}):f?e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(YN,{className:"h-3 w-3 text-red-500"}),e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"未连接"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v&&e.jsx(vt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:xe,disabled:f,title:"重新连接",children:e.jsx(pt,{className:Q("h-4 w-4",f&&"animate-spin")})})]})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 mt-2 text-sm text-muted-foreground",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),R?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:U,onChange:$=>A($.target.value),onKeyDown:$=>{$.key==="Enter"&&ie(),$.key==="Escape"&&_()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(y,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:ie,children:"保存"}),e.jsx(y,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:_,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:T}),e.jsx(y,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:q,title:"修改昵称",children:e.jsx(XN,{className:"h-3 w-3"})})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Pe,{className:"h-full",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto space-y-3 sm:space-y-4",children:[n.length===0&&!v&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(ir,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",Z.bot_name||"麦麦"," 对话吧!"]})]}),n.map($=>e.jsxs("div",{className:Q("flex gap-2 sm:gap-3",$.type==="user"&&"flex-row-reverse",$.type==="system"&&"justify-center",$.type==="error"&&"justify-center"),children:[$.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:$.content}),$.type==="error"&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 bg-red-100 dark:bg-red-900/30 px-3 py-1 rounded-full max-w-[90%]",children:$.content}),($.type==="user"||$.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(Ic,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Pc,{className:Q("text-xs",$.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:$.type==="bot"?e.jsx(ir,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(to,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:Q("flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",$.type==="user"&&"items-end"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] sm:text-xs text-muted-foreground",children:[e.jsx("span",{className:"hidden sm:inline",children:$.sender?.name||($.type==="bot"?Z.bot_name:T)}),e.jsx("span",{children:me($.timestamp)})]}),e.jsx("div",{className:Q("rounded-2xl px-3 py-2 text-sm whitespace-pre-wrap break-words",$.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:$.content})]})]})]},$.id)),p&&e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsx(Ic,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Pc,{className:"bg-primary/10 text-primary",children:e.jsx(ir,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsx("div",{className:"bg-muted rounded-2xl rounded-tl-sm px-4 py-3",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})]}),e.jsx("div",{ref:X})]})})}),e.jsx("div",{className:"shrink-0 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsx("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:c,onChange:$=>d($.target.value),onKeyDown:G,placeholder:h?"输入消息...":"等待连接...",disabled:!h,className:"flex-1 h-10 sm:h-10"}),e.jsx(y,{onClick:N,disabled:!h||!c.trim(),size:"icon",className:"h-10 w-10 shrink-0",children:e.jsx(KN,{className:"h-4 w-4"})})]})})})]})}function B2(){const n=Jt(),[r,c]=u.useState(!0);return u.useEffect(()=>{let d=!1;return(async()=>{try{const x=await Ju();!d&&!x&&n({to:"/auth"})}catch{d||n({to:"/auth"})}finally{d||c(!1)}})(),()=>{d=!0}},[n]),{checking:r}}async function H2(){return await Ju()}const q2=ai("pointer-events-none inline-flex select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono font-medium opacity-100",{variants:{size:{sm:"h-5 text-[10px]",default:"h-6 text-xs",lg:"h-7 text-sm"}},defaultVariants:{size:"default"}}),Xg=u.forwardRef(({className:n,size:r,abbrTitle:c,children:d,...h},x)=>e.jsx("kbd",{className:Q(q2({size:r,className:n})),ref:x,...h,children:c?e.jsx("abbr",{title:c,children:d}):d}));Xg.displayName="Kbd";const G2=[{icon:xr,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:Aa,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:Ng,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:bg,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:$u,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:si,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:wg,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:ZN,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:rn,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:ao,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:Rl,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function V2({open:n,onOpenChange:r}){const[c,d]=u.useState(""),[h,x]=u.useState(0),f=Jt(),j=G2.filter(v=>v.title.toLowerCase().includes(c.toLowerCase())||v.description.toLowerCase().includes(c.toLowerCase())||v.category.toLowerCase().includes(c.toLowerCase()));u.useEffect(()=>{n&&(d(""),x(0))},[n]);const p=u.useCallback(v=>{f({to:v}),r(!1)},[f,r]),w=u.useCallback(v=>{v.key==="ArrowDown"?(v.preventDefault(),x(k=>(k+1)%j.length)):v.key==="ArrowUp"?(v.preventDefault(),x(k=>(k-1+j.length)%j.length)):v.key==="Enter"&&j[h]&&(v.preventDefault(),p(j[h].path))},[j,h,p]);return e.jsx(Rs,{open:n,onOpenChange:r,children:e.jsxs(zs,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(Ms,{className:"px-4 pt-4 pb-0",children:[e.jsx(As,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ce,{value:c,onChange:v=>{d(v.target.value),x(0)},onKeyDown:w,placeholder:"搜索页面...",className:"h-12 pl-11 text-base border-0 focus-visible:ring-0 shadow-none",autoFocus:!0})]})]}),e.jsx("div",{className:"border-t",children:e.jsx(Pe,{className:"h-[400px]",children:j.length>0?e.jsx("div",{className:"p-2",children:j.map((v,k)=>{const T=v.icon;return e.jsxs("button",{onClick:()=>p(v.path),onMouseEnter:()=>x(k),className:Q("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",k===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[e.jsx(T,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:v.title}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:v.description})]}),e.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:v.category})]},v.path)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(_t,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),e.jsx("div",{className:"border-t px-4 py-3 flex items-center justify-between text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↑"}),e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↓"}),"导航"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Enter"}),"选择"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Esc"}),"关闭"]})]})})]})})}const F2=Ky,$2=Zy,Q2=Jy,Kg=u.forwardRef(({className:n,inset:r,children:c,...d},h)=>e.jsxs(Gp,{ref:h,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",n),...d,children:[c,e.jsx(il,{className:"ml-auto h-4 w-4"})]}));Kg.displayName=Gp.displayName;const Zg=u.forwardRef(({className:n,...r},c)=>e.jsx(Vp,{ref:c,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",n),...r}));Zg.displayName=Vp.displayName;const Jg=u.forwardRef(({className:n,...r},c)=>e.jsx(Xy,{children:e.jsx(Fp,{ref:c,className:Q("z-50 max-h-[--radix-context-menu-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",n),...r})}));Jg.displayName=Fp.displayName;const Na=u.forwardRef(({className:n,inset:r,...c},d)=>e.jsx($p,{ref:d,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r&&"pl-8",n),...c}));Na.displayName=$p.displayName;const Y2=u.forwardRef(({className:n,children:r,checked:c,...d},h)=>e.jsxs(Qp,{ref:h,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),checked:c,...d,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Yp,{children:e.jsx(fa,{className:"h-4 w-4"})})}),r]}));Y2.displayName=Qp.displayName;const X2=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs(Xp,{ref:d,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Yp,{children:e.jsx(JN,{className:"h-2 w-2 fill-current"})})}),r]}));X2.displayName=Xp.displayName;const K2=u.forwardRef(({className:n,inset:r,...c},d)=>e.jsx(Kp,{ref:d,className:Q("px-2 py-1.5 text-sm font-semibold text-foreground",r&&"pl-8",n),...c}));K2.displayName=Kp.displayName;const or=u.forwardRef(({className:n,...r},c)=>e.jsx(Zp,{ref:c,className:Q("-mx-1 my-1 h-px bg-border",n),...r}));or.displayName=Zp.displayName;const In=({className:n,...r})=>e.jsx("span",{className:Q("ml-auto text-xs tracking-widest text-muted-foreground",n),...r});In.displayName="ContextMenuShortcut";const Z2=jN,J2=vN,I2=yN,Ig=u.forwardRef(({className:n,sideOffset:r=4,...c},d)=>e.jsx(gN,{children:e.jsx(dg,{ref:d,sideOffset:r,className:Q("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",n),...c})}));Ig.displayName=dg.displayName;function P2({children:n}){const{checking:r}=B2(),[c,d]=u.useState(!0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),{theme:p,setTheme:w}=Yu(),v=gy(),k=Jt();if(u.useEffect(()=>{const U=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),j(!0))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),r)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"text-muted-foreground",children:"正在验证登录状态..."})});const T=[{title:"概览",items:[{icon:xr,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:Aa,label:"麦麦主程序配置",path:"/config/bot"},{icon:Ng,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:bg,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:Zf,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:$u,label:"表情包管理",path:"/resource/emoji"},{icon:si,label:"表达方式管理",path:"/resource/expression"},{icon:wg,label:"人物信息管理",path:"/resource/person"},{icon:yg,label:"知识库图谱可视化",path:"/resource/knowledge-graph"}]},{title:"扩展与监控",items:[{icon:rn,label:"插件市场",path:"/plugins"},{icon:Zf,label:"插件配置",path:"/plugin-config"},{icon:ao,label:"日志查看器",path:"/logs"},{icon:si,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:Rl,label:"系统设置",path:"/settings"}]}],R=p==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":p,K=async()=>{await y0()};return e.jsx(Z2,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:Q("fixed inset-y-0 left-0 z-50 flex flex-col border-r bg-card transition-all duration-300 lg:relative lg:z-0","w-64 lg:w-auto",c?"lg:w-64":"lg:w-16",h?"translate-x-0":"-translate-x-full lg:translate-x-0"),children:[e.jsx("div",{className:"flex h-16 items-center border-b px-4",children:e.jsxs("div",{className:Q("relative flex items-center justify-center flex-1 transition-all overflow-hidden","lg:flex-1",!c&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:Q("flex items-baseline gap-2",!c&&"lg:hidden"),children:[e.jsx("span",{className:"font-bold text-xl text-primary-gradient whitespace-nowrap",children:"MaiBot WebUI"}),e.jsx("span",{className:"text-xs text-primary/60 whitespace-nowrap",children:l0()})]}),!c&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(Pe,{className:Q("flex-1 overflow-x-hidden",!c&&"lg:w-16"),children:e.jsx("nav",{className:Q("p-4",!c&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:Q("space-y-6",!c&&"lg:space-y-3 lg:w-full"),children:T.map((U,A)=>e.jsxs("li",{children:[e.jsx("div",{className:Q("px-3 h-[1.25rem]","mb-2",!c&&"lg:mb-1 lg:invisible"),children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:U.title})}),!c&&A>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:U.items.map(Z=>{const H=v({to:Z.path}),z=Z.icon,B=e.jsxs(e.Fragment,{children:[H&&e.jsx("div",{className:"absolute left-0 top-1/2 h-8 w-1 -translate-y-1/2 rounded-r-full bg-primary transition-opacity duration-300"}),e.jsxs("div",{className:Q("flex items-center transition-all duration-300",c?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(z,{className:Q("h-5 w-5 flex-shrink-0",H&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:Q("text-sm font-medium whitespace-nowrap transition-all duration-300",H&&"font-semibold",c?"opacity-100 max-w-[200px]":"opacity-100 max-w-[200px] lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:Z.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(J2,{children:[e.jsx(I2,{asChild:!0,children:e.jsx(Kc,{to:Z.path,"data-tour":Z.tourId,className:Q("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",H?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground",c?"px-3":"px-3 lg:px-0 lg:justify-center lg:w-12 lg:mx-auto"),onClick:()=>x(!1),children:B})}),!c&&e.jsx(Ig,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:Z.label})})]})},Z.path)})})]},U.title))})})})]}),h&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>x(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"flex h-16 items-center justify-between border-b bg-card/80 backdrop-blur-md px-4 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(!h),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(IN,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>d(!c),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:c?"收起侧边栏":"展开侧边栏",children:e.jsx(cn,{className:Q("h-5 w-5 transition-transform",!c&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>j(!0),className:"relative hidden md:flex items-center w-64 h-9 pl-9 pr-16 bg-background/50 border rounded-md hover:bg-accent/50 transition-colors text-left",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"搜索..."}),e.jsxs(Xg,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(V2,{open:f,onOpenChange:j}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(PN,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:U=>{Wb(R==="dark"?"light":"dark",w,U)},className:"rounded-lg p-2 hover:bg-accent",title:R==="dark"?"切换到浅色模式":"切换到深色模式",children:R==="dark"?e.jsx(Ou,{className:"h-5 w-5"}):e.jsx(Ru,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:K,className:"gap-2",title:"登出系统",children:[e.jsx(Jf,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsxs(F2,{children:[e.jsx($2,{asChild:!0,children:e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:n})}),e.jsxs(Jg,{className:"w-64",children:[e.jsxs(Na,{onClick:()=>k({to:"/"}),children:[e.jsx(xr,{className:"mr-2 h-4 w-4"}),"首页"]}),e.jsxs(Na,{onClick:()=>k({to:"/settings"}),children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"系统设置"]}),e.jsxs(Na,{onClick:()=>k({to:"/logs"}),children:[e.jsx(ao,{className:"mr-2 h-4 w-4"}),"日志查看器"]}),e.jsx(or,{}),e.jsxs(Q2,{children:[e.jsxs(Kg,{children:[e.jsx(gg,{className:"mr-2 h-4 w-4"}),"切换主题"]}),e.jsxs(Zg,{className:"w-48",children:[e.jsxs(Na,{onClick:()=>w("light"),disabled:p==="light",children:[e.jsx(Ou,{className:"mr-2 h-4 w-4"}),"浅色",p==="light"&&e.jsx(In,{children:"✓"})]}),e.jsxs(Na,{onClick:()=>w("dark"),disabled:p==="dark",children:[e.jsx(Ru,{className:"mr-2 h-4 w-4"}),"深色",p==="dark"&&e.jsx(In,{children:"✓"})]}),e.jsxs(Na,{onClick:()=>w("system"),disabled:p==="system",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"跟随系统",p==="system"&&e.jsx(In,{children:"✓"})]})]})]}),e.jsx(or,{}),e.jsxs(Na,{onClick:()=>window.location.reload(),children:[e.jsx(WN,{className:"mr-2 h-4 w-4"}),"刷新页面",e.jsx(In,{children:"⌘R"})]}),e.jsxs(Na,{onClick:()=>j(!0),children:[e.jsx(_t,{className:"mr-2 h-4 w-4"}),"搜索",e.jsx(In,{children:"⌘K"})]}),e.jsx(or,{}),e.jsxs(Na,{onClick:()=>window.open("https://docs.mai-mai.org","_blank"),children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),"麦麦文档"]}),e.jsx(or,{}),e.jsxs(Na,{onClick:K,className:"text-destructive focus:text-destructive",children:[e.jsx(Jf,{className:"mr-2 h-4 w-4"}),"登出系统"]})]})]})]})]})})}function W2(n){const r=n.split(` +`).slice(1),c=[];for(const d of r){const h=d.trim();if(!h.startsWith("at "))continue;const x=h.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);x?c.push({functionName:x[1]||"",fileName:x[2],lineNumber:x[3],columnNumber:x[4],raw:h}):c.push({functionName:"",fileName:"",lineNumber:"",columnNumber:"",raw:h})}return c}function e_({error:n,errorInfo:r}){const[c,d]=u.useState(!0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),p=n.stack?W2(n.stack):[],w=async()=>{const v=` +Error: ${n.name} +Message: ${n.message} + +Stack Trace: +${n.stack||"No stack trace available"} + +Component Stack: +${r?.componentStack||"No component stack available"} + +URL: ${window.location.href} +User Agent: ${navigator.userAgent} +Time: ${new Date().toISOString()} + `.trim();try{await navigator.clipboard.writeText(v),j(!0),setTimeout(()=>j(!1),2e3)}catch(k){console.error("Failed to copy:",k)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ha,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(ba,{className:"h-4 w-4"}),e.jsxs(xa,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[n.name,":"]})," ",n.message]})]}),p.length>0&&e.jsxs(Gu,{open:c,onOpenChange:d,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(y,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(eb,{className:"h-4 w-4"}),"Stack Trace (",p.length," frames)"]}),c?e.jsx(fr,{className:"h-4 w-4"}):e.jsx(Ll,{className:"h-4 w-4"})]})}),e.jsx(Fu,{children:e.jsx(Pe,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:p.map((v,k)=>e.jsx("div",{className:"font-mono text-xs p-2 rounded hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"text-muted-foreground w-6 text-right flex-shrink-0",children:[k+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-primary font-medium",children:v.functionName}),v.fileName&&e.jsxs("div",{className:"text-muted-foreground mt-0.5 break-all",children:[v.fileName,v.lineNumber&&e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:[":",v.lineNumber,":",v.columnNumber]})]})]})]})},k))})})})]}),r?.componentStack&&e.jsxs(Gu,{open:h,onOpenChange:x,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(y,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(ba,{className:"h-4 w-4"}),"Component Stack"]}),h?e.jsx(fr,{className:"h-4 w-4"}):e.jsx(Ll,{className:"h-4 w-4"})]})}),e.jsx(Fu,{children:e.jsx(Pe,{className:"h-[200px] rounded-md border bg-muted/30",children:e.jsx("pre",{className:"p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground",children:r.componentStack})})})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:w,className:"w-full",children:f?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(so,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function Pg({error:n,errorInfo:r}){const c=()=>{window.location.href="/"},d=()=>{window.location.reload()};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Fe,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(gs,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30 mb-4",children:e.jsx(ba,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(js,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(Zs,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(bs,{className:"space-y-4",children:[e.jsx(e_,{error:n,errorInfo:r}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:[e.jsxs(y,{onClick:d,className:"flex-1",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(y,{onClick:c,variant:"outline",className:"flex-1",children:[e.jsx(xr,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class s_ extends u.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,c){console.error("ErrorBoundary caught an error:",r,c),this.setState({errorInfo:c})}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:e.jsx(Pg,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function Wg({error:n}){return e.jsx(Pg,{error:n,errorInfo:null})}const kr=jy({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(Np,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!H2())throw yy({to:"/auth"})}}),t_=lt({getParentRoute:()=>kr,path:"/auth",component:N0}),a_=lt({getParentRoute:()=>kr,path:"/setup",component:B0}),Nt=lt({getParentRoute:()=>kr,id:"protected",component:()=>e.jsx(P2,{children:e.jsx(Np,{})}),errorComponent:({error:n})=>e.jsx(Wg,{error:n})}),l_=lt({getParentRoute:()=>Nt,path:"/",component:Ib}),n_=lt({getParentRoute:()=>Nt,path:"/config/bot",component:I0}),i_=lt({getParentRoute:()=>Nt,path:"/config/modelProvider",component:Nw}),r_=lt({getParentRoute:()=>Nt,path:"/config/model",component:Sw}),c_=lt({getParentRoute:()=>Nt,path:"/config/adapter",component:kw}),o_=lt({getParentRoute:()=>Nt,path:"/resource/emoji",component:Kw}),d_=lt({getParentRoute:()=>Nt,path:"/resource/expression",component:i1}),u_=lt({getParentRoute:()=>Nt,path:"/resource/person",component:g1}),m_=lt({getParentRoute:()=>Nt,path:"/resource/knowledge-graph",component:C1}),h_=lt({getParentRoute:()=>Nt,path:"/logs",component:a2}),x_=lt({getParentRoute:()=>Nt,path:"/chat",component:U2}),f_=lt({getParentRoute:()=>Nt,path:"/plugins",component:k2}),p_=lt({getParentRoute:()=>Nt,path:"/plugin-config",component:z2}),g_=lt({getParentRoute:()=>Nt,path:"/plugin-mirrors",component:M2}),j_=lt({getParentRoute:()=>Nt,path:"/settings",component:x0}),v_=lt({getParentRoute:()=>kr,path:"*",component:Rg}),y_=kr.addChildren([t_,a_,Nt.addChildren([l_,n_,i_,r_,c_,o_,d_,u_,m_,f_,p_,g_,h_,x_,j_]),v_]),N_=vy({routeTree:y_,defaultNotFoundComponent:Rg,defaultErrorComponent:({error:n})=>e.jsx(Wg,{error:n})});function b_({children:n,defaultTheme:r="system",storageKey:c="ui-theme",...d}){const[h,x]=u.useState(()=>localStorage.getItem(c)||r);u.useEffect(()=>{const j=window.document.documentElement;if(j.classList.remove("light","dark"),h==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";j.classList.add(p);return}j.classList.add(h)},[h]),u.useEffect(()=>{const j=localStorage.getItem("accent-color");if(j){const p=document.documentElement,v={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[j];v&&(p.style.setProperty("--primary",v.hsl),v.gradient?(p.style.setProperty("--primary-gradient",v.gradient),p.classList.add("has-gradient")):(p.style.removeProperty("--primary-gradient"),p.classList.remove("has-gradient")))}},[]);const f={theme:h,setTheme:j=>{localStorage.setItem(c,j),x(j)}};return e.jsx(Eg.Provider,{...d,value:f,children:n})}function w_({children:n,defaultEnabled:r=!0,defaultWavesEnabled:c=!0,storageKey:d="enable-animations",wavesStorageKey:h="enable-waves-background"}){const[x,f]=u.useState(()=>{const v=localStorage.getItem(d);return v!==null?v==="true":r}),[j,p]=u.useState(()=>{const v=localStorage.getItem(h);return v!==null?v==="true":c});u.useEffect(()=>{const v=document.documentElement;x?v.classList.remove("no-animations"):v.classList.add("no-animations"),localStorage.setItem(d,String(x))},[x,d]),u.useEffect(()=>{localStorage.setItem(h,String(j))},[j,h]);const w={enableAnimations:x,setEnableAnimations:f,enableWavesBackground:j,setEnableWavesBackground:p};return e.jsx(zg.Provider,{value:w,children:n})}const __=NN,ej=u.forwardRef(({className:n,...r},c)=>e.jsx(ug,{ref:c,className:Q("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px] gap-2",n),...r}));ej.displayName=ug.displayName;const S_=ai("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-slide-in-from-right data-[state=open]:animate-fade-in data-[state=closed]:animate-slide-out-to-right data-[state=closed]:animate-fade-out data-[swipe=end]:animate-slide-out-to-right",{variants:{variant:{default:"border bg-primary/5 text-foreground backdrop-blur-sm",destructive:"destructive group border-destructive bg-destructive/10 text-destructive-foreground backdrop-blur-sm"}},defaultVariants:{variant:"default"}}),sj=u.forwardRef(({className:n,variant:r,...c},d)=>e.jsx(mg,{ref:d,className:Q(S_({variant:r}),n),...c}));sj.displayName=mg.displayName;const C_=u.forwardRef(({className:n,...r},c)=>e.jsx(hg,{ref:c,className:Q("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",n),...r}));C_.displayName=hg.displayName;const tj=u.forwardRef(({className:n,...r},c)=>e.jsx(xg,{ref:c,className:Q("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",n),"toast-close":"",...r,children:e.jsx(li,{className:"h-4 w-4"})}));tj.displayName=xg.displayName;const aj=u.forwardRef(({className:n,...r},c)=>e.jsx(fg,{ref:c,className:Q("text-sm font-semibold [&+div]:text-xs",n),...r}));aj.displayName=fg.displayName;const lj=u.forwardRef(({className:n,...r},c)=>e.jsx(pg,{ref:c,className:Q("text-sm opacity-90",n),...r}));lj.displayName=pg.displayName;function k_(){const{toasts:n}=Hs();return e.jsxs(__,{children:[n.map(function({id:r,title:c,description:d,action:h,...x}){return e.jsxs(sj,{...x,children:[e.jsxs("div",{className:"grid gap-1",children:[c&&e.jsx(aj,{children:c}),d&&e.jsx(lj,{children:d})]}),h,e.jsx(tj,{})]},r)}),e.jsx(ej,{})]})}Hb.createRoot(document.getElementById("root")).render(e.jsx(u.StrictMode,{children:e.jsx(s_,{children:e.jsx(b_,{defaultTheme:"system",children:e.jsx(w_,{children:e.jsxs(pw,{children:[e.jsx(Ny,{router:N_}),e.jsx(vw,{}),e.jsx(k_,{})]})})})})})); diff --git a/webui/dist/assets/index-DuV8F13p.js b/webui/dist/assets/index-DuV8F13p.js deleted file mode 100644 index 3dd4ef1e..00000000 --- a/webui/dist/assets/index-DuV8F13p.js +++ /dev/null @@ -1,52 +0,0 @@ -import{r as u,j as e,L as Kc,e as It,b as xy,f as fy,g as py,h as gy,k as lt,l as jy,m as vy,O as vp,n as yy}from"./router-CWhjJi2n.js";import{a as Ny,b as by,g as wy}from"./react-vendor-Dtc2IqVY.js";import{I as _y,c as Sy,J as ai,K as qc,L as wu,M as Cy,N as er,O as sr,P as ky,n as _u}from"./utils-CCeOswSm.js";import{L as yp,T as Np,C as bp,R as Ty,a as wp,V as Ey,b as zy,S as _p,c as My,d as Sp,I as Ay,e as Cp,f as Dy,g as kp,h as Oy,i as Ry,j as Ly,O as Tp,P as Uy,k as Ep,l as zp,D as Mp,A as Ap,m as Dp,n as By,o as Hy,p as Op,q as qy,r as Rp,s as Gy,t as Vy,u as Fy,v as Qy,w as $y,x as Lp,y as Up,F as Bp,z as Hp,B as qp,E as Yy,G as Gp,H as Vp,J as Fp,K as Qp,M as $p,N as Yp,Q as Xp,U as Xy,W as Ky,X as Zy}from"./radix-extra-Cw1azsjZ.js";import{aj as Iy,ak as Jy,al as Py,am as Wy,an as Gc,ao as Vc,ap as tr,aq as eN,ar as Su,as as Fc,at as sN,au as tN,av as aN}from"./charts-Dhri-zxi.js";import{S as lN,H as Kp,O as Zp,o as nN,C as Ip,p as Jp,T as Pp,D as Wp,R as iN,q as rN,I as eg,J as cN,K as sg,L as tg,M as oN,N as ag,V as dN,Q as lg,U as ng,X as uN,Y as mN,Z as ig,_ as hN,$ as xN,a0 as rg,a1 as fN,a2 as pN,a3 as cg,a4 as gN,a5 as jN,a6 as vN,a7 as og,a8 as dg,a9 as ug,aa as mg,ab as hg,ac as xg,ad as yN}from"./radix-core-BlBHu_Lw.js";import{R as ft,P as Nr,C as xa,a as Aa,Z as ln,b as Wc,F as Ma,c as NN,S as Rl,A as bN,D as wN,d as eo,e as Wn,M as si,T as _N,X as li,f as fg,g as SN,I as Xt,h as ya,i as ha,j as so,E as mr,k as Zt,l as pg,H as CN,m as ns,n as nl,U as hr,o as Ou,p as Ru,L as $f,K as gg,q as ro,r as kN,s as dr,t as vt,u as TN,B as ir,v as to,w as Qu,x as EN,y as zN,z as St,G as xr,J as ti,N as Ll,O as fr,Q as MN,V as AN,W as br,Y as gt,_ as ao,$ as nn,a0 as wr,a1 as cn,a2 as il,a3 as _r,a4 as $u,a5 as DN,a6 as ON,a7 as RN,a8 as rn,a9 as LN,aa as Lu,ab as pr,ac as UN,ad as BN,ae as Uu,af as HN,ag as jg,ah as Yf,ai as qN,aj as GN,ak as VN,al as Ol,am as Cu,an as Xf,ao as FN,ap as QN,aq as $N,ar as YN,as as XN,at as vg,au as yg,av as Ng,aw as KN,ax as ZN,ay as Kf,az as IN,aA as JN,aB as Zf,aC as PN,aD as WN}from"./icons-Bw5y5Hqz.js";import{S as eb,p as sb,j as tb,a as ab,E as If,R as lb,o as nb}from"./codemirror-BHeANvwm.js";import{_ as Lt,c as ib,g as bg,D as rb}from"./misc-Ii-X5qWA.js";import{u as cb,a as Jf,D as ob,c as db,S as ub,h as mb,b as hb,s as xb,K as fb,P as pb,d as gb,C as jb}from"./dnd-Dyi3CnuX.js";import{D as vb,U as yb}from"./uppy-DSH7n_-V.js";import{M as Nb,r as bb,a as wb,b as _b}from"./markdown-A1ShuLvG.js";import{r as Sb,H as lo,P as no,u as Cb,a as kb,R as Tb,B as Eb,b as zb,C as Mb,M as Ab,c as Db}from"./reactflow-B3n3_Vkw.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const h of document.querySelectorAll('link[rel="modulepreload"]'))d(h);new MutationObserver(h=>{for(const x of h)if(x.type==="childList")for(const f of x.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&d(f)}).observe(document,{childList:!0,subtree:!0});function c(h){const x={};return h.integrity&&(x.integrity=h.integrity),h.referrerPolicy&&(x.referrerPolicy=h.referrerPolicy),h.crossOrigin==="use-credentials"?x.credentials="include":h.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function d(h){if(h.ep)return;h.ep=!0;const x=c(h);fetch(h.href,x)}})();var ku={exports:{}},ar={},Tu={exports:{}},Eu={};var Pf;function Ob(){return Pf||(Pf=1,(function(n){function r(y,q){var H=y.length;y.push(q);e:for(;0>>1,S=y[ne];if(0>>1;neh(Q,H))oeh(ge,Q)?(y[ne]=ge,y[oe]=H,ne=oe):(y[ne]=Q,y[he]=H,ne=he);else if(oeh(ge,H))y[ne]=ge,y[oe]=H,ne=oe;else break e}}return q}function h(y,q){var H=y.sortIndex-q.sortIndex;return H!==0?H:y.id-q.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var x=performance;n.unstable_now=function(){return x.now()}}else{var f=Date,j=f.now();n.unstable_now=function(){return f.now()-j}}var g=[],_=[],v=1,k=null,z=3,T=!1,L=!1,K=!1,U=!1,R=typeof setTimeout=="function"?setTimeout:null,ee=typeof clearTimeout=="function"?clearTimeout:null,V=typeof setImmediate<"u"?setImmediate:null;function E(y){for(var q=c(_);q!==null;){if(q.callback===null)d(_);else if(q.startTime<=y)d(_),q.sortIndex=q.expirationTime,r(g,q);else break;q=c(_)}}function B(y){if(K=!1,E(y),!L)if(c(g)!==null)L=!0,X||(X=!0,ye());else{var q=c(_);q!==null&&Ne(B,q.startTime-y)}}var X=!1,w=-1,D=5,te=-1;function xe(){return U?!0:!(n.unstable_now()-tey&&xe());){var ne=k.callback;if(typeof ne=="function"){k.callback=null,z=k.priorityLevel;var S=ne(k.expirationTime<=y);if(y=n.unstable_now(),typeof S=="function"){k.callback=S,E(y),q=!0;break s}k===c(g)&&d(g),E(y)}else d(g);k=c(g)}if(k!==null)q=!0;else{var me=c(_);me!==null&&Ne(B,me.startTime-y),q=!1}}break e}finally{k=null,z=H,T=!1}q=void 0}}finally{q?ye():X=!1}}}var ye;if(typeof V=="function")ye=function(){V(be)};else if(typeof MessageChannel<"u"){var ve=new MessageChannel,pe=ve.port2;ve.port1.onmessage=be,ye=function(){pe.postMessage(null)}}else ye=function(){R(be,0)};function Ne(y,q){w=R(function(){y(n.unstable_now())},q)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(y){y.callback=null},n.unstable_forceFrameRate=function(y){0>y||125ne?(y.sortIndex=H,r(_,y),c(g)===null&&y===c(_)&&(K?(ee(w),w=-1):K=!0,Ne(B,H-ne))):(y.sortIndex=S,r(g,y),L||T||(L=!0,X||(X=!0,ye()))),y},n.unstable_shouldYield=xe,n.unstable_wrapCallback=function(y){var q=z;return function(){var H=z;z=q;try{return y.apply(this,arguments)}finally{z=H}}}})(Eu)),Eu}var Wf;function Rb(){return Wf||(Wf=1,Tu.exports=Ob()),Tu.exports}var ep;function Lb(){if(ep)return ar;ep=1;var n=Rb(),r=Ny(),c=by();function d(s){var t="https://react.dev/errors/"+s;if(1S||(s.current=ne[S],ne[S]=null,S--)}function Q(s,t){S++,ne[S]=s.current,s.current=t}var oe=me(null),ge=me(null),le=me(null),O=me(null);function F(s,t){switch(Q(le,t),Q(ge,s),Q(oe,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?xf(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=xf(t),s=ff(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}he(oe),Q(oe,s)}function A(){he(oe),he(ge),he(le)}function W(s){s.memoizedState!==null&&Q(O,s);var t=oe.current,a=ff(t,s.type);t!==a&&(Q(ge,s),Q(oe,a))}function _e(s){ge.current===s&&(he(oe),he(ge)),O.current===s&&(he(O),Ii._currentValue=H)}var Me,ss;function Ie(s){if(Me===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||"",ss=-1)":-1i||C[l]!==I[i]){var ae=` -`+C[l].replace(" at new "," at ");return s.displayName&&ae.includes("")&&(ae=ae.replace("",s.displayName)),ae}while(1<=l&&0<=i);break}}}finally{Rs=!1,Error.prepareStackTrace=a}return(a=s?s.displayName||s.name:"")?Ie(a):""}function ie(s,t){switch(s.tag){case 26:case 27:case 5:return Ie(s.type);case 16:return Ie("Lazy");case 13:return s.child!==t&&t!==null?Ie("Suspense Fallback"):Ie("Suspense");case 19:return Ie("SuspenseList");case 0:case 15:return qs(s.type,!1);case 11:return qs(s.type.render,!1);case 1:return qs(s.type,!0);case 31:return Ie("Activity");default:return""}}function we(s){try{var t="",a=null;do t+=ie(s,a),a=s,s=s.return;while(s);return t}catch(l){return` -Error generating stack: `+l.message+` -`+l.stack}}var Ke=Object.prototype.hasOwnProperty,Le=n.unstable_scheduleCallback,st=n.unstable_cancelCallback,Jt=n.unstable_shouldYield,bt=n.unstable_requestPaint,Je=n.unstable_now,Ue=n.unstable_getCurrentPriorityLevel,jt=n.unstable_ImmediatePriority,nt=n.unstable_UserBlockingPriority,Ct=n.unstable_NormalPriority,kt=n.unstable_LowPriority,rl=n.unstable_IdlePriority,cl=n.log,ol=n.unstable_setDisableYieldValue,Se=null,Re=null;function it(s){if(typeof cl=="function"&&ol(s),Re&&typeof Re.setStrictMode=="function")try{Re.setStrictMode(Se,s)}catch{}}var ot=Math.clz32?Math.clz32:dt,di=Math.log,on=Math.LN2;function dt(s){return s>>>=0,s===0?32:31-(di(s)/on|0)|0}var Pt=256,Wt=262144,La=4194304;function Ut(s){var t=s&42;if(t!==0)return t;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ua(s,t,a){var l=s.pendingLanes;if(l===0)return 0;var i=0,o=s.suspendedLanes,m=s.pingedLanes;s=s.warmLanes;var p=l&134217727;return p!==0?(l=p&~o,l!==0?i=Ut(l):(m&=p,m!==0?i=Ut(m):a||(a=p&~s,a!==0&&(i=Ut(a))))):(p=l&~o,p!==0?i=Ut(p):m!==0?i=Ut(m):a||(a=l&~s,a!==0&&(i=Ut(a)))),i===0?0:t!==0&&t!==i&&(t&o)===0&&(o=i&-i,a=t&-t,o>=a||o===32&&(a&4194048)!==0)?t:i}function ba(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function P(s,t){switch(s){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function je(){var s=La;return La<<=1,(La&62914560)===0&&(La=4194304),s}function Ae(s){for(var t=[],a=0;31>a;a++)t.push(s);return t}function tt(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Bt(s,t,a,l,i,o){var m=s.pendingLanes;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=a,s.entangledLanes&=a,s.errorRecoveryDisabledLanes&=a,s.shellSuspendCounter=0;var p=s.entanglements,C=s.expirationTimes,I=s.hiddenUpdates;for(a=m&~a;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var cj=/[\n"\\]/g;function sa(s){return s.replace(cj,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function go(s,t,a,l,i,o,m,p){s.name="",m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"?s.type=m:s.removeAttribute("type"),t!=null?m==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+ea(t)):s.value!==""+ea(t)&&(s.value=""+ea(t)):m!=="submit"&&m!=="reset"||s.removeAttribute("value"),t!=null?jo(s,m,ea(t)):a!=null?jo(s,m,ea(a)):l!=null&&s.removeAttribute("value"),i==null&&o!=null&&(s.defaultChecked=!!o),i!=null&&(s.checked=i&&typeof i!="function"&&typeof i!="symbol"),p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"?s.name=""+ea(p):s.removeAttribute("name")}function rm(s,t,a,l,i,o,m,p){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(s.type=o),t!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){po(s);return}a=a!=null?""+ea(a):"",t=t!=null?""+ea(t):a,p||t===s.value||(s.value=t),s.defaultValue=t}l=l??i,l=typeof l!="function"&&typeof l!="symbol"&&!!l,s.checked=p?s.checked:!!l,s.defaultChecked=!!l,m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(s.name=m),po(s)}function jo(s,t,a){t==="number"&&zr(s.ownerDocument)===s||s.defaultValue===""+a||(s.defaultValue=""+a)}function pn(s,t,a,l){if(s=s.options,t){t={};for(var i=0;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wo=!1;if(Ga)try{var xi={};Object.defineProperty(xi,"passive",{get:function(){wo=!0}}),window.addEventListener("test",xi,xi),window.removeEventListener("test",xi,xi)}catch{wo=!1}var ul=null,_o=null,Ar=null;function xm(){if(Ar)return Ar;var s,t=_o,a=t.length,l,i="value"in ul?ul.value:ul.textContent,o=i.length;for(s=0;s=gi),ym=" ",Nm=!1;function bm(s,t){switch(s){case"keyup":return Lj.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wm(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var yn=!1;function Bj(s,t){switch(s){case"compositionend":return wm(t);case"keypress":return t.which!==32?null:(Nm=!0,ym);case"textInput":return s=t.data,s===ym&&Nm?null:s;default:return null}}function Hj(s,t){if(yn)return s==="compositionend"||!Eo&&bm(s,t)?(s=xm(),Ar=_o=ul=null,yn=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:a,offset:t-s};s=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Mm(a)}}function Dm(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?Dm(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function Om(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=zr(s.document);t instanceof s.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)s=t.contentWindow;else break;t=zr(s.document)}return t}function Ao(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t&&(t==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||t==="textarea"||s.contentEditable==="true")}var Xj=Ga&&"documentMode"in document&&11>=document.documentMode,Nn=null,Do=null,Ni=null,Oo=!1;function Rm(s,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Oo||Nn==null||Nn!==zr(l)||(l=Nn,"selectionStart"in l&&Ao(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Ni&&yi(Ni,l)||(Ni=l,l=Sc(Do,"onSelect"),0>=m,i-=m,Sa=1<<32-ot(t)+i|a<Pe?(rs=Te,Te=null):rs=Te.sibling;var ys=J(G,Te,Z[Pe],re);if(ys===null){Te===null&&(Te=rs);break}s&&Te&&ys.alternate===null&&t(G,Te),M=o(ys,M,Pe),vs===null?Ee=ys:vs.sibling=ys,vs=ys,Te=rs}if(Pe===Z.length)return a(G,Te),fs&&Fa(G,Pe),Ee;if(Te===null){for(;PePe?(rs=Te,Te=null):rs=Te.sibling;var Dl=J(G,Te,ys.value,re);if(Dl===null){Te===null&&(Te=rs);break}s&&Te&&Dl.alternate===null&&t(G,Te),M=o(Dl,M,Pe),vs===null?Ee=Dl:vs.sibling=Dl,vs=Dl,Te=rs}if(ys.done)return a(G,Te),fs&&Fa(G,Pe),Ee;if(Te===null){for(;!ys.done;Pe++,ys=Z.next())ys=de(G,ys.value,re),ys!==null&&(M=o(ys,M,Pe),vs===null?Ee=ys:vs.sibling=ys,vs=ys);return fs&&Fa(G,Pe),Ee}for(Te=l(Te);!ys.done;Pe++,ys=Z.next())ys=se(Te,G,Pe,ys.value,re),ys!==null&&(s&&ys.alternate!==null&&Te.delete(ys.key===null?Pe:ys.key),M=o(ys,M,Pe),vs===null?Ee=ys:vs.sibling=ys,vs=ys);return s&&Te.forEach(function(hy){return t(G,hy)}),fs&&Fa(G,Pe),Ee}function ks(G,M,Z,re){if(typeof Z=="object"&&Z!==null&&Z.type===K&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case T:e:{for(var Ee=Z.key;M!==null;){if(M.key===Ee){if(Ee=Z.type,Ee===K){if(M.tag===7){a(G,M.sibling),re=i(M,Z.props.children),re.return=G,G=re;break e}}else if(M.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===D&&Il(Ee)===M.type){a(G,M.sibling),re=i(M,Z.props),ki(re,Z),re.return=G,G=re;break e}a(G,M);break}else t(G,M);M=M.sibling}Z.type===K?(re=$l(Z.props.children,G.mode,re,Z.key),re.return=G,G=re):(re=Vr(Z.type,Z.key,Z.props,null,G.mode,re),ki(re,Z),re.return=G,G=re)}return m(G);case L:e:{for(Ee=Z.key;M!==null;){if(M.key===Ee)if(M.tag===4&&M.stateNode.containerInfo===Z.containerInfo&&M.stateNode.implementation===Z.implementation){a(G,M.sibling),re=i(M,Z.children||[]),re.return=G,G=re;break e}else{a(G,M);break}else t(G,M);M=M.sibling}re=Go(Z,G.mode,re),re.return=G,G=re}return m(G);case D:return Z=Il(Z),ks(G,M,Z,re)}if(Ne(Z))return Ce(G,M,Z,re);if(ye(Z)){if(Ee=ye(Z),typeof Ee!="function")throw Error(d(150));return Z=Ee.call(Z),Oe(G,M,Z,re)}if(typeof Z.then=="function")return ks(G,M,Zr(Z),re);if(Z.$$typeof===V)return ks(G,M,$r(G,Z),re);Ir(G,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,M!==null&&M.tag===6?(a(G,M.sibling),re=i(M,Z),re.return=G,G=re):(a(G,M),re=qo(Z,G.mode,re),re.return=G,G=re),m(G)):a(G,M)}return function(G,M,Z,re){try{Ci=0;var Ee=ks(G,M,Z,re);return An=null,Ee}catch(Te){if(Te===Mn||Te===Xr)throw Te;var vs=qt(29,Te,null,G.mode);return vs.lanes=re,vs.return=G,vs}finally{}}}var Pl=lh(!0),nh=lh(!1),pl=!1;function Wo(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ed(s,t){s=s.updateQueue,t.updateQueue===s&&(t.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function gl(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function jl(s,t,a){var l=s.updateQueue;if(l===null)return null;if(l=l.shared,(Ns&2)!==0){var i=l.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),l.pending=t,t=Gr(s),Vm(s,null,a),t}return qr(s,l,t,a),Gr(s)}function Ti(s,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,dl(s,a)}}function sd(s,t){var a=s.updateQueue,l=s.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var i=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var m={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?i=o=m:o=o.next=m,a=a.next}while(a!==null);o===null?i=o=t:o=o.next=t}else i=o=t;a={baseState:l.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:l.shared,callbacks:l.callbacks},s.updateQueue=a;return}s=a.lastBaseUpdate,s===null?a.firstBaseUpdate=t:s.next=t,a.lastBaseUpdate=t}var td=!1;function Ei(){if(td){var s=zn;if(s!==null)throw s}}function zi(s,t,a,l){td=!1;var i=s.updateQueue;pl=!1;var o=i.firstBaseUpdate,m=i.lastBaseUpdate,p=i.shared.pending;if(p!==null){i.shared.pending=null;var C=p,I=C.next;C.next=null,m===null?o=I:m.next=I,m=C;var ae=s.alternate;ae!==null&&(ae=ae.updateQueue,p=ae.lastBaseUpdate,p!==m&&(p===null?ae.firstBaseUpdate=I:p.next=I,ae.lastBaseUpdate=C))}if(o!==null){var de=i.baseState;m=0,ae=I=C=null,p=o;do{var J=p.lane&-536870913,se=J!==p.lane;if(se?(is&J)===J:(l&J)===J){J!==0&&J===En&&(td=!0),ae!==null&&(ae=ae.next={lane:0,tag:p.tag,payload:p.payload,callback:null,next:null});e:{var Ce=s,Oe=p;J=t;var ks=a;switch(Oe.tag){case 1:if(Ce=Oe.payload,typeof Ce=="function"){de=Ce.call(ks,de,J);break e}de=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Oe.payload,J=typeof Ce=="function"?Ce.call(ks,de,J):Ce,J==null)break e;de=k({},de,J);break e;case 2:pl=!0}}J=p.callback,J!==null&&(s.flags|=64,se&&(s.flags|=8192),se=i.callbacks,se===null?i.callbacks=[J]:se.push(J))}else se={lane:J,tag:p.tag,payload:p.payload,callback:p.callback,next:null},ae===null?(I=ae=se,C=de):ae=ae.next=se,m|=J;if(p=p.next,p===null){if(p=i.shared.pending,p===null)break;se=p,p=se.next,se.next=null,i.lastBaseUpdate=se,i.shared.pending=null}}while(!0);ae===null&&(C=de),i.baseState=C,i.firstBaseUpdate=I,i.lastBaseUpdate=ae,o===null&&(i.shared.lanes=0),wl|=m,s.lanes=m,s.memoizedState=de}}function ih(s,t){if(typeof s!="function")throw Error(d(191,s));s.call(t)}function rh(s,t){var a=s.callbacks;if(a!==null)for(s.callbacks=null,s=0;so?o:8;var m=y.T,p={};y.T=p,Nd(s,!1,t,a);try{var C=i(),I=y.S;if(I!==null&&I(p,C),C!==null&&typeof C=="object"&&typeof C.then=="function"){var ae=tv(C,l);Di(s,t,ae,$t(s))}else Di(s,t,l,$t(s))}catch(de){Di(s,t,{then:function(){},status:"rejected",reason:de},$t())}finally{q.p=o,m!==null&&p.types!==null&&(m.types=p.types),y.T=m}}function cv(){}function vd(s,t,a,l){if(s.tag!==5)throw Error(d(476));var i=Hh(s).queue;Bh(s,i,t,H,a===null?cv:function(){return qh(s),a(l)})}function Hh(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:H},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:a},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function qh(s){var t=Hh(s);t.next===null&&(t=s.alternate.memoizedState),Di(s,t.next.queue,{},$t())}function yd(){return mt(Ii)}function Gh(){return Ks().memoizedState}function Vh(){return Ks().memoizedState}function ov(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var a=$t();s=gl(a);var l=jl(t,s,a);l!==null&&(Ot(l,t,a),Ti(l,t,a)),t={cache:Zo()},s.payload=t;return}t=t.return}}function dv(s,t,a){var l=$t();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},ic(s)?Qh(t,a):(a=Bo(s,t,a,l),a!==null&&(Ot(a,s,l),$h(a,t,l)))}function Fh(s,t,a){var l=$t();Di(s,t,a,l)}function Di(s,t,a,l){var i={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(ic(s))Qh(t,i);else{var o=s.alternate;if(s.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var m=t.lastRenderedState,p=o(m,a);if(i.hasEagerState=!0,i.eagerState=p,Ht(p,m))return qr(s,t,i,0),Ts===null&&Hr(),!1}catch{}finally{}if(a=Bo(s,t,i,l),a!==null)return Ot(a,s,l),$h(a,t,l),!0}return!1}function Nd(s,t,a,l){if(l={lane:2,revertLane:Wd(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ic(s)){if(t)throw Error(d(479))}else t=Bo(s,a,l,2),t!==null&&Ot(t,s,2)}function ic(s){var t=s.alternate;return s===Ze||t!==null&&t===Ze}function Qh(s,t){On=Wr=!0;var a=s.pending;a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t}function $h(s,t,a){if((a&4194048)!==0){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,dl(s,a)}}var Oi={readContext:mt,use:tc,useCallback:Gs,useContext:Gs,useEffect:Gs,useImperativeHandle:Gs,useLayoutEffect:Gs,useInsertionEffect:Gs,useMemo:Gs,useReducer:Gs,useRef:Gs,useState:Gs,useDebugValue:Gs,useDeferredValue:Gs,useTransition:Gs,useSyncExternalStore:Gs,useId:Gs,useHostTransitionStatus:Gs,useFormState:Gs,useActionState:Gs,useOptimistic:Gs,useMemoCache:Gs,useCacheRefresh:Gs};Oi.useEffectEvent=Gs;var Yh={readContext:mt,use:tc,useCallback:function(s,t){return wt().memoizedState=[s,t===void 0?null:t],s},useContext:mt,useEffect:Eh,useImperativeHandle:function(s,t,a){a=a!=null?a.concat([s]):null,lc(4194308,4,Dh.bind(null,t,s),a)},useLayoutEffect:function(s,t){return lc(4194308,4,s,t)},useInsertionEffect:function(s,t){lc(4,2,s,t)},useMemo:function(s,t){var a=wt();t=t===void 0?null:t;var l=s();if(Wl){it(!0);try{s()}finally{it(!1)}}return a.memoizedState=[l,t],l},useReducer:function(s,t,a){var l=wt();if(a!==void 0){var i=a(t);if(Wl){it(!0);try{a(t)}finally{it(!1)}}}else i=t;return l.memoizedState=l.baseState=i,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:i},l.queue=s,s=s.dispatch=dv.bind(null,Ze,s),[l.memoizedState,s]},useRef:function(s){var t=wt();return s={current:s},t.memoizedState=s},useState:function(s){s=xd(s);var t=s.queue,a=Fh.bind(null,Ze,t);return t.dispatch=a,[s.memoizedState,a]},useDebugValue:gd,useDeferredValue:function(s,t){var a=wt();return jd(a,s,t)},useTransition:function(){var s=xd(!1);return s=Bh.bind(null,Ze,s.queue,!0,!1),wt().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,a){var l=Ze,i=wt();if(fs){if(a===void 0)throw Error(d(407));a=a()}else{if(a=t(),Ts===null)throw Error(d(349));(is&127)!==0||hh(l,t,a)}i.memoizedState=a;var o={value:a,getSnapshot:t};return i.queue=o,Eh(fh.bind(null,l,o,s),[s]),l.flags|=2048,Ln(9,{destroy:void 0},xh.bind(null,l,o,a,t),null),a},useId:function(){var s=wt(),t=Ts.identifierPrefix;if(fs){var a=Ca,l=Sa;a=(l&~(1<<32-ot(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=ec++,0<\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof l.is=="string"?m.createElement("select",{is:l.is}):m.createElement("select"),l.multiple?o.multiple=!0:l.size&&(o.size=l.size);break;default:o=typeof l.is=="string"?m.createElement(i,{is:l.is}):m.createElement(i)}}o[Fe]=t,o[Ys]=l;e:for(m=t.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.tag!==27&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===t)break e;for(;m.sibling===null;){if(m.return===null||m.return===t)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}t.stateNode=o;e:switch(xt(o,i,l),i){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Za(t)}}return Ds(t),Rd(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,a),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==l&&Za(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(d(166));if(s=le.current,kn(t)){if(s=t.stateNode,a=t.memoizedProps,l=null,i=ut,i!==null)switch(i.tag){case 27:case 5:l=i.memoizedProps}s[Fe]=t,s=!!(s.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||mf(s.nodeValue,a)),s||xl(t,!0)}else s=Cc(s).createTextNode(l),s[Fe]=t,t.stateNode=s}return Ds(t),null;case 31:if(a=t.memoizedState,s===null||s.memoizedState!==null){if(l=kn(t),a!==null){if(s===null){if(!l)throw Error(d(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(d(557));s[Fe]=t}else Yl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ds(t),s=!1}else a=$o(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=a),s=!0;if(!s)return t.flags&256?(Vt(t),t):(Vt(t),null);if((t.flags&128)!==0)throw Error(d(558))}return Ds(t),null;case 13:if(l=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(i=kn(t),l!==null&&l.dehydrated!==null){if(s===null){if(!i)throw Error(d(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(d(317));i[Fe]=t}else Yl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ds(t),i=!1}else i=$o(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Vt(t),t):(Vt(t),null)}return Vt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,s=s!==null&&s.memoizedState!==null,a&&(l=t.child,i=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(i=l.alternate.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==i&&(l.flags|=2048)),a!==s&&a&&(t.child.flags|=8192),uc(t,t.updateQueue),Ds(t),null);case 4:return A(),s===null&&au(t.stateNode.containerInfo),Ds(t),null;case 10:return $a(t.type),Ds(t),null;case 19:if(he(Xs),l=t.memoizedState,l===null)return Ds(t),null;if(i=(t.flags&128)!==0,o=l.rendering,o===null)if(i)Li(l,!1);else{if(Vs!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(o=Pr(s),o!==null){for(t.flags|=128,Li(l,!1),s=o.updateQueue,t.updateQueue=s,uc(t,s),t.subtreeFlags=0,s=a,a=t.child;a!==null;)Fm(a,s),a=a.sibling;return Q(Xs,Xs.current&1|2),fs&&Fa(t,l.treeForkCount),t.child}s=s.sibling}l.tail!==null&&Je()>pc&&(t.flags|=128,i=!0,Li(l,!1),t.lanes=4194304)}else{if(!i)if(s=Pr(o),s!==null){if(t.flags|=128,i=!0,s=s.updateQueue,t.updateQueue=s,uc(t,s),Li(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!fs)return Ds(t),null}else 2*Je()-l.renderingStartTime>pc&&a!==536870912&&(t.flags|=128,i=!0,Li(l,!1),t.lanes=4194304);l.isBackwards?(o.sibling=t.child,t.child=o):(s=l.last,s!==null?s.sibling=o:t.child=o,l.last=o)}return l.tail!==null?(s=l.tail,l.rendering=s,l.tail=s.sibling,l.renderingStartTime=Je(),s.sibling=null,a=Xs.current,Q(Xs,i?a&1|2:a&1),fs&&Fa(t,l.treeForkCount),s):(Ds(t),null);case 22:case 23:return Vt(t),ld(),l=t.memoizedState!==null,s!==null?s.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(Ds(t),t.subtreeFlags&6&&(t.flags|=8192)):Ds(t),a=t.updateQueue,a!==null&&uc(t,a.retryQueue),a=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),s!==null&&he(Zl),null;case 24:return a=null,s!==null&&(a=s.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),$a(Js),Ds(t),null;case 25:return null;case 30:return null}throw Error(d(156,t.tag))}function fv(s,t){switch(Fo(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return $a(Js),A(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return _e(t),null;case 31:if(t.memoizedState!==null){if(Vt(t),t.alternate===null)throw Error(d(340));Yl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(Vt(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(d(340));Yl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return he(Xs),null;case 4:return A(),null;case 10:return $a(t.type),null;case 22:case 23:return Vt(t),ld(),s!==null&&he(Zl),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return $a(Js),null;case 25:return null;default:return null}}function px(s,t){switch(Fo(t),t.tag){case 3:$a(Js),A();break;case 26:case 27:case 5:_e(t);break;case 4:A();break;case 31:t.memoizedState!==null&&Vt(t);break;case 13:Vt(t);break;case 19:he(Xs);break;case 10:$a(t.type);break;case 22:case 23:Vt(t),ld(),s!==null&&he(Zl);break;case 24:$a(Js)}}function Ui(s,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var i=l.next;a=i;do{if((a.tag&s)===s){l=void 0;var o=a.create,m=a.inst;l=o(),m.destroy=l}a=a.next}while(a!==i)}}catch(p){_s(t,t.return,p)}}function Nl(s,t,a){try{var l=t.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var o=i.next;l=o;do{if((l.tag&s)===s){var m=l.inst,p=m.destroy;if(p!==void 0){m.destroy=void 0,i=t;var C=a,I=p;try{I()}catch(ae){_s(i,C,ae)}}}l=l.next}while(l!==o)}}catch(ae){_s(t,t.return,ae)}}function gx(s){var t=s.updateQueue;if(t!==null){var a=s.stateNode;try{rh(t,a)}catch(l){_s(s,s.return,l)}}}function jx(s,t,a){a.props=en(s.type,s.memoizedProps),a.state=s.memoizedState;try{a.componentWillUnmount()}catch(l){_s(s,t,l)}}function Bi(s,t){try{var a=s.ref;if(a!==null){switch(s.tag){case 26:case 27:case 5:var l=s.stateNode;break;case 30:l=s.stateNode;break;default:l=s.stateNode}typeof a=="function"?s.refCleanup=a(l):a.current=l}}catch(i){_s(s,t,i)}}function ka(s,t){var a=s.ref,l=s.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(i){_s(s,t,i)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(i){_s(s,t,i)}else a.current=null}function vx(s){var t=s.type,a=s.memoizedProps,l=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(i){_s(s,s.return,i)}}function Ld(s,t,a){try{var l=s.stateNode;Uv(l,s.type,a,t),l[Ys]=t}catch(i){_s(s,s.return,i)}}function yx(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Tl(s.type)||s.tag===4}function Ud(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||yx(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Tl(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Bd(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(s,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(s),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=qa));else if(l!==4&&(l===27&&Tl(s.type)&&(a=s.stateNode,t=null),s=s.child,s!==null))for(Bd(s,t,a),s=s.sibling;s!==null;)Bd(s,t,a),s=s.sibling}function mc(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?a.insertBefore(s,t):a.appendChild(s);else if(l!==4&&(l===27&&Tl(s.type)&&(a=s.stateNode),s=s.child,s!==null))for(mc(s,t,a),s=s.sibling;s!==null;)mc(s,t,a),s=s.sibling}function Nx(s){var t=s.stateNode,a=s.memoizedProps;try{for(var l=s.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);xt(t,l,a),t[Fe]=s,t[Ys]=a}catch(o){_s(s,s.return,o)}}var Ia=!1,et=!1,Hd=!1,bx=typeof WeakSet=="function"?WeakSet:Set,ct=null;function pv(s,t){if(s=s.containerInfo,iu=Dc,s=Om(s),Ao(s)){if("selectionStart"in s)var a={start:s.selectionStart,end:s.selectionEnd};else e:{a=(a=s.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var i=l.anchorOffset,o=l.focusNode;l=l.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var m=0,p=-1,C=-1,I=0,ae=0,de=s,J=null;s:for(;;){for(var se;de!==a||i!==0&&de.nodeType!==3||(p=m+i),de!==o||l!==0&&de.nodeType!==3||(C=m+l),de.nodeType===3&&(m+=de.nodeValue.length),(se=de.firstChild)!==null;)J=de,de=se;for(;;){if(de===s)break s;if(J===a&&++I===i&&(p=m),J===o&&++ae===l&&(C=m),(se=de.nextSibling)!==null)break;de=J,J=de.parentNode}de=se}a=p===-1||C===-1?null:{start:p,end:C}}else a=null}a=a||{start:0,end:0}}else a=null;for(ru={focusedElem:s,selectionRange:a},Dc=!1,ct=t;ct!==null;)if(t=ct,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,ct=s;else for(;ct!==null;){switch(t=ct,o=t.alternate,s=t.flags,t.tag){case 0:if((s&4)!==0&&(s=t.updateQueue,s=s!==null?s.events:null,s!==null))for(a=0;a title"))),xt(o,l,a),o[Fe]=s,rt(o),l=o;break e;case"link":var m=Ef("link","href",i).get(l+(a.href||""));if(m){for(var p=0;pks&&(m=ks,ks=Oe,Oe=m);var G=Am(p,Oe),M=Am(p,ks);if(G&&M&&(se.rangeCount!==1||se.anchorNode!==G.node||se.anchorOffset!==G.offset||se.focusNode!==M.node||se.focusOffset!==M.offset)){var Z=de.createRange();Z.setStart(G.node,G.offset),se.removeAllRanges(),Oe>ks?(se.addRange(Z),se.extend(M.node,M.offset)):(Z.setEnd(M.node,M.offset),se.addRange(Z))}}}}for(de=[],se=p;se=se.parentNode;)se.nodeType===1&&de.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;pa?32:a,y.T=null,a=Yd,Yd=null;var o=Sl,m=sl;if(at=0,Gn=Sl=null,sl=0,(Ns&6)!==0)throw Error(d(331));var p=Ns;if(Ns|=4,Dx(o.current),zx(o,o.current,m,a),Ns=p,Qi(0,!1),Re&&typeof Re.onPostCommitFiberRoot=="function")try{Re.onPostCommitFiberRoot(Se,o)}catch{}return!0}finally{q.p=i,y.T=l,Jx(s,t)}}function Wx(s,t,a){t=aa(a,t),t=Sd(s.stateNode,t,2),s=jl(s,t,2),s!==null&&(tt(s,2),Ta(s))}function _s(s,t,a){if(s.tag===3)Wx(s,s,a);else for(;t!==null;){if(t.tag===3){Wx(t,s,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(_l===null||!_l.has(l))){s=aa(a,s),a=ex(2),l=jl(t,a,2),l!==null&&(sx(a,l,t,s),tt(l,2),Ta(l));break}}t=t.return}}function Id(s,t,a){var l=s.pingCache;if(l===null){l=s.pingCache=new vv;var i=new Set;l.set(t,i)}else i=l.get(t),i===void 0&&(i=new Set,l.set(t,i));i.has(a)||(Vd=!0,i.add(a),s=_v.bind(null,s,t,a),t.then(s,s))}function _v(s,t,a){var l=s.pingCache;l!==null&&l.delete(t),s.pingedLanes|=s.suspendedLanes&a,s.warmLanes&=~a,Ts===s&&(is&a)===a&&(Vs===4||Vs===3&&(is&62914560)===is&&300>Je()-fc?(Ns&2)===0&&Vn(s,0):Fd|=a,qn===is&&(qn=0)),Ta(s)}function ef(s,t){t===0&&(t=je()),s=Ql(s,t),s!==null&&(tt(s,t),Ta(s))}function Sv(s){var t=s.memoizedState,a=0;t!==null&&(a=t.retryLane),ef(s,a)}function Cv(s,t){var a=0;switch(s.tag){case 31:case 13:var l=s.stateNode,i=s.memoizedState;i!==null&&(a=i.retryLane);break;case 19:l=s.stateNode;break;case 22:l=s.stateNode._retryCache;break;default:throw Error(d(314))}l!==null&&l.delete(t),ef(s,a)}function kv(s,t){return Le(s,t)}var bc=null,Qn=null,Jd=!1,wc=!1,Pd=!1,kl=0;function Ta(s){s!==Qn&&s.next===null&&(Qn===null?bc=Qn=s:Qn=Qn.next=s),wc=!0,Jd||(Jd=!0,Ev())}function Qi(s,t){if(!Pd&&wc){Pd=!0;do for(var a=!1,l=bc;l!==null;){if(s!==0){var i=l.pendingLanes;if(i===0)var o=0;else{var m=l.suspendedLanes,p=l.pingedLanes;o=(1<<31-ot(42|s)+1)-1,o&=i&~(m&~p),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,lf(l,o))}else o=is,o=Ua(l,l===Ts?o:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(o&3)===0||ba(l,o)||(a=!0,lf(l,o));l=l.next}while(a);Pd=!1}}function Tv(){sf()}function sf(){wc=Jd=!1;var s=0;kl!==0&&Hv()&&(s=kl);for(var t=Je(),a=null,l=bc;l!==null;){var i=l.next,o=tf(l,t);o===0?(l.next=null,a===null?bc=i:a.next=i,i===null&&(Qn=a)):(a=l,(s!==0||(o&3)!==0)&&(wc=!0)),l=i}at!==0&&at!==5||Qi(s),kl!==0&&(kl=0)}function tf(s,t){for(var a=s.suspendedLanes,l=s.pingedLanes,i=s.expirationTimes,o=s.pendingLanes&-62914561;0p)break;var ae=C.transferSize,de=C.initiatorType;ae&&hf(de)&&(C=C.responseEnd,m+=ae*(C"u"?null:document;function Sf(s,t,a){var l=$n;if(l&&typeof t=="string"&&t){var i=sa(t);i='link[rel="'+s+'"][href="'+i+'"]',typeof a=="string"&&(i+='[crossorigin="'+a+'"]'),_f.has(i)||(_f.add(i),s={rel:s,crossOrigin:a,href:t},l.querySelector(i)===null&&(t=l.createElement("link"),xt(t,"link",s),rt(t),l.head.appendChild(t)))}}function Kv(s){tl.D(s),Sf("dns-prefetch",s,null)}function Zv(s,t){tl.C(s,t),Sf("preconnect",s,t)}function Iv(s,t,a){tl.L(s,t,a);var l=$n;if(l&&s&&t){var i='link[rel="preload"][as="'+sa(t)+'"]';t==="image"&&a&&a.imageSrcSet?(i+='[imagesrcset="'+sa(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(i+='[imagesizes="'+sa(a.imageSizes)+'"]')):i+='[href="'+sa(s)+'"]';var o=i;switch(t){case"style":o=Yn(s);break;case"script":o=Xn(s)}oa.has(o)||(s=k({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:s,as:t},a),oa.set(o,s),l.querySelector(i)!==null||t==="style"&&l.querySelector(Ki(o))||t==="script"&&l.querySelector(Zi(o))||(t=l.createElement("link"),xt(t,"link",s),rt(t),l.head.appendChild(t)))}}function Jv(s,t){tl.m(s,t);var a=$n;if(a&&s){var l=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+sa(l)+'"][href="'+sa(s)+'"]',o=i;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=Xn(s)}if(!oa.has(o)&&(s=k({rel:"modulepreload",href:s},t),oa.set(o,s),a.querySelector(i)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Zi(o)))return}l=a.createElement("link"),xt(l,"link",s),rt(l),a.head.appendChild(l)}}}function Pv(s,t,a){tl.S(s,t,a);var l=$n;if(l&&s){var i=xn(l).hoistableStyles,o=Yn(s);t=t||"default";var m=i.get(o);if(!m){var p={loading:0,preload:null};if(m=l.querySelector(Ki(o)))p.loading=5;else{s=k({rel:"stylesheet",href:s,"data-precedence":t},a),(a=oa.get(o))&&xu(s,a);var C=m=l.createElement("link");rt(C),xt(C,"link",s),C._p=new Promise(function(I,ae){C.onload=I,C.onerror=ae}),C.addEventListener("load",function(){p.loading|=1}),C.addEventListener("error",function(){p.loading|=2}),p.loading|=4,Tc(m,t,l)}m={type:"stylesheet",instance:m,count:1,state:p},i.set(o,m)}}}function Wv(s,t){tl.X(s,t);var a=$n;if(a&&s){var l=xn(a).hoistableScripts,i=Xn(s),o=l.get(i);o||(o=a.querySelector(Zi(i)),o||(s=k({src:s,async:!0},t),(t=oa.get(i))&&fu(s,t),o=a.createElement("script"),rt(o),xt(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(i,o))}}function ey(s,t){tl.M(s,t);var a=$n;if(a&&s){var l=xn(a).hoistableScripts,i=Xn(s),o=l.get(i);o||(o=a.querySelector(Zi(i)),o||(s=k({src:s,async:!0,type:"module"},t),(t=oa.get(i))&&fu(s,t),o=a.createElement("script"),rt(o),xt(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(i,o))}}function Cf(s,t,a,l){var i=(i=le.current)?kc(i):null;if(!i)throw Error(d(446));switch(s){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Yn(a.href),a=xn(i).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){s=Yn(a.href);var o=xn(i).hoistableStyles,m=o.get(s);if(m||(i=i.ownerDocument||i,m={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(s,m),(o=i.querySelector(Ki(s)))&&!o._p&&(m.instance=o,m.state.loading=5),oa.has(s)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},oa.set(s,a),o||sy(i,s,a,m.state))),t&&l===null)throw Error(d(528,""));return m}if(t&&l!==null)throw Error(d(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Xn(a),a=xn(i).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(d(444,s))}}function Yn(s){return'href="'+sa(s)+'"'}function Ki(s){return'link[rel="stylesheet"]['+s+"]"}function kf(s){return k({},s,{"data-precedence":s.precedence,precedence:null})}function sy(s,t,a,l){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=s.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),xt(t,"link",a),rt(t),s.head.appendChild(t))}function Xn(s){return'[src="'+sa(s)+'"]'}function Zi(s){return"script[async]"+s}function Tf(s,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=s.querySelector('style[data-href~="'+sa(a.href)+'"]');if(l)return t.instance=l,rt(l),l;var i=k({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(s.ownerDocument||s).createElement("style"),rt(l),xt(l,"style",i),Tc(l,a.precedence,s),t.instance=l;case"stylesheet":i=Yn(a.href);var o=s.querySelector(Ki(i));if(o)return t.state.loading|=4,t.instance=o,rt(o),o;l=kf(a),(i=oa.get(i))&&xu(l,i),o=(s.ownerDocument||s).createElement("link"),rt(o);var m=o;return m._p=new Promise(function(p,C){m.onload=p,m.onerror=C}),xt(o,"link",l),t.state.loading|=4,Tc(o,a.precedence,s),t.instance=o;case"script":return o=Xn(a.src),(i=s.querySelector(Zi(o)))?(t.instance=i,rt(i),i):(l=a,(i=oa.get(o))&&(l=k({},a),fu(l,i)),s=s.ownerDocument||s,i=s.createElement("script"),rt(i),xt(i,"link",l),s.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(d(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,Tc(l,a.precedence,s));return t.instance}function Tc(s,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=l.length?l[l.length-1]:null,o=i,m=0;m title"):null)}function ty(s,t,a){if(a===1||t.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return s=t.disabled,typeof t.precedence=="string"&&s==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Mf(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function ay(s,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var i=Yn(l.href),o=t.querySelector(Ki(i));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=zc.bind(s),t.then(s,s)),a.state.loading|=4,a.instance=o,rt(o);return}o=t.ownerDocument||t,l=kf(l),(i=oa.get(i))&&xu(l,i),o=o.createElement("link"),rt(o);var m=o;m._p=new Promise(function(p,C){m.onload=p,m.onerror=C}),xt(o,"link",l),a.instance=o}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(s.count++,a=zc.bind(s),t.addEventListener("load",a),t.addEventListener("error",a))}}var pu=0;function ly(s,t){return s.stylesheets&&s.count===0&&Ac(s,s.stylesheets),0pu?50:800)+t);return s.unsuspend=a,function(){s.unsuspend=null,clearTimeout(l),clearTimeout(i)}}:null}function zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ac(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Mc=null;function Ac(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Mc=new Map,t.forEach(ny,s),Mc=null,zc.call(s))}function ny(s,t){if(!(t.state.loading&4)){var a=Mc.get(s);if(a)var l=a.get(null);else{a=new Map,Mc.set(s,a);for(var i=s.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}return n(),ku.exports=Lb(),ku.exports}var Bb=Ub();function $(...n){return _y(Sy(n))}const Be=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("rounded-xl border bg-card text-card-foreground shadow",n),...r}));Be.displayName="Card";const gs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("flex flex-col space-y-1.5 p-6",n),...r}));gs.displayName="CardHeader";const js=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("font-semibold leading-none tracking-tight",n),...r}));js.displayName="CardTitle";const Zs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("text-sm text-muted-foreground",n),...r}));Zs.displayName="CardDescription";const bs=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("p-6 pt-0",n),...r}));bs.displayName="CardContent";const wg=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("flex items-center p-6 pt-0",n),...r}));wg.displayName="CardFooter";const Kt=Ty,Rt=u.forwardRef(({className:n,...r},c)=>e.jsx(yp,{ref:c,className:$("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n),...r}));Rt.displayName=yp.displayName;const He=u.forwardRef(({className:n,...r},c)=>e.jsx(Np,{ref:c,className:$("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",n),...r}));He.displayName=Np.displayName;const We=u.forwardRef(({className:n,...r},c)=>e.jsx(bp,{ref:c,className:$("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[state=active]:animate-in data-[state=active]:fade-in data-[state=active]:duration-300",n),...r}));We.displayName=bp.displayName;const es=u.forwardRef(({className:n,children:r,viewportRef:c,...d},h)=>e.jsxs(wp,{ref:h,className:$("relative overflow-hidden",n),...d,children:[e.jsx(Ey,{ref:c,className:"h-full w-full rounded-[inherit]",children:r}),e.jsx(Bu,{}),e.jsx(Bu,{orientation:"horizontal"}),e.jsx(zy,{})]}));es.displayName=wp.displayName;const Bu=u.forwardRef(({className:n,orientation:r="vertical",...c},d)=>e.jsx(_p,{ref:d,orientation:r,className:$("flex touch-none select-none transition-colors",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...c,children:e.jsx(My,{className:"relative flex-1 rounded-full bg-border"})}));Bu.displayName=_p.displayName;function Hb({className:n,...r}){return e.jsx("div",{className:$("animate-pulse rounded-md bg-primary/10",n),...r})}const Sr=u.forwardRef(({className:n,value:r,...c},d)=>e.jsx(Sp,{ref:d,className:$("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",n),...c,children:e.jsx(Ay,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})}));Sr.displayName=Sp.displayName;const qb={light:"",dark:".dark"},_g=u.createContext(null);function Sg(){const n=u.useContext(_g);if(!n)throw new Error("useChart must be used within a ");return n}const Zn=u.forwardRef(({id:n,className:r,children:c,config:d,...h},x)=>{const f=u.useId(),j=`chart-${n||f.replace(/:/g,"")}`;return e.jsx(_g.Provider,{value:{config:d},children:e.jsxs("div",{"data-chart":j,ref:x,className:$("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",r),...h,children:[e.jsx(Gb,{id:j,config:d}),e.jsx(Iy,{children:c})]})})});Zn.displayName="Chart";const Gb=({id:n,config:r})=>{const c=Object.entries(r).filter(([,d])=>d.theme||d.color);return c.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(qb).map(([d,h])=>` -${h} [data-chart=${n}] { -${c.map(([x,f])=>{const j=f.theme?.[d]||f.color;return j?` --color-${x}: ${j};`:null}).join(` -`)} -} -`).join(` -`)}}):null},lr=Jy,In=u.forwardRef(({active:n,payload:r,className:c,indicator:d="dot",hideLabel:h=!1,hideIndicator:x=!1,label:f,labelFormatter:j,labelClassName:g,formatter:_,color:v,nameKey:k,labelKey:z},T)=>{const{config:L}=Sg(),K=u.useMemo(()=>{if(h||!r?.length)return null;const[R]=r,ee=`${z||R?.dataKey||R?.name||"value"}`,V=Hu(L,R,ee),E=!z&&typeof f=="string"?L[f]?.label||f:V?.label;return j?e.jsx("div",{className:$("font-medium",g),children:j(E,r)}):E?e.jsx("div",{className:$("font-medium",g),children:E}):null},[f,j,r,h,g,L,z]);if(!n||!r?.length)return null;const U=r.length===1&&d!=="dot";return e.jsxs("div",{ref:T,className:$("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",c),children:[U?null:K,e.jsx("div",{className:"grid gap-1.5",children:r.filter(R=>R.type!=="none").map((R,ee)=>{const V=`${k||R.name||R.dataKey||"value"}`,E=Hu(L,R,V),B=v||R.payload.fill||R.color;return e.jsx("div",{className:$("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",d==="dot"&&"items-center"),children:_&&R?.value!==void 0&&R.name?_(R.value,R.name,R,ee,R.payload):e.jsxs(e.Fragment,{children:[E?.icon?e.jsx(E.icon,{}):!x&&e.jsx("div",{className:$("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":d==="dot","w-1":d==="line","w-0 border-[1.5px] border-dashed bg-transparent":d==="dashed","my-0.5":U&&d==="dashed"}),style:{"--color-bg":B,"--color-border":B}}),e.jsxs("div",{className:$("flex flex-1 justify-between leading-none",U?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[U?K:null,e.jsx("span",{className:"text-muted-foreground",children:E?.label||R.name})]}),R.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:R.value.toLocaleString()})]})]})},R.dataKey)})})]})});In.displayName="ChartTooltip";const Vb=Py,Cg=u.forwardRef(({className:n,hideIcon:r=!1,payload:c,verticalAlign:d="bottom",nameKey:h},x)=>{const{config:f}=Sg();return c?.length?e.jsx("div",{ref:x,className:$("flex items-center justify-center gap-4",d==="top"?"pb-3":"pt-3",n),children:c.filter(j=>j.type!=="none").map(j=>{const g=`${h||j.dataKey||"value"}`,_=Hu(f,j,g);return e.jsxs("div",{className:$("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[_?.icon&&!r?e.jsx(_.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:j.color}}),_?.label]},j.value)})}):null});Cg.displayName="ChartLegend";function Hu(n,r,c){if(typeof r!="object"||r===null)return;const d="payload"in r&&typeof r.payload=="object"&&r.payload!==null?r.payload:void 0;let h=c;return c in r&&typeof r[c]=="string"?h=r[c]:d&&c in d&&typeof d[c]=="string"&&(h=d[c]),h in n?n[h]:n[c]}const gr=ai("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),N=u.forwardRef(({className:n,variant:r,size:c,asChild:d=!1,...h},x)=>{const f=d?lN:"button";return e.jsx(f,{className:$(gr({variant:r,size:c,className:n})),ref:x,...h})});N.displayName="Button";const Fb=ai("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Xe({className:n,variant:r,...c}){return e.jsx("div",{className:$(Fb({variant:r}),n),...c})}const Qb=5,$b=5e3;let zu=0;function Yb(){return zu=(zu+1)%Number.MAX_SAFE_INTEGER,zu.toString()}const Mu=new Map,tp=n=>{if(Mu.has(n))return;const r=setTimeout(()=>{Mu.delete(n),ur({type:"REMOVE_TOAST",toastId:n})},$b);Mu.set(n,r)},Xb=(n,r)=>{switch(r.type){case"ADD_TOAST":return{...n,toasts:[r.toast,...n.toasts].slice(0,Qb)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(c=>c.id===r.toast.id?{...c,...r.toast}:c)};case"DISMISS_TOAST":{const{toastId:c}=r;return c?tp(c):n.toasts.forEach(d=>{tp(d.id)}),{...n,toasts:n.toasts.map(d=>d.id===c||c===void 0?{...d,open:!1}:d)}}case"REMOVE_TOAST":return r.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==r.toastId)}}},Zc=[];let Ic={toasts:[]};function ur(n){Ic=Xb(Ic,n),Zc.forEach(r=>{r(Ic)})}function Kb({...n}){const r=Yb(),c=h=>ur({type:"UPDATE_TOAST",toast:{...h,id:r}}),d=()=>ur({type:"DISMISS_TOAST",toastId:r});return ur({type:"ADD_TOAST",toast:{...n,id:r,open:!0,onOpenChange:h=>{h||d()}}}),{id:r,dismiss:d,update:c}}function Bs(){const[n,r]=u.useState(Ic);return u.useEffect(()=>(Zc.push(r),()=>{const c=Zc.indexOf(r);c>-1&&Zc.splice(c,1)}),[n]),{...n,toast:Kb,dismiss:c=>ur({type:"DISMISS_TOAST",toastId:c})}}const Zb=n=>{const r=[];for(let c=0;c{try{T(!0);const H=await qc.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");k({hitokoto:H.data.hitokoto,from:H.data.from||H.data.from_who||"未知"})}catch(H){console.error("获取一言失败:",H),k({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{T(!1)}},[]),E=u.useCallback(async()=>{try{const H=localStorage.getItem("access-token"),ne=await qc.get("/api/webui/system/status",{headers:{Authorization:`Bearer ${H}`}});K(ne.data)}catch(H){console.error("获取机器人状态失败:",H),K(null)}},[]),B=async()=>{if(!U)try{R(!0);const H=localStorage.getItem("access-token");await qc.post("/api/webui/system/restart",{},{headers:{Authorization:`Bearer ${H}`}}),ee({title:"重启中",description:"麦麦正在重启,请稍候..."}),setTimeout(()=>{E(),R(!1)},3e3)}catch(H){console.error("重启失败:",H),ee({title:"重启失败",description:"无法重启麦麦,请检查控制台",variant:"destructive"}),R(!1)}},X=u.useCallback(async()=>{try{const H=localStorage.getItem("access-token"),ne=await qc.get(`/api/webui/statistics/dashboard?hours=${f}`,{headers:{Authorization:`Bearer ${H}`}});r(ne.data),d(!1),x(100)}catch(H){console.error("Failed to fetch dashboard data:",H),d(!1),x(100)}},[f]);if(u.useEffect(()=>{if(!c)return;x(0);const H=setTimeout(()=>x(15),200),ne=setTimeout(()=>x(30),800),S=setTimeout(()=>x(45),2e3),me=setTimeout(()=>x(60),4e3),he=setTimeout(()=>x(75),6500),Q=setTimeout(()=>x(85),9e3),oe=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(H),clearTimeout(ne),clearTimeout(S),clearTimeout(me),clearTimeout(he),clearTimeout(Q),clearTimeout(oe)}},[c]),u.useEffect(()=>{X(),V(),E()},[X,V,E]),u.useEffect(()=>{if(!g)return;const H=setInterval(()=>{X(),E()},3e4);return()=>clearInterval(H)},[g,X,E]),c||!n)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:e.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[e.jsx(ft,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-lg font-medium",children:"加载统计数据中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取麦麦运行数据"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Sr,{value:h,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h,"%"]})]})]})});const{summary:w,model_stats:D=[],hourly_data:te=[],daily_data:xe=[],recent_activity:be=[]}=n,ye=w??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},ve=H=>{const ne=Math.floor(H/3600),S=Math.floor(H%3600/60);return`${ne}小时${S}分钟`},pe=H=>new Date(H).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),Ne=Zb(D.length),y=D.map((H,ne)=>({name:H.model_name,value:H.request_count,fill:Ne[ne]})),q={requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--chart-3))"}};return e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"实时监控面板"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"麦麦运行状态和统计数据一览"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Kt,{value:f.toString(),onValueChange:H=>j(Number(H)),children:e.jsxs(Rt,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(He,{value:"24",children:"24小时"}),e.jsx(He,{value:"168",children:"7天"}),e.jsx(He,{value:"720",children:"30天"})]})}),e.jsxs(N,{variant:g?"default":"outline",size:"sm",onClick:()=>_(!g),className:"gap-2",children:[e.jsx(ft,{className:`h-4 w-4 ${g?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:X,children:e.jsx(ft,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[z?e.jsx(Hb,{className:"h-5 flex-1"}):v?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',v.hitokoto,'" —— ',v.from]}):null,e.jsx(N,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:V,disabled:z,children:e.jsx(ft,{className:`h-3.5 w-3.5 ${z?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Be,{className:"lg:col-span-1",children:[e.jsx(gs,{className:"pb-3",children:e.jsxs(js,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Nr,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(bs,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:L?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Xe,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(xa,{className:"h-3 w-3 mr-1"}),"运行中"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),e.jsxs(Xe,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Aa,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),L&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",L.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",ve(L.uptime)]})]})]})})]}),e.jsxs(Be,{className:"lg:col-span-2",children:[e.jsx(gs,{className:"pb-3",children:e.jsxs(js,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(bs,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:B,disabled:U,className:"gap-2",children:[e.jsx(Wc,{className:`h-4 w-4 ${U?"animate-spin":""}`}),U?"重启中...":"重启麦麦"]}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/logs",children:[e.jsx(Ma,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/plugins",children:[e.jsx(NN,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kc,{to:"/settings",children:[e.jsx(Rl,{className:"h-4 w-4"}),"系统设置"]})})]})})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(bN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:ye.total_requests.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",f<48?f+"小时":Math.floor(f/24)+"天"]})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"总花费"}),e.jsx(wN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["¥",ye.total_cost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ye.cost_per_hour>0?`¥${ye.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(eo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(ye.total_tokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ye.tokens_per_hour>0?`${(ye.tokens_per_hour/1e3).toFixed(1)}K/小时`:"暂无数据"})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ye.avg_response_time.toFixed(2),"s"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"API平均耗时"})]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(Wn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(bs,{children:e.jsx("div",{className:"text-xl font-bold",children:ve(ye.online_time)})})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-xl font-bold",children:ye.total_messages.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",ye.total_replies.toLocaleString()," 条"]})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(_N,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-xl font-bold",children:ye.total_messages>0?`¥${(ye.total_cost/ye.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(Kt,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(He,{value:"trends",children:"趋势"}),e.jsx(He,{value:"models",children:"模型"}),e.jsx(He,{value:"activity",children:"活动"}),e.jsx(He,{value:"daily",children:"日统计"})]}),e.jsxs(We,{value:"trends",className:"space-y-4",children:[e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"请求趋势"}),e.jsxs(Zs,{children:["最近",f,"小时的请求量变化"]})]}),e.jsx(bs,{children:e.jsx(Zn,{config:q,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(Wy,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:H=>pe(H),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(In,{labelFormatter:H=>pe(H)})}),e.jsx(eN,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"花费趋势"}),e.jsx(Zs,{children:"API调用成本变化"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:q,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Su,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:H=>pe(H),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(In,{labelFormatter:H=>pe(H)})}),e.jsx(Fc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"Token消耗"}),e.jsx(Zs,{children:"Token使用量变化"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:q,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Su,{data:te,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:H=>pe(H),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(In,{labelFormatter:H=>pe(H)})}),e.jsx(Fc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(We,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"模型请求分布"}),e.jsxs(Zs,{children:["各模型使用占比 (共 ",D.length," 个模型)"]})]}),e.jsx(bs,{children:e.jsx(Zn,{config:Object.fromEntries(D.map((H,ne)=>[H.model_name,{label:H.model_name,color:Ne[ne]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(sN,{children:[e.jsx(lr,{content:e.jsx(In,{})}),e.jsx(tN,{data:y,cx:"50%",cy:"50%",labelLine:!1,label:({name:H,percent:ne})=>ne&&ne<.05?"":`${H} ${ne?(ne*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:y.map((H,ne)=>e.jsx(aN,{fill:H.fill},`cell-${ne}`))})]})})})]}),e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"模型详细统计"}),e.jsx(Zs,{children:"请求数、花费和性能"})]}),e.jsx(bs,{children:e.jsx(es,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:D.map((H,ne)=>e.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:H.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${ne%5+1}))`}})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"请求数:"}),e.jsx("span",{className:"ml-1 font-medium",children:H.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",H.total_cost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[(H.total_tokens/1e3).toFixed(1),"K"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"平均耗时:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[H.avg_response_time.toFixed(2),"s"]})]})]})]},ne))})})})]})]})}),e.jsx(We,{value:"activity",children:e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"最近活动"}),e.jsx(Zs,{children:"最新的API调用记录"})]}),e.jsx(bs,{children:e.jsx(es,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:be.map((H,ne)=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:H.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:H.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:pe(H.timestamp)})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsx("span",{className:"ml-1",children:H.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",H.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[H.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${H.status==="success"?"text-green-600":"text-red-600"}`,children:H.status})]})]})]},ne))})})})]})}),e.jsx(We,{value:"daily",children:e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"每日统计"}),e.jsx(Zs,{children:"最近7天的数据汇总"})]}),e.jsx(bs,{children:e.jsx(Zn,{config:{requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:e.jsxs(Su,{data:xe,children:[e.jsx(Gc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Vc,{dataKey:"timestamp",tickFormatter:H=>{const ne=new Date(H);return`${ne.getMonth()+1}/${ne.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(tr,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{content:e.jsx(In,{labelFormatter:H=>new Date(H).toLocaleDateString("zh-CN")})}),e.jsx(Vb,{content:e.jsx(Cg,{})}),e.jsx(Fc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Fc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]})]})})}const Jb={theme:"system",setTheme:()=>null},kg=u.createContext(Jb),Yu=()=>{const n=u.useContext(kg);if(n===void 0)throw new Error("useTheme must be used within a ThemeProvider");return n},Pb=(n,r,c)=>{const d=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||d){r(n);return}const h=c.clientX,x=c.clientY,f=Math.hypot(Math.max(h,innerWidth-h),Math.max(x,innerHeight-x));document.startViewTransition(()=>{r(n)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${x}px)`,`circle(${f}px at ${h}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},Tg=u.createContext(void 0),Eg=()=>{const n=u.useContext(Tg);if(n===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return n},qe=u.forwardRef(({className:n,...r},c)=>e.jsx(Cp,{className:$("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...r,ref:c,children:e.jsx(Dy,{className:$("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));qe.displayName=Cp.displayName;const Wb=ai("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),b=u.forwardRef(({className:n,...r},c)=>e.jsx(Kp,{ref:c,className:$(Wb(),n),...r}));b.displayName=Kp.displayName;const ce=u.forwardRef(({className:n,type:r,...c},d)=>e.jsx("input",{type:r,className:$("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:d,...c}));ce.displayName="Input";const e0=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:n=>n.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:n=>/[A-Z]/.test(n)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:n=>/[a-z]/.test(n)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:n=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(n)}];function s0(n){const r=e0.map(d=>({id:d.id,label:d.label,description:d.description,passed:d.validate(n)}));return{isValid:r.every(d=>d.passed),rules:r}}const Xu="0.11.6 Beta",Ku="MaiBot Dashboard",t0=`${Ku} v${Xu}`,a0=(n="v")=>`${n}${Xu}`,_t={THEME:"maibot-ui-theme",ACCENT_COLOR:"accent-color",ENABLE_ANIMATIONS:"maibot-animations",ENABLE_WAVES_BACKGROUND:"maibot-waves-background",LOG_CACHE_SIZE:"maibot-log-cache-size",LOG_AUTO_SCROLL:"maibot-log-auto-scroll",LOG_FONT_SIZE:"maibot-log-font-size",LOG_LINE_SPACING:"maibot-log-line-spacing",DATA_SYNC_INTERVAL:"maibot-data-sync-interval",WS_RECONNECT_INTERVAL:"maibot-ws-reconnect-interval",WS_MAX_RECONNECT_ATTEMPTS:"maibot-ws-max-reconnect-attempts",ACCESS_TOKEN:"access-token",COMPLETED_TOURS:"maibot-completed-tours"},Ea={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function Fs(n){const r=zg(n),c=localStorage.getItem(r);if(c===null)return Ea[n];const d=Ea[n];if(typeof d=="boolean")return c==="true";if(typeof d=="number"){const h=parseFloat(c);return isNaN(h)?d:h}return c}function Pn(n,r){const c=zg(n);localStorage.setItem(c,String(r)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:n,value:r}}))}function l0(){return{theme:Fs("theme"),accentColor:Fs("accentColor"),enableAnimations:Fs("enableAnimations"),enableWavesBackground:Fs("enableWavesBackground"),logCacheSize:Fs("logCacheSize"),logAutoScroll:Fs("logAutoScroll"),logFontSize:Fs("logFontSize"),logLineSpacing:Fs("logLineSpacing"),dataSyncInterval:Fs("dataSyncInterval"),wsReconnectInterval:Fs("wsReconnectInterval"),wsMaxReconnectAttempts:Fs("wsMaxReconnectAttempts")}}function n0(){const n=l0(),r=localStorage.getItem(_t.COMPLETED_TOURS),c=r?JSON.parse(r):[];return{...n,completedTours:c}}function i0(n){const r=[],c=[];for(const[d,h]of Object.entries(n)){if(d==="completedTours"){Array.isArray(h)?(localStorage.setItem(_t.COMPLETED_TOURS,JSON.stringify(h)),r.push("completedTours")):c.push("completedTours");continue}if(d in Ea){const x=d,f=Ea[x];if(typeof h==typeof f){if(x==="theme"&&!["light","dark","system"].includes(h)){c.push(d);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(h)){c.push(d);continue}Pn(x,h),r.push(d)}else c.push(d)}else c.push(d)}return{success:r.length>0,imported:r,skipped:c}}function r0(){for(const n of Object.keys(Ea))Pn(n,Ea[n]);localStorage.removeItem(_t.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function c0(){const n=[],r=[],c=new Set([_t.ACCESS_TOKEN]),d=[];for(let h=0;hd.size-c.size),{used:n,items:localStorage.length,details:r}}function o0(n){if(n===0)return"0 B";const r=1024,c=["B","KB","MB"],d=Math.floor(Math.log(n)/Math.log(r));return parseFloat((n/Math.pow(r,d)).toFixed(2))+" "+c[d]}function zg(n){return{theme:_t.THEME,accentColor:_t.ACCENT_COLOR,enableAnimations:_t.ENABLE_ANIMATIONS,enableWavesBackground:_t.ENABLE_WAVES_BACKGROUND,logCacheSize:_t.LOG_CACHE_SIZE,logAutoScroll:_t.LOG_AUTO_SCROLL,logFontSize:_t.LOG_FONT_SIZE,logLineSpacing:_t.LOG_LINE_SPACING,dataSyncInterval:_t.DATA_SYNC_INTERVAL,wsReconnectInterval:_t.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:_t.WS_MAX_RECONNECT_ATTEMPTS}[n]}const za=u.forwardRef(({className:n,...r},c)=>e.jsxs(kp,{ref:c,className:$("relative flex w-full touch-none select-none items-center",n),...r,children:[e.jsx(Oy,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(Ry,{className:"absolute h-full bg-primary"})}),e.jsx(Ly,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));za.displayName=kp.displayName;class d0{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return Fs("logCacheSize")}getMaxReconnectAttempts(){return Fs("wsMaxReconnectAttempts")}getReconnectInterval(){return Fs("wsReconnectInterval")}getWebSocketUrl(){{const r=window.location.protocol==="https:"?"wss:":"ws:",c=window.location.host;return`${r}//${c}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const r=this.getWebSocketUrl();try{this.ws=new WebSocket(r),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=c=>{try{if(c.data==="pong")return;const d=JSON.parse(c.data);this.notifyLog(d)}catch(d){console.error("解析日志消息失败:",d)}},this.ws.onerror=c=>{console.error("❌ WebSocket 错误:",c),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(c){console.error("创建 WebSocket 连接失败:",c),this.attemptReconnect()}}attemptReconnect(){const r=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=r)return;this.reconnectAttempts+=1;const c=this.getReconnectInterval(),d=Math.min(c*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},d)}startHeartbeat(){this.heartbeatInterval=window.setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},3e4)}stopHeartbeat(){this.heartbeatInterval!==null&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.reconnectTimeout!==null&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.stopHeartbeat(),this.ws&&(this.ws.close(),this.ws=null),this.isConnected=!1,this.reconnectAttempts=0}onLog(r){return this.logCallbacks.add(r),()=>this.logCallbacks.delete(r)}onConnectionChange(r){return this.connectionCallbacks.add(r),r(this.isConnected),()=>this.connectionCallbacks.delete(r)}notifyLog(r){if(!this.logCache.some(d=>d.id===r.id)){this.logCache.push(r);const d=this.getMaxCacheSize();this.logCache.length>d&&(this.logCache=this.logCache.slice(-d)),this.logCallbacks.forEach(h=>{try{h(r)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(r){this.connectionCallbacks.forEach(c=>{try{c(r)}catch(d){console.error("连接状态回调执行失败:",d)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const an=new d0;typeof window<"u"&&an.connect();const Os=iN,ni=rN,u0=nN,Zu=Jp,Mg=u.forwardRef(({className:n,...r},c)=>e.jsx(Zp,{ref:c,className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r}));Mg.displayName=Zp.displayName;const Es=u.forwardRef(({className:n,children:r,preventOutsideClose:c=!1,...d},h)=>e.jsxs(u0,{children:[e.jsx(Mg,{}),e.jsxs(Ip,{ref:h,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),onPointerDownOutside:c?x=>x.preventDefault():void 0,onInteractOutside:c?x=>x.preventDefault():void 0,...d,children:[r,e.jsxs(Jp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(li,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Es.displayName=Ip.displayName;const zs=({className:n,...r})=>e.jsx("div",{className:$("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});zs.displayName="DialogHeader";const Is=({className:n,...r})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Is.displayName="DialogFooter";const Ms=u.forwardRef(({className:n,...r},c)=>e.jsx(Pp,{ref:c,className:$("text-lg font-semibold leading-none tracking-tight",n),...r}));Ms.displayName=Pp.displayName;const $s=u.forwardRef(({className:n,...r},c)=>e.jsx(Wp,{ref:c,className:$("text-sm text-muted-foreground",n),...r}));$s.displayName=Wp.displayName;const ps=By,Qs=Hy,m0=Uy,Ag=u.forwardRef(({className:n,...r},c)=>e.jsx(Tp,{className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r,ref:c}));Ag.displayName=Tp.displayName;const cs=u.forwardRef(({className:n,...r},c)=>e.jsxs(m0,{children:[e.jsx(Ag,{}),e.jsx(Ep,{ref:c,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...r})]}));cs.displayName=Ep.displayName;const os=({className:n,...r})=>e.jsx("div",{className:$("flex flex-col space-y-2 text-center sm:text-left",n),...r});os.displayName="AlertDialogHeader";const ds=({className:n,...r})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});ds.displayName="AlertDialogFooter";const us=u.forwardRef(({className:n,...r},c)=>e.jsx(zp,{ref:c,className:$("text-lg font-semibold",n),...r}));us.displayName=zp.displayName;const ms=u.forwardRef(({className:n,...r},c)=>e.jsx(Mp,{ref:c,className:$("text-sm text-muted-foreground",n),...r}));ms.displayName=Mp.displayName;const hs=u.forwardRef(({className:n,...r},c)=>e.jsx(Ap,{ref:c,className:$(gr(),n),...r}));hs.displayName=Ap.displayName;const xs=u.forwardRef(({className:n,...r},c)=>e.jsx(Dp,{ref:c,className:$(gr({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));xs.displayName=Dp.displayName;function h0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"系统设置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理您的应用偏好设置"})]})}),e.jsxs(Kt,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(He,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(fg,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(He,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(SN,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(He,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Rl,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(He,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Xt,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(es,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(We,{value:"appearance",className:"mt-0",children:e.jsx(x0,{})}),e.jsx(We,{value:"security",className:"mt-0",children:e.jsx(f0,{})}),e.jsx(We,{value:"other",className:"mt-0",children:e.jsx(p0,{})}),e.jsx(We,{value:"about",className:"mt-0",children:e.jsx(g0,{})})]})]})]})}function lp(n){const r=document.documentElement,d={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[n];if(d)r.style.setProperty("--primary",d.hsl),d.gradient?(r.style.setProperty("--primary-gradient",d.gradient),r.classList.add("has-gradient")):(r.style.removeProperty("--primary-gradient"),r.classList.remove("has-gradient"));else if(n.startsWith("#")){const h=x=>{x=x.replace("#","");const f=parseInt(x.substring(0,2),16)/255,j=parseInt(x.substring(2,4),16)/255,g=parseInt(x.substring(4,6),16)/255,_=Math.max(f,j,g),v=Math.min(f,j,g);let k=0,z=0;const T=(_+v)/2;if(_!==v){const L=_-v;switch(z=T>.5?L/(2-_-v):L/(_+v),_){case f:k=((j-g)/L+(jlocalStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const _=localStorage.getItem("accent-color")||"blue";lp(_)},[]);const g=_=>{j(_),localStorage.setItem("accent-color",_),lp(_)};return e.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题模式"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(Au,{value:"light",current:n,onChange:r,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Au,{value:"dark",current:n,onChange:r,label:"深色",description:"始终使用深色主题"}),e.jsx(Au,{value:"system",current:n,onChange:r,label:"跟随系统",description:"根据系统设置自动切换"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题色"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"单色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(da,{value:"blue",current:f,onChange:g,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(da,{value:"purple",current:f,onChange:g,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(da,{value:"green",current:f,onChange:g,label:"绿色",colorClass:"bg-green-500"}),e.jsx(da,{value:"orange",current:f,onChange:g,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(da,{value:"pink",current:f,onChange:g,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(da,{value:"red",current:f,onChange:g,label:"红色",colorClass:"bg-red-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"渐变色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(da,{value:"gradient-sunset",current:f,onChange:g,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(da,{value:"gradient-ocean",current:f,onChange:g,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(da,{value:"gradient-forest",current:f,onChange:g,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(da,{value:"gradient-aurora",current:f,onChange:g,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(da,{value:"gradient-fire",current:f,onChange:g,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(da,{value:"gradient-twilight",current:f,onChange:g,label:"暮光",colorClass:"bg-gradient-to-r from-indigo-500 to-purple-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"自定义颜色"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{type:"color",value:f.startsWith("#")?f:"#3b82f6",onChange:_=>g(_.target.value),className:"h-10 sm:h-12 w-full rounded-lg border-2 border-border cursor-pointer",title:"选择自定义颜色"})}),e.jsx("div",{className:"flex-1",children:e.jsx(ce,{type:"text",value:f,onChange:_=>g(_.target.value),placeholder:"#3b82f6",className:"font-mono text-sm"})})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-2",children:"点击色块选择颜色,或手动输入 HEX 颜色代码"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"动画效果"}),e.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[e.jsx("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(qe,{id:"animations",checked:c,onCheckedChange:d})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(qe,{id:"waves-background",checked:h,onCheckedChange:x})]})})]})]})]})}function f0(){const n=It(),[r,c]=u.useState(""),[d,h]=u.useState(""),[x,f]=u.useState(!1),[j,g]=u.useState(!1),[_,v]=u.useState(!1),[k,z]=u.useState(!1),[T,L]=u.useState(!1),[K,U]=u.useState(!1),[R,ee]=u.useState(""),[V,E]=u.useState(!1),{toast:B}=Bs(),X=u.useMemo(()=>s0(d),[d]),w=()=>localStorage.getItem("access-token")||"",D=async pe=>{try{await navigator.clipboard.writeText(pe),L(!0),B({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>L(!1),2e3)}catch{B({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},te=async()=>{if(!d.trim()){B({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!X.isValid){const pe=X.rules.filter(Ne=>!Ne.passed).map(Ne=>Ne.label).join(", ");B({title:"格式错误",description:`Token 不符合要求: ${pe}`,variant:"destructive"});return}v(!0);try{const pe=w(),Ne=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${pe}`},body:JSON.stringify({new_token:d.trim()})}),y=await Ne.json();Ne.ok&&y.success?(localStorage.setItem("access-token",d.trim()),h(""),r&&c(d.trim()),B({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{localStorage.removeItem("access-token"),n({to:"/auth"})},1500)):B({title:"更新失败",description:y.message||"无法更新 Token",variant:"destructive"})}catch(pe){console.error("更新 Token 错误:",pe),B({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{v(!1)}},xe=async()=>{z(!0);try{const pe=w(),Ne=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${pe}`}}),y=await Ne.json();Ne.ok&&y.success?(localStorage.setItem("access-token",y.token),c(y.token),ee(y.token),U(!0),E(!1),B({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):B({title:"生成失败",description:y.message||"无法生成新 Token",variant:"destructive"})}catch(pe){console.error("生成 Token 错误:",pe),B({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{z(!1)}},be=async()=>{try{await navigator.clipboard.writeText(R),E(!0),B({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{B({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},ye=()=>{U(!1),setTimeout(()=>{ee(""),E(!1)},300),setTimeout(()=>{localStorage.removeItem("access-token"),n({to:"/auth"})},500)},ve=pe=>{pe||ye()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Os,{open:K,onOpenChange:ve,children:e.jsxs(Es,{className:"sm:max-w-md",children:[e.jsxs(zs,{children:[e.jsxs(Ms,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx($s,{children:"这是您的新 Token,请立即保存。关闭此窗口后将跳转到登录页面。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-4",children:[e.jsx(b,{className:"text-xs text-muted-foreground mb-2 block",children:"您的新 Token (64位安全令牌)"}),e.jsx("div",{className:"font-mono text-sm break-all select-all bg-background p-3 rounded border",children:R})]}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"重要提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"此 Token 仅显示一次,关闭后无法再查看"}),e.jsx("li",{children:"请立即复制并保存到安全的位置"}),e.jsx("li",{children:"关闭窗口后将自动跳转到登录页面"}),e.jsx("li",{children:"请使用新 Token 重新登录系统"})]})]})]})})]}),e.jsxs(Is,{className:"gap-2 sm:gap-0",children:[e.jsx(N,{variant:"outline",onClick:be,className:"gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(so,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(N,{onClick:ye,children:"我已保存,关闭"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"当前 Access Token"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"current-token",className:"text-sm",children:"您的访问令牌"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ce,{id:"current-token",type:x?"text":"password",value:r||w(),readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"点击查看按钮显示 Token"}),e.jsx("button",{onClick:()=>{r||c(w()),f(!x)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(N,{variant:"outline",size:"icon",onClick:()=>D(w()),title:"复制到剪贴板",className:"flex-shrink-0",children:T?e.jsx(ha,{className:"h-4 w-4 text-green-500"}):e.jsx(so,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:k,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(ft,{className:$("h-4 w-4",k&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重新生成 Token"}),e.jsx(ms,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:xe,children:"确认生成"})]})]})]})]})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"请妥善保管您的 Access Token,不要泄露给他人"})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"自定义 Access Token"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"new-token",type:j?"text":"password",value:d,onChange:pe=>h(pe.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>g(!j),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:j?"隐藏":"显示",children:j?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),d&&e.jsxs("div",{className:"mt-3 space-y-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Token 安全要求:"}),e.jsx("div",{className:"space-y-1.5",children:X.rules.map(pe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[pe.passed?e.jsx(xa,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(pg,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:$(pe.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:pe.label})]},pe.id))}),X.isValid&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(ha,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(N,{onClick:te,disabled:_||!X.isValid||!d,className:"w-full sm:w-auto",children:_?"更新中...":"更新自定义 Token"})]})]}),e.jsxs("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm sm:text-base font-semibold text-yellow-900 dark:text-yellow-200 mb-2",children:"安全提示"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-yellow-800 dark:text-yellow-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"重新生成 Token 会创建系统随机生成的 64 位安全令牌"}),e.jsx("li",{children:"自定义 Token 必须满足所有安全要求才能使用"}),e.jsx("li",{children:"更新 Token 后,旧的 Token 将立即失效"}),e.jsx("li",{children:"请在安全的环境下查看和复制 Token"}),e.jsx("li",{children:"如果怀疑 Token 泄露,请立即重新生成或更新"}),e.jsx("li",{children:"建议使用系统生成的 Token 以获得最高安全性"})]})]})]})}function p0(){const n=It(),{toast:r}=Bs(),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(()=>Fs("logCacheSize")),[g,_]=u.useState(()=>Fs("wsReconnectInterval")),[v,k]=u.useState(()=>Fs("wsMaxReconnectAttempts")),[z,T]=u.useState(()=>Fs("dataSyncInterval")),[L,K]=u.useState(()=>ap()),[U,R]=u.useState(!1),[ee,V]=u.useState(!1),E=u.useRef(null);if(h)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const B=()=>{K(ap())},X=y=>{const q=y[0];j(q),Pn("logCacheSize",q)},w=y=>{const q=y[0];_(q),Pn("wsReconnectInterval",q)},D=y=>{const q=y[0];k(q),Pn("wsMaxReconnectAttempts",q)},te=y=>{const q=y[0];T(q),Pn("dataSyncInterval",q)},xe=()=>{an.clearLogs(),r({title:"日志已清除",description:"日志缓存已清空"})},be=()=>{const y=c0();B(),r({title:"缓存已清除",description:`已清除 ${y.clearedKeys.length} 项缓存数据`})},ye=()=>{R(!0);try{const y=n0(),q=JSON.stringify(y,null,2),H=new Blob([q],{type:"application/json"}),ne=URL.createObjectURL(H),S=document.createElement("a");S.href=ne,S.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(S),S.click(),document.body.removeChild(S),URL.revokeObjectURL(ne),r({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(y){console.error("导出设置失败:",y),r({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{R(!1)}},ve=y=>{const q=y.target.files?.[0];if(!q)return;V(!0);const H=new FileReader;H.onload=ne=>{try{const S=ne.target?.result,me=JSON.parse(S),he=i0(me);he.success?(j(Fs("logCacheSize")),_(Fs("wsReconnectInterval")),k(Fs("wsMaxReconnectAttempts")),T(Fs("dataSyncInterval")),B(),r({title:"导入成功",description:`成功导入 ${he.imported.length} 项设置${he.skipped.length>0?`,跳过 ${he.skipped.length} 项`:""}`}),(he.imported.includes("theme")||he.imported.includes("accentColor"))&&r({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):r({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(S){console.error("导入设置失败:",S),r({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{V(!1),E.current&&(E.current.value="")}},H.readAsText(q)},pe=()=>{r0(),j(Ea.logCacheSize),_(Ea.wsReconnectInterval),k(Ea.wsMaxReconnectAttempts),T(Ea.dataSyncInterval),B(),r({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},Ne=async()=>{d(!0);try{const y=localStorage.getItem("access-token"),q=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${y}`}}),H=await q.json();q.ok&&H.success?(r({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{n({to:"/setup"})},1e3)):r({title:"重置失败",description:H.message||"无法重置配置状态",variant:"destructive"})}catch(y){console.error("重置配置状态错误:",y),r({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{d(!1)}};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(eo,{className:"h-5 w-5"}),"性能与存储"]}),e.jsxs("div",{className:"space-y-4 sm:space-y-5",children:[e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(CN,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:B,className:"h-7 px-2",children:e.jsx(ft,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:o0(L.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[L.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f," 条"]})]}),e.jsx(za,{value:[f],onValueChange:X,min:100,max:5e3,step:100,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制日志查看器最多缓存的日志条数,较大的值会占用更多内存"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[z," 秒"]})]}),e.jsx(za,{value:[z],onValueChange:te,min:10,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制首页统计数据的自动刷新间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g/1e3," 秒"]})]}),e.jsx(za,{value:[g],onValueChange:w,min:1e3,max:1e4,step:500,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"日志 WebSocket 连接断开后的重连基础间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[v," 次"]})]}),e.jsx(za,{value:[v],onValueChange:D,min:3,max:30,step:1,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"连接失败后的最大重连尝试次数"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:xe,className:"gap-2",children:[e.jsx(ns,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ns,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认清除本地缓存"}),e.jsx(ms,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:be,children:"确认清除"})]})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(nl,{className:"h-5 w-5"}),"导入/导出设置"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"导出当前的界面设置以便备份,或从之前导出的文件中恢复设置。"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",onClick:ye,disabled:U,className:"gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),U?"导出中...":"导出设置"]}),e.jsx("input",{ref:E,type:"file",accept:".json",onChange:ve,className:"hidden"}),e.jsxs(N,{variant:"outline",onClick:()=>E.current?.click(),disabled:ee,className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),ee?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Wc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重置所有设置"}),e.jsx(ms,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:pe,children:"确认重置"})]})]})]})})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"配置向导"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"重新进行初次配置向导,可以帮助您重新设置系统的基础配置。"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:c,className:"gap-2",children:[e.jsx(Wc,{className:$("h-4 w-4",c&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重新配置"}),e.jsx(ms,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:Ne,children:"确认重置"})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dashed border-yellow-500/50 bg-yellow-500/5 p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"开发者工具"]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"以下功能仅供开发调试使用,可能会导致页面崩溃或异常。"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{variant:"destructive",className:"gap-2",children:[e.jsx(ya,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认触发错误"}),e.jsx(ms,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function g0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"rounded-lg border-2 border-primary/30 bg-gradient-to-r from-primary/5 to-primary/10 p-4 sm:p-6",children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-primary/10 p-2 sm:p-3",children:e.jsx("svg",{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-2",children:"开源项目"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mb-3",children:"本项目在 GitHub 开源,欢迎 Star ⭐ 支持!"}),e.jsxs("a",{href:"https://github.com/Mai-with-u/MaiBot-Dashboard",target:"_blank",rel:"noopener noreferrer",className:$("inline-flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground font-medium text-sm","hover:bg-primary/90 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"前往 GitHub",e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:["关于 ",Ku]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Xu]}),e.jsx("p",{children:"麦麦(MaiBot)的现代化 Web 管理界面"})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"作者"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"MaiBot 核心"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Mai-with-u"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"WebUI"}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:["Mai-with-u ",e.jsx("a",{href:"https://github.com/DrSmoothl",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"@MotricSeven"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"技术栈"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"前端框架"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"React 19.2.0"}),e.jsx("li",{children:"TypeScript 5.7.2"}),e.jsx("li",{children:"Vite 6.0.7"}),e.jsx("li",{children:"TanStack Router 1.94.2"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"UI 组件"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"shadcn/ui"}),e.jsx("li",{children:"Radix UI"}),e.jsx("li",{children:"Tailwind CSS 3.4.17"}),e.jsx("li",{children:"Lucide Icons"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"后端"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Python 3.12+"}),e.jsx("li",{children:"FastAPI"}),e.jsx("li",{children:"Uvicorn"}),e.jsx("li",{children:"WebSocket"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"构建工具"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Bun / npm"}),e.jsx("li",{children:"ESLint 9.17.0"}),e.jsx("li",{children:"PostCSS"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源库感谢"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mb-3",children:"本项目使用了以下优秀的开源库,感谢他们的贡献:"}),e.jsx(es,{className:"h-[300px] sm:h-[400px]",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"UI 框架与组件"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(Hs,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(Hs,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(Hs,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(Hs,{name:"Lucide React",description:"精美的图标库",license:"ISC"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"路由与状态管理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(Hs,{name:"Zustand",description:"轻量级状态管理",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"表单处理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(Hs,{name:"Zod",description:"TypeScript 优先的 schema 验证",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"工具库"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(Hs,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(Hs,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(Hs,{name:"date-fns",description:"现代化日期处理库",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"动画效果"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(Hs,{name:"vaul",description:"抽屉组件动画",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"后端框架"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(Hs,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(Hs,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(Hs,{name:"python-multipart",description:"文件上传支持",license:"Apache-2.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"开发工具"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Hs,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(Hs,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(Hs,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(Hs,{name:"PostCSS",description:"CSS 转换工具",license:"MIT"})]})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源许可"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:"rounded-md bg-primary/10 px-2 py-1",children:e.jsx("span",{className:"text-xs sm:text-sm font-bold text-primary",children:"GPLv3"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm sm:text-base font-semibold text-foreground mb-1",children:"MaiBot WebUI"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目采用 GNU General Public License v3.0 开源许可证。 您可以自由地使用、修改和分发本软件,但必须保持相同的开源许可。"})]})]})}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目依赖的所有开源库均遵循各自的开源许可证(MIT、Apache-2.0、BSD 等)。 感谢所有开源贡献者的无私奉献。"})]})]})]})}function Hs({name:n,description:r,license:c}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border bg-muted/30 p-2.5 sm:p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:n}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:r})]}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary flex-shrink-0",children:c})]})}function Au({value:n,current:r,onChange:c,label:d,description:h}){const x=r===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:d}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:h})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[n==="light"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-300"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-400"})]}),n==="dark"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-900"})]}),n==="system"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-200 to-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-300 to-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-400 to-slate-900"})]})]})]})}function da({value:n,current:r,onChange:c,label:d,colorClass:h}){const x=r===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:$("h-8 w-8 sm:h-10 sm:w-10 rounded-full",h)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:d})]})]})}class j0{grad3;p;perm;constructor(r=0){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.p=[];for(let c=0;c<256;c++)this.p[c]=Math.floor(Math.random()*256);this.perm=[];for(let c=0;c<512;c++)this.perm[c]=this.p[c&255]}dot(r,c,d){return r[0]*c+r[1]*d}mix(r,c,d){return(1-d)*r+d*c}fade(r){return r*r*r*(r*(r*6-15)+10)}perlin2(r,c){const d=Math.floor(r)&255,h=Math.floor(c)&255;r-=Math.floor(r),c-=Math.floor(c);const x=this.fade(r),f=this.fade(c),j=this.perm[d]+h,g=this.perm[j],_=this.perm[j+1],v=this.perm[d+1]+h,k=this.perm[v],z=this.perm[v+1];return this.mix(this.mix(this.dot(this.grad3[g%12],r,c),this.dot(this.grad3[k%12],r-1,c),x),this.mix(this.dot(this.grad3[_%12],r,c-1),this.dot(this.grad3[z%12],r-1,c-1),x),f)}}function v0(){const n=u.useRef(null),r=u.useRef(null),c=u.useRef(void 0),d=u.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new j0(Math.random()),bounding:null});return u.useEffect(()=>{const h=r.current,x=n.current;if(!h||!x)return;const f=d.current,j=()=>{const K=h.getBoundingClientRect();f.bounding=K,x.style.width=`${K.width}px`,x.style.height=`${K.height}px`},g=()=>{if(!f.bounding)return;const{width:K,height:U}=f.bounding;f.lines=[],f.paths.forEach(te=>te.remove()),f.paths=[];const R=10,ee=32,V=K+200,E=U+30,B=Math.ceil(V/R),X=Math.ceil(E/ee),w=(K-R*B)/2,D=(U-ee*X)/2;for(let te=0;te<=B;te++){const xe=[];for(let ye=0;ye<=X;ye++){const ve={x:w+R*te,y:D+ee*ye,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};xe.push(ve)}const be=document.createElementNS("http://www.w3.org/2000/svg","path");x.appendChild(be),f.paths.push(be),f.lines.push(xe)}},_=K=>{const{lines:U,mouse:R,noise:ee}=f;U.forEach(V=>{V.forEach(E=>{const B=ee.perlin2((E.x+K*.0125)*.002,(E.y+K*.005)*.0015)*12;E.wave.x=Math.cos(B)*32,E.wave.y=Math.sin(B)*16;const X=E.x-R.sx,w=E.y-R.sy,D=Math.hypot(X,w),te=Math.max(175,R.vs);if(D{const R={x:K.x+K.wave.x+(U?K.cursor.x:0),y:K.y+K.wave.y+(U?K.cursor.y:0)};return R.x=Math.round(R.x*10)/10,R.y=Math.round(R.y*10)/10,R},k=()=>{const{lines:K,paths:U}=f;K.forEach((R,ee)=>{let V=v(R[0],!1),E=`M ${V.x} ${V.y}`;R.forEach((B,X)=>{const w=X===R.length-1;V=v(B,!w),E+=`L ${V.x} ${V.y}`}),U[ee].setAttribute("d",E)})},z=K=>{const{mouse:U}=f;U.sx+=(U.x-U.sx)*.1,U.sy+=(U.y-U.sy)*.1;const R=U.x-U.lx,ee=U.y-U.ly,V=Math.hypot(R,ee);U.v=V,U.vs+=(V-U.vs)*.1,U.vs=Math.min(100,U.vs),U.lx=U.x,U.ly=U.y,U.a=Math.atan2(ee,R),h&&(h.style.setProperty("--x",`${U.sx}px`),h.style.setProperty("--y",`${U.sy}px`)),_(K),k(),c.current=requestAnimationFrame(z)},T=K=>{if(!f.bounding)return;const{mouse:U}=f;U.x=K.pageX-f.bounding.left,U.y=K.pageY-f.bounding.top+window.scrollY,U.set||(U.sx=U.x,U.sy=U.y,U.lx=U.x,U.ly=U.y,U.set=!0)},L=()=>{j(),g()};return j(),g(),window.addEventListener("resize",L),window.addEventListener("mousemove",T),c.current=requestAnimationFrame(z),()=>{window.removeEventListener("resize",L),window.removeEventListener("mousemove",T),c.current&&cancelAnimationFrame(c.current)}},[]),e.jsxs("div",{ref:r,className:"waves-background",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"},children:[e.jsx("div",{className:"waves-cursor",style:{position:"absolute",top:0,left:0,width:"0.5rem",height:"0.5rem",background:"hsl(var(--primary) / 0.3)",borderRadius:"50%",transform:"translate3d(calc(var(--x, -0.5rem) - 50%), calc(var(--y, 50%) - 50%), 0)",willChange:"transform",pointerEvents:"none"}}),e.jsx("svg",{ref:n,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:` - path { - fill: none; - stroke: hsl(var(--primary) / 0.20); - stroke-width: 1px; - } - `})})]})}function y0(){const n=It();u.useEffect(()=>{localStorage.getItem("access-token")||n({to:"/auth"})},[n])}function Dg(){return!!localStorage.getItem("access-token")}function N0(){const[n,r]=u.useState(""),[c,d]=u.useState(!1),[h,x]=u.useState(""),f=It(),{enableWavesBackground:j,setEnableWavesBackground:g}=Eg(),{theme:_,setTheme:v}=Yu();u.useEffect(()=>{Dg()&&f({to:"/"})},[f]);const z=_==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":_,T=()=>{v(z==="dark"?"light":"dark")},L=async K=>{if(K.preventDefault(),x(""),!n.trim()){x("请输入 Access Token");return}d(!0);try{const U=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n.trim()})}),R=await U.json();if(U.ok&&R.valid){localStorage.setItem("access-token",n.trim());const ee=await fetch("/api/webui/setup/status",{method:"GET",headers:{Authorization:`Bearer ${n.trim()}`}}),V=await ee.json();ee.ok&&V.is_first_setup?f({to:"/setup"}):f({to:"/"})}else x(R.message||"Token 验证失败,请检查后重试")}catch(U){console.error("Token 验证错误:",U),x("连接服务器失败,请检查网络连接")}finally{d(!1)}};return e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[j&&e.jsx(v0,{}),e.jsxs(Be,{className:"relative z-10 w-full max-w-md shadow-2xl backdrop-blur-xl bg-card/80 border-border/50",children:[e.jsx("button",{onClick:T,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:z==="dark"?"切换到浅色模式":"切换到深色模式",children:z==="dark"?e.jsx(Ou,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(Ru,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(gs,{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx($f,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(js,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(Zs,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(bs,{children:e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(gg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(ce,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:n,onChange:K=>r(K.target.value),className:$("pl-10",h&&"border-red-500 focus-visible:ring-red-500"),disabled:c,autoFocus:!0,autoComplete:"off"})]})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-red-50 p-3 text-sm text-red-600 dark:bg-red-950/50 dark:text-red-400",children:[e.jsx(Aa,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:h})]}),e.jsx(N,{type:"submit",className:"w-full",disabled:c,children:c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"验证中..."]}):"验证并进入"}),e.jsxs(Os,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-primary hover:text-primary/80 transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(ro,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token,我该去哪里获得 Token?"]})}),e.jsxs(Es,{className:"sm:max-w-md",children:[e.jsxs(zs,{children:[e.jsxs(Ms,{className:"flex items-center gap-2",children:[e.jsx($f,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx($s,{children:"Access Token 是访问 MaiBot WebUI 的唯一凭证,请按以下方式获取"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(kN,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式一:查看启动日志"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在 MaiBot 启动时,控制台会显示 WebUI Access Token。"}),e.jsxs("div",{className:"rounded bg-background p-2 font-mono text-xs",children:[e.jsx("p",{className:"text-muted-foreground",children:"🔑 WebUI Access Token: abc123..."}),e.jsx("p",{className:"text-muted-foreground",children:"💡 请使用此 Token 登录 WebUI"})]})]})]})}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ma,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式二:查看配置文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Token 保存在项目根目录的配置文件中:"}),e.jsx("div",{className:"rounded bg-background p-2 font-mono text-xs break-all",children:e.jsx("code",{className:"text-primary",children:"data/webui.json"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["打开此文件,复制 ",e.jsx("code",{className:"px-1 py-0.5 bg-background rounded",children:"access_token"})," 字段的值"]})]})]})}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Aa,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"安全提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"请妥善保管您的 Token,不要泄露给他人"}),e.jsx("li",{children:"如需重置 Token,请在登录后前往系统设置"})]})]})]})})]})]})]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-muted-foreground hover:text-foreground transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(ln,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(ms,{children:"背景动画可能会在低性能设备上造成卡顿。关闭动画可以显著提升界面流畅度。"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭动画后,背景将变为纯色,但不影响任何功能的使用。您可以随时在系统设置中重新开启动画。"})}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>g(!1),children:"关闭动画"})]})]})]})]})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 text-center text-xs text-muted-foreground",children:e.jsx("p",{children:t0})})]})}const Us=u.forwardRef(({className:n,...r},c)=>e.jsx("textarea",{className:$("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:c,...r}));Us.displayName="Textarea";const jr=u.forwardRef(({className:n,orientation:r="horizontal",decorative:c=!0,...d},h)=>e.jsx(Op,{ref:h,decorative:c,orientation:r,className:$("shrink-0 bg-border",r==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",n),...d}));jr.displayName=Op.displayName;function b0({config:n,onChange:r}){const c=h=>{h.trim()&&!n.alias_names.includes(h.trim())&&r({...n,alias_names:[...n.alias_names,h.trim()]})},d=h=>{r({...n,alias_names:n.alias_names.filter((x,f)=>f!==h)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(ce,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:n.qq_account||"",onChange:h=>r({...n,qq_account:Number(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(ce,{id:"nickname",placeholder:"请输入机器人的昵称",value:n.nickname,onChange:h=>r({...n,nickname:h.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:n.alias_names.map((h,x)=>e.jsxs(Xe,{variant:"secondary",className:"gap-1",children:[h,e.jsx("button",{type:"button",onClick:()=>d(x),className:"ml-1 hover:text-destructive",children:e.jsx(li,{className:"h-3 w-3"})})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:h=>{h.key==="Enter"&&(c(h.target.value),h.target.value="")}}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>{const h=document.getElementById("alias_input");h&&(c(h.value),h.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function w0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(Us,{id:"personality",placeholder:"描述机器人的人格特质和身份特征(建议120字以内)",value:n.personality,onChange:c=>r({...n,personality:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:是一个女大学生,现在在读大二,会刷贴吧"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(Us,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:n.reply_style,onChange:c=>r({...n,reply_style:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:回复平淡一些,简短一些,说中文,参考贴吧、知乎和微博的回复风格"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(Us,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:n.interest,onChange:c=>r({...n,interest:c.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(jr,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(Us,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:n.plan_style,onChange:c=>r({...n,plan_style:c.target.value}),rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在群聊中如何行动,例如回复频率、条件等"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(Us,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:n.private_plan_style,onChange:c=>r({...n,private_plan_style:c.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function _0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(n.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ce,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:n.emoji_chance,onChange:c=>r({...n,emoji_chance:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人发送表情包的概率"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",max:"200",value:n.max_reg_num,onChange:c=>r({...n,max_reg_num:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人最多保存的表情包数量"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(qe,{id:"do_replace",checked:n.do_replace,onCheckedChange:c=>r({...n,do_replace:c})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",max:"120",value:n.check_interval,onChange:c=>r({...n,check_interval:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(qe,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:c=>r({...n,steal_emoji:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(qe,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:c=>r({...n,content_filtration:c})})]}),n.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:n.filtration_prompt,onChange:c=>r({...n,filtration_prompt:c.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function S0({config:n,onChange:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(qe,{id:"enable_tool",checked:n.enable_tool,onCheckedChange:c=>r({...n,enable_tool:c})})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"enable_mood",children:"启用情绪系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"让机器人具有情绪变化能力"})]}),e.jsx(qe,{id:"enable_mood",checked:n.enable_mood,onCheckedChange:c=>r({...n,enable_mood:c})})]}),n.enable_mood&&e.jsxs("div",{className:"ml-6 space-y-6 border-l-2 border-primary/20 pl-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"mood_update_threshold",children:"情绪更新阈值"}),e.jsx(ce,{id:"mood_update_threshold",type:"number",min:"0.1",max:"10",step:"0.1",value:n.mood_update_threshold||1,onChange:c=>r({...n,mood_update_threshold:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"值越高,情绪更新越慢"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"emotion_style",children:"情感特征"}),e.jsx(Us,{id:"emotion_style",placeholder:"描述情绪的变化情况,例如:情绪较为稳定,但遭遇特定事件时起伏较大",value:n.emotion_style||"",onChange:c=>r({...n,emotion_style:c.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响机器人的情绪变化方式"})]})]}),e.jsx(jr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(qe,{id:"all_global",checked:n.all_global,onCheckedChange:c=>r({...n,all_global:c})})]})]})}function C0({config:n,onChange:r}){const[c,d]=u.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("svg",{className:"h-5 w-5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-1",children:"关于硅基流动 (SiliconFlow)"}),e.jsx("p",{className:"text-blue-700 dark:text-blue-300 mb-2",children:"硅基流动提供了完整的模型覆盖,包括 DeepSeek V3、Qwen、视觉模型、语音识别和嵌入模型。 只需一个 API Key 即可使用麦麦的所有功能!"}),e.jsxs("a",{href:"https://cloud.siliconflow.cn",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:["前往硅基流动获取 API Key",e.jsx(dr,{className:"h-3 w-3"})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{htmlFor:"siliconflow_api_key",children:"SiliconFlow API Key *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"siliconflow_api_key",type:c?"text":"password",placeholder:"sk-...",value:n.api_key,onChange:h=>r({api_key:h.target.value}),className:"font-mono pr-10"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>d(!c),children:c?e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"请输入您的硅基流动 API 密钥。获取后,麦麦将自动配置所有必需的模型。"})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium",children:"将自动配置以下模型:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"DeepSeek V3 - 主要对话和工具模型"}),e.jsx("li",{children:"Qwen3 30B - 高频小任务和工具调用"}),e.jsx("li",{children:"Qwen3 VL 30B - 图像识别"}),e.jsx("li",{children:"SenseVoice - 语音识别"}),e.jsx("li",{children:"BGE-M3 - 文本嵌入"}),e.jsx("li",{children:"知识库相关模型 (LPMM)"})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 p-4",children:e.jsxs("p",{className:"text-sm text-amber-900 dark:text-amber-100",children:[e.jsx("span",{className:"font-medium",children:"💡 提示:"}),'完成向导后,您可以在"系统设置 → 模型配置"中添加更多 API 提供商和模型。']})})]})}async function ke(n,r){const c=await fetch(n,r);if(c.status===401)throw localStorage.removeItem("access-token"),window.location.href="/auth",new Error("认证失败,请重新登录");return c}function ze(){return{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("access-token")}`}}async function k0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:ze()});if(!n.ok)throw new Error("读取Bot配置失败");const c=(await n.json()).config.bot||{};return{qq_account:c.qq_account||0,nickname:c.nickname||"",alias_names:c.alias_names||[]}}async function T0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:ze()});if(!n.ok)throw new Error("读取人格配置失败");const c=(await n.json()).config.personality||{};return{personality:c.personality||"",reply_style:c.reply_style||"",interest:c.interest||"",plan_style:c.plan_style||"",private_plan_style:c.private_plan_style||""}}async function E0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:ze()});if(!n.ok)throw new Error("读取表情包配置失败");const c=(await n.json()).config.emoji||{};return{emoji_chance:c.emoji_chance??.4,max_reg_num:c.max_reg_num??40,do_replace:c.do_replace??!0,check_interval:c.check_interval??10,steal_emoji:c.steal_emoji??!0,content_filtration:c.content_filtration??!1,filtration_prompt:c.filtration_prompt||""}}async function z0(){const n=await ke("/api/webui/config/bot",{method:"GET",headers:ze()});if(!n.ok)throw new Error("读取其他配置失败");const c=(await n.json()).config,d=c.tool||{},h=c.mood||{},x=c.jargon||{};return{enable_tool:d.enable_tool??!0,enable_mood:h.enable_mood??!1,mood_update_threshold:h.mood_update_threshold,emotion_style:h.emotion_style,all_global:x.all_global??!0}}async function M0(){const n=await ke("/api/webui/config/model",{method:"GET",headers:ze()});if(!n.ok)throw new Error("读取模型配置失败");return{api_key:((await n.json()).config.api_providers||[]).find(x=>x.name==="SiliconFlow")?.api_key||""}}async function A0(n){const r=await ke("/api/webui/config/bot/section/bot",{method:"POST",headers:ze(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存Bot基础配置失败")}return await r.json()}async function D0(n){const r=await ke("/api/webui/config/bot/section/personality",{method:"POST",headers:ze(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存人格配置失败")}return await r.json()}async function O0(n){const r=await ke("/api/webui/config/bot/section/emoji",{method:"POST",headers:ze(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存表情包配置失败")}return await r.json()}async function R0(n){const r=[];r.push(ke("/api/webui/config/bot/section/tool",{method:"POST",headers:ze(),body:JSON.stringify({enable_tool:n.enable_tool})})),r.push(ke("/api/webui/config/bot/section/jargon",{method:"POST",headers:ze(),body:JSON.stringify({all_global:n.all_global})}));const c={enable_mood:n.enable_mood};n.enable_mood&&(c.mood_update_threshold=n.mood_update_threshold||1,c.emotion_style=n.emotion_style||""),r.push(ke("/api/webui/config/bot/section/mood",{method:"POST",headers:ze(),body:JSON.stringify(c)}));const d=await Promise.all(r);for(const h of d)if(!h.ok){const x=await h.json();throw new Error(x.detail||"保存其他配置失败")}return{success:!0}}async function L0(n){const r=await ke("/api/webui/config/model",{method:"GET",headers:ze()});if(!r.ok)throw new Error("读取模型配置失败");const d=(await r.json()).config,h=d.api_providers||[],x=h.findIndex(g=>g.name==="SiliconFlow");x>=0?h[x]={...h[x],api_key:n.api_key}:h.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:n.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const f={...d,api_providers:h},j=await ke("/api/webui/config/model",{method:"POST",headers:ze(),body:JSON.stringify(f)});if(!j.ok){const g=await j.json();throw new Error(g.detail||"保存模型配置失败")}return await j.json()}async function np(){const n=localStorage.getItem("access-token"),r=await ke("/api/webui/setup/complete",{method:"POST",headers:{Authorization:`Bearer ${n}`}});if(!r.ok){const c=await r.json();throw new Error(c.message||"标记配置完成失败")}return await r.json()}async function co(){const n=await ke("/api/webui/system/restart",{method:"POST",headers:ze()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"重启失败")}return await n.json()}async function U0(){const n=await ke("/api/webui/system/status",{method:"GET",headers:ze()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取状态失败")}return await n.json()}function B0(){const n=It(),{toast:r}=Bs(),[c,d]=u.useState(0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[g,_]=u.useState(!0),[v,k]=u.useState({qq_account:0,nickname:"",alias_names:[]}),[z,T]=u.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 -2.如果相同的内容已经被执行,请不要重复执行 -3.请控制你的发言频率,不要太过频繁的发言 -4.如果有人对你感到厌烦,请减少回复 -5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 -2.如果相同的内容已经被执行,请不要重复执行 -3.某句话如果已经被回复过,不要重复回复`}),[L,K]=u.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[U,R]=u.useState({enable_tool:!0,enable_mood:!1,mood_update_threshold:1,emotion_style:"情绪较为稳定,但遇遇特定事件的时候起伏较大",all_global:!0}),[ee,V]=u.useState({api_key:""}),[E,B]=u.useState(!1),[X,w]=u.useState(""),D=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:ir},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:to},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:Qu},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:Rl},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:gg}],te=(c+1)/D.length*100;u.useEffect(()=>{(async()=>{try{_(!0);const[q,H,ne,S,me]=await Promise.all([k0(),T0(),E0(),z0(),M0()]);k(q),T(H),K(ne),R(S),V(me)}catch(q){r({title:"加载配置失败",description:q instanceof Error?q.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{_(!1)}})()},[r]);const xe=async()=>{j(!0);try{switch(c){case 0:await A0(v);break;case 1:await D0(z);break;case 2:await O0(L);break;case 3:await R0(U);break;case 4:await L0(ee);break}return r({title:"保存成功",description:`${D[c].title}配置已保存`}),!0}catch(y){return r({title:"保存失败",description:y instanceof Error?y.message:"未知错误",variant:"destructive"}),!1}finally{j(!1)}},be=async()=>{await xe()&&c{c>0&&d(c-1)},ve=async()=>{x(!0),B(!0);try{if(w("正在保存API配置..."),!await xe()){x(!1),B(!1);return}w("正在完成初始化..."),await np(),w("正在重启麦麦..."),await co(),r({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),w("等待麦麦重启完成...");const q=60;let H=0,ne=!1;for(;HsetTimeout(S,1e3));try{(await U0()).running&&(ne=!0,w("重启成功!正在跳转..."))}catch{H++}}if(!ne)throw new Error("重启超时,请手动检查麦麦状态");setTimeout(()=>{n({to:"/"})},1e3)}catch(y){B(!1),r({title:"配置失败",description:y instanceof Error?y.message:"未知错误",variant:"destructive"})}finally{x(!1)}},pe=async()=>{try{await np(),n({to:"/"})}catch(y){r({title:"跳过失败",description:y instanceof Error?y.message:"未知错误",variant:"destructive"})}},Ne=()=>{switch(c){case 0:return e.jsx(b0,{config:v,onChange:k});case 1:return e.jsx(w0,{config:z,onChange:T});case 2:return e.jsx(_0,{config:L,onChange:K});case 3:return e.jsx(S0,{config:U,onChange:R});case 4:return e.jsx(C0,{config:ee,onChange:V});default:return null}};return e.jsxs("div",{className:"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-gradient-to-br from-primary/5 via-background to-secondary/5 p-4 md:p-6",children:[E&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:e.jsxs("div",{className:"mx-auto flex max-w-md flex-col items-center space-y-6 rounded-lg border bg-card p-8 text-center shadow-lg",children:[e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(vt,{className:"h-10 w-10 animate-spin text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground",children:X})]}),e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full w-full animate-pulse bg-primary",style:{animation:"pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请稍候,这可能需要一分钟..."})]})}),e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute left-1/4 top-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-primary/5 blur-3xl"}),e.jsx("div",{className:"absolute right-1/4 bottom-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-secondary/5 blur-3xl"})]}),g?e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center",children:e.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),e.jsx("p",{className:"text-lg font-medium",children:"加载配置中..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"正在读取现有配置"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-10 w-full max-w-4xl",children:[e.jsxs("div",{className:"mb-6 md:mb-8 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 md:h-16 md:w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx(TN,{className:"h-6 w-6 md:h-8 md:w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsx("h1",{className:"mb-2 text-2xl md:text-3xl font-bold",children:"首次配置向导"}),e.jsxs("p",{className:"text-sm md:text-base text-muted-foreground",children:["让我们一起完成 ",Ku," 的初始配置"]})]}),e.jsxs("div",{className:"mb-6 md:mb-8",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs md:text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["步骤 ",c+1," / ",D.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(te),"%"]})]}),e.jsx(Sr,{value:te,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:D.map((y,q)=>{const H=y.icon;return e.jsxs("div",{className:$("flex flex-1 flex-col items-center gap-1 md:gap-2",qn({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(xr,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(N,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx(ti,{className:"h-4 w-4"}),"返回上一页"]})]}),e.jsx("div",{className:"mt-12 pt-8 border-t border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"如果您认为这是一个错误,请联系系统管理员"})})]})})}const Qe=hN,$e=xN,Ge=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs(eg,{ref:d,className:$("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n),...c,children:[r,e.jsx(cN,{asChild:!0,children:e.jsx(Ll,{className:"h-4 w-4 opacity-50"})})]}));Ge.displayName=eg.displayName;const Rg=u.forwardRef(({className:n,...r},c)=>e.jsx(sg,{ref:c,className:$("flex cursor-default items-center justify-center py-1",n),...r,children:e.jsx(fr,{className:"h-4 w-4"})}));Rg.displayName=sg.displayName;const Lg=u.forwardRef(({className:n,...r},c)=>e.jsx(tg,{ref:c,className:$("flex cursor-default items-center justify-center py-1",n),...r,children:e.jsx(Ll,{className:"h-4 w-4"})}));Lg.displayName=tg.displayName;const Ve=u.forwardRef(({className:n,children:r,position:c="popper",...d},h)=>e.jsx(oN,{children:e.jsxs(ag,{ref:h,className:$("relative z-[100] max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-hidden rounded-md border border-border bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",c==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:c,...d,children:[e.jsx(Rg,{}),e.jsx(dN,{className:$("p-1",c==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e.jsx(Lg,{})]})}));Ve.displayName=ag.displayName;const H0=u.forwardRef(({className:n,...r},c)=>e.jsx(lg,{ref:c,className:$("px-2 py-1.5 text-sm font-semibold",n),...r}));H0.displayName=lg.displayName;const ue=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs(ng,{ref:d,className:$("relative flex w-full cursor-default select-none items-center rounded-sm py-2 pl-2 pr-8 text-sm outline-none bg-white dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 focus:bg-gray-100 dark:focus:bg-gray-800 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...c,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(uN,{children:e.jsx(ha,{className:"h-4 w-4"})})}),e.jsx(mN,{children:r})]}));ue.displayName=ng.displayName;const q0=u.forwardRef(({className:n,...r},c)=>e.jsx(ig,{ref:c,className:$("-mx-1 my-1 h-px bg-muted",n),...r}));q0.displayName=ig.displayName;const Da=Gy,Oa=Vy,Na=u.forwardRef(({className:n,align:r="center",sideOffset:c=4,...d},h)=>e.jsx(qy,{children:e.jsx(Rp,{ref:h,align:r,sideOffset:c,className:$("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",n),...d})}));Na.displayName=Rp.displayName;const Ul="/api/webui/config";async function ip(){const r=await(await ke(`${Ul}/bot`)).json();if(!r.success)throw new Error("获取配置数据失败");return r.config}async function ei(){const r=await(await ke(`${Ul}/model`)).json();if(!r.success)throw new Error("获取模型配置数据失败");return r.config}async function rp(n){const c=await(await ke(`${Ul}/bot`,{method:"POST",headers:ze(),body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function G0(){const r=await(await ke(`${Ul}/bot/raw`)).json();if(!r.success)throw new Error("获取配置源代码失败");return r.content}async function V0(n){const c=await(await ke(`${Ul}/bot/raw`,{method:"POST",headers:ze(),body:JSON.stringify({raw_content:n})})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function io(n){const c=await(await ke(`${Ul}/model`,{method:"POST",headers:ze(),body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}async function F0(n,r){const d=await(await ke(`${Ul}/bot/section/${n}`,{method:"POST",headers:ze(),body:JSON.stringify(r)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function qu(n,r){const d=await(await ke(`${Ul}/model/section/${n}`,{method:"POST",headers:ze(),body:JSON.stringify(r)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function Q0(n,r="openai",c="/models"){const d=new URLSearchParams({provider_name:n,parser:r,endpoint:c}),h=await ke(`/api/webui/models/list?${d}`);if(!h.ok){const f=await h.json().catch(()=>({}));throw new Error(f.detail||`获取模型列表失败 (${h.status})`)}const x=await h.json();if(!x.success)throw new Error("获取模型列表失败");return x.models}async function $0(n){const r=new URLSearchParams({provider_name:n}),c=await ke(`/api/webui/models/test-connection-by-name?${r}`,{method:"POST"});if(!c.ok){const d=await c.json().catch(()=>({}));throw new Error(d.detail||`测试连接失败 (${c.status})`)}return await c.json()}const Y0=ai("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),ua=u.forwardRef(({className:n,variant:r,...c},d)=>e.jsx("div",{ref:d,role:"alert",className:$(Y0({variant:r}),n),...c}));ua.displayName="Alert";const X0=u.forwardRef(({className:n,...r},c)=>e.jsx("h5",{ref:c,className:$("mb-1 font-medium leading-none tracking-tight",n),...r}));X0.displayName="AlertTitle";const ma=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{ref:c,className:$("text-sm [&_p]:leading-relaxed",n),...r}));ma.displayName="AlertDescription";function Iu({onRestartComplete:n,onRestartFailed:r}){const[c,d]=u.useState(0),[h,x]=u.useState("restarting"),[f,j]=u.useState(0),[g,_]=u.useState(0);u.useEffect(()=>{const z=setInterval(()=>{d(K=>K>=90?K:K+1)},200),T=setInterval(()=>{j(K=>K+1)},1e3),L=setTimeout(()=>{x("checking"),v()},3e3);return()=>{clearInterval(z),clearInterval(T),clearTimeout(L)}},[]);const v=()=>{const T=async()=>{try{if(_(K=>K+1),(await fetch("/api/webui/system/status",{method:"GET",headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(3e3)})).ok)d(100),x("success"),setTimeout(()=>{n?.()},1500);else throw new Error("Status check failed")}catch{g<60?setTimeout(T,2e3):(x("failed"),r?.())}};T()},k=z=>{const T=Math.floor(z/60),L=z%60;return`${T}:${L.toString().padStart(2,"0")}`};return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[h==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"请稍候,麦麦正在重启中..."})]}),h==="checking"&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"检查服务状态"}),e.jsxs("p",{className:"text-muted-foreground text-center",children:["等待服务恢复... (尝试 ",g,"/60)"]})]}),h==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(xa,{className:"h-16 w-16 text-green-500"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启成功"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"正在跳转到登录页面..."})]}),h==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx(Aa,{className:"h-16 w-16 text-destructive"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启超时"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"服务未能在预期时间内恢复,请手动检查或刷新页面"})]})]}),h!=="failed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Sr,{value:c,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[c,"%"]}),e.jsxs("span",{children:["已用时: ",k(f)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[h==="restarting"&&"🔄 配置已保存,正在重启主程序...",h==="checking"&&"⏳ 正在等待服务恢复,请勿关闭页面...",h==="success"&&"✅ 配置已生效,服务运行正常",h==="failed"&&"⚠️ 如果长时间无响应,请尝试手动重启"]})}),e.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/50 rounded-lg p-4",children:e.jsxs("p",{className:"text-sm text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"⚠️ 重要提示:"})," 由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。如需结束程序,请使用脚本目录下的进程管理脚本。"]})}),h==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"刷新页面"}),e.jsx("button",{onClick:()=>{x("checking"),_(0),v()},className:"flex-1 px-4 py-2 bg-secondary text-secondary-foreground rounded-md hover:bg-secondary/90",children:"重试检测"})]})]})})}const K0={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(n,r){let c;if(!r.inString&&(c=n.match(/^('''|"""|'|")/))&&(r.stringType=c[0],r.inString=!0),n.sol()&&!r.inString&&r.inArray===0&&(r.lhs=!0),r.inString){for(;r.inString;)if(n.match(r.stringType))r.inString=!1;else if(n.peek()==="\\")n.next(),n.next();else{if(n.eol())break;n.match(/^.[^\\\"\']*/)}return r.lhs?"property":"string"}else{if(r.inArray&&n.peek()==="]")return n.next(),r.inArray--,"bracket";if(r.lhs&&n.peek()==="["&&n.skipTo("]"))return n.next(),n.peek()==="]"&&n.next(),"atom";if(n.peek()==="#")return n.skipToEnd(),"comment";if(n.eatSpace())return null;if(r.lhs&&n.eatWhile(function(d){return d!="="&&d!=" "}))return"property";if(r.lhs&&n.peek()==="=")return n.next(),r.lhs=!1,null;if(!r.lhs&&n.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!r.lhs&&(n.match("true")||n.match("false")))return"atom";if(!r.lhs&&n.peek()==="[")return r.inArray++,n.next(),"bracket";if(!r.lhs&&n.match(/^\-?\d+(?:\.\d+)?/))return"number";n.eatSpace()||n.next()}return null},languageData:{commentTokens:{line:"#"}}},Z0={python:[sb()],json:[tb(),ab()],toml:[eb.define(K0)],text:[]};function I0({value:n,onChange:r,language:c="text",readOnly:d=!1,height:h="400px",minHeight:x,maxHeight:f,placeholder:j,theme:g="dark",className:_=""}){const[v,k]=u.useState(!1);if(u.useEffect(()=>{k(!0)},[]),!v)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${_}`,style:{height:h,minHeight:x,maxHeight:f}});const z=[...Z0[c]||[],If.lineWrapping];return d&&z.push(If.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border ${_}`,children:e.jsx(lb,{value:n,height:h,minHeight:x,maxHeight:f,theme:g==="dark"?nb:void 0,extensions:z,onChange:r,placeholder:j,basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,foldGutter:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,syntaxHighlighting:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0}})})}function J0(){const[n,r]=u.useState(!0),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[g,_]=u.useState(!1),[v,k]=u.useState(!1),[z,T]=u.useState("visual"),[L,K]=u.useState(""),[U,R]=u.useState(!1),{toast:ee}=Bs(),[V,E]=u.useState(null),[B,X]=u.useState(null),[w,D]=u.useState(null),[te,xe]=u.useState(null),[be,ye]=u.useState(null),[ve,pe]=u.useState(null),[Ne,y]=u.useState(null),[q,H]=u.useState(null),[ne,S]=u.useState(null),[me,he]=u.useState(null),[Q,oe]=u.useState(null),[ge,le]=u.useState(null),[O,F]=u.useState(null),[A,W]=u.useState(null),[_e,Me]=u.useState(null),[ss,Ie]=u.useState(null),[Rs,qs]=u.useState(null),[ie,we]=u.useState(null),Ke=u.useRef(null),Le=u.useRef(!0),st=u.useRef({}),Jt=u.useCallback(async()=>{try{const Se=await G0();K(Se),R(!1)}catch(Se){ee({variant:"destructive",title:"加载失败",description:Se instanceof Error?Se.message:"加载源代码失败"})}},[ee]),bt=u.useCallback(async()=>{try{r(!0);const Se=await ip();st.current=Se,E(Se.bot),X(Se.personality);const Re=Se.chat;Re.talk_value_rules||(Re.talk_value_rules=[]),D(Re),xe(Se.expression),ye(Se.emoji),pe(Se.memory),y(Se.tool),H(Se.mood),S(Se.voice),he(Se.lpmm_knowledge),oe(Se.keyword_reaction),le(Se.response_post_process),F(Se.chinese_typo),W(Se.response_splitter),Me(Se.log),Ie(Se.debug),qs(Se.maim_message),we(Se.telemetry),j(!1),Le.current=!1,await Jt()}catch(Se){console.error("加载配置失败:",Se),ee({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{r(!1)}},[ee,Jt]);u.useEffect(()=>{bt()},[bt]);const Je=u.useCallback(async(Se,Re)=>{if(!Le.current)try{x(!0),await F0(Se,Re),j(!1)}catch(it){console.error(`自动保存 ${Se} 失败:`,it),j(!0)}finally{x(!1)}},[]),Ue=u.useCallback((Se,Re)=>{Le.current||(j(!0),Ke.current&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{Je(Se,Re)},2e3))},[Je]);u.useEffect(()=>{V&&!Le.current&&Ue("bot",V)},[V,Ue]),u.useEffect(()=>{B&&!Le.current&&Ue("personality",B)},[B,Ue]),u.useEffect(()=>{w&&!Le.current&&Ue("chat",w)},[w,Ue]),u.useEffect(()=>{te&&!Le.current&&Ue("expression",te)},[te,Ue]),u.useEffect(()=>{be&&!Le.current&&Ue("emoji",be)},[be,Ue]),u.useEffect(()=>{ve&&!Le.current&&Ue("memory",ve)},[ve,Ue]),u.useEffect(()=>{Ne&&!Le.current&&Ue("tool",Ne)},[Ne,Ue]),u.useEffect(()=>{q&&!Le.current&&Ue("mood",q)},[q,Ue]),u.useEffect(()=>{ne&&!Le.current&&Ue("voice",ne)},[ne,Ue]),u.useEffect(()=>{me&&!Le.current&&Ue("lpmm_knowledge",me)},[me,Ue]),u.useEffect(()=>{Q&&!Le.current&&Ue("keyword_reaction",Q)},[Q,Ue]),u.useEffect(()=>{ge&&!Le.current&&Ue("response_post_process",ge)},[ge,Ue]),u.useEffect(()=>{O&&!Le.current&&Ue("chinese_typo",O)},[O,Ue]),u.useEffect(()=>{A&&!Le.current&&Ue("response_splitter",A)},[A,Ue]),u.useEffect(()=>{_e&&!Le.current&&Ue("log",_e)},[_e,Ue]),u.useEffect(()=>{ss&&!Le.current&&Ue("debug",ss)},[ss,Ue]),u.useEffect(()=>{Rs&&!Le.current&&Ue("maim_message",Rs)},[Rs,Ue]),u.useEffect(()=>{ie&&!Le.current&&Ue("telemetry",ie)},[ie,Ue]);const jt=async()=>{try{d(!0),await V0(L),j(!1),R(!1),ee({title:"保存成功",description:"配置已保存"}),await bt()}catch(Se){R(!0),ee({variant:"destructive",title:"保存失败",description:Se instanceof Error?Se.message:"保存配置失败"})}finally{d(!1)}},nt=async Se=>{if(f){ee({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(T(Se),Se==="source")await Jt();else try{const Re=await ip();st.current=Re,E(Re.bot),X(Re.personality);const it=Re.chat;it.talk_value_rules||(it.talk_value_rules=[]),D(it),xe(Re.expression),ye(Re.emoji),pe(Re.memory),y(Re.tool),H(Re.mood),S(Re.voice),he(Re.lpmm_knowledge),oe(Re.keyword_reaction),le(Re.response_post_process),F(Re.chinese_typo),W(Re.response_splitter),Me(Re.log),Ie(Re.debug),qs(Re.maim_message),we(Re.telemetry),j(!1)}catch(Re){console.error("加载配置失败:",Re),ee({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},Ct=async()=>{try{d(!0),Ke.current&&clearTimeout(Ke.current);const Se={...st.current,bot:V,personality:B,chat:w,expression:te,emoji:be,memory:ve,tool:Ne,mood:q,voice:ne,lpmm_knowledge:me,keyword_reaction:Q,response_post_process:ge,chinese_typo:O,response_splitter:A,log:_e,debug:ss,maim_message:Rs,telemetry:ie};await rp(Se),j(!1),ee({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(Se){console.error("保存配置失败:",Se),ee({title:"保存失败",description:Se.message,variant:"destructive"})}finally{d(!1)}},kt=async()=>{try{_(!0),co().catch(()=>{}),k(!0)}catch(Se){console.error("重启失败:",Se),k(!1),ee({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),_(!1)}},rl=async()=>{try{d(!0),Ke.current&&clearTimeout(Ke.current);const Se={...st.current,bot:V,personality:B,chat:w,expression:te,emoji:be,memory:ve,tool:Ne,mood:q,voice:ne,lpmm_knowledge:me,keyword_reaction:Q,response_post_process:ge,chinese_typo:O,response_splitter:A,log:_e,debug:ss,maim_message:Rs,telemetry:ie};await rp(Se),j(!1),ee({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(Re=>setTimeout(Re,500)),await kt()}catch(Se){console.error("保存失败:",Se),ee({title:"保存失败",description:Se.message,variant:"destructive"})}finally{d(!1)}},cl=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},ol=()=>{k(!1),_(!1),ee({title:"重启失败",description:"服务器未能在预期时间内恢复,请手动检查",variant:"destructive"})};return n?e.jsx(es,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦主程序配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的核心功能和行为设置"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto items-center",children:[e.jsx(Kt,{value:z,onValueChange:Se=>nt(Se),className:"w-auto",children:e.jsxs(Rt,{className:"h-9",children:[e.jsxs(He,{value:"visual",className:"text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(MN,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"可视化"]}),e.jsxs(He,{value:"source",className:"text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(AN,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码"]})]})}),e.jsxs(N,{onClick:z==="visual"?Ct:jt,disabled:c||h||!f||g,size:"sm",variant:"outline",className:"flex-1 sm:flex-none",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),c?"保存中...":h?"自动保存中...":f?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{disabled:c||h||g,size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),g?"重启中...":f?"保存并重启":"重启麦麦"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重启麦麦?"}),e.jsx(ms,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:f?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ua,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(ma,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Os,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(Es,{className:"max-w-2xl",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx($s,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx(He,{value:"windows",children:"Windows"}),e.jsx(He,{value:"macos",children:"macOS"}),e.jsx(He,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:['在"进程"或"详细信息"标签页中找到 ',e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:'右键点击并选择"结束任务"'})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"}),' 打开 Spotlight,搜索"活动监视器"']}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Is,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(N,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:f?rl:kt,children:f?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ua,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(ma,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),z==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ua,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(ma,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在后端验证格式,只有格式完全正确才能保存。",U&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(I0,{value:L,onChange:Se=>{K(Se),j(!0),U&&R(!1)},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),z==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(Kt,{defaultValue:"bot",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs(Rt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5 lg:grid-cols-10",children:[e.jsx(He,{value:"bot",className:"flex-shrink-0",children:"基本信息"}),e.jsx(He,{value:"personality",className:"flex-shrink-0",children:"人格"}),e.jsx(He,{value:"chat",className:"flex-shrink-0",children:"聊天"}),e.jsx(He,{value:"expression",className:"flex-shrink-0",children:"表达"}),e.jsx(He,{value:"features",className:"flex-shrink-0",children:"功能"}),e.jsx(He,{value:"processing",className:"flex-shrink-0",children:"处理"}),e.jsx(He,{value:"mood",className:"flex-shrink-0",children:"情绪"}),e.jsx(He,{value:"voice",className:"flex-shrink-0",children:"语音"}),e.jsx(He,{value:"lpmm",className:"flex-shrink-0",children:"知识库"}),e.jsx(He,{value:"other",className:"flex-shrink-0",children:"其他"})]})}),e.jsx(We,{value:"bot",className:"space-y-4",children:V&&e.jsx(P0,{config:V,onChange:E})}),e.jsx(We,{value:"personality",className:"space-y-4",children:B&&e.jsx(W0,{config:B,onChange:X})}),e.jsx(We,{value:"chat",className:"space-y-4",children:w&&e.jsx(ew,{config:w,onChange:D})}),e.jsx(We,{value:"expression",className:"space-y-4",children:te&&e.jsx(tw,{config:te,onChange:xe})}),e.jsx(We,{value:"features",className:"space-y-4",children:be&&ve&&Ne&&e.jsx(aw,{emojiConfig:be,memoryConfig:ve,toolConfig:Ne,onEmojiChange:ye,onMemoryChange:pe,onToolChange:y})}),e.jsx(We,{value:"processing",className:"space-y-4",children:Q&&ge&&O&&A&&e.jsx(lw,{keywordReactionConfig:Q,responsePostProcessConfig:ge,chineseTypoConfig:O,responseSplitterConfig:A,onKeywordReactionChange:oe,onResponsePostProcessChange:le,onChineseTypoChange:F,onResponseSplitterChange:W})}),e.jsx(We,{value:"mood",className:"space-y-4",children:q&&e.jsx(nw,{config:q,onChange:H})}),e.jsx(We,{value:"voice",className:"space-y-4",children:ne&&e.jsx(iw,{config:ne,onChange:S})}),e.jsx(We,{value:"lpmm",className:"space-y-4",children:me&&e.jsx(rw,{config:me,onChange:he})}),e.jsxs(We,{value:"other",className:"space-y-4",children:[_e&&e.jsx(cw,{config:_e,onChange:Me}),ss&&e.jsx(ow,{config:ss,onChange:Ie}),Rs&&e.jsx(dw,{config:Rs,onChange:qs}),ie&&e.jsx(uw,{config:ie,onChange:we})]})]})}),v&&e.jsx(Iu,{onRestartComplete:cl,onRestartFailed:ol})]})})}function P0({config:n,onChange:r}){const c=()=>{r({...n,platforms:[...n.platforms,""]})},d=g=>{r({...n,platforms:n.platforms.filter((_,v)=>v!==g)})},h=(g,_)=>{const v=[...n.platforms];v[g]=_,r({...n,platforms:v})},x=()=>{r({...n,alias_names:[...n.alias_names,""]})},f=g=>{r({...n,alias_names:n.alias_names.filter((_,v)=>v!==g)})},j=(g,_)=>{const v=[...n.alias_names];v[g]=_,r({...n,alias_names:v})};return e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"基本信息"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"platform",children:"平台"}),e.jsx(ce,{id:"platform",value:n.platform,onChange:g=>r({...n,platform:g.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ce,{id:"qq_account",value:n.qq_account,onChange:g=>r({...n,qq_account:g.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:n.nickname,onChange:g=>r({...n,nickname:g.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"其他平台账号"}),e.jsxs(N,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.platforms.map((g,_)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:g,onChange:v=>h(_,v.target.value),placeholder:"wx:114514"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除平台账号 "',g||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d(_),children:"删除"})]})]})]})]},_)),n.platforms.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"别名"}),e.jsxs(N,{onClick:x,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.alias_names.map((g,_)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:g,onChange:v=>j(_,v.target.value),placeholder:"小麦"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除别名 "',g||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>f(_),children:"删除"})]})]})]})]},_)),n.alias_names.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无别名"})]})]})]})]})})}function W0({config:n,onChange:r}){const c=()=>{r({...n,states:[...n.states,""]})},d=x=>{r({...n,states:n.states.filter((f,j)=>j!==x)})},h=(x,f)=>{const j=[...n.states];j[x]=f,r({...n,states:j})};return e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"人格设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"personality",children:"人格特质"}),e.jsx(Us,{id:"personality",value:n.personality,onChange:x=>r({...n,personality:x.target.value}),placeholder:"描述人格特质和身份特征(建议120字以内)",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"建议120字以内,描述人格特质和身份特征"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(Us,{id:"reply_style",value:n.reply_style,onChange:x=>r({...n,reply_style:x.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"interest",children:"兴趣"}),e.jsx(Us,{id:"interest",value:n.interest,onChange:x=>r({...n,interest:x.target.value}),placeholder:"会影响麦麦对什么话题进行回复",rows:2})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(Us,{id:"plan_style",value:n.plan_style,onChange:x=>r({...n,plan_style:x.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(Us,{id:"visual_style",value:n.visual_style,onChange:x=>r({...n,visual_style:x.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(Us,{id:"private_plan_style",value:n.private_plan_style,onChange:x=>r({...n,private_plan_style:x.target.value}),placeholder:"私聊的说话规则和行为风格",rows:4})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"状态列表(人格多样性)"}),e.jsxs(N,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加状态"]})]}),e.jsx("div",{className:"space-y-2",children:n.states.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Us,{value:x,onChange:j=>h(f,j.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsx(ms,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d(f),children:"删除"})]})]})]})]},f))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"state_probability",children:"状态替换概率"}),e.jsx(ce,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:n.state_probability,onChange:x=>r({...n,state_probability:parseFloat(x.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时替换 personality 的概率(0.0-1.0)"})]})]})]})})}function ew({config:n,onChange:r}){const c=()=>{r({...n,talk_value_rules:[...n.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},d=j=>{r({...n,talk_value_rules:n.talk_value_rules.filter((g,_)=>_!==j)})},h=(j,g,_)=>{const v=[...n.talk_value_rules];v[j]={...v[j],[g]:_},r({...n,talk_value_rules:v})},x=({value:j,onChange:g})=>{const[_,v]=u.useState("00"),[k,z]=u.useState("00"),[T,L]=u.useState("23"),[K,U]=u.useState("59");u.useEffect(()=>{const ee=j.split("-");if(ee.length===2){const[V,E]=ee,[B,X]=V.split(":"),[w,D]=E.split(":");B&&v(B.padStart(2,"0")),X&&z(X.padStart(2,"0")),w&&L(w.padStart(2,"0")),D&&U(D.padStart(2,"0"))}},[j]);const R=(ee,V,E,B)=>{const X=`${ee}:${V}-${E}:${B}`;g(X)};return e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"}),j||"选择时间段"]})}),e.jsx(Na,{className:"w-80",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"开始时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"小时"}),e.jsxs(Qe,{value:_,onValueChange:ee=>{v(ee),R(ee,k,T,K)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:Array.from({length:24},(ee,V)=>V).map(ee=>e.jsx(ue,{value:ee.toString().padStart(2,"0"),children:ee.toString().padStart(2,"0")},ee))})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"分钟"}),e.jsxs(Qe,{value:k,onValueChange:ee=>{z(ee),R(_,ee,T,K)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:Array.from({length:60},(ee,V)=>V).map(ee=>e.jsx(ue,{value:ee.toString().padStart(2,"0"),children:ee.toString().padStart(2,"0")},ee))})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"结束时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"小时"}),e.jsxs(Qe,{value:T,onValueChange:ee=>{L(ee),R(_,k,ee,K)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:Array.from({length:24},(ee,V)=>V).map(ee=>e.jsx(ue,{value:ee.toString().padStart(2,"0"),children:ee.toString().padStart(2,"0")},ee))})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs",children:"分钟"}),e.jsxs(Qe,{value:K,onValueChange:ee=>{U(ee),R(_,k,T,ee)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:Array.from({length:60},(ee,V)=>V).map(ee=>e.jsx(ue,{value:ee.toString().padStart(2,"0"),children:ee.toString().padStart(2,"0")},ee))})]})]})]})]})]})})]})},f=({rule:j})=>{const g=`{ target = "${j.target}", time = "${j.time}", value = ${j.value.toFixed(1)} }`;return e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Na,{className:"w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:g}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"聊天设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(ce,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:n.talk_value,onChange:j=>r({...n,talk_value:parseFloat(j.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越小越沉默,范围 0-1"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"mentioned_bot_reply",checked:n.mentioned_bot_reply,onCheckedChange:j=>r({...n,mentioned_bot_reply:j})}),e.jsx(b,{htmlFor:"mentioned_bot_reply",className:"cursor-pointer",children:"启用提及必回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(ce,{id:"max_context_size",type:"number",min:"1",value:n.max_context_size,onChange:j=>r({...n,max_context_size:parseInt(j.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ce,{id:"planner_smooth",type:"number",step:"1",min:"0",value:n.planner_smooth,onChange:j=>r({...n,planner_smooth:parseFloat(j.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-5,0 为关闭"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"enable_talk_value_rules",checked:n.enable_talk_value_rules,onCheckedChange:j=>r({...n,enable_talk_value_rules:j})}),e.jsx(b,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"include_planner_reasoning",checked:n.include_planner_reasoning,onCheckedChange:j=>r({...n,include_planner_reasoning:j})}),e.jsx(b,{htmlFor:"include_planner_reasoning",className:"cursor-pointer",children:"将 planner 推理加入 replyer"})]})]})]}),n.enable_talk_value_rules&&e.jsxs("div",{className:"border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"动态发言频率规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"按时段或聊天流ID调整发言频率,优先匹配具体聊天,再匹配全局规则"})]}),e.jsxs(N,{onClick:c,size:"sm",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),n.talk_value_rules&&n.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:n.talk_value_rules.map((j,g)=>e.jsxs("div",{className:"rounded-lg border p-4 bg-muted/50 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["规则 #",g+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{rule:j}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{variant:"ghost",size:"sm",children:e.jsx(ns,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除规则 #",g+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d(g),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Qe,{value:j.target===""?"global":"specific",onValueChange:_=>{_==="global"?h(g,"target",""):h(g,"target","qq::group")},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"global",children:"全局配置"}),e.jsx(ue,{value:"specific",children:"详细配置"})]})]})]}),j.target!==""&&(()=>{const _=j.target.split(":"),v=_[0]||"qq",k=_[1]||"",z=_[2]||"group";return e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Qe,{value:v,onValueChange:T=>{h(g,"target",`${T}:${k}:${z}`)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"qq",children:"QQ"}),e.jsx(ue,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:k,onChange:T=>{h(g,"target",`${v}:${T.target.value}:${z}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Qe,{value:z,onValueChange:T=>{h(g,"target",`${v}:${k}:${T}`)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"group",children:"群组(group)"}),e.jsx(ue,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",j.target||"(未设置)"]})]})})(),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(x,{value:j.time,onChange:_=>h(g,"time",_)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持跨夜区间,例如 23:00-02:00"})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:`rule-value-${g}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(ce,{id:`rule-value-${g}`,type:"number",step:"0.01",min:"0.01",max:"1",value:j.value,onChange:_=>{const v=parseFloat(_.target.value);isNaN(v)||h(g,"value",Math.max(.01,Math.min(1,v)))},className:"w-20 h-8 text-xs"})]}),e.jsx(za,{value:[j.value],onValueChange:_=>h(g,"value",_[0]),min:.01,max:1,step:.01,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.01 (极少发言)"}),e.jsx("span",{children:"0.5"}),e.jsx("span",{children:"1.0 (正常)"})]})]})]})]},g))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:'暂无规则,点击"添加规则"按钮创建'})}),e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsx("h5",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"📝 规则说明"}),e.jsxs("ul",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 为空"}),":全局规则,对所有聊天生效"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 指定"}),":仅对特定聊天流生效(格式:platform:id:type)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"优先级"}),":先匹配具体聊天流规则,再匹配全局规则"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"时间支持跨夜"}),":例如 23:00-02:00 表示晚上11点到次日凌晨2点"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"数值范围"}),":建议 0-1,0 表示完全沉默,1 表示正常发言"]})]})]})]})]})}function sw({member:n,groupIndex:r,memberIndex:c,availableChatIds:d,onUpdate:h,onRemove:x}){const f=d.includes(n)||n==="*",[j,g]=u.useState(!f);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:j?e.jsxs(e.Fragment,{children:[e.jsx(ce,{value:n,onChange:_=>h(r,c,_.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),d.length>0&&e.jsx(N,{size:"sm",variant:"outline",onClick:()=>g(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Qe,{value:n,onValueChange:_=>h(r,c,_),children:[e.jsx(Ge,{className:"flex-1",children:e.jsx($e,{placeholder:"选择聊天流"})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"*",children:"* (全局共享)"}),d.map((_,v)=>e.jsx(ue,{value:_,children:_},v))]})]}),e.jsx(N,{size:"sm",variant:"outline",onClick:()=>g(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除组成员 "',n||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>x(r,c),children:"删除"})]})]})]})]})}function tw({config:n,onChange:r}){const c=()=>{r({...n,learning_list:[...n.learning_list,["","enable","enable","1.0"]]})},d=k=>{r({...n,learning_list:n.learning_list.filter((z,T)=>T!==k)})},h=(k,z,T)=>{const L=[...n.learning_list];L[k][z]=T,r({...n,learning_list:L})},x=({rule:k})=>{const z=`["${k[0]}", "${k[1]}", "${k[2]}", "${k[3]}"]`;return e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Na,{className:"w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:z}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},f=()=>{r({...n,expression_groups:[...n.expression_groups,[]]})},j=k=>{r({...n,expression_groups:n.expression_groups.filter((z,T)=>T!==k)})},g=k=>{const z=[...n.expression_groups];z[k]=[...z[k],""],r({...n,expression_groups:z})},_=(k,z)=>{const T=[...n.expression_groups];T[k]=T[k].filter((L,K)=>K!==z),r({...n,expression_groups:T})},v=(k,z,T)=>{const L=[...n.expression_groups];L[k][z]=T,r({...n,expression_groups:L})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达学习配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置麦麦如何学习和使用表达方式"})]}),e.jsxs(N,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.learning_list.map((k,z)=>{const T=n.learning_list.some((V,E)=>E!==z&&V[0]===""),L=k[0]==="",K=k[0].split(":"),U=K[0]||"qq",R=K[1]||"",ee=K[2]||"group";return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["规则 ",z+1," ",L&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{rule:k}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除学习规则 ",z+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d(z),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Qe,{value:L?"global":"specific",onValueChange:V=>{V==="global"?h(z,0,""):h(z,0,"qq::group")},disabled:T&&!L,children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"global",children:"全局配置"}),e.jsx(ue,{value:"specific",disabled:T&&!L,children:"详细配置"})]})]}),T&&!L&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!L&&e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Qe,{value:U,onValueChange:V=>{h(z,0,`${V}:${R}:${ee}`)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"qq",children:"QQ"}),e.jsx(ue,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:R,onChange:V=>{h(z,0,`${U}:${V.target.value}:${ee}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Qe,{value:ee,onValueChange:V=>{h(z,0,`${U}:${R}:${V}`)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"group",children:"群组(group)"}),e.jsx(ue,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",k[0]||"(未设置)"]})]}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(qe,{checked:k[1]==="enable",onCheckedChange:V=>h(z,1,V?"enable":"disable")})]})}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(qe,{checked:k[2]==="enable",onCheckedChange:V=>h(z,2,V?"enable":"disable")})]})}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-xs font-medium",children:"学习强度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"5",value:k[3],onChange:V=>{const E=parseFloat(V.target.value);isNaN(E)||h(z,3,Math.max(0,Math.min(5,E)).toFixed(1))},className:"w-20 h-8 text-xs"})]}),e.jsx(za,{value:[parseFloat(k[3])||1],onValueChange:V=>h(z,3,V[0].toFixed(1)),min:0,max:5,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0 (不学习)"}),e.jsx("span",{children:"2.5"}),e.jsx("span",{children:"5.0 (快速学习)"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响学习频率,最短学习间隔 = 300/学习强度(秒)"})]})]})]},z)}),n.learning_list.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无学习规则,点击"添加规则"开始配置'})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达共享组配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置不同聊天流之间如何共享学到的表达方式"})]}),e.jsxs(N,{onClick:f,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.expression_groups.map((k,z)=>{const T=n.learning_list.map(L=>L[0]).filter(L=>L!=="");return e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["共享组 ",z+1,k.length===1&&k[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{onClick:()=>g(z),size:"sm",variant:"outline",children:e.jsx(gt,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除共享组 ",z+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>j(z),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:k.map((L,K)=>e.jsx(sw,{member:L,groupIndex:z,memberIndex:K,availableChatIds:T,onUpdate:v,onRemove:_},`${z}-${K}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},z)}),n.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})}function aw({emojiConfig:n,memoryConfig:r,toolConfig:c,onEmojiChange:d,onMemoryChange:h,onToolChange:x}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"工具设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"enable_tool",checked:c.enable_tool,onCheckedChange:f=>x({...c,enable_tool:f})}),e.jsx(b,{htmlFor:"enable_tool",className:"cursor-pointer",children:"启用工具系统"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"允许麦麦使用各种工具来增强功能"})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"记忆设置"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(ce,{id:"max_agent_iterations",type:"number",min:"1",value:r.max_agent_iterations,onChange:f=>h({...r,max_agent_iterations:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1(不深入思考)"})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"表情包设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsx(ce,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:n.emoji_chance,onChange:f=>d({...n,emoji_chance:parseFloat(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"范围 0-1,越大越容易发送表情包"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",value:n.max_reg_num,onChange:f=>d({...n,max_reg_num:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦最多可以注册的表情包数量"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",value:n.check_interval,onChange:f=>d({...n,check_interval:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包(注册、破损、删除)的时间间隔"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"do_replace",checked:n.do_replace,onCheckedChange:f=>d({...n,do_replace:f})}),e.jsx(b,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:f=>d({...n,steal_emoji:f})}),e.jsx(b,{htmlFor:"steal_emoji",className:"cursor-pointer",children:"偷取表情包"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"允许麦麦将看到的表情包据为己有"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:f=>d({...n,content_filtration:f})}),e.jsx(b,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),n.content_filtration&&e.jsxs("div",{className:"grid gap-2 pl-6 border-l-2 border-primary/20",children:[e.jsx(b,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",value:n.filtration_prompt,onChange:f=>d({...n,filtration_prompt:f.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}function lw({keywordReactionConfig:n,responsePostProcessConfig:r,chineseTypoConfig:c,responseSplitterConfig:d,onKeywordReactionChange:h,onResponsePostProcessChange:x,onChineseTypoChange:f,onResponseSplitterChange:j}){const g=()=>{h({...n,regex_rules:[...n.regex_rules,{regex:[""],reaction:""}]})},_=E=>{h({...n,regex_rules:n.regex_rules.filter((B,X)=>X!==E)})},v=(E,B,X)=>{const w=[...n.regex_rules];B==="regex"&&typeof X=="string"?w[E]={...w[E],regex:[X]}:B==="reaction"&&typeof X=="string"&&(w[E]={...w[E],reaction:X}),h({...n,regex_rules:w})},k=({regex:E,reaction:B,onRegexChange:X,onReactionChange:w})=>{const[D,te]=u.useState(!1),[xe,be]=u.useState(""),[ye,ve]=u.useState(null),[pe,Ne]=u.useState(""),[y,q]=u.useState({}),[H,ne]=u.useState(""),S=u.useRef(null),[me,he]=u.useState("build"),Q=O=>O.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),oe=(O,F=0)=>{const A=S.current;if(!A)return;const W=A.selectionStart||0,_e=A.selectionEnd||0,Me=E.substring(0,W)+O+E.substring(_e);X(Me),setTimeout(()=>{const ss=W+O.length+F;A.setSelectionRange(ss,ss),A.focus()},0)};u.useEffect(()=>{if(!E||!xe){ve(null),q({}),ne(B),Ne("");return}try{const O=Q(E),F=new RegExp(O,"g"),A=xe.match(F);ve(A),Ne("");const _e=new RegExp(O).exec(xe);if(_e&&_e.groups){q(_e.groups);let Me=B;Object.entries(_e.groups).forEach(([ss,Ie])=>{Me=Me.replace(new RegExp(`\\[${ss}\\]`,"g"),Ie||"")}),ne(Me)}else q({}),ne(B)}catch(O){Ne(O.message),ve(null),q({}),ne(B)}},[E,xe,B]);const ge=()=>{if(!xe||!ye||ye.length===0)return e.jsx("span",{className:"text-muted-foreground",children:xe||"请输入测试文本"});try{const O=Q(E),F=new RegExp(O,"g");let A=0;const W=[];let _e;for(;(_e=F.exec(xe))!==null;)_e.index>A&&W.push(e.jsx("span",{children:xe.substring(A,_e.index)},`text-${A}`)),W.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:_e[0]},`match-${_e.index}`)),A=_e.index+_e[0].length;return A)",desc:"Python风格命名捕获组",moveCursor:-1},{label:"非捕获组",pattern:"(?:)",desc:"分组但不保存匹配结果",moveCursor:-1}]},{category:"字符类",items:[{label:"字符集",pattern:"[]",desc:"匹配括号内的任意字符",moveCursor:-1},{label:"排除字符",pattern:"[^]",desc:"匹配不在括号内的字符",moveCursor:-1},{label:"范围",pattern:"[a-z]",desc:"匹配a到z的字符"},{label:"中文字符",pattern:"[\\u4e00-\\u9fa5]",desc:"匹配中文汉字"}]},{category:"常用模板",items:[{label:"捕获词语",pattern:"(?P\\S+)",desc:"捕获一个词语"},{label:"捕获句子",pattern:"(?P.+)",desc:"捕获整个句子"},{label:"捕获数字",pattern:"(?P\\d+)",desc:"捕获一个或多个数字"},{label:"可选词语",pattern:"(?:词语1|词语2)",desc:"匹配多个可选项之一"}]}];return e.jsxs(Os,{open:D,onOpenChange:te,children:[e.jsx(ni,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",children:[e.jsx(ao,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(Es,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"正则表达式编辑器"}),e.jsx($s,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(es,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(Kt,{value:me,onValueChange:O=>he(O),className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-2",children:[e.jsx(He,{value:"build",children:"🔧 构建器"}),e.jsx(He,{value:"test",children:"🧪 测试器"})]}),e.jsxs(We,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ce,{ref:S,value:E,onChange:O=>X(O.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(Us,{value:B,onChange:O=>w(O.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[le.map(O=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:O.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:O.items.map(F=>e.jsx(N,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>oe(F.pattern,F.moveCursor||0),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("span",{className:"text-xs font-medium",children:F.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:F.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:F.desc})]})},F.label))})]},O.category)),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:"完整示例模板"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("^(?P\\S{1,20})是这样的$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:["^(?P\\S","{1,20}",")是这样的$"]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「某事物是这样的」并捕获事物名称"})]})}),e.jsx(N,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「我没要求你做某事」并捕获具体行为"})]})}),e.jsx(N,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>X("(?P.+?)(?:是|为什么|怎么)"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?P.+?)(?:是|为什么|怎么)"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"捕获问题主题词"})]})})]})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 使用提示"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"点击输入框设置光标位置,然后点击按钮插入模式"}),e.jsxs("li",{children:["命名捕获组格式:",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"(?P<名称>模式)"})]}),e.jsxs("li",{children:["在 reaction 中使用 ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"[名称]"})," 引用捕获的内容"]}),e.jsx("li",{children:"切换到测试器标签页验证正则表达式效果"})]})]})]}),e.jsxs(We,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:E||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(Us,{id:"test-text",value:xe,onChange:O=>be(O.target.value),placeholder:`在此输入要测试的文本... -例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),pe&&e.jsxs("div",{className:"rounded-md bg-destructive/10 border border-destructive/20 p-3",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:"正则表达式错误"}),e.jsx("p",{className:"text-xs text-destructive/80 mt-1",children:pe})]}),!pe&&xe&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:ye&&ye.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsxs("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["匹配成功 (",ye.length," 处)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-400"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"无匹配"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(es,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:ge()})})]}),Object.keys(y).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(es,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(y).map(([O,F])=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"font-mono font-semibold text-primary min-w-[80px]",children:["[",O,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:F})]},O))})})]}),Object.keys(y).length>0&&B&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(es,{className:"h-48 rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3",children:e.jsx("div",{className:"text-sm break-words",children:H})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"reaction 中的 [name] 已被替换为对应的捕获组值"})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 测试说明"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"匹配的文本会以黄色背景高亮显示"}),e.jsx("li",{children:"命名捕获组的值会显示在下方列表中"}),e.jsx("li",{children:"Reaction 替换预览显示最终生成的反应内容"}),e.jsx("li",{children:"如需修改正则,切换回构建器标签页"})]})]})]})]})})]})]})},z=()=>{h({...n,keyword_rules:[...n.keyword_rules,{keywords:[],reaction:""}]})},T=E=>{h({...n,keyword_rules:n.keyword_rules.filter((B,X)=>X!==E)})},L=(E,B,X)=>{const w=[...n.keyword_rules];typeof X=="string"&&(w[E]={...w[E],reaction:X}),h({...n,keyword_rules:w})},K=E=>{const B=[...n.keyword_rules];B[E]={...B[E],keywords:[...B[E].keywords||[],""]},h({...n,keyword_rules:B})},U=(E,B)=>{const X=[...n.keyword_rules];X[E]={...X[E],keywords:(X[E].keywords||[]).filter((w,D)=>D!==B)},h({...n,keyword_rules:X})},R=(E,B,X)=>{const w=[...n.keyword_rules],D=[...w[E].keywords||[]];D[B]=X,w[E]={...w[E],keywords:D},h({...n,keyword_rules:w})},ee=({rule:E})=>{const B=`{ regex = [${(E.regex||[]).map(X=>`"${X}"`).join(", ")}], reaction = "${E.reaction}" }`;return e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Na,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(es,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:B})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},V=({rule:E})=>{const B=`[[keyword_reaction.keyword_rules]] -keywords = [${(E.keywords||[]).map(X=>`"${X}"`).join(", ")}] -reaction = "${E.reaction}"`;return e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Na,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(es,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:B})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"关键词反应配置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置触发特定反应的关键词和正则表达式规则"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"正则表达式规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用正则表达式匹配消息内容"})]}),e.jsxs(N,{onClick:g,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.regex_rules.map((E,B)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["正则规则 ",B+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{regex:E.regex&&E.regex[0]||"",reaction:E.reaction,onRegexChange:X=>v(B,"regex",X),onReactionChange:X=>v(B,"reaction",X)}),e.jsx(ee,{rule:E}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除正则规则 ",B+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>_(B),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"正则表达式(Python 语法)"}),e.jsx(ce,{value:E.regex&&E.regex[0]||"",onChange:X=>v(B,"regex",X.target.value),placeholder:"例如:^(?P\\\\S{1,20})是这样的$ (点击正则编辑器按钮可视化构建)",className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'支持命名捕获组 (?Ppattern),可在 reaction 中使用 [name] 引用。点击"正则编辑器"可视化构建和测试!'})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Us,{value:E.reaction,onChange:X=>v(B,"reaction",X.target.value),placeholder:`触发后麦麦的反应... -可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},B)),n.regex_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无正则规则,点击"添加正则规则"开始配置'})]})]}),e.jsxs("div",{className:"space-y-4 border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"关键词规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用关键词列表匹配消息内容"})]}),e.jsxs(N,{onClick:z,size:"sm",variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.keyword_rules.map((E,B)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["关键词规则 ",B+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{rule:E}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除关键词规则 ",B+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>T(B),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(N,{onClick:()=>K(B),size:"sm",variant:"ghost",children:[e.jsx(gt,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(E.keywords||[]).map((X,w)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:X,onChange:D=>R(B,w,D.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(N,{onClick:()=>U(B,w),size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})]},w)),(!E.keywords||E.keywords.length===0)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:'暂无关键词,点击"添加关键词"开始配置'})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Us,{value:E.reaction,onChange:X=>L(B,"reaction",X.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},B)),n.keyword_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无关键词规则,点击"添加关键词规则"开始配置'})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"回复后处理配置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"enable_response_post_process",checked:r.enable_response_post_process,onCheckedChange:E=>x({...r,enable_response_post_process:E})}),e.jsx(b,{htmlFor:"enable_response_post_process",className:"cursor-pointer",children:"启用回复后处理"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"包括错别字生成器和回复分割器"})]}),r.enable_response_post_process&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(qe,{id:"enable_chinese_typo",checked:c.enable,onCheckedChange:E=>f({...c,enable:E})}),e.jsx(b,{htmlFor:"enable_chinese_typo",className:"cursor-pointer font-semibold",children:"中文错别字生成器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"为回复添加随机错别字,让麦麦的回复更自然"}),c.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"error_rate",className:"text-xs font-medium",children:"单字替换概率"}),e.jsx(ce,{id:"error_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.error_rate,onChange:E=>f({...c,error_rate:parseFloat(E.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(ce,{id:"min_freq",type:"number",min:"0",value:c.min_freq,onChange:E=>f({...c,min_freq:parseInt(E.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"tone_error_rate",className:"text-xs font-medium",children:"声调错误概率"}),e.jsx(ce,{id:"tone_error_rate",type:"number",step:"0.01",min:"0",max:"1",value:c.tone_error_rate,onChange:E=>f({...c,tone_error_rate:parseFloat(E.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"word_replace_rate",className:"text-xs font-medium",children:"整词替换概率"}),e.jsx(ce,{id:"word_replace_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.word_replace_rate,onChange:E=>f({...c,word_replace_rate:parseFloat(E.target.value)})})]})]})]})}),e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(qe,{id:"enable_response_splitter",checked:d.enable,onCheckedChange:E=>j({...d,enable:E})}),e.jsx(b,{htmlFor:"enable_response_splitter",className:"cursor-pointer font-semibold",children:"回复分割器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"控制回复的长度和句子数量"}),d.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(ce,{id:"max_length",type:"number",min:"1",value:d.max_length,onChange:E=>j({...d,max_length:parseInt(E.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(ce,{id:"max_sentence_num",type:"number",min:"1",value:d.max_sentence_num,onChange:E=>j({...d,max_sentence_num:parseInt(E.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大句子数量"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"enable_kaomoji_protection",checked:d.enable_kaomoji_protection,onCheckedChange:E=>j({...d,enable_kaomoji_protection:E})}),e.jsx(b,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"enable_overflow_return_all",checked:d.enable_overflow_return_all,onCheckedChange:E=>j({...d,enable_overflow_return_all:E})}),e.jsx(b,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}function nw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"情绪设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{checked:n.enable_mood,onCheckedChange:c=>r({...n,enable_mood:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用情绪系统"})]}),n.enable_mood&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"情绪更新阈值"}),e.jsx(ce,{type:"number",min:"1",value:n.mood_update_threshold,onChange:c=>r({...n,mood_update_threshold:parseInt(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越高,更新越慢"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"情感特征"}),e.jsx(Us,{value:n.emotion_style,onChange:c=>r({...n,emotion_style:c.target.value}),placeholder:"影响情绪的变化情况",rows:2})]})]})]})]})}function iw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"语音设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{checked:n.enable_asr,onCheckedChange:c=>r({...n,enable_asr:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用语音识别"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后麦麦可以识别语音消息,需要配置语音识别模型"})]})}function rw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{checked:n.enable,onCheckedChange:c=>r({...n,enable:c})}),e.jsx(b,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),n.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"LPMM 模式"}),e.jsxs(Qe,{value:n.lpmm_mode,onValueChange:c=>r({...n,lpmm_mode:c}),children:[e.jsx(Ge,{children:e.jsx($e,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"classic",children:"经典模式"}),e.jsx(ue,{value:"agent",children:"Agent 模式"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"同义词搜索 TopK"}),e.jsx(ce,{type:"number",min:"1",value:n.rag_synonym_search_top_k,onChange:c=>r({...n,rag_synonym_search_top_k:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"同义词阈值"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:n.rag_synonym_threshold,onChange:c=>r({...n,rag_synonym_threshold:parseFloat(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"实体提取线程数"}),e.jsx(ce,{type:"number",min:"1",value:n.info_extraction_workers,onChange:c=>r({...n,info_extraction_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"嵌入向量维度"}),e.jsx(ce,{type:"number",min:"1",value:n.embedding_dimension,onChange:c=>r({...n,embedding_dimension:parseInt(c.target.value)})})]})]})]})]})]})}function cw({config:n,onChange:r}){const[c,d]=u.useState(""),[h,x]=u.useState("WARNING"),f=()=>{c&&!n.suppress_libraries.includes(c)&&(r({...n,suppress_libraries:[...n.suppress_libraries,c]}),d(""))},j=T=>{r({...n,suppress_libraries:n.suppress_libraries.filter(L=>L!==T)})},g=()=>{c&&!n.library_log_levels[c]&&(r({...n,library_log_levels:{...n.library_log_levels,[c]:h}}),d(""),x("WARNING"))},_=T=>{const L={...n.library_log_levels};delete L[T],r({...n,library_log_levels:L})},v=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],k=["FULL","compact","lite"],z=["none","title","full"];return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"日志配置"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日期格式"}),e.jsx(ce,{value:n.date_style,onChange:T=>r({...n,date_style:T.target.value}),placeholder:"例如: m-d H:i:s"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"m=月, d=日, H=时, i=分, s=秒"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日志级别样式"}),e.jsxs(Qe,{value:n.log_level_style,onValueChange:T=>r({...n,log_level_style:T}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:k.map(T=>e.jsx(ue,{value:T,children:T},T))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"日志文本颜色"}),e.jsxs(Qe,{value:n.color_text,onValueChange:T=>r({...n,color_text:T}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:z.map(T=>e.jsx(ue,{value:T,children:T},T))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"全局日志级别"}),e.jsxs(Qe,{value:n.log_level,onValueChange:T=>r({...n,log_level:T}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:v.map(T=>e.jsx(ue,{value:T,children:T},T))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"控制台日志级别"}),e.jsxs(Qe,{value:n.console_log_level,onValueChange:T=>r({...n,console_log_level:T}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:v.map(T=>e.jsx(ue,{value:T,children:T},T))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"文件日志级别"}),e.jsxs(Qe,{value:n.file_log_level,onValueChange:T=>r({...n,file_log_level:T}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsx(Ve,{children:v.map(T=>e.jsx(ue,{value:T,children:T},T))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:T=>d(T.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),f())}}),e.jsx(N,{onClick:f,size:"sm",className:"flex-shrink-0",children:e.jsx(gt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.suppress_libraries.map(T=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-3 py-1 rounded-md",children:[e.jsx("span",{className:"text-sm",children:T}),e.jsx(N,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>j(T),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},T))})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:T=>d(T.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(Qe,{value:h,onValueChange:x,children:[e.jsx(Ge,{className:"w-32",children:e.jsx($e,{})}),e.jsx(Ve,{children:v.map(T=>e.jsx(ue,{value:T,children:T},T))})]}),e.jsx(N,{onClick:g,size:"sm",children:e.jsx(gt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.library_log_levels).map(([T,L])=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-medium",children:T}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:L}),e.jsx(N,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>_(T),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},T))})]})]})}function ow({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"调试配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(qe,{checked:n.show_prompt,onCheckedChange:c=>r({...n,show_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(qe,{checked:n.show_replyer_prompt,onCheckedChange:c=>r({...n,show_replyer_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(qe,{checked:n.show_replyer_reasoning,onCheckedChange:c=>r({...n,show_replyer_reasoning:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(qe,{checked:n.show_jargon_prompt,onCheckedChange:c=>r({...n,show_jargon_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示记忆检索 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示记忆检索相关的提示词"})]}),e.jsx(qe,{checked:n.show_memory_prompt,onCheckedChange:c=>r({...n,show_memory_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 Planner Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 Planner 的提示词和原始返回结果"})]}),e.jsx(qe,{checked:n.show_planner_prompt,onCheckedChange:c=>r({...n,show_planner_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"显示 LPMM 相关文段"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 LPMM 知识库找到的相关文段日志"})]}),e.jsx(qe,{checked:n.show_lpmm_paragraph,onCheckedChange:c=>r({...n,show_lpmm_paragraph:c})})]})]})]})}function dw({config:n,onChange:r}){const[c,d]=u.useState(""),h=()=>{c&&!n.auth_token.includes(c)&&(r({...n,auth_token:[...n.auth_token,c]}),d(""))},x=f=>{r({...n,auth_token:n.auth_token.filter((j,g)=>g!==f)})};return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"MaimMessage 服务配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"启用自定义服务器"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否使用自定义的 MaimMessage 服务器"})]}),e.jsx(qe,{checked:n.use_custom,onCheckedChange:f=>r({...n,use_custom:f})})]}),n.use_custom&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"主机地址"}),e.jsx(ce,{value:n.host,onChange:f=>r({...n,host:f.target.value}),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"端口号"}),e.jsx(ce,{type:"number",value:n.port,onChange:f=>r({...n,port:parseInt(f.target.value)}),placeholder:"8090"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"连接模式"}),e.jsxs(Qe,{value:n.mode,onValueChange:f=>r({...n,mode:f}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"ws",children:"WebSocket (ws)"}),e.jsx(ue,{value:"tcp",children:"TCP"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{checked:n.use_wss,onCheckedChange:f=>r({...n,use_wss:f}),disabled:n.mode!=="ws"}),e.jsx(b,{children:"使用 WSS 安全连接"})]})]}),n.use_wss&&n.mode==="ws"&&e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"SSL 证书文件路径"}),e.jsx(ce,{value:n.cert_file,onChange:f=>r({...n,cert_file:f.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"SSL 密钥文件路径"}),e.jsx(ce,{value:n.key_file,onChange:f=>r({...n,key_file:f.target.value}),placeholder:"key.pem"})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"mb-2 block",children:"认证令牌"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"用于 API 验证,为空则不启用验证"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:f=>d(f.target.value),placeholder:"输入认证令牌",onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}}),e.jsx(N,{onClick:h,size:"sm",children:e.jsx(gt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:n.auth_token.map((f,j)=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-mono",children:f}),e.jsx(N,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>x(j),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},j))})]})]})}function uw({config:n,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"统计信息"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(qe,{checked:n.enable,onCheckedChange:c=>r({...n,enable:c})})]})]})}const ii=u.forwardRef(({className:n,...r},c)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:c,className:$("w-full caption-bottom text-sm",n),...r})}));ii.displayName="Table";const ri=u.forwardRef(({className:n,...r},c)=>e.jsx("thead",{ref:c,className:$("[&_tr]:border-b",n),...r}));ri.displayName="TableHeader";const ci=u.forwardRef(({className:n,...r},c)=>e.jsx("tbody",{ref:c,className:$("[&_tr:last-child]:border-0",n),...r}));ci.displayName="TableBody";const mw=u.forwardRef(({className:n,...r},c)=>e.jsx("tfoot",{ref:c,className:$("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n),...r}));mw.displayName="TableFooter";const pt=u.forwardRef(({className:n,...r},c)=>e.jsx("tr",{ref:c,className:$("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n),...r}));pt.displayName="TableRow";const ls=u.forwardRef(({className:n,...r},c)=>e.jsx("th",{ref:c,className:$("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...r}));ls.displayName="TableHead";const Ye=u.forwardRef(({className:n,...r},c)=>e.jsx("td",{ref:c,className:$("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...r}));Ye.displayName="TableCell";const hw=u.forwardRef(({className:n,...r},c)=>e.jsx("caption",{ref:c,className:$("mt-4 text-sm text-muted-foreground",n),...r}));hw.displayName="TableCaption";const oo=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt,{ref:c,className:$("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...r}));oo.displayName=Lt.displayName;const uo=u.forwardRef(({className:n,...r},c)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(St,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Lt.Input,{ref:c,className:$("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",n),...r})]}));uo.displayName=Lt.Input.displayName;const mo=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.List,{ref:c,className:$("max-h-[300px] overflow-y-auto overflow-x-hidden",n),...r}));mo.displayName=Lt.List.displayName;const ho=u.forwardRef((n,r)=>e.jsx(Lt.Empty,{ref:r,className:"py-6 text-center text-sm",...n}));ho.displayName=Lt.Empty.displayName;const vr=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Group,{ref:c,className:$("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",n),...r}));vr.displayName=Lt.Group.displayName;const xw=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Separator,{ref:c,className:$("-mx-1 h-px bg-border",n),...r}));xw.displayName=Lt.Separator.displayName;const yr=u.forwardRef(({className:n,...r},c)=>e.jsx(Lt.Item,{ref:c,className:$("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n),...r}));yr.displayName=Lt.Item.displayName;const yt=u.forwardRef(({className:n,...r},c)=>e.jsx(rg,{ref:c,className:$("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...r,children:e.jsx(fN,{className:$("grid place-content-center text-current"),children:e.jsx(ha,{className:"h-4 w-4"})})}));yt.displayName=rg.displayName;const Ug=u.createContext(null),Bg="maibot-completed-tours";function fw(){try{const n=localStorage.getItem(Bg);return n?new Set(JSON.parse(n)):new Set}catch{return new Set}}function cp(n){localStorage.setItem(Bg,JSON.stringify([...n]))}function pw({children:n}){const[r,c]=u.useState({activeTourId:null,stepIndex:0,isRunning:!1}),d=u.useRef(new Map),[,h]=u.useState(0),[x,f]=u.useState(fw),j=u.useCallback((V,E)=>{d.current.set(V,E),h(B=>B+1)},[]),g=u.useCallback(V=>{d.current.delete(V),c(E=>E.activeTourId===V?{...E,activeTourId:null,isRunning:!1,stepIndex:0}:E)},[]),_=u.useCallback((V,E=0)=>{d.current.has(V)&&c({activeTourId:V,stepIndex:E,isRunning:!0})},[]),v=u.useCallback(()=>{c(V=>({...V,isRunning:!1}))},[]),k=u.useCallback(V=>{c(E=>({...E,stepIndex:V}))},[]),z=u.useCallback(()=>{c(V=>({...V,stepIndex:V.stepIndex+1}))},[]),T=u.useCallback(()=>{c(V=>({...V,stepIndex:Math.max(0,V.stepIndex-1)}))},[]),L=u.useCallback(()=>r.activeTourId?d.current.get(r.activeTourId)||[]:[],[r.activeTourId]),K=u.useCallback(V=>{f(E=>{const B=new Set(E);return B.add(V),cp(B),B})},[]),U=u.useCallback(V=>{const{action:E,index:B,status:X,type:w}=V,D=["finished","skipped"];if(E==="close"){c(te=>({...te,isRunning:!1,stepIndex:0}));return}D.includes(X)?c(te=>(X==="finished"&&te.activeTourId&&setTimeout(()=>K(te.activeTourId),0),{...te,isRunning:!1,stepIndex:0})):w==="step:after"&&(E==="next"?c(te=>({...te,stepIndex:B+1})):E==="prev"&&c(te=>({...te,stepIndex:B-1})))},[K]),R=u.useCallback(V=>x.has(V),[x]),ee=u.useCallback(V=>{f(E=>{const B=new Set(E);return B.delete(V),cp(B),B})},[]);return e.jsx(Ug.Provider,{value:{state:r,tours:d.current,registerTour:j,unregisterTour:g,startTour:_,stopTour:v,goToStep:k,nextStep:z,prevStep:T,getCurrentSteps:L,handleJoyrideCallback:U,isTourCompleted:R,markTourCompleted:K,resetTourCompleted:ee},children:n})}function Ju(){const n=u.useContext(Ug);if(!n)throw new Error("useTour must be used within a TourProvider");return n}const gw={options:{zIndex:1e4,primaryColor:"hsl(var(--primary))",textColor:"hsl(var(--foreground))",backgroundColor:"hsl(var(--background))",arrowColor:"hsl(var(--background))",overlayColor:"rgba(0, 0, 0, 0.5)"},tooltip:{borderRadius:"var(--radius)",padding:"1rem"},tooltipContainer:{textAlign:"left"},tooltipTitle:{fontSize:"1rem",fontWeight:600,marginBottom:"0.5rem"},tooltipContent:{fontSize:"0.875rem",padding:"0.5rem 0"},buttonNext:{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))",borderRadius:"calc(var(--radius) - 2px)",fontSize:"0.875rem",padding:"0.5rem 1rem"},buttonBack:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem",marginRight:"0.5rem"},buttonSkip:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem"},buttonClose:{color:"hsl(var(--muted-foreground))"},spotlight:{borderRadius:"var(--radius)"}},jw={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function vw(){const{state:n,getCurrentSteps:r,handleJoyrideCallback:c}=Ju(),d=r(),[h,x]=u.useState(!1),f=u.useRef(n.stepIndex),j=u.useRef(null);u.useEffect(()=>{f.current!==n.stepIndex&&(x(!1),f.current=n.stepIndex)},[n.stepIndex]),u.useEffect(()=>{if(!n.isRunning||d.length===0){x(!1);return}const v=d[n.stepIndex];if(!v){x(!1);return}const k=v.target;if(k==="body"){x(!0);return}x(!1);const z=setTimeout(()=>{const T=()=>{const R=document.querySelector(k);if(R){const ee=R.getBoundingClientRect();if(ee.width>0&&ee.height>0)return!0}return!1};if(T()){setTimeout(()=>x(!0),100);return}const L=setInterval(()=>{T()&&(clearInterval(L),setTimeout(()=>x(!0),100))},100),K=setTimeout(()=>{clearInterval(L),x(!0)},5e3),U=()=>{clearInterval(L),clearTimeout(K)};j.current=U},150);return()=>{clearTimeout(z),j.current&&(j.current(),j.current=null)}},[n.isRunning,n.stepIndex,d]);const g=u.useRef(null);if(u.useEffect(()=>{let v=document.getElementById("tour-portal-container");return v||(v=document.createElement("div"),v.id="tour-portal-container",v.style.cssText="position: fixed; top: 0; left: 0; z-index: 99999; pointer-events: none;",document.body.appendChild(v)),g.current=v,()=>{}},[]),!n.isRunning||d.length===0||!h)return null;const _=e.jsx(ib,{steps:d,stepIndex:n.stepIndex,run:n.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:c,styles:gw,locale:jw,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${n.stepIndex}`);return g.current?xy.createPortal(_,g.current):_}const ll="model-assignment-tour",Hg=[{target:"body",content:"本引导旨在帮助你配置模型提供商和对应的模型,并为麦麦的各个组件分配合适的模型。",placement:"center",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="sidebar-model-provider"]',content:'第一步,你需要配置模型提供商。模型提供商决定了你要使用谁家的模型,无论是单一厂商(如 DeepSeek),还是模型平台(如 Siliconflow),都可以在这里进行配置。点击"下一步"进入配置页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-provider-button"]',content:'点击"添加提供商"按钮,开始配置你的模型提供商。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="provider-dialog"]',content:"在这里,你可以选择你想要配置的模型提供商,填写相关信息后保存即可。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-name-input"]',content:"这里的名称是你为这个模型提供商起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-apikey-input"]',content:"这里需要填写你从模型提供商那里获取的 API 密钥,用于验证和调用模型服务。对于不同的提供商,获取 API 密钥的方式可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-url-input"]',content:"这里需要填写模型提供商的 API 访问地址,确保填写正确以便系统能够连接到模型服务。对于不同的提供商,API 地址可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-template-select"]',content:"当然,如果你不知道如何填写这些信息,很多模型提供商在这里都提供了预设的模板供你选择,选择对应的模板后,相关信息会自动填充。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-save-button"]',content:"填写完所有信息后,点击保存按钮,模型提供商就配置完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-cancel-button"]',content:"因为这次咱们什么都没有填写,所以点击取消按钮退出吧。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="sidebar-model-management"]',content:'配置好模型提供商后,接下来我们需要为麦麦添加模型并分配功能。点击"下一步"进入模型管理页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-model-button"]',content:'在为麦麦的组件分配模型之前,首先需要添加你想要分配的模型,点击"添加模型"按钮开始添加。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="model-dialog"]',content:"在这里,你可以选择你之前配置好的模型提供商,然后选择对应的模型来添加。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-name-input"]',content:"这里的模型名称是你为这个模型起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-provider-select"]',content:"在这里选择你之前配置好的模型提供商,这样系统才能知道你要添加哪个提供商的模型。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-identifier-input"]',content:"这里需要填写你想要添加的模型的标识符,不同的模型提供商可能有不同的标识符格式,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-save-button"]',content:"填写完所有信息后,点击保存按钮,模型就添加完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-cancel-button"]',content:"当然,因为这次咱们什么都没有填写,所以直接点击取消按钮退出吧,等你准备好了再来添加模型。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="tasks-tab-trigger"]',content:'最后一步,添加好模型后,切换到"为模型分配功能"标签页,为麦麦的各个组件分配合适的模型。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="task-model-select"]',content:"在这里,你可以为每个组件选择一个或多个合适的模型,选择完成后配置会自动保存。恭喜你完成了模型配置的学习!",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1}],qg={0:"/config/model",1:"/config/model",2:"/config/modelProvider",3:"/config/modelProvider",4:"/config/modelProvider",5:"/config/modelProvider",6:"/config/modelProvider",7:"/config/modelProvider",8:"/config/modelProvider",9:"/config/modelProvider",10:"/config/modelProvider",11:"/config/model",12:"/config/model",13:"/config/model",14:"/config/model",15:"/config/model",16:"/config/model",17:"/config/model",18:"/config/model",19:"/config/model"},rr=[{id:"siliconflow",name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",client_type:"openai",display_name:"硅基流动 (SiliconFlow)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"deepseek",name:"DeepSeek",base_url:"https://api.deepseek.com",client_type:"openai",display_name:"DeepSeek",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"rinkoai",name:"RinkoAI",base_url:"https://rinkoai.com/v1",client_type:"openai",display_name:"RinkoAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"zhipu",name:"ZhipuAI",base_url:"https://open.bigmodel.cn/api/paas/v4",client_type:"openai",display_name:"智谱 AI (ZhipuAI / GLM)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"moonshot",name:"Moonshot",base_url:"https://api.moonshot.cn/v1",client_type:"openai",display_name:"月之暗面 (Moonshot / Kimi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"doubao",name:"Doubao",base_url:"https://ark.cn-beijing.volces.com/api/v3",client_type:"openai",display_name:"字节豆包 (Doubao)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"alibaba",name:"Alibaba",base_url:"https://dashscope.aliyuncs.com/compatible-mode/v1",client_type:"openai",display_name:"阿里云百炼 (Alibaba Qwen)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"baichuan",name:"Baichuan",base_url:"https://api.baichuan-ai.com/v1",client_type:"openai",display_name:"百川智能 (Baichuan)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"minimax",name:"MiniMax",base_url:"https://api.minimax.chat/v1",client_type:"openai",display_name:"MiniMax (海螺 AI)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"stepfun",name:"StepFun",base_url:"https://api.stepfun.com/v1",client_type:"openai",display_name:"阶跃星辰 (StepFun)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"lingyi",name:"Lingyi",base_url:"https://api.lingyiwanwu.com/v1",client_type:"openai",display_name:"零一万物 (Lingyi / Yi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"openai",name:"OpenAI",base_url:"https://api.openai.com/v1",client_type:"openai",display_name:"OpenAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"xai",name:"xAI",base_url:"https://api.x.ai/v1",client_type:"openai",display_name:"xAI (Grok)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"anthropic",name:"Anthropic",base_url:"https://api.anthropic.com/v1",client_type:"openai",display_name:"Anthropic (Claude)"},{id:"gemini",name:"Gemini",base_url:"https://generativelanguage.googleapis.com/v1beta",client_type:"gemini",display_name:"Google Gemini",modelFetcher:{endpoint:"/models",parser:"gemini"}},{id:"cohere",name:"Cohere",base_url:"https://api.cohere.ai/v1",client_type:"openai",display_name:"Cohere"},{id:"groq",name:"Groq",base_url:"https://api.groq.com/openai/v1",client_type:"openai",display_name:"Groq",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"together",name:"Together AI",base_url:"https://api.together.xyz/v1",client_type:"openai",display_name:"Together AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"fireworks",name:"Fireworks",base_url:"https://api.fireworks.ai/inference/v1",client_type:"openai",display_name:"Fireworks AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"mistral",name:"Mistral",base_url:"https://api.mistral.ai/v1",client_type:"openai",display_name:"Mistral AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"perplexity",name:"Perplexity",base_url:"https://api.perplexity.ai",client_type:"openai",display_name:"Perplexity AI"},{id:"custom",name:"",base_url:"",client_type:"openai",display_name:"自定义"}];function op(n){return n?n.replace(/\/+$/,"").toLowerCase():""}function yw(n){if(!n)return null;const r=op(n);return rr.find(c=>c.id!=="custom"&&op(c.base_url)===r)||null}function Nw(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[g,_]=u.useState(!1),[v,k]=u.useState(!1),[z,T]=u.useState(!1),[L,K]=u.useState(!1),[U,R]=u.useState(null),[ee,V]=u.useState(null),[E,B]=u.useState("custom"),[X,w]=u.useState(!1),[D,te]=u.useState(!1),[xe,be]=u.useState(null),[ye,ve]=u.useState(!1),[pe,Ne]=u.useState(""),[y,q]=u.useState(new Set),[H,ne]=u.useState(!1),[S,me]=u.useState(1),[he,Q]=u.useState(20),[oe,ge]=u.useState(""),[le,O]=u.useState({}),[F,A]=u.useState(new Set),[W,_e]=u.useState(new Map),{toast:Me}=Bs(),ss=It(),{state:Ie,goToStep:Rs,registerTour:qs}=Ju(),ie=u.useRef(null),we=u.useRef(!0);u.useEffect(()=>{qs(ll,Hg)},[qs]),u.useEffect(()=>{if(Ie.activeTourId===ll&&Ie.isRunning){const P=qg[Ie.stepIndex];P&&!window.location.pathname.endsWith(P.replace("/config/",""))&&ss({to:P})}},[Ie.stepIndex,Ie.activeTourId,Ie.isRunning,ss]);const Ke=u.useRef(Ie.stepIndex);u.useEffect(()=>{if(Ie.activeTourId===ll&&Ie.isRunning){const P=Ke.current,je=Ie.stepIndex;P>=3&&P<=9&&je<3&&K(!1),P>=10&&je>=3&&je<=9&&(O({}),B("custom"),R({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),V(null),ve(!1),K(!0)),Ke.current=je}},[Ie.stepIndex,Ie.activeTourId,Ie.isRunning]),u.useEffect(()=>{if(Ie.activeTourId!==ll||!Ie.isRunning)return;const P=je=>{const Ae=je.target,tt=Ie.stepIndex;tt===2&&Ae.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Rs(3),300):tt===9&&Ae.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>Rs(10),300)};return document.addEventListener("click",P,!0),()=>document.removeEventListener("click",P,!0)},[Ie,Rs]),u.useEffect(()=>{Le()},[]);const Le=async()=>{try{d(!0);const P=await ei();r(P.api_providers||[]),_(!1),we.current=!1}catch(P){console.error("加载配置失败:",P)}finally{d(!1)}},st=async()=>{try{k(!0),co().catch(()=>{}),T(!0)}catch(P){console.error("重启失败:",P),T(!1),Me({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),k(!1)}},Jt=async()=>{try{x(!0),ie.current&&clearTimeout(ie.current);const P=await ei();P.api_providers=n,await io(P),_(!1),Me({title:"保存成功",description:"正在重启麦麦..."}),await st()}catch(P){console.error("保存配置失败:",P),Me({title:"保存失败",description:P.message,variant:"destructive"}),x(!1)}},bt=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Je=()=>{T(!1),k(!1),Me({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},Ue=u.useCallback(async P=>{if(!we.current)try{j(!0),await qu("api_providers",P),_(!1)}catch(je){console.error("自动保存失败:",je),_(!0)}finally{j(!1)}},[]);u.useEffect(()=>{if(!we.current)return _(!0),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{Ue(n)},2e3),()=>{ie.current&&clearTimeout(ie.current)}},[n,Ue]);const jt=async()=>{try{x(!0),ie.current&&clearTimeout(ie.current);const P=await ei();P.api_providers=n,await io(P),_(!1),Me({title:"保存成功",description:"模型提供商配置已保存"})}catch(P){console.error("保存配置失败:",P),Me({title:"保存失败",description:P.message,variant:"destructive"})}finally{x(!1)}},nt=(P,je)=>{if(O({}),P){const Ae=rr.find(tt=>tt.base_url===P.base_url&&tt.client_type===P.client_type);B(Ae?.id||"custom"),R(P)}else B("custom"),R({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});V(je),ve(!1),K(!0)},Ct=P=>{B(P),w(!1);const je=rr.find(Ae=>Ae.id===P);je&&je.id!=="custom"?R(Ae=>({...Ae,name:je.name,base_url:je.base_url,client_type:je.client_type})):je?.id==="custom"&&R(Ae=>({...Ae,name:"",base_url:"",client_type:"openai"}))},kt=u.useMemo(()=>E!=="custom",[E]),rl=async()=>{if(U?.api_key)try{await navigator.clipboard.writeText(U.api_key),Me({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{Me({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},cl=()=>{if(!U)return;const P={};if(U.name?.trim()||(P.name="请输入提供商名称"),U.base_url?.trim()||(P.base_url="请输入基础 URL"),U.api_key?.trim()||(P.api_key="请输入 API Key"),Object.keys(P).length>0){O(P);return}O({});const je={...U,max_retry:U.max_retry??2,timeout:U.timeout??30,retry_interval:U.retry_interval??10};if(ee!==null){const Ae=[...n];Ae[ee]=je,r(Ae)}else r([...n,je]);K(!1),R(null),V(null)},ol=P=>{if(!P&&U){const je={...U,max_retry:U.max_retry??2,timeout:U.timeout??30,retry_interval:U.retry_interval??10};R(je)}K(P)},Se=P=>{be(P),te(!0)},Re=()=>{if(xe!==null){const P=n.filter((je,Ae)=>Ae!==xe);r(P),Me({title:"删除成功",description:"提供商已从列表中移除"})}te(!1),be(null)},it=P=>{const je=new Set(y);je.has(P)?je.delete(P):je.add(P),q(je)},ot=()=>{if(y.size===dt.length)q(new Set);else{const P=dt.map((je,Ae)=>n.findIndex(tt=>tt===dt[Ae]));q(new Set(P))}},di=()=>{if(y.size===0){Me({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}ne(!0)},on=()=>{const P=n.filter((je,Ae)=>!y.has(Ae));r(P),q(new Set),ne(!1),Me({title:"批量删除成功",description:`已删除 ${y.size} 个提供商`})},dt=n.filter(P=>{if(!pe)return!0;const je=pe.toLowerCase();return P.name.toLowerCase().includes(je)||P.base_url.toLowerCase().includes(je)||P.client_type.toLowerCase().includes(je)}),Pt=Math.ceil(dt.length/he),Wt=dt.slice((S-1)*he,S*he),La=()=>{const P=parseInt(oe);P>=1&&P<=Pt&&(me(P),ge(""))},Ut=async P=>{A(je=>new Set(je).add(P));try{const je=await $0(P);_e(Ae=>new Map(Ae).set(P,je)),je.network_ok?je.api_key_valid===!0?Me({title:"连接正常",description:`${P} 网络连接正常,API Key 有效 (${je.latency_ms}ms)`}):je.api_key_valid===!1?Me({title:"连接正常但 Key 无效",description:`${P} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):Me({title:"网络连接正常",description:`${P} 可以访问 (${je.latency_ms}ms)`}):Me({title:"连接失败",description:je.error||"无法连接到提供商",variant:"destructive"})}catch(je){Me({title:"测试失败",description:je.message,variant:"destructive"})}finally{A(je=>{const Ae=new Set(je);return Ae.delete(P),Ae})}},Ua=async()=>{for(const P of n)await Ut(P.name)},ba=P=>{const je=F.has(P),Ae=W.get(P);return je?e.jsxs(Xe,{variant:"secondary",className:"gap-1",children:[e.jsx(vt,{className:"h-3 w-3 animate-spin"}),"测试中"]}):Ae?Ae.network_ok?Ae.api_key_valid===!0?e.jsxs(Xe,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(xa,{className:"h-3 w-3"}),"正常"]}):Ae.api_key_valid===!1?e.jsxs(Xe,{variant:"destructive",className:"gap-1",children:[e.jsx(Aa,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(Xe,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(xa,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(Xe,{variant:"destructive",className:"gap-1",children:[e.jsx(pg,{className:"h-3 w-3"}),"离线"]}):null};return c?e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})}):e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"AI模型厂商配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理 AI 模型厂商的 API 配置"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[y.size>0&&e.jsxs(N,{onClick:di,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",y.size,")"]}),e.jsxs(N,{onClick:Ua,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:n.length===0||F.size>0,children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),F.size>0?`测试中 (${F.size})`:"测试全部"]}),e.jsxs(N,{onClick:()=>nt(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(gt,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(N,{onClick:jt,disabled:h||f||!g||v,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),h?"保存中...":f?"自动保存中...":g?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{disabled:h||f||v,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),v?"重启中...":g?"保存并重启":"重启麦麦"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重启麦麦?"}),e.jsx(ms,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:g?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ua,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(ma,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Os,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(Es,{className:"max-w-2xl",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx($s,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx(He,{value:"windows",children:"Windows"}),e.jsx(He,{value:"macos",children:"macOS"}),e.jsx(He,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:["在“进程”或“详细信息”标签页中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:"右键点击并选择“结束任务”"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"})," 打开 Spotlight,搜索“活动监视器”"]}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Is,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(N,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:g?Jt:st,children:g?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ua,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(ma,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(es,{className:"h-[calc(100vh-260px)]",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索提供商名称、URL 或类型...",value:pe,onChange:P=>Ne(P.target.value),className:"pl-9"})]}),pe&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",dt.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:dt.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:pe?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):Wt.map((P,je)=>{const Ae=n.findIndex(tt=>tt===P);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-base truncate",children:P.name}),ba(P.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:P.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Ut(P.name),disabled:F.has(P.name),title:"测试连接",children:F.has(P.name)?e.jsx(vt,{className:"h-4 w-4 animate-spin"}):e.jsx(ln,{className:"h-4 w-4"})}),e.jsx(N,{variant:"default",size:"sm",onClick:()=>nt(P,Ae),children:e.jsx(nn,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(N,{size:"sm",onClick:()=>Se(Ae),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(ns,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"客户端类型"}),e.jsx("p",{className:"font-medium",children:P.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:P.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:P.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:P.retry_interval})]})]})]},je)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(pt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:y.size===dt.length&&dt.length>0,onCheckedChange:ot})}),e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"基础URL"}),e.jsx(ls,{children:"客户端类型"}),e.jsx(ls,{className:"text-right",children:"最大重试"}),e.jsx(ls,{className:"text-right",children:"超时(秒)"}),e.jsx(ls,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:Wt.length===0?e.jsx(pt,{children:e.jsx(Ye,{colSpan:9,className:"text-center text-muted-foreground py-8",children:pe?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):Wt.map((P,je)=>{const Ae=n.findIndex(tt=>tt===P);return e.jsxs(pt,{children:[e.jsx(Ye,{children:e.jsx(yt,{checked:y.has(Ae),onCheckedChange:()=>it(Ae)})}),e.jsx(Ye,{children:ba(P.name)||e.jsx(Xe,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Ye,{className:"font-medium",children:P.name}),e.jsx(Ye,{className:"max-w-xs truncate",title:P.base_url,children:P.base_url}),e.jsx(Ye,{children:P.client_type}),e.jsx(Ye,{className:"text-right",children:P.max_retry}),e.jsx(Ye,{className:"text-right",children:P.timeout}),e.jsx(Ye,{className:"text-right",children:P.retry_interval}),e.jsx(Ye,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Ut(P.name),disabled:F.has(P.name),title:"测试连接",children:F.has(P.name)?e.jsx(vt,{className:"h-4 w-4 animate-spin"}):e.jsx(ln,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"default",size:"sm",onClick:()=>nt(P,Ae),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(N,{size:"sm",onClick:()=>Se(Ae),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},je)})})]})})}),dt.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Qe,{value:he.toString(),onValueChange:P=>{Q(parseInt(P)),me(1),q(new Set)},children:[e.jsx(Ge,{id:"page-size-provider",className:"w-20",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"10",children:"10"}),e.jsx(ue,{value:"20",children:"20"}),e.jsx(ue,{value:"50",children:"50"}),e.jsx(ue,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(S-1)*he+1," 到"," ",Math.min(S*he,dt.length)," 条,共 ",dt.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>me(1),disabled:S===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>me(P=>Math.max(1,P-1)),disabled:S===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:oe,onChange:P=>ge(P.target.value),onKeyDown:P=>P.key==="Enter"&&La(),placeholder:S.toString(),className:"w-16 h-8 text-center",min:1,max:Pt}),e.jsx(N,{variant:"outline",size:"sm",onClick:La,disabled:!oe,className:"h-8",children:"跳转"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>me(P=>P+1),disabled:S>=Pt,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>me(Pt),disabled:S>=Pt,className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]}),e.jsx(Os,{open:L,onOpenChange:ol,children:e.jsxs(Es,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:Ie.isRunning,children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:ee!==null?"编辑提供商":"添加提供商"}),e.jsx($s,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:P=>{P.preventDefault(),cl()},autoComplete:"off",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"provider-template-select",children:[e.jsx(b,{htmlFor:"template",children:"提供商模板"}),e.jsxs(Da,{open:X,onOpenChange:w,children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",role:"combobox","aria-expanded":X,className:"w-full justify-between",children:[E?rr.find(P=>P.id===E)?.display_name:"选择提供商模板...",e.jsx($u,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Na,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索提供商模板..."}),e.jsx(es,{className:"h-[300px]",children:e.jsxs(mo,{className:"max-h-none overflow-visible",children:[e.jsx(ho,{children:"未找到匹配的模板"}),e.jsx(vr,{children:rr.map(P=>e.jsxs(yr,{value:P.display_name,onSelect:()=>Ct(P.id),children:[e.jsx(ha,{className:`mr-2 h-4 w-4 ${E===P.id?"opacity-100":"opacity-0"}`}),P.display_name]},P.id))})]})})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"选择预设模板可自动填充 URL 和客户端类型,支持搜索"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-name-input",children:[e.jsx(b,{htmlFor:"name",className:le.name?"text-destructive":"",children:"名称 *"}),e.jsx(ce,{id:"name",value:U?.name||"",onChange:P=>{R(je=>je?{...je,name:P.target.value}:null),le.name&&O(je=>({...je,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:le.name?"border-destructive focus-visible:ring-destructive":""}),le.name&&e.jsx("p",{className:"text-xs text-destructive",children:le.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsx(b,{htmlFor:"base_url",className:le.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(ce,{id:"base_url",value:U?.base_url||"",onChange:P=>{R(je=>je?{...je,base_url:P.target.value}:null),le.base_url&&O(je=>({...je,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:kt,className:`${kt?"bg-muted cursor-not-allowed":""} ${le.base_url?"border-destructive focus-visible:ring-destructive":""}`}),le.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:le.base_url}),kt&&!le.base_url&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时 URL 不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-apikey-input",children:[e.jsx(b,{htmlFor:"api_key",className:le.api_key?"text-destructive":"",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"api_key",type:ye?"text":"password",value:U?.api_key||"",onChange:P=>{R(je=>je?{...je,api_key:P.target.value}:null),le.api_key&&O(je=>({...je,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${le.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(N,{type:"button",variant:"outline",size:"icon",onClick:()=>ve(!ye),title:ye?"隐藏密钥":"显示密钥",children:ye?e.jsx(mr,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})}),e.jsx(N,{type:"button",variant:"outline",size:"icon",onClick:rl,title:"复制密钥",children:e.jsx(so,{className:"h-4 w-4"})})]}),le.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:le.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs(Qe,{value:U?.client_type||"openai",onValueChange:P=>R(je=>je?{...je,client_type:P}:null),disabled:kt,children:[e.jsx(Ge,{id:"client_type",className:kt?"bg-muted cursor-not-allowed":"",children:e.jsx($e,{placeholder:"选择客户端类型"})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"openai",children:"OpenAI"}),e.jsx(ue,{value:"gemini",children:"Gemini"})]})]}),kt&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时客户端类型不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(ce,{id:"max_retry",type:"number",min:"0",value:U?.max_retry??"",onChange:P=>{const je=P.target.value===""?null:parseInt(P.target.value);R(Ae=>Ae?{...Ae,max_retry:je}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(ce,{id:"timeout",type:"number",min:"1",value:U?.timeout??"",onChange:P=>{const je=P.target.value===""?null:parseInt(P.target.value);R(Ae=>Ae?{...Ae,timeout:je}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(ce,{id:"retry_interval",type:"number",min:"1",value:U?.retry_interval??"",onChange:P=>{const je=P.target.value===""?null:parseInt(P.target.value);R(Ae=>Ae?{...Ae,retry_interval:je}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(Is,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>K(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(N,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(ps,{open:D,onOpenChange:te,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除提供商 "',xe!==null?n[xe]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:Re,children:"删除"})]})]})}),e.jsx(ps,{open:H,onOpenChange:ne,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认批量删除"}),e.jsxs(ms,{children:["确定要删除选中的 ",y.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:on,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),z&&e.jsx(Iu,{onRestartComplete:bt,onRestartFailed:Je})]})}function bw({value:n,label:r,onRemove:c}){const{attributes:d,listeners:h,setNodeRef:x,transform:f,transition:j,isDragging:g}=gb({id:n}),_={transform:jb.Transform.toString(f),transition:j,opacity:g?.5:1};return e.jsx("div",{ref:x,style:_,className:$("inline-flex items-center gap-1",g&&"shadow-lg"),children:e.jsxs(Xe,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...d,...h,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(DN,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:r}),e.jsx(li,{className:"ml-1 h-3 w-3 cursor-pointer hover:text-destructive",strokeWidth:2,fill:"none",onClick:v=>{v.stopPropagation(),c(n)}})]})})}function ww({options:n,selected:r,onChange:c,placeholder:d="选择选项...",emptyText:h="未找到选项",className:x}){const[f,j]=u.useState(!1),g=cb(Jf(pb,{activationConstraint:{distance:8}}),Jf(fb,{coordinateGetter:xb})),_=z=>{r.includes(z)?c(r.filter(T=>T!==z)):c([...r,z])},v=z=>{c(r.filter(T=>T!==z))},k=z=>{const{active:T,over:L}=z;if(L&&T.id!==L.id){const K=r.indexOf(T.id),U=r.indexOf(L.id);c(hb(r,K,U))}};return e.jsxs(Da,{open:f,onOpenChange:j,children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",role:"combobox","aria-expanded":f,className:$("w-full justify-between min-h-10 h-auto",x),children:[e.jsx(ob,{sensors:g,collisionDetection:db,onDragEnd:k,children:e.jsx(ub,{items:r,strategy:mb,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:r.length===0?e.jsx("span",{className:"text-muted-foreground",children:d}):r.map(z=>{const T=n.find(L=>L.value===z);return e.jsx(bw,{value:z,label:T?.label||z,onRemove:v},z)})})})}),e.jsx($u,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(Na,{className:"w-full p-0",align:"start",children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索...",className:"h-9"}),e.jsxs(mo,{children:[e.jsx(ho,{children:h}),e.jsx(vr,{children:n.map(z=>{const T=r.includes(z.value);return e.jsxs(yr,{value:z.value,onSelect:()=>_(z.value),children:[e.jsx("div",{className:$("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",T?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ha,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:z.label})]},z.value)})})]})]})})]})}const dp=new Map,_w=300*1e3;function Sw(){const[n,r]=u.useState([]),[c,d]=u.useState([]),[h,x]=u.useState([]),[f,j]=u.useState([]),[g,_]=u.useState(null),[v,k]=u.useState(!0),[z,T]=u.useState(!1),[L,K]=u.useState(!1),[U,R]=u.useState(!1),[ee,V]=u.useState(!1),[E,B]=u.useState(!1),[X,w]=u.useState(!1),[D,te]=u.useState(null),[xe,be]=u.useState(null),[ye,ve]=u.useState(!1),[pe,Ne]=u.useState(null),[y,q]=u.useState(""),[H,ne]=u.useState(new Set),[S,me]=u.useState(!1),[he,Q]=u.useState(1),[oe,ge]=u.useState(20),[le,O]=u.useState(""),[F,A]=u.useState([]),[W,_e]=u.useState(!1),[Me,ss]=u.useState(null),[Ie,Rs]=u.useState(!1),[qs,ie]=u.useState(null),[we,Ke]=u.useState({}),{toast:Le}=Bs(),st=It(),{registerTour:Jt,startTour:bt,state:Je,goToStep:Ue}=Ju(),jt=u.useRef(null),nt=u.useRef(null),Ct=u.useRef(!0);u.useEffect(()=>{Jt(ll,Hg)},[Jt]),u.useEffect(()=>{if(Je.activeTourId===ll&&Je.isRunning){const Y=qg[Je.stepIndex];Y&&!window.location.pathname.endsWith(Y.replace("/config/",""))&&st({to:Y})}},[Je.stepIndex,Je.activeTourId,Je.isRunning,st]);const kt=u.useRef(Je.stepIndex);u.useEffect(()=>{if(Je.activeTourId===ll&&Je.isRunning){const Y=kt.current,fe=Je.stepIndex;Y>=12&&Y<=17&&fe<12&&w(!1),kt.current=fe}},[Je.stepIndex,Je.activeTourId,Je.isRunning]),u.useEffect(()=>{if(Je.activeTourId!==ll||!Je.isRunning)return;const Y=fe=>{const De=fe.target,Fe=Je.stepIndex;Fe===2&&De.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Ue(3),300):Fe===9&&De.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>Ue(10),300):Fe===11&&De.closest('[data-tour="add-model-button"]')?setTimeout(()=>Ue(12),300):Fe===17&&De.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>Ue(18),300):Fe===18&&De.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>Ue(19),300)};return document.addEventListener("click",Y,!0),()=>document.removeEventListener("click",Y,!0)},[Je,Ue]);const rl=()=>{bt(ll)};u.useEffect(()=>{cl()},[]);const cl=async()=>{try{k(!0);const Y=await ei(),fe=Y.models||[];r(fe),j(fe.map(Fe=>Fe.name));const De=Y.api_providers||[];d(De.map(Fe=>Fe.name)),x(De),_(Y.model_task_config||null),R(!1),Ct.current=!1}catch(Y){console.error("加载配置失败:",Y)}finally{k(!1)}},ol=u.useCallback(Y=>h.find(fe=>fe.name===Y),[h]),Se=u.useCallback(async(Y,fe=!1)=>{const De=ol(Y);if(!De?.base_url){A([]),ie(null),ss('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!De.api_key){A([]),ie(null),ss('该提供商未配置 API Key,请先在"模型提供商配置"中填写');return}const Fe=yw(De.base_url);if(ie(Fe),!Fe?.modelFetcher){A([]),ss(null);return}const Ys=`${Y}:${De.base_url}`,wa=dp.get(Ys);if(!fe&&wa&&Date.now()-wa.timestamp<_w){A(wa.models),ss(null);return}_e(!0),ss(null);try{const Ba=await Q0(Y,Fe.modelFetcher.parser,Fe.modelFetcher.endpoint);A(Ba),dp.set(Ys,{models:Ba,timestamp:Date.now()})}catch(Ba){console.error("获取模型列表失败:",Ba);const _a=Ba.message||"获取模型列表失败";_a.includes("无效")||_a.includes("过期")||_a.includes("API Key")?ss('API Key 无效或已过期,请检查"模型提供商配置"中的密钥'):_a.includes("权限")?ss("没有权限获取模型列表,请检查 API Key 权限"):_a.includes("timeout")||_a.includes("超时")?ss("请求超时,请检查网络连接后重试"):_a.includes("不支持")?ss("该提供商不支持自动获取模型列表,请手动输入"):ss(_a),A([])}finally{_e(!1)}},[ol]);u.useEffect(()=>{X&&D?.api_provider&&Se(D.api_provider)},[X,D?.api_provider,Se]);const Re=async()=>{try{V(!0),co().catch(()=>{}),B(!0)}catch(Y){console.error("重启失败:",Y),B(!1),Le({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),V(!1)}},it=async()=>{try{T(!0),jt.current&&clearTimeout(jt.current),nt.current&&clearTimeout(nt.current);const Y=await ei();Y.models=n,Y.model_task_config=g,await io(Y),R(!1),Le({title:"保存成功",description:"正在重启麦麦..."}),await Re()}catch(Y){console.error("保存配置失败:",Y),Le({title:"保存失败",description:Y.message,variant:"destructive"}),T(!1)}},ot=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},di=()=>{B(!1),V(!1),Le({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},on=u.useCallback(async Y=>{if(!Ct.current)try{K(!0),await qu("models",Y),R(!1)}catch(fe){console.error("自动保存模型列表失败:",fe),R(!0)}finally{K(!1)}},[]),dt=u.useCallback(async Y=>{if(!Ct.current)try{K(!0),await qu("model_task_config",Y),R(!1)}catch(fe){console.error("自动保存任务配置失败:",fe),R(!0)}finally{K(!1)}},[]);u.useEffect(()=>{if(!Ct.current)return R(!0),jt.current&&clearTimeout(jt.current),jt.current=setTimeout(()=>{on(n)},2e3),()=>{jt.current&&clearTimeout(jt.current)}},[n,on]),u.useEffect(()=>{if(!(Ct.current||!g))return R(!0),nt.current&&clearTimeout(nt.current),nt.current=setTimeout(()=>{dt(g)},2e3),()=>{nt.current&&clearTimeout(nt.current)}},[g,dt]);const Pt=async()=>{try{T(!0),jt.current&&clearTimeout(jt.current),nt.current&&clearTimeout(nt.current);const Y=await ei();Y.models=n,Y.model_task_config=g,await io(Y),R(!1),Le({title:"保存成功",description:"模型配置已保存"}),await cl()}catch(Y){console.error("保存配置失败:",Y),Le({title:"保存失败",description:Y.message,variant:"destructive"})}finally{T(!1)}},Wt=(Y,fe)=>{Ke({}),te(Y||{model_identifier:"",name:"",api_provider:c[0]||"",price_in:0,price_out:0,force_stream_mode:!1,extra_params:{}}),be(fe),w(!0)},La=()=>{if(!D)return;const Y={};if(D.name?.trim()||(Y.name="请输入模型名称"),D.api_provider?.trim()||(Y.api_provider="请选择 API 提供商"),D.model_identifier?.trim()||(Y.model_identifier="请输入模型标识符"),Object.keys(Y).length>0){Ke(Y);return}Ke({});const fe={...D,price_in:D.price_in??0,price_out:D.price_out??0};let De;xe!==null?(De=[...n],De[xe]=fe):De=[...n,fe],r(De),j(De.map(Fe=>Fe.name)),w(!1),te(null),be(null)},Ut=Y=>{if(!Y&&D){const fe={...D,price_in:D.price_in??0,price_out:D.price_out??0};te(fe)}w(Y)},Ua=Y=>{Ne(Y),ve(!0)},ba=()=>{if(pe!==null){const Y=n.filter((fe,De)=>De!==pe);r(Y),j(Y.map(fe=>fe.name)),Le({title:"删除成功",description:"模型已从列表中移除"})}ve(!1),Ne(null)},P=Y=>{const fe=new Set(H);fe.has(Y)?fe.delete(Y):fe.add(Y),ne(fe)},je=()=>{if(H.size===Tt.length)ne(new Set);else{const Y=Tt.map((fe,De)=>n.findIndex(Fe=>Fe===Tt[De]));ne(new Set(Y))}},Ae=()=>{if(H.size===0){Le({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}me(!0)},tt=()=>{const Y=n.filter((fe,De)=>!H.has(De));r(Y),j(Y.map(fe=>fe.name)),ne(new Set),me(!1),Le({title:"批量删除成功",description:`已删除 ${H.size} 个模型`})},Bt=(Y,fe,De)=>{g&&_({...g,[Y]:{...g[Y],[fe]:De}})},Tt=n.filter(Y=>{if(!y)return!0;const fe=y.toLowerCase();return Y.name.toLowerCase().includes(fe)||Y.model_identifier.toLowerCase().includes(fe)||Y.api_provider.toLowerCase().includes(fe)}),dl=Math.ceil(Tt.length/oe),Hl=Tt.slice((he-1)*oe,he*oe),dn=()=>{const Y=parseInt(le);Y>=1&&Y<=dl&&(Q(Y),O(""))},un=Y=>g?[g.utils?.model_list||[],g.utils_small?.model_list||[],g.tool_use?.model_list||[],g.replyer?.model_list||[],g.planner?.model_list||[],g.vlm?.model_list||[],g.voice?.model_list||[],g.embedding?.model_list||[],g.lpmm_entity_extract?.model_list||[],g.lpmm_rdf_build?.model_list||[],g.lpmm_qa?.model_list||[]].some(De=>De.includes(Y)):!1;return v?e.jsx(es,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"模型管理与分配"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"添加模型并为模型分配功能"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(N,{onClick:Pt,disabled:z||L||!U||ee,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(br,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),z?"保存中...":L?"自动保存中...":U?"保存配置":"已保存"]}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsxs(N,{disabled:z||L||ee,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),ee?"重启中...":U?"保存并重启":"重启麦麦"]})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认重启麦麦?"}),e.jsx(ms,{className:"space-y-3",asChild:!0,children:e.jsxs("div",{children:[e.jsx("p",{children:U?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"}),e.jsxs(ua,{className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(ma,{className:"text-yellow-900 dark:text-yellow-100",children:[e.jsx("strong",{children:"重要提示:"}),"由于技术原因,使用重启功能后,将无法再使用 ",e.jsx("code",{className:"px-1 py-0.5 bg-yellow-200 dark:bg-yellow-900 rounded",children:"Ctrl+C"})," 结束程序。",e.jsxs(Os,{children:[e.jsx(ni,{asChild:!0,children:e.jsxs("button",{className:"ml-1 text-yellow-700 dark:text-yellow-300 underline hover:text-yellow-800 dark:hover:text-yellow-200 inline-flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),"如何结束程序?"]})}),e.jsxs(Es,{className:"max-w-2xl",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"如何结束使用重启功能后的麦麦程序"}),e.jsx($s,{children:"由于重启功能会使程序脱离终端控制,需要通过系统命令来结束进程"})]}),e.jsxs(Kt,{defaultValue:"windows",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsx(He,{value:"windows",children:"Windows"}),e.jsx(He,{value:"macos",children:"macOS"}),e.jsx(He,{value:"linux",children:"Linux"})]}),e.jsxs(We,{value:"windows",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用任务管理器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Ctrl + Shift + Esc"})," 打开任务管理器"]}),e.jsxs("li",{children:['在"进程"或"详细信息"标签页中找到 ',e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"python.exe"})]}),e.jsx("li",{children:'右键点击并选择"结束任务"'})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用命令行"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开 PowerShell 或命令提示符,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:'Get-Process python | Where-Object {$_.MainWindowTitle -eq ""}'}),e.jsx("p",{className:"mt-2",children:"# 结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"Stop-Process -Name python -Force"})]})]})]}),e.jsxs(We,{value:"macos",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法一:使用活动监视器"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Cmd + Space"}),' 打开 Spotlight,搜索"活动监视器"']}),e.jsxs("li",{children:["在进程列表中找到 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"Python"})]}),e.jsx("li",{children:"选中后点击左上角的 X 按钮结束进程"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"方法二:使用终端"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]})]}),e.jsxs(We,{value:"linux",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用终端命令"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"打开终端,执行以下命令:"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md font-mono text-sm",children:[e.jsx("p",{children:"# 查找麦麦进程"}),e.jsx("p",{children:"ps aux | grep python | grep -v grep"}),e.jsx("p",{className:"mt-2",children:"# 结束指定 PID 的进程"}),e.jsx("p",{children:"kill -9 "}),e.jsx("p",{className:"mt-2",children:"# 或使用 pkill 按名称结束"}),e.jsx("p",{children:'pkill -9 -f "bot.py"'}),e.jsx("p",{className:"mt-2",children:"# 或结束所有 Python 进程(谨慎使用)"}),e.jsx("p",{children:"pkill -9 python"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"使用 htop(如已安装)"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{children:["在终端输入 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"htop"})]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F3"})," 搜索 python"]}),e.jsxs("li",{children:["按 ",e.jsx("code",{className:"px-1 py-0.5 bg-muted rounded",children:"F9"})," 发送信号,选择 SIGKILL"]})]})]})]})]}),e.jsx(Is,{children:e.jsx(Zu,{asChild:!0,children:e.jsx(N,{variant:"outline",children:"关闭"})})})]})]})]})]})]})})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:U?it:Re,children:U?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ua,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsxs(ma,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(ua,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:rl,children:[e.jsx(ON,{className:"h-4 w-4 text-primary"}),e.jsxs(ma,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:"新手引导:"}),"不知道如何配置模型?点击这里开始学习如何为麦麦的组件分配模型。"]}),e.jsx(N,{variant:"outline",size:"sm",className:"ml-4 shrink-0",children:"开始引导"})]})]}),e.jsxs(Kt,{defaultValue:"models",className:"w-full",children:[e.jsxs(Rt,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx(He,{value:"models",children:"添加模型"}),e.jsx(He,{value:"tasks","data-tour":"tasks-tab-trigger",children:"为模型分配功能"})]}),e.jsxs(We,{value:"models",className:"space-y-4 mt-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置可用的模型列表"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[H.size>0&&e.jsxs(N,{onClick:Ae,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",H.size,")"]}),e.jsxs(N,{onClick:()=>Wt(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(gt,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加模型"]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索模型名称、标识符或提供商...",value:y,onChange:Y=>q(Y.target.value),className:"pl-9"})]}),y&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Tt.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Hl.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:y?"未找到匹配的模型":"暂无模型配置"}):Hl.map((Y,fe)=>{const De=n.findIndex(Ys=>Ys===Y),Fe=un(Y.name);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-base",children:Y.name}),e.jsx(Xe,{variant:Fe?"default":"secondary",className:Fe?"bg-green-600 hover:bg-green-700":"",children:Fe?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:Y.model_identifier,children:Y.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(N,{variant:"default",size:"sm",onClick:()=>Wt(Y,De),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(N,{size:"sm",onClick:()=>Ua(De),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"提供商"}),e.jsx("p",{className:"font-medium",children:Y.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"强制流式"}),e.jsx("p",{className:"font-medium",children:Y.force_stream_mode?"是":"否"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输入价格"}),e.jsxs("p",{className:"font-medium",children:["¥",Y.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",Y.price_out,"/M"]})]})]})]},fe)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(pt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:H.size===Tt.length&&Tt.length>0,onCheckedChange:je})}),e.jsx(ls,{className:"w-24",children:"使用状态"}),e.jsx(ls,{children:"模型名称"}),e.jsx(ls,{children:"模型标识符"}),e.jsx(ls,{children:"提供商"}),e.jsx(ls,{className:"text-right",children:"输入价格"}),e.jsx(ls,{className:"text-right",children:"输出价格"}),e.jsx(ls,{className:"text-center",children:"强制流式"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:Hl.length===0?e.jsx(pt,{children:e.jsx(Ye,{colSpan:9,className:"text-center text-muted-foreground py-8",children:y?"未找到匹配的模型":"暂无模型配置"})}):Hl.map((Y,fe)=>{const De=n.findIndex(Ys=>Ys===Y),Fe=un(Y.name);return e.jsxs(pt,{children:[e.jsx(Ye,{children:e.jsx(yt,{checked:H.has(De),onCheckedChange:()=>P(De)})}),e.jsx(Ye,{children:e.jsx(Xe,{variant:Fe?"default":"secondary",className:Fe?"bg-green-600 hover:bg-green-700":"",children:Fe?"已使用":"未使用"})}),e.jsx(Ye,{className:"font-medium",children:Y.name}),e.jsx(Ye,{className:"max-w-xs truncate",title:Y.model_identifier,children:Y.model_identifier}),e.jsx(Ye,{children:Y.api_provider}),e.jsxs(Ye,{className:"text-right",children:["¥",Y.price_in,"/M"]}),e.jsxs(Ye,{className:"text-right",children:["¥",Y.price_out,"/M"]}),e.jsx(Ye,{className:"text-center",children:Y.force_stream_mode?"是":"否"}),e.jsx(Ye,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(N,{variant:"default",size:"sm",onClick:()=>Wt(Y,De),children:[e.jsx(nn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(N,{size:"sm",onClick:()=>Ua(De),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},fe)})})]})})}),Tt.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Qe,{value:oe.toString(),onValueChange:Y=>{ge(parseInt(Y)),Q(1),ne(new Set)},children:[e.jsx(Ge,{id:"page-size-model",className:"w-20",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"10",children:"10"}),e.jsx(ue,{value:"20",children:"20"}),e.jsx(ue,{value:"50",children:"50"}),e.jsx(ue,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(he-1)*oe+1," 到"," ",Math.min(he*oe,Tt.length)," 条,共 ",Tt.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Q(1),disabled:he===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>Q(Y=>Math.max(1,Y-1)),disabled:he===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:le,onChange:Y=>O(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&dn(),placeholder:he.toString(),className:"w-16 h-8 text-center",min:1,max:dl}),e.jsx(N,{variant:"outline",size:"sm",onClick:dn,disabled:!le,className:"h-8",children:"跳转"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>Q(Y=>Y+1),disabled:he>=dl,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Q(dl),disabled:he>=dl,className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]}),e.jsxs(We,{value:"tasks",className:"space-y-6 mt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"为不同的任务配置使用的模型和参数"}),g&&e.jsxs("div",{className:"grid gap-4 sm:gap-6",children:[e.jsx(ja,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:g.utils,modelNames:f,onChange:(Y,fe)=>Bt("utils",Y,fe),dataTour:"task-model-select"}),e.jsx(ja,{title:"组件小模型 (utils_small)",description:"消耗量较大的组件,建议使用速度较快的小模型",taskConfig:g.utils_small,modelNames:f,onChange:(Y,fe)=>Bt("utils_small",Y,fe)}),e.jsx(ja,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:g.tool_use,modelNames:f,onChange:(Y,fe)=>Bt("tool_use",Y,fe)}),e.jsx(ja,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:g.replyer,modelNames:f,onChange:(Y,fe)=>Bt("replyer",Y,fe)}),e.jsx(ja,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:g.planner,modelNames:f,onChange:(Y,fe)=>Bt("planner",Y,fe)}),e.jsx(ja,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:g.vlm,modelNames:f,onChange:(Y,fe)=>Bt("vlm",Y,fe),hideTemperature:!0}),e.jsx(ja,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:g.voice,modelNames:f,onChange:(Y,fe)=>Bt("voice",Y,fe),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(ja,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:g.embedding,modelNames:f,onChange:(Y,fe)=>Bt("embedding",Y,fe),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(ja,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:g.lpmm_entity_extract,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_entity_extract",Y,fe)}),e.jsx(ja,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:g.lpmm_rdf_build,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_rdf_build",Y,fe)}),e.jsx(ja,{title:"问答模型 (lpmm_qa)",description:"知识库问答",taskConfig:g.lpmm_qa,modelNames:f,onChange:(Y,fe)=>Bt("lpmm_qa",Y,fe)})]})]})]})]}),e.jsx(Os,{open:X,onOpenChange:Ut,children:e.jsxs(Es,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Je.isRunning,children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:xe!==null?"编辑模型":"添加模型"}),e.jsx($s,{children:"配置模型的基本信息和参数"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"model-name-input",children:[e.jsx(b,{htmlFor:"model_name",className:we.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ce,{id:"model_name",value:D?.name||"",onChange:Y=>{te(fe=>fe?{...fe,name:Y.target.value}:null),we.name&&Ke(fe=>({...fe,name:void 0}))},placeholder:"例如: qwen3-30b",className:we.name?"border-destructive focus-visible:ring-destructive":""}),we.name?e.jsx("p",{className:"text-xs text-destructive",children:we.name}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于在任务配置中引用此模型"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-provider-select",children:[e.jsx(b,{htmlFor:"api_provider",className:we.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs(Qe,{value:D?.api_provider||"",onValueChange:Y=>{te(fe=>fe?{...fe,api_provider:Y}:null),A([]),ss(null),we.api_provider&&Ke(fe=>({...fe,api_provider:void 0}))},children:[e.jsx(Ge,{id:"api_provider",className:we.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx($e,{placeholder:"选择提供商"})}),e.jsx(Ve,{children:c.map(Y=>e.jsx(ue,{value:Y,children:Y},Y))})]}),we.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:we.api_provider})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-identifier-input",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{htmlFor:"model_identifier",className:we.model_identifier?"text-destructive":"",children:"模型标识符 *"}),qs?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{variant:"secondary",className:"text-xs",children:qs.display_name}),e.jsx(N,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>D?.api_provider&&Se(D.api_provider,!0),disabled:W,children:W?e.jsx(vt,{className:"h-3 w-3 animate-spin"}):e.jsx(ft,{className:"h-3 w-3"})})]})]}),qs?.modelFetcher?e.jsxs(Da,{open:Ie,onOpenChange:Rs,children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",role:"combobox","aria-expanded":Ie,className:"w-full justify-between font-normal",disabled:W||!!Me,children:[W?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(vt,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):Me?e.jsx("span",{className:"text-muted-foreground text-sm",children:"点击下方输入框手动填写"}):D?.model_identifier?e.jsx("span",{className:"truncate",children:D.model_identifier}):e.jsx("span",{className:"text-muted-foreground",children:"搜索或选择模型..."}),e.jsx($u,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Na,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(oo,{children:[e.jsx(uo,{placeholder:"搜索模型..."}),e.jsx(es,{className:"h-[300px]",children:e.jsxs(mo,{className:"max-h-none overflow-visible",children:[e.jsx(ho,{children:Me?e.jsxs("div",{className:"py-4 px-2 text-center space-y-2",children:[e.jsx("p",{className:"text-sm text-destructive",children:Me}),!Me.includes("API Key")&&e.jsx(N,{variant:"link",size:"sm",onClick:()=>D?.api_provider&&Se(D.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(vr,{heading:"可用模型",children:F.map(Y=>e.jsxs(yr,{value:Y.id,onSelect:()=>{te(fe=>fe?{...fe,model_identifier:Y.id}:null),Rs(!1)},children:[e.jsx(ha,{className:`mr-2 h-4 w-4 ${D?.model_identifier===Y.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:Y.id}),Y.name!==Y.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Y.name})]})]},Y.id))}),e.jsx(vr,{heading:"手动输入",children:e.jsxs(yr,{value:"__manual_input__",onSelect:()=>{Rs(!1)},children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ce,{id:"model_identifier",value:D?.model_identifier||"",onChange:Y=>{te(fe=>fe?{...fe,model_identifier:Y.target.value}:null),we.model_identifier&&Ke(fe=>({...fe,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:we.model_identifier?"border-destructive focus-visible:ring-destructive":""}),we.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:we.model_identifier}),Me&&qs?.modelFetcher&&!we.model_identifier&&e.jsxs(ua,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsx(ma,{className:"text-xs",children:Me})]}),qs?.modelFetcher&&e.jsx(ce,{value:D?.model_identifier||"",onChange:Y=>{te(fe=>fe?{...fe,model_identifier:Y.target.value}:null),we.model_identifier&&Ke(fe=>({...fe,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${we.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!we.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:Me?'请手动输入模型标识符,或前往"模型提供商配置"检查 API Key':qs?.modelFetcher?`已识别为 ${qs.display_name},支持自动获取模型列表`:"API 提供商提供的模型 ID"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(ce,{id:"price_in",type:"number",step:"0.1",min:"0",value:D?.price_in??"",onChange:Y=>{const fe=Y.target.value===""?null:parseFloat(Y.target.value);te(De=>De?{...De,price_in:fe}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ce,{id:"price_out",type:"number",step:"0.1",min:"0",value:D?.price_out??"",onChange:Y=>{const fe=Y.target.value===""?null:parseFloat(Y.target.value);te(De=>De?{...De,price_out:fe}:null)},placeholder:"默认: 0"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"force_stream_mode",checked:D?.force_stream_mode||!1,onCheckedChange:Y=>te(fe=>fe?{...fe,force_stream_mode:Y}:null)}),e.jsx(b,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>w(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(N,{onClick:La,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(ps,{open:ye,onOpenChange:ve,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除模型 "',pe!==null?n[pe]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:ba,children:"删除"})]})]})}),e.jsx(ps,{open:S,onOpenChange:me,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认批量删除"}),e.jsxs(ms,{children:["确定要删除选中的 ",H.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:tt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),E&&e.jsx(Iu,{onRestartComplete:ot,onRestartFailed:di})]})})}function ja({title:n,description:r,taskConfig:c,modelNames:d,onChange:h,hideTemperature:x=!1,hideMaxTokens:f=!1,dataTour:j}){const g=_=>{h("model_list",_)};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-base sm:text-lg",children:n}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:r})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":j,children:[e.jsx(b,{children:"模型列表"}),e.jsx(ww,{options:d.map(_=>({label:_,value:_})),selected:c.model_list||[],onChange:g,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!x&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"温度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:c.temperature??.3,onChange:_=>{const v=parseFloat(_.target.value);!isNaN(v)&&v>=0&&v<=1&&h("temperature",v)},className:"w-20 h-8 text-sm"})]}),e.jsx(za,{value:[c.temperature??.3],onValueChange:_=>h("temperature",_[0]),min:0,max:1,step:.1,className:"w-full"})]}),!f&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"最大 Token"}),e.jsx(ce,{type:"number",step:"1",min:"1",value:c.max_tokens??1024,onChange:_=>h("max_tokens",parseInt(_.target.value))})]})]})]})]})}const xo="/api/webui/config";async function Cw(){const r=await(await ke(`${xo}/adapter-config/path`)).json();return!r.success||!r.path?null:{path:r.path,lastModified:r.lastModified}}async function up(n){const c=await(await ke(`${xo}/adapter-config/path`,{method:"POST",headers:ze(),body:JSON.stringify({path:n})})).json();if(!c.success)throw new Error(c.message||"保存路径失败")}async function mp(n){const c=await(await ke(`${xo}/adapter-config?path=${encodeURIComponent(n)}`)).json();if(!c.success)throw new Error("读取配置文件失败");return c.content}async function hp(n,r){const d=await(await ke(`${xo}/adapter-config`,{method:"POST",headers:ze(),body:JSON.stringify({path:n,content:r})})).json();if(!d.success)throw new Error(d.message||"保存配置失败")}const Yt={inner:{version:"0.1.2"},nickname:{nickname:""},napcat_server:{host:"localhost",port:8095,token:"",heartbeat_interval:30},maibot_server:{host:"localhost",port:8e3},chat:{group_list_type:"whitelist",group_list:[],private_list_type:"whitelist",private_list:[],ban_user_id:[],ban_qq_bot:!1,enable_poke:!0},voice:{use_tts:!1},debug:{level:"INFO"}},Du={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:rn},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:RN}};function kw(){const[n,r]=u.useState("upload"),[c,d]=u.useState(null),[h,x]=u.useState(""),[f,j]=u.useState(""),[g,_]=u.useState("oneclick"),[v,k]=u.useState(""),[z,T]=u.useState(!1),[L,K]=u.useState(!1),[U,R]=u.useState(!1),[ee,V]=u.useState(!1),[E,B]=u.useState(null),X=u.useRef(null),{toast:w}=Bs(),D=u.useRef(null),te=O=>{if(!O.trim())return{valid:!1,error:"路径不能为空"};if(!O.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const F=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,A=/^(\/|~\/).+\.toml$/i,W=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,_e=F.test(O),Me=A.test(O),ss=W.test(O);return!_e&&!Me&&!ss?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(O)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}},xe=O=>{if(j(O),O.trim()){const F=te(O);k(F.error)}else k("")},be=u.useCallback(async O=>{const F=Du[O];K(!0);try{const A=await mp(F.path),W=he(A);d(W),_(O),j(F.path),await up(F.path),w({title:"加载成功",description:`已从${F.name}预设加载配置`})}catch(A){console.error("加载预设配置失败:",A),w({title:"加载失败",description:A instanceof Error?A.message:"无法读取预设配置文件",variant:"destructive"})}finally{K(!1)}},[w]),ye=u.useCallback(async O=>{const F=te(O);if(!F.valid){k(F.error),w({title:"路径无效",description:F.error,variant:"destructive"});return}k(""),K(!0);try{const A=await mp(O),W=he(A);d(W),j(O),await up(O),w({title:"加载成功",description:"已从配置文件加载"})}catch(A){console.error("加载配置失败:",A),w({title:"加载失败",description:A instanceof Error?A.message:"无法读取配置文件",variant:"destructive"})}finally{K(!1)}},[w]);u.useEffect(()=>{(async()=>{try{const F=await Cw();if(F&&F.path){j(F.path);const A=Object.entries(Du).find(([,W])=>W.path===F.path);A?(r("preset"),_(A[0]),await be(A[0])):(r("path"),await ye(F.path))}}catch(F){console.error("加载保存的路径失败:",F)}})()},[ye,be]);const ve=u.useCallback(O=>{n!=="path"&&n!=="preset"||!f||(D.current&&clearTimeout(D.current),D.current=setTimeout(async()=>{T(!0);try{const F=Q(O);await hp(f,F),w({title:"自动保存成功",description:"配置已保存到文件"})}catch(F){console.error("自动保存失败:",F),w({title:"自动保存失败",description:F instanceof Error?F.message:"保存配置失败",variant:"destructive"})}finally{T(!1)}},1e3))},[n,f,w]),pe=async()=>{if(!c||!f)return;const O=te(f);if(!O.valid){w({title:"保存失败",description:O.error,variant:"destructive"});return}T(!0);try{const F=Q(c);await hp(f,F),w({title:"保存成功",description:"配置已保存到文件"})}catch(F){console.error("保存失败:",F),w({title:"保存失败",description:F instanceof Error?F.message:"保存配置失败",variant:"destructive"})}finally{T(!1)}},Ne=async()=>{f&&await ye(f)},y=O=>{if(O!==n){if(c){B(O),R(!0);return}q(O)}},q=O=>{d(null),x(""),k(""),r(O),O==="preset"&&be("oneclick"),w({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[O]})},H=()=>{E&&(q(E),B(null)),R(!1)},ne=()=>{if(c){V(!0);return}S()},S=()=>{j(""),d(null),k(""),w({title:"已清空",description:"路径和配置已清空"})},me=()=>{S(),V(!1)},he=O=>{const F=JSON.parse(JSON.stringify(Yt)),A=O.split(` -`);let W="";for(const _e of A){const Me=_e.trim();if(!Me||Me.startsWith("#"))continue;const ss=Me.match(/^\[(\w+)\]/);if(ss){W=ss[1];continue}const Ie=Me.match(/^(\w+)\s*=\s*(.+)$/);if(Ie&&W){const[,Rs,qs]=Ie;let ie=qs.trim();const we=ie.match(/^("[^"]*")/);if(we)ie=we[1];else{const Le=ie.indexOf("#");Le!==-1&&(ie=ie.substring(0,Le).trim())}let Ke;if(ie==="true")Ke=!0;else if(ie==="false")Ke=!1;else if(ie.startsWith("[")&&ie.endsWith("]")){const Le=ie.slice(1,-1).trim();if(Le){const st=Le.split(",").map(bt=>{const Je=bt.trim();return isNaN(Number(Je))?Je.replace(/"/g,""):Number(Je)}),Jt=typeof st[0];Ke=st.every(bt=>typeof bt===Jt)?st:st.filter(bt=>typeof bt=="number")}else Ke=[]}else ie.startsWith('"')&&ie.endsWith('"')?Ke=ie.slice(1,-1):isNaN(Number(ie))?Ke=ie.replace(/"/g,""):Ke=Number(ie);if(W in F){const Le=F[W];Le[Rs]=Ke}}}return F},Q=O=>{const F=[],A=(W,_e)=>W===""||W===null||W===void 0?_e:W;return F.push("[inner]"),F.push(`version = "${A(O.inner.version,Yt.inner.version)}" # 版本号`),F.push("# 请勿修改版本号,除非你知道自己在做什么"),F.push(""),F.push("[nickname] # 现在没用"),F.push(`nickname = "${A(O.nickname.nickname,Yt.nickname.nickname)}"`),F.push(""),F.push("[napcat_server] # Napcat连接的ws服务设置"),F.push(`host = "${A(O.napcat_server.host,Yt.napcat_server.host)}" # Napcat设定的主机地址`),F.push(`port = ${A(O.napcat_server.port||0,Yt.napcat_server.port)} # Napcat设定的端口`),F.push(`token = "${A(O.napcat_server.token,Yt.napcat_server.token)}" # Napcat设定的访问令牌,若无则留空`),F.push(`heartbeat_interval = ${A(O.napcat_server.heartbeat_interval||0,Yt.napcat_server.heartbeat_interval)} # 与Napcat设置的心跳相同(按秒计)`),F.push(""),F.push("[maibot_server] # 连接麦麦的ws服务设置"),F.push(`host = "${A(O.maibot_server.host,Yt.maibot_server.host)}" # 麦麦在.env文件中设置的主机地址,即HOST字段`),F.push(`port = ${A(O.maibot_server.port||0,Yt.maibot_server.port)} # 麦麦在.env文件中设置的端口,即PORT字段`),F.push(""),F.push("[chat] # 黑白名单功能"),F.push(`group_list_type = "${A(O.chat.group_list_type,Yt.chat.group_list_type)}" # 群组名单类型,可选为:whitelist, blacklist`),F.push(`group_list = [${O.chat.group_list.join(", ")}] # 群组名单`),F.push("# 当group_list_type为whitelist时,只有群组名单中的群组可以聊天"),F.push("# 当group_list_type为blacklist时,群组名单中的任何群组无法聊天"),F.push(`private_list_type = "${A(O.chat.private_list_type,Yt.chat.private_list_type)}" # 私聊名单类型,可选为:whitelist, blacklist`),F.push(`private_list = [${O.chat.private_list.join(", ")}] # 私聊名单`),F.push("# 当private_list_type为whitelist时,只有私聊名单中的用户可以聊天"),F.push("# 当private_list_type为blacklist时,私聊名单中的任何用户无法聊天"),F.push(`ban_user_id = [${O.chat.ban_user_id.join(", ")}] # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`),F.push(`ban_qq_bot = ${O.chat.ban_qq_bot} # 是否屏蔽QQ官方机器人`),F.push(`enable_poke = ${O.chat.enable_poke} # 是否启用戳一戳功能`),F.push(""),F.push("[voice] # 发送语音设置"),F.push(`use_tts = ${O.voice.use_tts} # 是否使用tts语音(请确保你配置了tts并有对应的adapter)`),F.push(""),F.push("[debug]"),F.push(`level = "${A(O.debug.level,Yt.debug.level)}" # 日志等级(DEBUG, INFO, WARNING, ERROR, CRITICAL)`),F.join(` -`)},oe=O=>{const F=O.target.files?.[0];if(!F)return;const A=new FileReader;A.onload=W=>{try{const _e=W.target?.result,Me=he(_e);d(Me),x(F.name),w({title:"上传成功",description:`已加载配置文件:${F.name}`})}catch(_e){console.error("解析配置文件失败:",_e),w({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},A.readAsText(F)},ge=()=>{if(!c)return;const O=Q(c),F=new Blob([O],{type:"text/plain;charset=utf-8"}),A=URL.createObjectURL(F),W=document.createElement("a");W.href=A,W.download=h||"config.toml",document.body.appendChild(W),W.click(),document.body.removeChild(W),URL.revokeObjectURL(A),w({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},le=()=>{d(JSON.parse(JSON.stringify(Yt))),x("config.toml"),w({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦适配器配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的 QQ 适配器的配置文件"})]})}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg border border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400",children:[e.jsx(Aa,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"工作模式"}),e.jsx(Zs,{children:"选择配置文件的管理方式"})]}),e.jsxs(bs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 md:gap-4",children:[e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>y("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(rn,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"预设模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"使用预设的部署配置"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>y("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(hr,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"上传文件模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"上传配置文件,编辑后下载并手动覆盖"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>y("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(LN,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"指定路径模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"指定配置文件路径,自动加载和保存"})]})]})})]}),n==="preset"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsx(b,{className:"text-sm md:text-base",children:"选择部署方式"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(Du).map(([O,F])=>{const A=F.icon,W=g===O;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${W?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{_(O),be(O)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(A,{className:"h-5 w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-semibold text-sm",children:F.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:F.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:F.path})]})]})},O)})})]}),n==="path"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"config-path",className:"text-sm md:text-base",children:"配置文件路径"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(ce,{id:"config-path",value:f,onChange:O=>xe(O.target.value),placeholder:"例: C:\\Adapter\\config.toml",className:`text-sm ${v?"border-destructive":""}`}),v&&e.jsx("p",{className:"text-xs text-destructive",children:v})]}),e.jsx(N,{onClick:()=>ye(f),disabled:L||!f||!!v,className:"w-full sm:w-auto",children:L?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"h-4 w-4 animate-spin mr-2"}),e.jsx("span",{className:"sm:hidden",children:"加载中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:"加载配置"}),e.jsx("span",{className:"hidden sm:inline",children:"加载"})]})})]})]}),e.jsxs("details",{className:"rounded-lg bg-muted/50 p-3 group",children:[e.jsxs("summary",{className:"text-xs font-medium cursor-pointer select-none list-none flex items-center justify-between",children:[e.jsx("span",{children:"路径格式说明"}),e.jsx("svg",{className:"h-4 w-4 transition-transform group-open:rotate-180",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsxs("div",{className:"mt-2 space-y-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Windows"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"C:\\Adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"D:\\MaiBot\\adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"\\\\server\\share\\config.toml"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Linux"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"/opt/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"/home/user/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"~/adapter/config.toml"})]})]}),e.jsx("p",{className:"pt-1 border-t text-[10px] md:text-xs",children:"💡 配置会自动保存到指定文件,修改后 1 秒自动保存"})]})]})]})]})]}),e.jsxs(ua,{children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsx(ma,{children:n==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",z&&" (正在保存...)"]}):n==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",z&&" (正在保存...)"]})})]}),n==="upload"&&!c&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:X,type:"file",accept:".toml",className:"hidden",onChange:oe}),e.jsxs(N,{onClick:()=>X.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(hr,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(N,{onClick:le,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Ma,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),n==="upload"&&c&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(N,{onClick:ge,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(nl,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(n==="preset"||n==="path")&&c&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(N,{onClick:pe,size:"sm",disabled:z||!!v,className:"w-full sm:w-auto",children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),z?"保存中...":"立即保存"]}),e.jsxs(N,{onClick:Ne,size:"sm",variant:"outline",disabled:L,className:"w-full sm:w-auto",children:[e.jsx(ft,{className:`mr-2 h-4 w-4 ${L?"animate-spin":""}`}),"刷新"]}),n==="path"&&e.jsxs(N,{onClick:ne,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),c?e.jsxs(Kt,{defaultValue:"napcat",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs(Rt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5",children:[e.jsxs(He,{value:"napcat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"Napcat 连接"}),e.jsx("span",{className:"sm:hidden",children:"Napcat"})]}),e.jsxs(He,{value:"maibot",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"麦麦连接"}),e.jsx("span",{className:"sm:hidden",children:"麦麦"})]}),e.jsxs(He,{value:"chat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"聊天控制"}),e.jsx("span",{className:"sm:hidden",children:"聊天"})]}),e.jsxs(He,{value:"voice",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"语音设置"}),e.jsx("span",{className:"sm:hidden",children:"语音"})]}),e.jsx(He,{value:"debug",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:"调试"})]})}),e.jsx(We,{value:"napcat",className:"space-y-4",children:e.jsx(Tw,{config:c,onChange:O=>{d(O),ve(O)}})}),e.jsx(We,{value:"maibot",className:"space-y-4",children:e.jsx(Ew,{config:c,onChange:O=>{d(O),ve(O)}})}),e.jsx(We,{value:"chat",className:"space-y-4",children:e.jsx(zw,{config:c,onChange:O=>{d(O),ve(O)}})}),e.jsx(We,{value:"voice",className:"space-y-4",children:e.jsx(Mw,{config:c,onChange:O=>{d(O),ve(O)}})}),e.jsx(We,{value:"debug",className:"space-y-4",children:e.jsx(Aw,{config:c,onChange:O=>{d(O),ve(O)}})})]}):e.jsx("div",{className:"rounded-lg border bg-card p-6 md:p-12",children:e.jsxs("div",{className:"text-center space-y-3 md:space-y-4",children:[e.jsx(Ma,{className:"h-12 w-12 md:h-16 md:w-16 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold",children:"尚未加载配置"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-2 px-4",children:n==="preset"?"请选择预设的部署方式":n==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(ps,{open:U,onOpenChange:R,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认切换模式"}),e.jsxs(ms,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(ds,{children:[e.jsx(xs,{onClick:()=>{R(!1),B(null)},children:"取消"}),e.jsx(hs,{onClick:H,children:"确认切换"})]})]})}),e.jsx(ps,{open:ee,onOpenChange:V,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认清空路径"}),e.jsxs(ms,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(ds,{children:[e.jsx(xs,{onClick:()=>V(!1),children:"取消"}),e.jsx(hs,{onClick:me,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function Tw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"Napcat WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"napcat-host",value:n.napcat_server.host,onChange:c=>r({...n,napcat_server:{...n.napcat_server,host:c.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的主机地址"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"napcat-port",type:"number",value:n.napcat_server.port||"",onChange:c=>r({...n,napcat_server:{...n.napcat_server,port:c.target.value?parseInt(c.target.value):0}}),placeholder:"8095",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的端口(留空使用默认值 8095)"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-token",className:"text-sm md:text-base",children:"访问令牌(Token)"}),e.jsx(ce,{id:"napcat-token",type:"password",value:n.napcat_server.token,onChange:c=>r({...n,napcat_server:{...n.napcat_server,token:c.target.value}}),placeholder:"留空表示无需令牌",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的访问令牌,若无则留空"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"napcat-heartbeat",className:"text-sm md:text-base",children:"心跳间隔(秒)"}),e.jsx(ce,{id:"napcat-heartbeat",type:"number",value:n.napcat_server.heartbeat_interval||"",onChange:c=>r({...n,napcat_server:{...n.napcat_server,heartbeat_interval:c.target.value?parseInt(c.target.value):0}}),placeholder:"30",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"与 Napcat 设置的心跳间隔保持一致(留空使用默认值 30)"})]})]})]})})}function Ew({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"麦麦 WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"maibot-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"maibot-host",value:n.maibot_server.host,onChange:c=>r({...n,maibot_server:{...n.maibot_server,host:c.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 HOST 字段"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"maibot-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"maibot-port",type:"number",value:n.maibot_server.port||"",onChange:c=>r({...n,maibot_server:{...n.maibot_server,port:c.target.value?parseInt(c.target.value):0}}),placeholder:"8000",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 PORT 字段(留空使用默认值 8000)"})]})]})]})})}function zw({config:n,onChange:r}){const c=x=>{const f={...n};x==="group"?f.chat.group_list=[...f.chat.group_list,0]:x==="private"?f.chat.private_list=[...f.chat.private_list,0]:f.chat.ban_user_id=[...f.chat.ban_user_id,0],r(f)},d=(x,f)=>{const j={...n};x==="group"?j.chat.group_list=j.chat.group_list.filter((g,_)=>_!==f):x==="private"?j.chat.private_list=j.chat.private_list.filter((g,_)=>_!==f):j.chat.ban_user_id=j.chat.ban_user_id.filter((g,_)=>_!==f),r(j)},h=(x,f,j)=>{const g={...n};x==="group"?g.chat.group_list[f]=j:x==="private"?g.chat.private_list[f]=j:g.chat.ban_user_id[f]=j,r(g)};return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"聊天黑白名单功能"}),e.jsxs("div",{className:"grid gap-4 md:gap-6",children:[e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"群组名单类型"}),e.jsxs(Qe,{value:n.chat.group_list_type,onValueChange:x=>r({...n,chat:{...n.chat,group_list_type:x}}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(ue,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(b,{className:"text-sm md:text-base",children:"群组列表"}),e.jsxs(N,{onClick:()=>c("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ma,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),n.chat.group_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("group",f,parseInt(j.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除群号 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d("group",f),children:"删除"})]})]})]})]},f)),n.chat.group_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无群组"})]})]}),e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"私聊名单类型"}),e.jsxs(Qe,{value:n.chat.private_list_type,onValueChange:x=>r({...n,chat:{...n.chat,private_list_type:x}}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(ue,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(b,{className:"text-sm md:text-base",children:"私聊列表"}),e.jsxs(N,{onClick:()=>c("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ma,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.private_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("private",f,parseInt(j.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d("private",f),children:"删除"})]})]})]})]},f)),n.chat.private_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无用户"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"全局禁止名单"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"名单中的用户无法进行任何聊天"})]}),e.jsxs(N,{onClick:()=>c("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ma,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.ban_user_id.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:x,onChange:j=>h("ban",f,parseInt(j.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ps,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(N,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:["确定要从全局禁止名单中删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>d("ban",f),children:"删除"})]})]})]})]},f)),n.chat.ban_user_id.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无禁止用户"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"屏蔽QQ官方机器人"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否屏蔽来自QQ官方机器人的消息"})]}),e.jsx(qe,{checked:n.chat.ban_qq_bot,onCheckedChange:x=>r({...n,chat:{...n.chat,ban_qq_bot:x}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"启用戳一戳功能"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否响应戳一戳消息"})]}),e.jsx(qe,{checked:n.chat.enable_poke,onCheckedChange:x=>r({...n,chat:{...n.chat,enable_poke:x}})})]})]})]})})}function Mw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"发送语音设置"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-sm md:text-base",children:"使用 TTS 语音"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"请确保已配置 TTS 并有对应的适配器"})]}),e.jsx(qe,{checked:n.voice.use_tts,onCheckedChange:c=>r({...n,voice:{use_tts:c}})})]})]})})}function Aw({config:n,onChange:r}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"调试设置"}),e.jsx("div",{className:"grid gap-3 md:gap-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{className:"text-sm md:text-base",children:"日志等级"}),e.jsxs(Qe,{value:n.debug.level,onValueChange:c=>r({...n,debug:{level:c}}),children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"DEBUG",children:"DEBUG(调试)"}),e.jsx(ue,{value:"INFO",children:"INFO(信息)"}),e.jsx(ue,{value:"WARNING",children:"WARNING(警告)"}),e.jsx(ue,{value:"ERROR",children:"ERROR(错误)"}),e.jsx(ue,{value:"CRITICAL",children:"CRITICAL(严重)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const Dw=["defaultChecked","defaultValue","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML","accessKey","className","contentEditable","contextMenu","dir","draggable","hidden","id","lang","placeholder","slot","spellCheck","style","tabIndex","title","translate","radioGroup","role","about","datatype","inlist","prefix","property","resource","typeof","vocab","autoCapitalize","autoCorrect","autoSave","color","itemProp","itemScope","itemType","itemID","itemRef","results","security","unselectable","inputMode","is","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],Ow=/^(aria-|data-)/,Gg=n=>Object.fromEntries(Object.entries(n).filter(([r])=>Ow.test(r)||Dw.includes(r)));function Rw(n,r){const c=Gg(n);return Object.keys(n).some(d=>!Object.hasOwn(c,d)&&n[d]!==r[d])}class Lw extends u.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(r){if(r.uppy!==this.props.uppy)this.uninstallPlugin(r),this.installPlugin();else if(Rw(this.props,r)){const{uppy:c,...d}={...this.props,target:this.container};this.plugin.setOptions(d)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:r,...c}={id:"Dashboard",...this.props,inline:!0,target:this.container};r.use(vb,c),this.plugin=r.getPlugin(c.id)}uninstallPlugin(r=this.props){const{uppy:c}=r;c.removePlugin(this.plugin)}render(){return u.createElement("div",{className:"uppy-Container",ref:r=>{this.container=r},...Gg(this.props)})}}function Uw({content:n,className:r=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${r}`,children:e.jsx(Nb,{remarkPlugins:[wb,_b],rehypePlugins:[bb],components:{code({inline:c,className:d,children:h,...x}){return c?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...x,children:h}):e.jsx("code",{className:`${d} block bg-muted p-4 rounded-lg overflow-x-auto`,...x,children:h})},table({children:c,...d}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...d,children:c})})},th({children:c,...d}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...d,children:c})},td({children:c,...d}){return e.jsx("td",{className:"border border-border px-4 py-2",...d,children:c})},a({children:c,...d}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...d,children:c})},blockquote({children:c,...d}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...d,children:c})},h1({children:c,...d}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...d,children:c})},h2({children:c,...d}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...d,children:c})},h3({children:c,...d}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...d,children:c})},h4({children:c,...d}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...d,children:c})},ul({children:c,...d}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...d,children:c})},ol({children:c,...d}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...d,children:c})},p({children:c,...d}){return e.jsx("p",{className:"my-2 leading-relaxed",...d,children:c})},hr({...c}){return e.jsx("hr",{className:"my-4 border-border",...c})}},children:n})})}function Bw({children:n,className:r}){return e.jsx(Uw,{content:n,className:r})}const Ra="/api/webui/emoji";async function Hw(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.is_registered!==void 0&&r.append("is_registered",n.is_registered.toString()),n.is_banned!==void 0&&r.append("is_banned",n.is_banned.toString()),n.format&&r.append("format",n.format),n.sort_by&&r.append("sort_by",n.sort_by),n.sort_order&&r.append("sort_order",n.sort_order);const c=await ke(`${Ra}/list?${r}`,{headers:ze()});if(!c.ok)throw new Error(`获取表情包列表失败: ${c.statusText}`);return c.json()}async function qw(n){const r=await ke(`${Ra}/${n}`,{headers:ze()});if(!r.ok)throw new Error(`获取表情包详情失败: ${r.statusText}`);return r.json()}async function Gw(n,r){const c=await ke(`${Ra}/${n}`,{method:"PATCH",headers:ze(),body:JSON.stringify(r)});if(!c.ok)throw new Error(`更新表情包失败: ${c.statusText}`);return c.json()}async function Vw(n){const r=await ke(`${Ra}/${n}`,{method:"DELETE",headers:ze()});if(!r.ok)throw new Error(`删除表情包失败: ${r.statusText}`);return r.json()}async function Fw(){const n=await ke(`${Ra}/stats/summary`,{headers:ze()});if(!n.ok)throw new Error(`获取统计数据失败: ${n.statusText}`);return n.json()}async function Qw(n){const r=await ke(`${Ra}/${n}/register`,{method:"POST",headers:ze()});if(!r.ok)throw new Error(`注册表情包失败: ${r.statusText}`);return r.json()}async function $w(n){const r=await ke(`${Ra}/${n}/ban`,{method:"POST",headers:ze()});if(!r.ok)throw new Error(`封禁表情包失败: ${r.statusText}`);return r.json()}function Vg(n){const r=localStorage.getItem("access-token");return`${Ra}/${n}/thumbnail?token=${encodeURIComponent(r||"")}`}async function Yw(n){const r=await ke(`${Ra}/batch/delete`,{method:"POST",headers:ze(),body:JSON.stringify({emoji_ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除失败")}return r.json()}function Xw(){return`${Ra}/upload`}function Kw(){const[n,r]=u.useState([]),[c,d]=u.useState(null),[h,x]=u.useState(!1),[f,j]=u.useState(1),[g,_]=u.useState(0),[v,k]=u.useState(20),[z,T]=u.useState("all"),[L,K]=u.useState("all"),[U,R]=u.useState("all"),[ee,V]=u.useState("usage_count"),[E,B]=u.useState("desc"),[X,w]=u.useState(null),[D,te]=u.useState(!1),[xe,be]=u.useState(!1),[ye,ve]=u.useState(!1),[pe,Ne]=u.useState(new Set),[y,q]=u.useState(!1),[H,ne]=u.useState(""),[S,me]=u.useState("medium"),[he,Q]=u.useState(!1),{toast:oe}=Bs(),ge=u.useCallback(async()=>{try{x(!0);const ie=await Hw({page:f,page_size:v,is_registered:z==="all"?void 0:z==="registered",is_banned:L==="all"?void 0:L==="banned",format:U==="all"?void 0:U,sort_by:ee,sort_order:E});r(ie.data),_(ie.total)}catch(ie){const we=ie instanceof Error?ie.message:"加载表情包列表失败";oe({title:"错误",description:we,variant:"destructive"})}finally{x(!1)}},[f,v,z,L,U,ee,E,oe]),le=async()=>{try{const ie=await Fw();d(ie.data)}catch(ie){console.error("加载统计数据失败:",ie)}};u.useEffect(()=>{ge()},[ge]),u.useEffect(()=>{le()},[]);const O=async ie=>{try{const we=await qw(ie.id);w(we.data),te(!0)}catch(we){const Ke=we instanceof Error?we.message:"加载详情失败";oe({title:"错误",description:Ke,variant:"destructive"})}},F=ie=>{w(ie),be(!0)},A=ie=>{w(ie),ve(!0)},W=async()=>{if(X)try{await Vw(X.id),oe({title:"成功",description:"表情包已删除"}),ve(!1),w(null),ge(),le()}catch(ie){const we=ie instanceof Error?ie.message:"删除失败";oe({title:"错误",description:we,variant:"destructive"})}},_e=async ie=>{try{await Qw(ie.id),oe({title:"成功",description:"表情包已注册"}),ge(),le()}catch(we){const Ke=we instanceof Error?we.message:"注册失败";oe({title:"错误",description:Ke,variant:"destructive"})}},Me=async ie=>{try{await $w(ie.id),oe({title:"成功",description:"表情包已封禁"}),ge(),le()}catch(we){const Ke=we instanceof Error?we.message:"封禁失败";oe({title:"错误",description:Ke,variant:"destructive"})}},ss=ie=>{const we=new Set(pe);we.has(ie)?we.delete(ie):we.add(ie),Ne(we)},Ie=async()=>{try{const ie=await Yw(Array.from(pe));oe({title:"批量删除完成",description:ie.message}),Ne(new Set),q(!1),ge(),le()}catch(ie){oe({title:"批量删除失败",description:ie instanceof Error?ie.message:"批量删除失败",variant:"destructive"})}},Rs=()=>{const ie=parseInt(H),we=Math.ceil(g/v);ie>=1&&ie<=we?(j(ie),ne("")):oe({title:"无效的页码",description:`请输入1-${we}之间的页码`,variant:"destructive"})},qs=c?.formats?Object.keys(c.formats):[];return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"表情包管理"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理麦麦的表情包资源"})]}),e.jsxs(N,{onClick:()=>Q(!0),className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[c&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Be,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"总数"}),e.jsx(js,{className:"text-2xl",children:c.total})]})}),e.jsx(Be,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"已注册"}),e.jsx(js,{className:"text-2xl text-green-600",children:c.registered})]})}),e.jsx(Be,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"已封禁"}),e.jsx(js,{className:"text-2xl text-red-600",children:c.banned})]})}),e.jsx(Be,{children:e.jsxs(gs,{className:"pb-2",children:[e.jsx(Zs,{children:"未注册"}),e.jsx(js,{className:"text-2xl text-gray-600",children:c.unregistered})]})})]}),e.jsxs(Be,{children:[e.jsx(gs,{children:e.jsxs(js,{className:"flex items-center gap-2",children:[e.jsx(Lu,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(bs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"排序方式"}),e.jsxs(Qe,{value:`${ee}-${E}`,onValueChange:ie=>{const[we,Ke]=ie.split("-");V(we),B(Ke),j(1)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(ue,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(ue,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(ue,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(ue,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(ue,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(ue,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(ue,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"注册状态"}),e.jsxs(Qe,{value:z,onValueChange:ie=>{T(ie),j(1)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部"}),e.jsx(ue,{value:"registered",children:"已注册"}),e.jsx(ue,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"封禁状态"}),e.jsxs(Qe,{value:L,onValueChange:ie=>{K(ie),j(1)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部"}),e.jsx(ue,{value:"banned",children:"已封禁"}),e.jsx(ue,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"格式"}),e.jsxs(Qe,{value:U,onValueChange:ie=>{R(ie),j(1)},children:[e.jsx(Ge,{children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部"}),qs.map(ie=>e.jsxs(ue,{value:ie,children:[ie.toUpperCase()," (",c?.formats[ie],")"]},ie))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[pe.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",pe.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs(Qe,{value:S,onValueChange:ie=>me(ie),children:[e.jsx(Ge,{className:"w-24",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"small",children:"小"}),e.jsx(ue,{value:"medium",children:"中"}),e.jsx(ue,{value:"large",children:"大"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Qe,{value:v.toString(),onValueChange:ie=>{k(parseInt(ie)),j(1),Ne(new Set)},children:[e.jsx(Ge,{id:"emoji-page-size",className:"w-20",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"20",children:"20"}),e.jsx(ue,{value:"40",children:"40"}),e.jsx(ue,{value:"60",children:"60"}),e.jsx(ue,{value:"100",children:"100"})]})]}),pe.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Ne(new Set),children:"取消选择"}),e.jsxs(N,{variant:"destructive",size:"sm",onClick:()=>q(!0),children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(N,{variant:"outline",size:"sm",onClick:ge,disabled:h,children:[e.jsx(ft,{className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"表情包列表"}),e.jsxs(Zs,{children:["共 ",g," 个表情包,当前第 ",f," 页"]})]}),e.jsxs(bs,{children:[n.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${S==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":S==="medium"?"grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8":"grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5"}`,children:n.map(ie=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${pe.has(ie.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>ss(ie.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${pe.has(ie.id)?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:e.jsx("div",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center ${pe.has(ie.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:pe.has(ie.id)&&e.jsx(xa,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[ie.is_registered&&e.jsx(Xe,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),ie.is_banned&&e.jsx(Xe,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"已封禁"})]}),e.jsx("div",{className:`aspect-square bg-muted flex items-center justify-center overflow-hidden ${S==="small"?"p-1":S==="medium"?"p-2":"p-3"}`,children:e.jsx("img",{src:Vg(ie.id),alt:"表情包",className:"w-full h-full object-contain",loading:"lazy",onError:we=>{const Ke=we.target;Ke.style.display="none";const Le=Ke.parentElement;Le&&(Le.innerHTML='')}})}),e.jsxs("div",{className:`border-t bg-card ${S==="small"?"p-1":"p-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 text-xs text-muted-foreground mb-1",children:[e.jsx(Xe,{variant:"outline",className:"text-[10px] px-1 py-0",children:ie.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[ie.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${S==="small"?"flex-wrap":""}`,children:[e.jsx(N,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:we=>{we.stopPropagation(),F(ie)},title:"编辑",children:e.jsx(pr,{className:"h-3 w-3"})}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:we=>{we.stopPropagation(),O(ie)},title:"详情",children:e.jsx(Xt,{className:"h-3 w-3"})}),!ie.is_registered&&e.jsx(N,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:we=>{we.stopPropagation(),_e(ie)},title:"注册",children:e.jsx(xa,{className:"h-3 w-3"})}),!ie.is_banned&&e.jsx(N,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:we=>{we.stopPropagation(),Me(ie)},title:"封禁",children:e.jsx(UN,{className:"h-3 w-3"})}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:we=>{we.stopPropagation(),A(ie)},title:"删除",children:e.jsx(ns,{className:"h-3 w-3"})})]})]})]},ie.id))}),g>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["显示 ",(f-1)*v+1," 到"," ",Math.min(f*v,g)," 条,共 ",g," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(ie=>Math.max(1,ie-1)),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:H,onChange:ie=>ne(ie.target.value),onKeyDown:ie=>ie.key==="Enter"&&Rs(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(g/v)}),e.jsx(N,{variant:"outline",size:"sm",onClick:Rs,disabled:!H,className:"h-8",children:"跳转"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(ie=>ie+1),disabled:f>=Math.ceil(g/v),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(g/v)),disabled:f>=Math.ceil(g/v),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(Zw,{emoji:X,open:D,onOpenChange:te}),e.jsx(Iw,{emoji:X,open:xe,onOpenChange:be,onSuccess:()=>{ge(),le()}}),e.jsx(Jw,{open:he,onOpenChange:Q,onSuccess:()=>{ge(),le()}})]})}),e.jsx(ps,{open:y,onOpenChange:q,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认批量删除"}),e.jsxs(ms,{children:["你确定要删除选中的 ",pe.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:Ie,children:"确认删除"})]})]})}),e.jsx(Os,{open:ye,onOpenChange:ve,children:e.jsxs(Es,{children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"确认删除"}),e.jsx($s,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>ve(!1),children:"取消"}),e.jsx(N,{variant:"destructive",onClick:W,children:"删除"})]})]})})]})}function Zw({emoji:n,open:r,onOpenChange:c}){if(!n)return null;const d=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(zs,{children:e.jsx(Ms,{children:"表情包详情"})}),e.jsx(es,{className:"max-h-[calc(90vh-8rem)] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-32 h-32 bg-muted rounded-lg flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:Vg(n.id),alt:n.description||"表情包",className:"w-full h-full object-cover",onError:h=>{const x=h.target;x.style.display="none";const f=x.parentElement;f&&(f.innerHTML='')}})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:n.id})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(Xe,{variant:"outline",children:n.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.full_path})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"描述"}),n.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(Bw,{className:"prose-sm",children:n.description})}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"-"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"情绪"}),e.jsx("div",{className:"mt-1",children:n.emotion?e.jsx("span",{className:"text-sm",children:n.emotion}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[n.is_registered&&e.jsx(Xe,{variant:"default",className:"bg-green-600",children:"已注册"}),n.is_banned&&e.jsx(Xe,{variant:"destructive",children:"已封禁"}),!n.is_registered&&!n.is_banned&&e.jsx(Xe,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:n.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.record_time)})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.last_used_time)})]})]})})]})})}function Iw({emoji:n,open:r,onOpenChange:c,onSuccess:d}){const[h,x]=u.useState(""),[f,j]=u.useState(!1),[g,_]=u.useState(!1),[v,k]=u.useState(!1),{toast:z}=Bs();u.useEffect(()=>{n&&(x(n.emotion||""),j(n.is_registered),_(n.is_banned))},[n]);const T=async()=>{if(n)try{k(!0);const L=h.split(/[,,]/).map(K=>K.trim()).filter(Boolean).join(",");await Gw(n.id,{emotion:L||void 0,is_registered:f,is_banned:g}),z({title:"成功",description:"表情包信息已更新"}),c(!1),d()}catch(L){const K=L instanceof Error?L.message:"保存失败";z({title:"错误",description:K,variant:"destructive"})}finally{k(!1)}};return n?e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"编辑表情包"}),e.jsx($s,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(b,{children:"情绪"}),e.jsx(Us,{value:h,onChange:L=>x(L.target.value),placeholder:"输入情绪描述...",rows:2,className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入情绪相关的文本描述"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"is_registered",checked:f,onCheckedChange:L=>{L===!0?(j(!0),_(!1)):j(!1)}}),e.jsx(b,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"is_banned",checked:g,onCheckedChange:L=>{L===!0?(_(!0),j(!1)):_(!1)}}),e.jsx(b,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(N,{onClick:T,disabled:v,children:v?"保存中...":"保存"})]})]})}):null}function Jw({open:n,onOpenChange:r,onSuccess:c}){const[d,h]=u.useState("select"),[x,f]=u.useState([]),[j,g]=u.useState(null),[_,v]=u.useState(!1),{toast:k}=Bs(),z=u.useMemo(()=>new yb({id:"emoji-uploader",autoProceed:!1,restrictions:{maxFileSize:10485760,allowedFileTypes:["image/jpeg","image/png","image/gif","image/webp"],maxNumberOfFiles:20},locale:{pluralize:()=>0,strings:{addMoreFiles:"添加更多文件",addingMoreFiles:"正在添加更多文件",allowedFileTypes:"允许的文件类型:%{types}",cancel:"取消",closeModal:"关闭",complete:"完成",connectedToInternet:"已连接到互联网",copyLink:"复制链接",copyLinkToClipboardFallback:"复制下方链接",copyLinkToClipboardSuccess:"链接已复制到剪贴板",dashboardTitle:"选择文件",dashboardWindowTitle:"文件选择窗口(按 ESC 关闭)",done:"完成",dropHereOr:"拖放文件到这里或 %{browse}",dropHint:"将文件拖放到此处",dropPasteFiles:"将文件拖放到这里或 %{browseFiles}",dropPasteFolders:"将文件拖放到这里或 %{browseFolders}",dropPasteBoth:"将文件拖放到这里,%{browseFiles} 或 %{browseFolders}",dropPasteImportFiles:"将文件拖放到这里,%{browseFiles} 或从以下位置导入:",dropPasteImportFolders:"将文件拖放到这里,%{browseFolders} 或从以下位置导入:",dropPasteImportBoth:"将文件拖放到这里,%{browseFiles},%{browseFolders} 或从以下位置导入:",editFile:"编辑文件",editing:"正在编辑 %{file}",emptyFolderAdded:"未从空文件夹添加文件",exceedsSize:"%{file} 超过了最大允许大小 %{size}",failedToUpload:"上传 %{file} 失败",fileSource:"文件来源:%{name}",filesUploadedOfTotal:{0:"已上传 %{complete} / %{smart_count} 个文件",1:"已上传 %{complete} / %{smart_count} 个文件"},filter:"筛选",finishEditingFile:"完成编辑文件",folderAdded:{0:"已从 %{folder} 添加 %{smart_count} 个文件",1:"已从 %{folder} 添加 %{smart_count} 个文件"},generatingThumbnails:"正在生成缩略图...",import:"导入",importFiles:"从以下位置导入文件:",importFrom:"从 %{name} 导入",loading:"加载中...",logOut:"登出",myDevice:"我的设备",noFilesFound:"这里没有文件或文件夹",noInternetConnection:"无网络连接",openFolderNamed:"打开文件夹 %{name}",pause:"暂停",pauseUpload:"暂停上传",paused:"已暂停",poweredBy:"技术支持:%{uppy}",processingXFiles:{0:"正在处理 %{smart_count} 个文件",1:"正在处理 %{smart_count} 个文件"},recording:"录制中",removeFile:"移除文件",resetFilter:"重置筛选",resume:"继续",resumeUpload:"继续上传",retry:"重试",retryUpload:"重试上传",save:"保存",saveChanges:"保存更改",selectFileNamed:"选择文件 %{name}",selectX:{0:"选择 %{smart_count}",1:"选择 %{smart_count}"},smile:"笑一个!",startRecording:"开始录制视频",stopRecording:"停止录制视频",takePicture:"拍照",timedOut:"上传已停滞 %{seconds} 秒,正在中止。",upload:"下一步",uploadComplete:"上传完成",uploadFailed:"上传失败",uploadPaused:"上传已暂停",uploadXFiles:{0:"下一步(%{smart_count} 个文件)",1:"下一步(%{smart_count} 个文件)"},uploadXNewFiles:{0:"下一步(+%{smart_count} 个文件)",1:"下一步(+%{smart_count} 个文件)"},uploading:"正在上传",uploadingXFiles:{0:"正在上传 %{smart_count} 个文件",1:"正在上传 %{smart_count} 个文件"},xFilesSelected:{0:"已选择 %{smart_count} 个文件",1:"已选择 %{smart_count} 个文件"},xMoreFilesAdded:{0:"又添加了 %{smart_count} 个文件",1:"又添加了 %{smart_count} 个文件"},xTimeLeft:"剩余 %{time}",youCanOnlyUploadFileTypes:"您只能上传:%{types}",youCanOnlyUploadX:{0:"您只能上传 %{smart_count} 个文件",1:"您只能上传 %{smart_count} 个文件"},youHaveToAtLeastSelectX:{0:"您至少需要选择 %{smart_count} 个文件",1:"您至少需要选择 %{smart_count} 个文件"},browseFiles:"浏览文件",browseFolders:"浏览文件夹",cancelUpload:"取消上传",addMore:"添加更多",back:"返回",editFileWithFilename:"编辑文件 %{file}"}}}),[]);u.useEffect(()=>{const X=()=>{const w=z.getFiles();if(w.length===0)return;const D=w.map(te=>({id:te.id,name:te.name,previewUrl:te.preview||URL.createObjectURL(te.data),emotion:"",description:"",isRegistered:!0,file:te.data}));f(D),w.length===1?(g(D[0].id),h("edit-single")):h("edit-multiple")};return z.on("upload",X),()=>{z.off("upload",X)}},[z]),u.useEffect(()=>{n||(z.cancelAll(),h("select"),f([]),g(null),v(!1))},[n,z]);const T=u.useCallback((X,w)=>{f(D=>D.map(te=>te.id===X?{...te,...w}:te))},[]),L=u.useCallback(X=>X.emotion.trim().length>0,[]),K=u.useMemo(()=>x.length>0&&x.every(L),[x,L]),U=u.useMemo(()=>x.find(X=>X.id===j)||null,[x,j]),R=u.useCallback(()=>{(d==="edit-single"||d==="edit-multiple")&&(h("select"),f([]),g(null))},[d]),ee=u.useCallback(async()=>{if(!K){k({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}v(!0);const X=localStorage.getItem("access-token")||"";let w=0,D=0;try{for(const te of x){const xe=new FormData;xe.append("file",te.file),xe.append("emotion",te.emotion),xe.append("description",te.description),xe.append("is_registered",te.isRegistered.toString());try{(await fetch(Xw(),{method:"POST",headers:{Authorization:`Bearer ${X}`},body:xe})).ok?w++:D++}catch{D++}}D===0?(k({title:"上传成功",description:`成功上传 ${w} 个表情包`}),r(!1),c()):(k({title:"部分上传失败",description:`成功 ${w} 个,失败 ${D} 个`,variant:"destructive"}),c())}finally{v(!1)}},[K,x,k,r,c]),V=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(Lw,{uppy:z,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),E=()=>{const X=x[0];return X?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(N,{variant:"ghost",size:"sm",onClick:R,children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"编辑表情包信息"})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"w-32 h-32 rounded-lg border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:X.previewUrl,alt:X.name,className:"max-w-full max-h-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate max-w-32",children:X.name})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"single-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"single-emotion",value:X.emotion,onChange:w=>T(X.id,{emotion:w.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:X.emotion.trim()?"":"border-destructive"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于情感匹配,多个标签用逗号分隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"single-description",children:"描述"}),e.jsx(ce,{id:"single-description",value:X.description,onChange:w=>T(X.id,{description:w.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"single-is-registered",checked:X.isRegistered,onCheckedChange:w=>T(X.id,{isRegistered:w===!0})}),e.jsx(b,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(Is,{children:e.jsx(N,{onClick:ee,disabled:!K||_,children:_?"上传中...":"上传"})})]}):null},B=()=>{const X=x.filter(L).length,w=x.length;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(N,{variant:"ghost",size:"sm",onClick:R,children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",X,"/",w," 已完成)"]})]}),e.jsx(Xe,{variant:K?"default":"secondary",children:K?e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(es,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:x.map(D=>{const te=L(D),xe=j===D.id;return e.jsxs("div",{onClick:()=>g(D.id),className:` - flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all - ${xe?"ring-2 ring-primary":""} - ${te?"border-green-500 bg-green-50 dark:bg-green-950/20":"border-border hover:border-muted-foreground/50"} - `,children:[e.jsx("div",{className:"w-12 h-12 rounded border overflow-hidden bg-muted flex-shrink-0 flex items-center justify-center",children:e.jsx("img",{src:D.previewUrl,alt:D.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:D.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:D.emotion||"未填写情感标签"})]}),te?e.jsx(xa,{className:"h-5 w-5 text-green-500 flex-shrink-0"}):e.jsx("div",{className:"h-5 w-5 rounded-full border-2 border-muted-foreground/30 flex-shrink-0"})]},D.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:U?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:U.previewUrl,alt:U.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:U.name}),L(U)&&e.jsxs(Xe,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"已完成"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"multi-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"multi-emotion",value:U.emotion,onChange:D=>T(U.id,{emotion:D.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:U.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"multi-description",children:"描述"}),e.jsx(ce,{id:"multi-description",value:U.description,onChange:D=>T(U.id,{description:D.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"multi-is-registered",checked:U.isRegistered,onCheckedChange:D=>T(U.id,{isRegistered:D===!0})}),e.jsx(b,{htmlFor:"multi-is-registered",className:"cursor-pointer text-sm",children:"上传后立即注册"})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(BN,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(Is,{children:e.jsx(N,{onClick:ee,disabled:!K||_,children:_?"上传中...":`上传全部 (${w})`})})]})};return e.jsx(Os,{open:n,onOpenChange:r,children:e.jsxs(Es,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(zs,{children:[e.jsxs(Ms,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),d==="select"&&"上传表情包 - 选择文件",d==="edit-single"&&"上传表情包 - 填写信息",d==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs($s,{children:[d==="select"&&"支持 JPG、PNG、GIF、WebP 格式,单个文件最大 10MB,可同时上传多个文件",d==="edit-single"&&"请填写表情包的情感标签(必填)和描述",d==="edit-multiple"&&"点击左侧卡片编辑每个表情包的信息,情感标签为必填项"]})]}),e.jsxs("div",{className:"overflow-y-auto pr-1",children:[d==="select"&&V(),d==="edit-single"&&E(),d==="edit-multiple"&&B()]})]})})}const Bl="/api/webui/expression";async function Pw(){const n=await ke(`${Bl}/chats`,{headers:ze()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取聊天列表失败")}return n.json()}async function Ww(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.chat_id&&r.append("chat_id",n.chat_id);const c=await ke(`${Bl}/list?${r}`,{headers:ze()});if(!c.ok){const d=await c.json();throw new Error(d.detail||"获取表达方式列表失败")}return c.json()}async function e1(n){const r=await ke(`${Bl}/${n}`,{headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取表达方式详情失败")}return r.json()}async function s1(n){const r=await ke(`${Bl}/`,{method:"POST",headers:ze(),body:JSON.stringify(n)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"创建表达方式失败")}return r.json()}async function t1(n,r){const c=await ke(`${Bl}/${n}`,{method:"PATCH",headers:ze(),body:JSON.stringify(r)});if(!c.ok){const d=await c.json();throw new Error(d.detail||"更新表达方式失败")}return c.json()}async function a1(n){const r=await ke(`${Bl}/${n}`,{method:"DELETE",headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"删除表达方式失败")}return r.json()}async function l1(n){const r=await ke(`${Bl}/batch/delete`,{method:"POST",headers:ze(),body:JSON.stringify({ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除表达方式失败")}return r.json()}async function n1(){const n=await ke(`${Bl}/stats/summary`,{headers:ze()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取统计数据失败")}return n.json()}function i1(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(0),[f,j]=u.useState(1),[g,_]=u.useState(20),[v,k]=u.useState(""),[z,T]=u.useState(null),[L,K]=u.useState(!1),[U,R]=u.useState(!1),[ee,V]=u.useState(!1),[E,B]=u.useState(null),[X,w]=u.useState(new Set),[D,te]=u.useState(!1),[xe,be]=u.useState(""),[ye,ve]=u.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[pe,Ne]=u.useState([]),[y,q]=u.useState(new Map),{toast:H}=Bs(),ne=async()=>{try{d(!0);const W=await Ww({page:f,page_size:g,search:v||void 0});r(W.data),x(W.total)}catch(W){H({title:"加载失败",description:W instanceof Error?W.message:"无法加载表达方式",variant:"destructive"})}finally{d(!1)}},S=async()=>{try{const W=await n1();W?.data&&ve(W.data)}catch(W){console.error("加载统计数据失败:",W)}},me=async()=>{try{const W=await Pw();if(W?.data){Ne(W.data);const _e=new Map;W.data.forEach(Me=>{_e.set(Me.chat_id,Me.chat_name)}),q(_e)}}catch(W){console.error("加载聊天列表失败:",W)}},he=W=>y.get(W)||W;u.useEffect(()=>{ne(),S(),me()},[f,g,v]);const Q=async W=>{try{const _e=await e1(W.id);T(_e.data),K(!0)}catch(_e){H({title:"加载详情失败",description:_e instanceof Error?_e.message:"无法加载表达方式详情",variant:"destructive"})}},oe=W=>{T(W),R(!0)},ge=async W=>{try{await a1(W.id),H({title:"删除成功",description:`已删除表达方式: ${W.situation}`}),B(null),ne(),S()}catch(_e){H({title:"删除失败",description:_e instanceof Error?_e.message:"无法删除表达方式",variant:"destructive"})}},le=W=>{const _e=new Set(X);_e.has(W)?_e.delete(W):_e.add(W),w(_e)},O=()=>{X.size===n.length&&n.length>0?w(new Set):w(new Set(n.map(W=>W.id)))},F=async()=>{try{await l1(Array.from(X)),H({title:"批量删除成功",description:`已删除 ${X.size} 个表达方式`}),w(new Set),te(!1),ne(),S()}catch(W){H({title:"批量删除失败",description:W instanceof Error?W.message:"无法批量删除表达方式",variant:"destructive"})}},A=()=>{const W=parseInt(xe),_e=Math.ceil(h/g);W>=1&&W<=_e?(j(W),be("")):H({title:"无效的页码",description:`请输入1-${_e}之间的页码`,variant:"destructive"})};return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(si,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs(N,{onClick:()=>V(!0),className:"gap-2",children:[e.jsx(gt,{className:"h-4 w-4"}),"新增表达方式"]})]})}),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:ye.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"近7天新增"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:ye.recent_7days})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-blue-600",children:ye.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx(b,{htmlFor:"search",children:"搜索"}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2 mt-1.5",children:e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(St,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索情境、风格或上下文...",value:v,onChange:W=>k(W.target.value),className:"pl-9"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:X.size>0&&e.jsxs("span",{children:["已选择 ",X.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Qe,{value:g.toString(),onValueChange:W=>{_(parseInt(W)),j(1),w(new Set)},children:[e.jsx(Ge,{id:"page-size",className:"w-20",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"10",children:"10"}),e.jsx(ue,{value:"20",children:"20"}),e.jsx(ue,{value:"50",children:"50"}),e.jsx(ue,{value:"100",children:"100"})]})]}),X.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>w(new Set),children:"取消选择"}),e.jsxs(N,{variant:"destructive",size:"sm",onClick:()=>te(!0),children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(pt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:X.size===n.length&&n.length>0,onCheckedChange:O})}),e.jsx(ls,{children:"情境"}),e.jsx(ls,{children:"风格"}),e.jsx(ls,{children:"聊天"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c?e.jsx(pt,{children:e.jsx(Ye,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(pt,{children:e.jsx(Ye,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(W=>e.jsxs(pt,{children:[e.jsx(Ye,{children:e.jsx(yt,{checked:X.has(W.id),onCheckedChange:()=>le(W.id)})}),e.jsx(Ye,{className:"font-medium max-w-xs truncate",children:W.situation}),e.jsx(Ye,{className:"max-w-xs truncate",children:W.style}),e.jsx(Ye,{className:"max-w-[200px] truncate",title:he(W.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:he(W.chat_id)})}),e.jsx(Ye,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(N,{variant:"default",size:"sm",onClick:()=>oe(W),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(N,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(W),title:"查看详情",children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsxs(N,{size:"sm",onClick:()=>B(W),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},W.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:c?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(W=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(yt,{checked:X.has(W.id),onCheckedChange:()=>le(W.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"情境"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-2 w-full break-all",title:W.situation,children:W.situation})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"风格"}),e.jsx("p",{className:"text-sm line-clamp-2 w-full break-all",title:W.style,children:W.style})]})]})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"聊天"}),e.jsx("p",{className:"text-sm truncate",title:he(W.chat_id),style:{wordBreak:"keep-all"},children:he(W.chat_id)})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>oe(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>Q(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(Zt,{className:"h-3 w-3"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>B(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ns,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},W.id))}),h>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",h," 条记录,第 ",f," / ",Math.ceil(h/g)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(f-1),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:xe,onChange:W=>be(W.target.value),onKeyDown:W=>W.key==="Enter"&&A(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(h/g)}),e.jsx(N,{variant:"outline",size:"sm",onClick:A,disabled:!xe,className:"h-8",children:"跳转"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(f+1),disabled:f>=Math.ceil(h/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(h/g)),disabled:f>=Math.ceil(h/g),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(r1,{expression:z,open:L,onOpenChange:K,chatNameMap:y}),e.jsx(c1,{open:ee,onOpenChange:V,chatList:pe,onSuccess:()=>{ne(),S(),V(!1)}}),e.jsx(o1,{expression:z,open:U,onOpenChange:R,chatList:pe,onSuccess:()=>{ne(),S(),R(!1)}}),e.jsx(ps,{open:!!E,onOpenChange:()=>B(null),children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除表达方式 "',E?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>E&&ge(E),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(d1,{open:D,onOpenChange:te,onConfirm:F,count:X.size})]})}function r1({expression:n,open:r,onOpenChange:c,chatNameMap:d}){if(!n)return null;const h=f=>f?new Date(f*1e3).toLocaleString("zh-CN"):"-",x=f=>d.get(f)||f;return e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"表达方式详情"}),e.jsx($s,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(nr,{label:"情境",value:n.situation}),e.jsx(nr,{label:"风格",value:n.style}),e.jsx(nr,{label:"聊天",value:x(n.chat_id)}),e.jsx(nr,{icon:Uu,label:"记录ID",value:n.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(nr,{icon:Wn,label:"创建时间",value:h(n.create_date)})})]}),e.jsx(Is,{children:e.jsx(N,{onClick:()=>c(!1),children:"关闭"})})]})})}function nr({icon:n,label:r,value:c,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),r]}),e.jsx("div",{className:$("text-sm",d&&"font-mono",!c&&"text-muted-foreground"),children:c||"-"})]})}function c1({open:n,onOpenChange:r,chatList:c,onSuccess:d}){const[h,x]=u.useState({situation:"",style:"",chat_id:""}),[f,j]=u.useState(!1),{toast:g}=Bs(),_=async()=>{if(!h.situation||!h.style||!h.chat_id){g({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{j(!0),await s1(h),g({title:"创建成功",description:"表达方式已创建"}),x({situation:"",style:"",chat_id:""}),d()}catch(v){g({title:"创建失败",description:v instanceof Error?v.message:"无法创建表达方式",variant:"destructive"})}finally{j(!1)}};return e.jsx(Os,{open:n,onOpenChange:r,children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"新增表达方式"}),e.jsx($s,{children:"创建新的表达方式记录"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"situation",value:h.situation,onChange:v=>x({...h,situation:v.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"style",value:h.style,onChange:v=>x({...h,style:v.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Qe,{value:h.chat_id,onValueChange:v=>x({...h,chat_id:v}),children:[e.jsx(Ge,{children:e.jsx($e,{placeholder:"选择关联的聊天"})}),e.jsx(Ve,{children:c.map(v=>e.jsx(ue,{value:v.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[v.chat_name,v.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},v.chat_id))})]})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(N,{onClick:_,disabled:f,children:f?"创建中...":"创建"})]})]})})}function o1({expression:n,open:r,onOpenChange:c,chatList:d,onSuccess:h}){const[x,f]=u.useState({}),[j,g]=u.useState(!1),{toast:_}=Bs();u.useEffect(()=>{n&&f({situation:n.situation,style:n.style,chat_id:n.chat_id})},[n]);const v=async()=>{if(n)try{g(!0),await t1(n.id,x),_({title:"保存成功",description:"表达方式已更新"}),h()}catch(k){_({title:"保存失败",description:k instanceof Error?k.message:"无法更新表达方式",variant:"destructive"})}finally{g(!1)}};return n?e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"编辑表达方式"}),e.jsx($s,{children:"修改表达方式的信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_situation",children:"情境"}),e.jsx(ce,{id:"edit_situation",value:x.situation||"",onChange:k=>f({...x,situation:k.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_style",children:"风格"}),e.jsx(ce,{id:"edit_style",value:x.style||"",onChange:k=>f({...x,style:k.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Qe,{value:x.chat_id||"",onValueChange:k=>f({...x,chat_id:k}),children:[e.jsx(Ge,{children:e.jsx($e,{placeholder:"选择关联的聊天"})}),e.jsx(Ve,{children:d.map(k=>e.jsx(ue,{value:k.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[k.chat_name,k.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},k.chat_id))})]})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(N,{onClick:v,disabled:j,children:j?"保存中...":"保存"})]})]})}):null}function d1({open:n,onOpenChange:r,onConfirm:c,count:d}){return e.jsx(ps,{open:n,onOpenChange:r,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认批量删除"}),e.jsxs(ms,{children:["您即将删除 ",d," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const oi="/api/webui/person";async function u1(n){const r=new URLSearchParams;n.page&&r.append("page",n.page.toString()),n.page_size&&r.append("page_size",n.page_size.toString()),n.search&&r.append("search",n.search),n.is_known!==void 0&&r.append("is_known",n.is_known.toString()),n.platform&&r.append("platform",n.platform);const c=await ke(`${oi}/list?${r}`,{headers:ze()});if(!c.ok){const d=await c.json();throw new Error(d.detail||"获取人物列表失败")}return c.json()}async function m1(n){const r=await ke(`${oi}/${n}`,{headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取人物详情失败")}return r.json()}async function h1(n,r){const c=await ke(`${oi}/${n}`,{method:"PATCH",headers:ze(),body:JSON.stringify(r)});if(!c.ok){const d=await c.json();throw new Error(d.detail||"更新人物信息失败")}return c.json()}async function x1(n){const r=await ke(`${oi}/${n}`,{method:"DELETE",headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"删除人物信息失败")}return r.json()}async function f1(){const n=await ke(`${oi}/stats/summary`,{headers:ze()});if(!n.ok){const r=await n.json();throw new Error(r.detail||"获取统计数据失败")}return n.json()}async function p1(n){const r=await ke(`${oi}/batch/delete`,{method:"POST",headers:ze(),body:JSON.stringify({person_ids:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"批量删除失败")}return r.json()}function g1(){const[n,r]=u.useState([]),[c,d]=u.useState(!0),[h,x]=u.useState(0),[f,j]=u.useState(1),[g,_]=u.useState(20),[v,k]=u.useState(""),[z,T]=u.useState(void 0),[L,K]=u.useState(void 0),[U,R]=u.useState(null),[ee,V]=u.useState(!1),[E,B]=u.useState(!1),[X,w]=u.useState(null),[D,te]=u.useState({total:0,known:0,unknown:0,platforms:{}}),[xe,be]=u.useState(new Set),[ye,ve]=u.useState(!1),[pe,Ne]=u.useState(""),{toast:y}=Bs(),q=async()=>{try{d(!0);const A=await u1({page:f,page_size:g,search:v||void 0,is_known:z,platform:L});r(A.data),x(A.total)}catch(A){y({title:"加载失败",description:A instanceof Error?A.message:"无法加载人物信息",variant:"destructive"})}finally{d(!1)}},H=async()=>{try{const A=await f1();A?.data&&te(A.data)}catch(A){console.error("加载统计数据失败:",A)}};u.useEffect(()=>{q(),H()},[f,g,v,z,L]);const ne=async A=>{try{const W=await m1(A.person_id);R(W.data),V(!0)}catch(W){y({title:"加载详情失败",description:W instanceof Error?W.message:"无法加载人物详情",variant:"destructive"})}},S=A=>{R(A),B(!0)},me=async A=>{try{await x1(A.person_id),y({title:"删除成功",description:`已删除人物信息: ${A.person_name||A.nickname||A.user_id}`}),w(null),q(),H()}catch(W){y({title:"删除失败",description:W instanceof Error?W.message:"无法删除人物信息",variant:"destructive"})}},he=u.useMemo(()=>Object.keys(D.platforms),[D.platforms]),Q=A=>{const W=new Set(xe);W.has(A)?W.delete(A):W.add(A),be(W)},oe=()=>{xe.size===n.length&&n.length>0?be(new Set):be(new Set(n.map(A=>A.person_id)))},ge=()=>{if(xe.size===0){y({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}ve(!0)},le=async()=>{try{const A=await p1(Array.from(xe));y({title:"批量删除完成",description:A.message}),be(new Set),ve(!1),q(),H()}catch(A){y({title:"批量删除失败",description:A instanceof Error?A.message:"批量删除失败",variant:"destructive"})}},O=()=>{const A=parseInt(pe),W=Math.ceil(h/g);A>=1&&A<=W?(j(A),Ne("")):y({title:"无效的页码",description:`请输入1-${W}之间的页码`,variant:"destructive"})},F=A=>A?new Date(A*1e3).toLocaleString("zh-CN"):"-";return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(HN,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总人数"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:D.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"已认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:D.known})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"未认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-muted-foreground",children:D.unknown})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(b,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(St,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:v,onChange:A=>k(A.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(Qe,{value:z===void 0?"all":z.toString(),onValueChange:A=>{T(A==="all"?void 0:A==="true"),j(1)},children:[e.jsx(Ge,{id:"filter-known",className:"mt-1.5",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部"}),e.jsx(ue,{value:"true",children:"已认识"}),e.jsx(ue,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(Qe,{value:L||"all",onValueChange:A=>{K(A==="all"?void 0:A),j(1)},children:[e.jsx(Ge,{id:"filter-platform",className:"mt-1.5",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部平台"}),he.map(A=>e.jsxs(ue,{value:A,children:[A," (",D.platforms[A],")"]},A))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:xe.size>0&&e.jsxs("span",{children:["已选择 ",xe.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Qe,{value:g.toString(),onValueChange:A=>{_(parseInt(A)),j(1),be(new Set)},children:[e.jsx(Ge,{id:"page-size",className:"w-20",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"10",children:"10"}),e.jsx(ue,{value:"20",children:"20"}),e.jsx(ue,{value:"50",children:"50"}),e.jsx(ue,{value:"100",children:"100"})]})]}),xe.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>be(new Set),children:"取消选择"}),e.jsxs(N,{variant:"destructive",size:"sm",onClick:ge,children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(pt,{children:[e.jsx(ls,{className:"w-12",children:e.jsx(yt,{checked:n.length>0&&xe.size===n.length,onCheckedChange:oe,"aria-label":"全选"})}),e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"昵称"}),e.jsx(ls,{children:"平台"}),e.jsx(ls,{children:"用户ID"}),e.jsx(ls,{children:"最后更新"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c?e.jsx(pt,{children:e.jsx(Ye,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(pt,{children:e.jsx(Ye,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(A=>e.jsxs(pt,{children:[e.jsx(Ye,{children:e.jsx(yt,{checked:xe.has(A.person_id),onCheckedChange:()=>Q(A.person_id),"aria-label":`选择 ${A.person_name||A.nickname||A.user_id}`})}),e.jsx(Ye,{children:e.jsx("div",{className:$("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",A.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:A.is_known?"已认识":"未认识"})}),e.jsx(Ye,{className:"font-medium",children:A.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ye,{children:A.nickname||"-"}),e.jsx(Ye,{children:A.platform}),e.jsx(Ye,{className:"font-mono text-sm",children:A.user_id}),e.jsx(Ye,{className:"text-sm text-muted-foreground",children:F(A.last_know)}),e.jsx(Ye,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(N,{variant:"default",size:"sm",onClick:()=>ne(A),children:[e.jsx(Zt,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(N,{variant:"default",size:"sm",onClick:()=>S(A),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(N,{size:"sm",onClick:()=>w(A),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},A.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:c?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(A=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(yt,{checked:xe.has(A.person_id),onCheckedChange:()=>Q(A.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:$("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",A.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:A.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:A.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),A.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",A.nickname]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"平台"}),e.jsx("p",{className:"font-medium text-xs",children:A.platform})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"用户ID"}),e.jsx("p",{className:"font-mono text-xs truncate",title:A.user_id,children:A.user_id})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"最后更新"}),e.jsx("p",{className:"text-xs",children:F(A.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>ne(A),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>S(A),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>w(A),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ns,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},A.id))}),h>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",h," 条记录,第 ",f," / ",Math.ceil(h/g)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(wr,{className:"h-4 w-4"})}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(f-1),disabled:f===1,children:[e.jsx(cn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{type:"number",value:pe,onChange:A=>Ne(A.target.value),onKeyDown:A=>A.key==="Enter"&&O(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(h/g)}),e.jsx(N,{variant:"outline",size:"sm",onClick:O,disabled:!pe,className:"h-8",children:"跳转"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>j(f+1),disabled:f>=Math.ceil(h/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(il,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(Math.ceil(h/g)),disabled:f>=Math.ceil(h/g),className:"hidden sm:flex",children:e.jsx(_r,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(j1,{person:U,open:ee,onOpenChange:V}),e.jsx(v1,{person:U,open:E,onOpenChange:B,onSuccess:()=>{q(),H(),B(!1)}}),e.jsx(ps,{open:!!X,onOpenChange:()=>w(null),children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认删除"}),e.jsxs(ms,{children:['确定要删除人物信息 "',X?.person_name||X?.nickname||X?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:()=>X&&me(X),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(ps,{open:ye,onOpenChange:ve,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"确认批量删除"}),e.jsxs(ms,{children:["确定要删除选中的 ",xe.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{children:"取消"}),e.jsx(hs,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function j1({person:n,open:r,onOpenChange:c}){if(!n)return null;const d=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"人物详情"}),e.jsxs($s,{children:["查看 ",n.person_name||n.nickname||n.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(al,{icon:to,label:"人物名称",value:n.person_name}),e.jsx(al,{icon:si,label:"昵称",value:n.nickname}),e.jsx(al,{icon:Uu,label:"用户ID",value:n.user_id,mono:!0}),e.jsx(al,{icon:Uu,label:"人物ID",value:n.person_id,mono:!0}),e.jsx(al,{label:"平台",value:n.platform}),e.jsx(al,{label:"状态",value:n.is_known?"已认识":"未认识"})]}),n.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:n.name_reason})]}),n.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:n.memory_points})]}),n.group_nick_name&&n.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:n.group_nick_name.map((h,x)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:h.group_nick_name})]},x))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(al,{icon:Wn,label:"认识时间",value:d(n.know_times)}),e.jsx(al,{icon:Wn,label:"首次记录",value:d(n.know_since)}),e.jsx(al,{icon:Wn,label:"最后更新",value:d(n.last_know)})]})]}),e.jsx(Is,{children:e.jsx(N,{onClick:()=>c(!1),children:"关闭"})})]})})}function al({icon:n,label:r,value:c,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),r]}),e.jsx("div",{className:$("text-sm",d&&"font-mono",!c&&"text-muted-foreground"),children:c||"-"})]})}function v1({person:n,open:r,onOpenChange:c,onSuccess:d}){const[h,x]=u.useState({}),[f,j]=u.useState(!1),{toast:g}=Bs();u.useEffect(()=>{n&&x({person_name:n.person_name||"",name_reason:n.name_reason||"",nickname:n.nickname||"",memory_points:n.memory_points||"",is_known:n.is_known})},[n]);const _=async()=>{if(n)try{j(!0),await h1(n.person_id,h),g({title:"保存成功",description:"人物信息已更新"}),d()}catch(v){g({title:"保存失败",description:v instanceof Error?v.message:"无法更新人物信息",variant:"destructive"})}finally{j(!1)}};return n?e.jsx(Os,{open:r,onOpenChange:c,children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"编辑人物信息"}),e.jsxs($s,{children:["修改 ",n.person_name||n.nickname||n.user_id," 的信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"person_name",children:"人物名称"}),e.jsx(ce,{id:"person_name",value:h.person_name||"",onChange:v=>x({...h,person_name:v.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:h.nickname||"",onChange:v=>x({...h,nickname:v.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(Us,{id:"name_reason",value:h.name_reason||"",onChange:v=>x({...h,name_reason:v.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"memory_points",children:"个人印象"}),e.jsx(Us,{id:"memory_points",value:h.memory_points||"",onChange:v=>x({...h,memory_points:v.target.value}),placeholder:"对这个人的印象和记忆点...",rows:4})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(b,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(qe,{id:"is_known",checked:h.is_known,onCheckedChange:v=>x({...h,is_known:v})})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>c(!1),children:"取消"}),e.jsx(N,{onClick:_,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}var y1=Sb();const xp=wy(y1),Pu="/api/webui";async function N1(n=100,r="all"){const c=`${Pu}/knowledge/graph?limit=${n}&node_type=${r}`,d=await fetch(c);if(!d.ok)throw new Error(`获取知识图谱失败: ${d.status}`);return d.json()}async function b1(){const n=await fetch(`${Pu}/knowledge/stats`);if(!n.ok)throw new Error("获取知识图谱统计信息失败");return n.json()}async function w1(n){const r=await fetch(`${Pu}/knowledge/search?query=${encodeURIComponent(n)}`);if(!r.ok)throw new Error("搜索知识节点失败");return r.json()}const Fg=u.memo(({data:n})=>e.jsxs("div",{className:"px-4 py-2 shadow-md rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700 min-w-[120px]",children:[e.jsx(lo,{type:"target",position:no.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:n.content,children:n.label}),e.jsx(lo,{type:"source",position:no.Bottom})]}));Fg.displayName="EntityNode";const Qg=u.memo(({data:n})=>e.jsxs("div",{className:"px-3 py-2 shadow-md rounded-md bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700 min-w-[100px]",children:[e.jsx(lo,{type:"target",position:no.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:n.content,children:n.label}),e.jsx(lo,{type:"source",position:no.Bottom})]}));Qg.displayName="ParagraphNode";const _1={entity:Fg,paragraph:Qg};function S1(n,r){const c=new xp.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const d=[],h=[];return n.forEach(x=>{c.setNode(x.id,{width:150,height:50})}),r.forEach(x=>{c.setEdge(x.source,x.target)}),xp.layout(c),n.forEach(x=>{const f=c.node(x.id);d.push({id:x.id,type:x.type,position:{x:f.x-75,y:f.y-25},data:{label:x.content.slice(0,20)+(x.content.length>20?"...":""),content:x.content}})}),r.forEach((x,f)=>{const j={id:`edge-${f}`,source:x.source,target:x.target,animated:n.length<=200&&x.weight>5,style:{strokeWidth:Math.min(x.weight/2,5),opacity:.6}};x.weight>10&&n.length<100&&(j.label=`${x.weight.toFixed(0)}`),h.push(j)}),{nodes:d,edges:h}}function C1(){const n=It(),[r,c]=u.useState(!1),[d,h]=u.useState(null),[x,f]=u.useState(""),[j,g]=u.useState("all"),[_,v]=u.useState(50),[k,z]=u.useState("50"),[T,L]=u.useState(!1),[K,U]=u.useState(!0),[R,ee]=u.useState(!1),[V,E]=u.useState(!1),[B,X,w]=Cb([]),[D,te,xe]=kb([]),[be,ye]=u.useState(0),[ve,pe]=u.useState(null),[Ne,y]=u.useState(null),{toast:q}=Bs(),H=u.useCallback(le=>le.type==="entity"?"#6366f1":le.type==="paragraph"?"#10b981":"#6b7280",[]),ne=u.useCallback(async(le=!1)=>{try{if(!le&&_>200){E(!0);return}c(!0);const[O,F]=await Promise.all([N1(_,j),b1()]);if(h(F),O.nodes.length===0){q({title:"提示",description:"知识库为空,请先导入知识数据"}),X([]),te([]);return}const{nodes:A,edges:W}=S1(O.nodes,O.edges);X(A),te(W),ye(A.length),F&&F.total_nodes>_&&q({title:"提示",description:`知识图谱包含 ${F.total_nodes} 个节点,当前显示 ${A.length} 个`}),q({title:"加载成功",description:`已加载 ${A.length} 个节点,${W.length} 条边`})}catch(O){console.error("加载知识图谱失败:",O),q({title:"加载失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}finally{c(!1)}},[_,j,q]),S=u.useCallback(async()=>{if(!x.trim()){q({title:"提示",description:"请输入搜索关键词"});return}try{const le=await w1(x);if(le.length===0){q({title:"未找到",description:"没有找到匹配的节点"});return}const O=new Set(le.map(F=>F.id));X(F=>F.map(A=>({...A,style:{...A.style,opacity:O.has(A.id)?1:.3,filter:O.has(A.id)?"brightness(1.2)":"brightness(0.8)"}}))),q({title:"搜索完成",description:`找到 ${le.length} 个匹配节点`})}catch(le){console.error("搜索失败:",le),q({title:"搜索失败",description:le instanceof Error?le.message:"未知错误",variant:"destructive"})}},[x,q]),me=u.useCallback(()=>{X(le=>le.map(O=>({...O,style:{...O.style,opacity:1,filter:"brightness(1)"}})))},[]),he=u.useCallback(()=>{U(!1),ee(!0),ne()},[ne]),Q=u.useCallback(()=>{E(!1),setTimeout(()=>{ne(!0)},0)},[ne]),oe=u.useCallback((le,O)=>{B.find(A=>A.id===O.id)&&pe({id:O.id,type:O.type,content:O.data.content})},[B]);u.useEffect(()=>{K||R&&ne()},[_,j,K,R]);const ge=u.useCallback((le,O)=>{const F=B.find(_e=>_e.id===O.source),A=B.find(_e=>_e.id===O.target),W=D.find(_e=>_e.id===O.id);F&&A&&W&&y({source:{id:F.id,type:F.type,content:F.data.content},target:{id:A.id,type:A.type,content:A.data.content},edge:{source:O.source,target:O.target,weight:parseFloat(O.label||"0")}})},[B,D]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦知识库图谱"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"可视化知识实体与关系网络"})]}),d&&e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Xe,{variant:"outline",className:"gap-1",children:[e.jsx(eo,{className:"h-3 w-3"}),"节点: ",d.total_nodes]}),e.jsxs(Xe,{variant:"outline",className:"gap-1",children:[e.jsx(jg,{className:"h-3 w-3"}),"边: ",d.total_edges]}),e.jsxs(Xe,{variant:"outline",className:"gap-1",children:[e.jsx(Xt,{className:"h-3 w-3"}),"实体: ",d.entity_nodes]}),e.jsxs(Xe,{variant:"outline",className:"gap-1",children:[e.jsx(Ma,{className:"h-3 w-3"}),"段落: ",d.paragraph_nodes]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mt-4",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(ce,{placeholder:"搜索节点内容...",value:x,onChange:le=>f(le.target.value),onKeyDown:le=>le.key==="Enter"&&S(),className:"flex-1"}),e.jsx(N,{onClick:S,size:"sm",children:e.jsx(St,{className:"h-4 w-4"})}),e.jsx(N,{onClick:me,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Qe,{value:j,onValueChange:le=>g(le),children:[e.jsx(Ge,{className:"w-[120px]",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部节点"}),e.jsx(ue,{value:"entity",children:"仅实体"}),e.jsx(ue,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs(Qe,{value:_===1e4?"all":T?"custom":_.toString(),onValueChange:le=>{le==="custom"?(L(!0),z(_.toString())):le==="all"?(L(!1),v(1e4)):(L(!1),v(Number(le)))},children:[e.jsx(Ge,{className:"w-[120px]",children:e.jsx($e,{})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"50",children:"50 节点"}),e.jsx(ue,{value:"100",children:"100 节点"}),e.jsx(ue,{value:"200",children:"200 节点"}),e.jsx(ue,{value:"500",children:"500 节点"}),e.jsx(ue,{value:"1000",children:"1000 节点"}),e.jsx(ue,{value:"all",children:"全部 (最多10000)"}),e.jsx(ue,{value:"custom",children:"自定义..."})]})]}),T&&e.jsx(ce,{type:"number",min:"50",value:k,onChange:le=>z(le.target.value),onBlur:()=>{const le=parseInt(k);!isNaN(le)&&le>=50?v(le):(z("50"),v(50))},onKeyDown:le=>{if(le.key==="Enter"){const O=parseInt(k);!isNaN(O)&&O>=50?v(O):(z("50"),v(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(N,{onClick:()=>ne(),variant:"outline",size:"sm",disabled:r,children:e.jsx(ft,{className:$("h-4 w-4",r&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:r?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ft,{className:"h-8 w-8 animate-spin mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"加载知识图谱中..."})]})}):B.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(eo,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"知识库为空"}),e.jsx("p",{className:"text-muted-foreground",children:"请先导入知识数据"})]})}):e.jsxs(Tb,{nodes:B,edges:D,onNodesChange:w,onEdgesChange:xe,onNodeClick:oe,onEdgeClick:ge,nodeTypes:_1,fitView:!0,minZoom:.05,maxZoom:1.5,defaultViewport:{x:0,y:0,zoom:.5},elevateNodesOnSelect:be<=500,nodesDraggable:be<=1e3,attributionPosition:"bottom-left",children:[e.jsx(Eb,{variant:zb.Dots,gap:12,size:1}),e.jsx(Mb,{}),be<=500&&e.jsx(Ab,{nodeColor:H,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(Db,{position:"top-right",className:"bg-background/95 backdrop-blur-sm rounded-lg border p-3 shadow-lg",children:[e.jsx("div",{className:"text-sm font-semibold mb-2",children:"图例"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700"}),e.jsx("span",{children:"实体节点"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700"}),e.jsx("span",{children:"段落节点"})]}),be>200&&e.jsxs("div",{className:"mt-2 pt-2 border-t text-yellow-600 dark:text-yellow-500",children:[e.jsx("div",{className:"font-semibold",children:"性能模式"}),e.jsx("div",{children:"已禁用动画"}),be>500&&e.jsx("div",{children:"已禁用缩略图"})]})]})]})]})}),e.jsx(Os,{open:!!ve,onOpenChange:le=>!le&&pe(null),children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(zs,{children:e.jsx(Ms,{children:"节点详情"})}),ve&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"类型"}),e.jsx("div",{className:"mt-1",children:e.jsx(Xe,{variant:ve.type==="entity"?"default":"secondary",children:ve.type==="entity"?"🏷️ 实体":"📄 段落"})})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),e.jsx("code",{className:"mt-1 block p-2 bg-muted rounded text-xs break-all",children:ve.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(es,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:ve.content})})]})]})]})}),e.jsx(Os,{open:!!Ne,onOpenChange:le=>!le&&y(null),children:e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(zs,{children:e.jsx(Ms,{children:"边详情"})}),Ne&&e.jsx(es,{className:"flex-1 pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-blue-50 dark:bg-blue-950 rounded border-2 border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"源节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:Ne.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[Ne.source.id.slice(0,40),"..."]})]}),e.jsx("div",{className:"text-2xl text-muted-foreground flex-shrink-0",children:"→"}),e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-green-50 dark:bg-green-950 rounded border-2 border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"目标节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:Ne.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[Ne.target.id.slice(0,40),"..."]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"权重"}),e.jsx("div",{className:"mt-1",children:e.jsx(Xe,{variant:"outline",className:"text-base font-mono",children:Ne.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(ps,{open:K,onOpenChange:U,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"加载知识图谱"}),e.jsxs(ms,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(ds,{children:[e.jsx(xs,{onClick:()=>n({to:"/"}),children:"取消 (返回首页)"}),e.jsx(hs,{onClick:he,children:"确认加载"})]})]})}),e.jsx(ps,{open:V,onOpenChange:E,children:e.jsxs(cs,{children:[e.jsxs(os,{children:[e.jsx(us,{children:"⚠️ 节点数量较多"}),e.jsx(ms,{asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["您正在尝试加载 ",e.jsx("strong",{className:"text-orange-600",children:_>=1e4?"全部 (最多10000个)":_})," 个节点。"]}),e.jsx("p",{className:"mt-4",children:"节点数量过多可能导致:"}),e.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[e.jsx("li",{children:"页面加载时间较长"}),e.jsx("li",{children:"浏览器卡顿或崩溃"}),e.jsx("li",{children:"系统资源占用过高"})]}),e.jsx("p",{className:"mt-4",children:"建议先选择较少的节点数量 (50-200 个)。"})]})})]}),e.jsxs(ds,{children:[e.jsx(xs,{onClick:()=>{E(!1),_>200&&(v(50),L(!1))},children:"取消"}),e.jsx(hs,{onClick:Q,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function fp({className:n,classNames:r,showOutsideDays:c=!0,captionLayout:d="label",buttonVariant:h="ghost",formatters:x,components:f,...j}){const g=bg();return e.jsx(rb,{showOutsideDays:c,className:$("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,n),captionLayout:d,formatters:{formatMonthDropdown:_=>_.toLocaleString("default",{month:"short"}),...x},classNames:{root:$("w-fit",g.root),months:$("relative flex flex-col gap-4 md:flex-row",g.months),month:$("flex w-full flex-col gap-4",g.month),nav:$("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",g.nav),button_previous:$(gr({variant:h}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",g.button_previous),button_next:$(gr({variant:h}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",g.button_next),month_caption:$("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",g.month_caption),dropdowns:$("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",g.dropdowns),dropdown_root:$("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",g.dropdown_root),dropdown:$("bg-popover absolute inset-0 opacity-0",g.dropdown),caption_label:$("select-none font-medium",d==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",g.caption_label),table:"w-full border-collapse",weekdays:$("flex",g.weekdays),weekday:$("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",g.weekday),week:$("mt-2 flex w-full",g.week),week_number_header:$("w-[--cell-size] select-none",g.week_number_header),week_number:$("text-muted-foreground select-none text-[0.8rem]",g.week_number),day:$("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",g.day),range_start:$("bg-accent rounded-l-md",g.range_start),range_middle:$("rounded-none",g.range_middle),range_end:$("bg-accent rounded-r-md",g.range_end),today:$("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",g.today),outside:$("text-muted-foreground aria-selected:text-muted-foreground",g.outside),disabled:$("text-muted-foreground opacity-50",g.disabled),hidden:$("invisible",g.hidden),...r},components:{Root:({className:_,rootRef:v,...k})=>e.jsx("div",{"data-slot":"calendar",ref:v,className:$(_),...k}),Chevron:({className:_,orientation:v,...k})=>v==="left"?e.jsx(cn,{className:$("size-4",_),...k}):v==="right"?e.jsx(il,{className:$("size-4",_),...k}):e.jsx(Ll,{className:$("size-4",_),...k}),DayButton:k1,WeekNumber:({children:_,...v})=>e.jsx("td",{...v,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:_})}),...f},...j})}function k1({className:n,day:r,modifiers:c,...d}){const h=bg(),x=u.useRef(null);return u.useEffect(()=>{c.focused&&x.current?.focus()},[c.focused]),e.jsx(N,{ref:x,variant:"ghost",size:"icon","data-day":r.date.toLocaleDateString(),"data-selected-single":c.selected&&!c.range_start&&!c.range_end&&!c.range_middle,"data-range-start":c.range_start,"data-range-end":c.range_end,"data-range-middle":c.range_middle,className:$("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",h.day,n),...d})}const T1={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},E1=(n,r,c)=>{let d;const h=T1[n];return typeof h=="string"?d=h:r===1?d=h.one:d=h.other.replace("{{count}}",String(r)),c?.addSuffix?c.comparison&&c.comparison>0?d+"内":d+"前":d},z1={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},M1={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},A1={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},D1={date:wu({formats:z1,defaultWidth:"full"}),time:wu({formats:M1,defaultWidth:"full"}),dateTime:wu({formats:A1,defaultWidth:"full"})};function pp(n,r,c){const d="eeee p";return Cy(n,r,c)?d:n.getTime()>r.getTime()?"'下个'"+d:"'上个'"+d}const O1={lastWeek:pp,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:pp,other:"PP p"},R1=(n,r,c,d)=>{const h=O1[n];return typeof h=="function"?h(r,c,d):h},L1={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},U1={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},B1={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},H1={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},q1={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},G1={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},V1=(n,r)=>{const c=Number(n);switch(r?.unit){case"date":return c.toString()+"日";case"hour":return c.toString()+"时";case"minute":return c.toString()+"分";case"second":return c.toString()+"秒";default:return"第 "+c.toString()}},F1={ordinalNumber:V1,era:er({values:L1,defaultWidth:"wide"}),quarter:er({values:U1,defaultWidth:"wide",argumentCallback:n=>n-1}),month:er({values:B1,defaultWidth:"wide"}),day:er({values:H1,defaultWidth:"wide"}),dayPeriod:er({values:q1,defaultWidth:"wide",formattingValues:G1,defaultFormattingWidth:"wide"})},Q1=/^(第\s*)?\d+(日|时|分|秒)?/i,$1=/\d+/i,Y1={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},X1={any:[/^(前)/i,/^(公元)/i]},K1={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Z1={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},I1={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},J1={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},P1={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},W1={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},e2={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},s2={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},t2={ordinalNumber:ky({matchPattern:Q1,parsePattern:$1,valueCallback:n=>parseInt(n,10)}),era:sr({matchPatterns:Y1,defaultMatchWidth:"wide",parsePatterns:X1,defaultParseWidth:"any"}),quarter:sr({matchPatterns:K1,defaultMatchWidth:"wide",parsePatterns:Z1,defaultParseWidth:"any",valueCallback:n=>n+1}),month:sr({matchPatterns:I1,defaultMatchWidth:"wide",parsePatterns:J1,defaultParseWidth:"any"}),day:sr({matchPatterns:P1,defaultMatchWidth:"wide",parsePatterns:W1,defaultParseWidth:"any"}),dayPeriod:sr({matchPatterns:e2,defaultMatchWidth:"any",parsePatterns:s2,defaultParseWidth:"any"})},Qc={code:"zh-CN",formatDistance:E1,formatLong:D1,formatRelative:R1,localize:F1,match:t2,options:{weekStartsOn:1,firstWeekContainsDate:4}},$c={xs:{label:"小",rowHeight:28,class:"text-[10px] sm:text-xs"},sm:{label:"中",rowHeight:36,class:"text-xs sm:text-sm"},base:{label:"大",rowHeight:44,class:"text-sm sm:text-base"}};function a2(){const[n,r]=u.useState([]),[c,d]=u.useState(""),[h,x]=u.useState("all"),[f,j]=u.useState("all"),[g,_]=u.useState(void 0),[v,k]=u.useState(void 0),[z,T]=u.useState(!0),[L,K]=u.useState(!1),[U,R]=u.useState("xs"),[ee,V]=u.useState(4),E=u.useRef(null);u.useEffect(()=>{const y=an.getAllLogs();r(y);const q=an.onLog(()=>{r(an.getAllLogs())}),H=an.onConnectionChange(ne=>{K(ne)});return()=>{q(),H()}},[]);const B=u.useMemo(()=>{const y=new Set(n.map(q=>q.module).filter(q=>q&&q.trim()!==""));return Array.from(y).sort()},[n]),X=y=>{switch(y){case"DEBUG":return"text-muted-foreground";case"INFO":return"text-blue-500 dark:text-blue-400";case"WARNING":return"text-yellow-600 dark:text-yellow-500";case"ERROR":return"text-red-600 dark:text-red-500";case"CRITICAL":return"text-red-700 dark:text-red-400 font-bold";default:return"text-foreground"}},w=y=>{switch(y){case"DEBUG":return"bg-gray-800/30 dark:bg-gray-800/50";case"INFO":return"bg-blue-900/20 dark:bg-blue-500/20";case"WARNING":return"bg-yellow-900/20 dark:bg-yellow-500/20";case"ERROR":return"bg-red-900/20 dark:bg-red-500/20";case"CRITICAL":return"bg-red-900/30 dark:bg-red-600/30";default:return"bg-gray-800/20 dark:bg-gray-800/30"}},D=()=>{window.location.reload()},te=()=>{an.clearLogs(),r([])},xe=()=>{const y=ve.map(S=>`${S.timestamp} [${S.level.padEnd(8)}] [${S.module}] ${S.message}`).join(` -`),q=new Blob([y],{type:"text/plain;charset=utf-8"}),H=URL.createObjectURL(q),ne=document.createElement("a");ne.href=H,ne.download=`logs-${_u(new Date,"yyyy-MM-dd-HHmmss")}.txt`,ne.click(),URL.revokeObjectURL(H)},be=()=>{T(!z)},ye=()=>{_(void 0),k(void 0)},ve=u.useMemo(()=>n.filter(y=>{const q=c===""||y.message.toLowerCase().includes(c.toLowerCase())||y.module.toLowerCase().includes(c.toLowerCase()),H=h==="all"||y.level===h,ne=f==="all"||y.module===f;let S=!0;if(g||v){const me=new Date(y.timestamp);if(g){const he=new Date(g);he.setHours(0,0,0,0),S=S&&me>=he}if(v){const he=new Date(v);he.setHours(23,59,59,999),S=S&&me<=he}}return q&&H&&ne&&S}),[n,c,h,f,g,v]),pe=$c[U].rowHeight+ee,Ne=fy({count:ve.length,getScrollElement:()=>E.current,estimateSize:()=>pe,overscan:15});return u.useEffect(()=>{z&&ve.length>0&&Ne.scrollToIndex(ve.length-1,{align:"end",behavior:"auto"})},[ve.length,z,Ne]),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 space-y-4 p-3 sm:p-4 lg:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:$("h-2.5 w-2.5 sm:h-3 sm:w-3 rounded-full",L?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:L?"已连接":"未连接"})]})]}),e.jsx(Be,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索日志...",value:c,onChange:y=>d(y.target.value),className:"pl-9 h-9 text-sm"})]}),e.jsxs(Qe,{value:h,onValueChange:x,children:[e.jsxs(Ge,{className:"w-full sm:w-[140px] lg:w-[180px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx($e,{placeholder:"级别"})]}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部级别"}),e.jsx(ue,{value:"DEBUG",children:"DEBUG"}),e.jsx(ue,{value:"INFO",children:"INFO"}),e.jsx(ue,{value:"WARNING",children:"WARNING"}),e.jsx(ue,{value:"ERROR",children:"ERROR"}),e.jsx(ue,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(Qe,{value:f,onValueChange:j,children:[e.jsxs(Ge,{className:"w-full sm:w-[160px] lg:w-[200px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx($e,{placeholder:"模块"})]}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部模块"}),B.map(y=>e.jsx(ue,{value:y,children:y},y))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:$("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!g&&"text-muted-foreground"),children:[e.jsx(Yf,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:g?_u(g,"PPP",{locale:Qc}):"开始日期"})]})}),e.jsx(Na,{className:"w-auto p-0",align:"start",children:e.jsx(fp,{mode:"single",selected:g,onSelect:_,initialFocus:!0,locale:Qc})})]}),e.jsxs(Da,{children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:$("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!v&&"text-muted-foreground"),children:[e.jsx(Yf,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:v?_u(v,"PPP",{locale:Qc}):"结束日期"})]})}),e.jsx(Na,{className:"w-auto p-0",align:"start",children:e.jsx(fp,{mode:"single",selected:v,onSelect:k,initialFocus:!0,locale:Qc})})]}),(g||v)&&e.jsxs(N,{variant:"outline",size:"sm",onClick:ye,className:"w-full sm:w-auto h-9",children:[e.jsx(li,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline text-sm",children:"清除时间筛选"}),e.jsx("span",{className:"sm:hidden text-sm",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(N,{variant:z?"default":"outline",size:"sm",onClick:be,className:"flex-1 sm:flex-none h-9",children:[z?e.jsx(qN,{className:"h-4 w-4"}):e.jsx(GN,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:z?"自动滚动":"已暂停"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:D,className:"flex-1 sm:flex-none h-9",children:[e.jsx(ft,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"刷新"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:te,className:"flex-1 sm:flex-none h-9",children:[e.jsx(ns,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"清空"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:xe,className:"flex-1 sm:flex-none h-9",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"导出"})]})]}),e.jsx("div",{className:"flex-1 hidden sm:block"}),e.jsxs("div",{className:"text-xs sm:text-sm text-muted-foreground flex items-center justify-center sm:justify-end",children:[e.jsxs("span",{className:"font-mono",children:[ve.length," / ",n.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-6 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(VN,{className:"h-4 w-4"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys($c).map(y=>e.jsx(N,{variant:U===y?"default":"outline",size:"sm",onClick:()=>R(y),className:"h-7 px-3 text-xs",children:$c[y].label},y))})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 max-w-xs",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"行距"}),e.jsx(za,{value:[ee],onValueChange:([y])=>V(y),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-8",children:[ee,"px"]})]})]})]})})]}),e.jsx("div",{className:"flex-1 min-h-0 px-3 sm:px-4 lg:px-6 pb-3 sm:pb-4 lg:pb-6",children:e.jsx(Be,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900 h-full",children:e.jsx(es,{viewportRef:E,className:"h-full",children:e.jsx("div",{className:$("p-2 sm:p-3 font-mono relative",$c[U].class),style:{height:`${Ne.getTotalSize()}px`},children:ve.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-sm",children:"暂无日志数据"}):Ne.getVirtualItems().map(y=>{const q=ve[y.index];return e.jsxs("div",{"data-index":y.index,ref:Ne.measureElement,className:$("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors group",w(q.level)),style:{transform:`translateY(${y.start}px)`,paddingTop:`${ee/2}px`,paddingBottom:`${ee/2}px`},children:[e.jsxs("div",{className:"flex flex-col gap-0.5 sm:hidden",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600",children:q.timestamp}),e.jsxs("span",{className:$("font-semibold",X(q.level)),children:["[",q.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate",children:q.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words",children:q.message})]}),e.jsxs("div",{className:"hidden sm:flex gap-2 items-start",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600 flex-shrink-0 w-[130px] lg:w-[160px]",children:q.timestamp}),e.jsxs("span",{className:$("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",X(q.level)),children:["[",q.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:q.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:q.message})]})]},y.key)})})})})})]})}const l2="Mai-with-u",n2="plugin-repo",i2="main",r2="plugin_details.json";async function c2(){try{const n=await ke("/api/webui/plugins/fetch-raw",{method:"POST",headers:ze(),body:JSON.stringify({owner:l2,repo:n2,branch:i2,file_path:r2})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=await n.json();if(!r.success||!r.data)throw new Error(r.error||"获取插件列表失败");return JSON.parse(r.data).filter(h=>!h?.id||!h?.manifest?(console.warn("跳过无效插件数据:",h),!1):!h.manifest.name||!h.manifest.version?(console.warn("跳过缺少必需字段的插件:",h.id),!1):!0).map(h=>({id:h.id,manifest:{manifest_version:h.manifest.manifest_version||1,name:h.manifest.name,version:h.manifest.version,description:h.manifest.description||"",author:h.manifest.author||{name:"Unknown"},license:h.manifest.license||"Unknown",host_application:h.manifest.host_application||{min_version:"0.0.0"},homepage_url:h.manifest.homepage_url,repository_url:h.manifest.repository_url,keywords:h.manifest.keywords||[],categories:h.manifest.categories||[],default_locale:h.manifest.default_locale||"zh-CN",locales_path:h.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(n){throw console.error("Failed to fetch plugin list:",n),n}}async function o2(){try{const n=await ke("/api/webui/plugins/git-status");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to check Git status:",n),{installed:!1,error:"无法检测 Git 安装状态"}}}async function d2(){try{const n=await ke("/api/webui/plugins/version");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to get Maimai version:",n),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function u2(n,r,c){const d=n.split(".").map(j=>parseInt(j)||0),h=d[0]||0,x=d[1]||0,f=d[2]||0;if(c.version_majorparseInt(k)||0),g=j[0]||0,_=j[1]||0,v=j[2]||0;if(c.version_major>g||c.version_major===g&&c.version_minor>_||c.version_major===g&&c.version_minor===_&&c.version_patch>v)return!1}return!0}function m2(n,r){const c=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host,h=new WebSocket(`${c}//${d}/api/webui/ws/plugin-progress`);return h.onopen=()=>{console.log("Plugin progress WebSocket connected");const x=setInterval(()=>{h.readyState===WebSocket.OPEN?h.send("ping"):clearInterval(x)},3e4)},h.onmessage=x=>{try{if(x.data==="pong")return;const f=JSON.parse(x.data);n(f)}catch(f){console.error("Failed to parse progress data:",f)}},h.onerror=x=>{console.error("Plugin progress WebSocket error:",x),r?.(x)},h.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},h}async function cr(){try{const n=await ke("/api/webui/plugins/installed",{headers:ze()});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=await n.json();if(!r.success)throw new Error(r.message||"获取已安装插件列表失败");return r.plugins||[]}catch(n){return console.error("Failed to get installed plugins:",n),[]}}function Yc(n,r){return r.some(c=>c.id===n)}function Xc(n,r){const c=r.find(d=>d.id===n);if(c)return c.manifest?.version||c.version}async function h2(n,r,c="main"){const d=await ke("/api/webui/plugins/install",{method:"POST",headers:ze(),body:JSON.stringify({plugin_id:n,repository_url:r,branch:c})});if(!d.ok){const h=await d.json();throw new Error(h.detail||"安装失败")}return await d.json()}async function x2(n){const r=await ke("/api/webui/plugins/uninstall",{method:"POST",headers:ze(),body:JSON.stringify({plugin_id:n})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"卸载失败")}return await r.json()}async function f2(n,r,c="main"){const d=await ke("/api/webui/plugins/update",{method:"POST",headers:ze(),body:JSON.stringify({plugin_id:n,repository_url:r,branch:c})});if(!d.ok){const h=await d.json();throw new Error(h.detail||"更新失败")}return await d.json()}async function p2(n){const r=await ke(`/api/webui/plugins/config/${n}/schema`,{headers:ze()});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取配置 Schema 失败")}const c=await r.json();if(!c.success)throw new Error(c.message||"获取配置 Schema 失败");return c.schema}async function g2(n){const r=await ke(`/api/webui/plugins/config/${n}`,{headers:ze()});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取配置失败")}const c=await r.json();if(!c.success)throw new Error(c.message||"获取配置失败");return c.config}async function j2(n,r){const c=await ke(`/api/webui/plugins/config/${n}`,{method:"PUT",headers:ze(),body:JSON.stringify({config:r})});if(!c.ok){const d=await c.json();throw new Error(d.detail||"保存配置失败")}return await c.json()}async function v2(n){const r=await ke(`/api/webui/plugins/config/${n}/reset`,{method:"POST",headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"重置配置失败")}return await r.json()}async function y2(n){const r=await ke(`/api/webui/plugins/config/${n}/toggle`,{method:"POST",headers:ze()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"切换状态失败")}return await r.json()}const Cr="https://maibot-plugin-stats.maibot-webui.workers.dev";async function $g(n){try{const r=await fetch(`${Cr}/stats/${n}`);return r.ok?await r.json():(console.error("Failed to fetch plugin stats:",r.statusText),null)}catch(r){return console.error("Error fetching plugin stats:",r),null}}async function N2(n,r){try{const c=r||Wu(),d=await fetch(`${Cr}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:c})}),h=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...h}:{success:!1,error:h.error||"点赞失败"}}catch(c){return console.error("Error liking plugin:",c),{success:!1,error:"网络错误"}}}async function b2(n,r){try{const c=r||Wu(),d=await fetch(`${Cr}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:c})}),h=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...h}:{success:!1,error:h.error||"点踩失败"}}catch(c){return console.error("Error disliking plugin:",c),{success:!1,error:"网络错误"}}}async function w2(n,r,c,d){if(r<1||r>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const h=d||Wu(),x=await fetch(`${Cr}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,rating:r,comment:c,user_id:h})}),f=await x.json();return x.status===429?{success:!1,error:"每天最多评分 3 次"}:x.ok?{success:!0,...f}:{success:!1,error:f.error||"评分失败"}}catch(h){return console.error("Error rating plugin:",h),{success:!1,error:"网络错误"}}}async function _2(n){try{const r=await fetch(`${Cr}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n})}),c=await r.json();return r.status===429?(console.warn("Download recording rate limited"),{success:!0}):r.ok?{success:!0,...c}:(console.error("Failed to record download:",c.error),{success:!1,error:c.error})}catch(r){return console.error("Error recording download:",r),{success:!1,error:"网络错误"}}}function S2(){const n=navigator,r=[navigator.userAgent,navigator.language,navigator.languages?.join(",")||"",navigator.platform,navigator.hardwareConcurrency||0,screen.width,screen.height,screen.colorDepth,screen.pixelDepth,new Date().getTimezoneOffset(),Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.maxTouchPoints||0,n.deviceMemory||0].join("|");let c=0;for(let d=0;d{x(!0);const R=await $g(n);R&&d(R),x(!1)};u.useEffect(()=>{T()},[n]);const L=async()=>{const R=await N2(n);R.success?(z({title:"已点赞",description:"感谢你的支持!"}),T()):z({title:"点赞失败",description:R.error||"未知错误",variant:"destructive"})},K=async()=>{const R=await b2(n);R.success?(z({title:"已反馈",description:"感谢你的反馈!"}),T()):z({title:"操作失败",description:R.error||"未知错误",variant:"destructive"})},U=async()=>{if(f===0){z({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const R=await w2(n,f,g||void 0);R.success?(z({title:"评分成功",description:"感谢你的评价!"}),k(!1),j(0),_(""),T()):z({title:"评分失败",description:R.error||"未知错误",variant:"destructive"})};return h?e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):c?r?e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",title:`下载量: ${c.downloads.toLocaleString()}`,children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:c.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`评分: ${c.rating.toFixed(1)} (${c.rating_count} 条评价)`,children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:c.rating.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`点赞数: ${c.likes}`,children:[e.jsx(Cu,{className:"h-4 w-4"}),e.jsx("span",{children:c.likes})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(nl,{className:"h-5 w-5 text-muted-foreground mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.downloads.toLocaleString()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"下载量"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Ol,{className:"h-5 w-5 text-yellow-400 mb-1 fill-yellow-400"}),e.jsx("span",{className:"text-2xl font-bold",children:c.rating.toFixed(1)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.rating_count," 条评价"]})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Cu,{className:"h-5 w-5 text-green-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.likes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点赞"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(Xf,{className:"h-5 w-5 text-red-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:c.dislikes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点踩"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:L,children:[e.jsx(Cu,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:K,children:[e.jsx(Xf,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Os,{open:v,onOpenChange:k,children:[e.jsx(ni,{asChild:!0,children:e.jsxs(N,{variant:"default",size:"sm",children:[e.jsx(Ol,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(Es,{children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"为插件评分"}),e.jsx($s,{children:"分享你的使用体验,帮助其他用户"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex gap-2",children:[1,2,3,4,5].map(R=>e.jsx("button",{onClick:()=>j(R),className:"focus:outline-none",children:e.jsx(Ol,{className:`h-8 w-8 transition-colors ${R<=f?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-300"}`})},R))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f===0&&"点击星星进行评分",f===1&&"很差",f===2&&"一般",f===3&&"还行",f===4&&"不错",f===5&&"非常好"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"评论(可选)"}),e.jsx(Us,{value:g,onChange:R=>_(R.target.value),placeholder:"分享你的使用体验...",rows:4,maxLength:500}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 text-right",children:[g.length," / 500"]})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsx(N,{onClick:U,disabled:f===0,children:"提交评分"})]})]})]})]}),c.recent_ratings&&c.recent_ratings.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"最近评价"}),e.jsx("div",{className:"space-y-3",children:c.recent_ratings.map((R,ee)=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(V=>e.jsx(Ol,{className:`h-3 w-3 ${V<=R.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},V))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(R.created_at).toLocaleDateString()})]}),R.comment&&e.jsx("p",{className:"text-sm text-muted-foreground",children:R.comment})]},ee))})]})]}):null}const gp={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function k2(){const n=It(),[r,c]=u.useState(null),[d,h]=u.useState(""),[x,f]=u.useState("all"),[j,g]=u.useState("all"),[_,v]=u.useState(!0),[k,z]=u.useState([]),[T,L]=u.useState(!0),[K,U]=u.useState(null),[R,ee]=u.useState(null),[V,E]=u.useState(null),[B,X]=u.useState(null),[,w]=u.useState([]),[D,te]=u.useState({}),{toast:xe}=Bs(),be=async S=>{const me=S.map(async oe=>{try{const ge=await $g(oe.id);return{id:oe.id,stats:ge}}catch(ge){return console.warn(`Failed to load stats for ${oe.id}:`,ge),{id:oe.id,stats:null}}}),he=await Promise.all(me),Q={};he.forEach(({id:oe,stats:ge})=>{ge&&(Q[oe]=ge)}),te(Q)};u.useEffect(()=>{let S=null,me=!1;return(async()=>{if(S=m2(Q=>{me||(E(Q),Q.stage==="success"?setTimeout(()=>{me||E(null)},2e3):Q.stage==="error"&&(L(!1),U(Q.error||"加载失败")))},Q=>{console.error("WebSocket error:",Q),me||xe({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(Q=>{if(!S){Q();return}const oe=()=>{S&&S.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),Q()):S&&S.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),Q()):setTimeout(oe,100)};oe()}),!me){const Q=await o2();ee(Q),Q.installed||xe({title:"Git 未安装",description:Q.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!me){const Q=await d2();X(Q)}if(!me)try{L(!0),U(null);const Q=await c2();if(!me){const oe=await cr();w(oe);const ge=Q.map(le=>{const O=Yc(le.id,oe),F=Xc(le.id,oe);return{...le,installed:O,installed_version:F}});for(const le of oe)!ge.some(F=>F.id===le.id)&&le.manifest&&ge.push({id:le.id,manifest:{manifest_version:le.manifest.manifest_version||1,name:le.manifest.name,version:le.manifest.version,description:le.manifest.description||"",author:le.manifest.author,license:le.manifest.license||"Unknown",host_application:le.manifest.host_application,homepage_url:le.manifest.homepage_url,repository_url:le.manifest.repository_url,keywords:le.manifest.keywords||[],categories:le.manifest.categories||[],default_locale:le.manifest.default_locale||"zh-CN",locales_path:le.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:le.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});z(ge),be(ge)}}catch(Q){if(!me){const oe=Q instanceof Error?Q.message:"加载插件列表失败";U(oe),xe({title:"加载失败",description:oe,variant:"destructive"})}}finally{me||L(!1)}})(),()=>{me=!0,S&&S.close()}},[xe]);const ye=S=>{if(!S.installed&&B&&!ve(S))return e.jsxs(Xe,{variant:"destructive",className:"gap-1",children:[e.jsx(Aa,{className:"h-3 w-3"}),"不兼容"]});if(S.installed){const me=S.installed_version?.trim(),he=S.manifest.version?.trim();if(me!==he){const Q=me?.split(".").map(Number)||[0,0,0],oe=he?.split(".").map(Number)||[0,0,0];for(let ge=0;ge<3;ge++){if((oe[ge]||0)>(Q[ge]||0))return e.jsxs(Xe,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Aa,{className:"h-3 w-3"}),"可更新"]});if((oe[ge]||0)<(Q[ge]||0))break}}return e.jsxs(Xe,{variant:"default",className:"gap-1",children:[e.jsx(xa,{className:"h-3 w-3"}),"已安装"]})}return null},ve=S=>!B||!S.manifest?.host_application?!0:u2(S.manifest.host_application.min_version,S.manifest.host_application.max_version,B),pe=S=>{if(!S.installed||!S.installed_version||!S.manifest?.version)return!1;const me=S.installed_version.trim(),he=S.manifest.version.trim();if(me===he)return!1;const Q=me.split(".").map(Number),oe=he.split(".").map(Number);for(let ge=0;ge<3;ge++){if((oe[ge]||0)>(Q[ge]||0))return!0;if((oe[ge]||0)<(Q[ge]||0))return!1}return!1},Ne=k.filter(S=>{if(!S.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",S.id),!1;const me=d===""||S.manifest.name?.toLowerCase().includes(d.toLowerCase())||S.manifest.description?.toLowerCase().includes(d.toLowerCase())||S.manifest.keywords&&S.manifest.keywords.some(ge=>ge.toLowerCase().includes(d.toLowerCase())),he=x==="all"||S.manifest.categories&&S.manifest.categories.includes(x);let Q=!0;j==="installed"?Q=S.installed===!0:j==="updates"&&(Q=S.installed===!0&&pe(S));const oe=!_||!B||ve(S);return me&&he&&Q&&oe}),y=()=>{c(null)},q=async S=>{if(!R?.installed){xe({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(B&&!ve(S)){xe({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}try{await h2(S.id,S.manifest.repository_url||"","main"),_2(S.id).catch(he=>{console.warn("Failed to record download:",he)}),xe({title:"安装成功",description:`${S.manifest.name} 已成功安装`});const me=await cr();w(me),z(he=>he.map(Q=>{if(Q.id===S.id){const oe=Yc(Q.id,me),ge=Xc(Q.id,me);return{...Q,installed:oe,installed_version:ge}}return Q}))}catch(me){xe({title:"安装失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}},H=async S=>{try{await x2(S.id),xe({title:"卸载成功",description:`${S.manifest.name} 已成功卸载`});const me=await cr();w(me),z(he=>he.map(Q=>{if(Q.id===S.id){const oe=Yc(Q.id,me),ge=Xc(Q.id,me);return{...Q,installed:oe,installed_version:ge}}return Q}))}catch(me){xe({title:"卸载失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}},ne=async S=>{if(!R?.installed){xe({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const me=await f2(S.id,S.manifest.repository_url||"","main");xe({title:"更新成功",description:`${S.manifest.name} 已从 ${me.old_version} 更新到 ${me.new_version}`});const he=await cr();w(he),z(Q=>Q.map(oe=>{if(oe.id===S.id){const ge=Yc(oe.id,he),le=Xc(oe.id,he);return{...oe,installed:ge,installed_version:le}}return oe}))}catch(me){xe({title:"更新失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}};return e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件市场"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"浏览和管理麦麦的插件"})]}),e.jsxs(N,{onClick:()=>n({to:"/plugin-mirrors"}),children:[e.jsx(FN,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]}),R&&!R.installed&&e.jsxs(Be,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(gs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ya,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(js,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(Zs,{className:"text-orange-800 dark:text-orange-200",children:R.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(bs,{children:e.jsxs("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:["您可以从 ",e.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",className:"underline font-medium",children:"git-scm.com"})," 下载并安装 Git。 安装完成后,请重启麦麦应用。"]})})]}),e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:d,onChange:S=>h(S.target.value),className:"pl-9"})]}),e.jsxs(Qe,{value:x,onValueChange:f,children:[e.jsx(Ge,{className:"w-full sm:w-[200px]",children:e.jsx($e,{placeholder:"选择分类"})}),e.jsxs(Ve,{children:[e.jsx(ue,{value:"all",children:"全部分类"}),e.jsx(ue,{value:"Group Management",children:"群组管理"}),e.jsx(ue,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(ue,{value:"Utility Tools",children:"实用工具"}),e.jsx(ue,{value:"Content Generation",children:"内容生成"}),e.jsx(ue,{value:"Multimedia",children:"多媒体"}),e.jsx(ue,{value:"External Integration",children:"外部集成"}),e.jsx(ue,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(ue,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yt,{id:"compatible-only",checked:_,onCheckedChange:S=>v(S===!0)}),e.jsx("label",{htmlFor:"compatible-only",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:"只显示兼容当前版本的插件"})]})]})}),e.jsx(Kt,{value:j,onValueChange:g,className:"w-full",children:e.jsxs(Rt,{className:"grid w-full grid-cols-3",children:[e.jsxs(He,{value:"all",children:["全部插件 (",k.filter(S=>{if(!S.manifest)return!1;const me=d===""||S.manifest.name?.toLowerCase().includes(d.toLowerCase())||S.manifest.description?.toLowerCase().includes(d.toLowerCase())||S.manifest.keywords&&S.manifest.keywords.some(oe=>oe.toLowerCase().includes(d.toLowerCase())),he=x==="all"||S.manifest.categories&&S.manifest.categories.includes(x),Q=!_||!B||ve(S);return me&&he&&Q}).length,")"]}),e.jsxs(He,{value:"installed",children:["已安装 (",k.filter(S=>{if(!S.manifest)return!1;const me=d===""||S.manifest.name?.toLowerCase().includes(d.toLowerCase())||S.manifest.description?.toLowerCase().includes(d.toLowerCase())||S.manifest.keywords&&S.manifest.keywords.some(oe=>oe.toLowerCase().includes(d.toLowerCase())),he=x==="all"||S.manifest.categories&&S.manifest.categories.includes(x),Q=!_||!B||ve(S);return S.installed&&me&&he&&Q}).length,")"]}),e.jsxs(He,{value:"updates",children:["可更新 (",k.filter(S=>{if(!S.manifest)return!1;const me=d===""||S.manifest.name?.toLowerCase().includes(d.toLowerCase())||S.manifest.description?.toLowerCase().includes(d.toLowerCase())||S.manifest.keywords&&S.manifest.keywords.some(oe=>oe.toLowerCase().includes(d.toLowerCase())),he=x==="all"||S.manifest.categories&&S.manifest.categories.includes(x),Q=!_||!B||ve(S);return S.installed&&pe(S)&&me&&he&&Q}).length,")"]})]})}),V&&V.stage==="loading"&&e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vt,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm font-medium",children:[V.operation==="fetch"&&"加载插件列表",V.operation==="install"&&`安装插件${V.plugin_id?`: ${V.plugin_id}`:""}`,V.operation==="uninstall"&&`卸载插件${V.plugin_id?`: ${V.plugin_id}`:""}`,V.operation==="update"&&`更新插件${V.plugin_id?`: ${V.plugin_id}`:""}`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[V.progress,"%"]})]}),e.jsx(Sr,{value:V.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:V.message}),V.operation==="fetch"&&V.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",V.loaded_plugins," / ",V.total_plugins," 个插件"]})]})}),V&&V.stage==="error"&&V.error&&e.jsx(Be,{className:"border-destructive bg-destructive/10",children:e.jsx(gs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ya,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(js,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(Zs,{className:"text-destructive/80",children:V.error})]})]})})}),T?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):K?e.jsx(Be,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ya,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:K}),e.jsx(N,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):Ne.length===0?e.jsx(Be,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(St,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未找到插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d||x!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Ne.map(S=>e.jsxs(Be,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(gs,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(js,{className:"text-xl",children:S.manifest?.name||S.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[S.manifest?.categories&&S.manifest.categories[0]&&e.jsx(Xe,{variant:"secondary",className:"text-xs whitespace-nowrap",children:gp[S.manifest.categories[0]]||S.manifest.categories[0]}),ye(S)]})]}),e.jsx(Zs,{className:"line-clamp-2",children:S.manifest?.description||"无描述"})]}),e.jsx(bs,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:(D[S.id]?.downloads??S.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(D[S.id]?.rating??S.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[S.manifest?.keywords&&S.manifest.keywords.slice(0,3).map(me=>e.jsx(Xe,{variant:"outline",className:"text-xs",children:me},me)),S.manifest?.keywords&&S.manifest.keywords.length>3&&e.jsxs(Xe,{variant:"outline",className:"text-xs",children:["+",S.manifest.keywords.length-3]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground pt-2 border-t space-y-1",children:[e.jsxs("div",{children:["v",S.manifest?.version||"unknown"," · ",S.manifest?.author?.name||"Unknown"]}),S.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[S.manifest.host_application.min_version,S.manifest.host_application.max_version?` - ${S.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(wg,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>c(S),children:"查看详情"}),S.installed?pe(S)?e.jsxs(N,{size:"sm",disabled:!R?.installed,title:R?.installed?void 0:"Git 未安装",onClick:()=>ne(S),children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(N,{variant:"destructive",size:"sm",disabled:!R?.installed,title:R?.installed?void 0:"Git 未安装",onClick:()=>H(S),children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(N,{size:"sm",disabled:!R?.installed||V?.operation==="install"||B!==null&&!ve(S),title:R?.installed?B!==null&&!ve(S)?`不兼容当前版本 (需要 ${S.manifest?.host_application?.min_version||"未知"}${S.manifest?.host_application?.max_version?` - ${S.manifest.host_application.max_version}`:"+"},当前 ${B?.version})`:void 0:"Git 未安装",onClick:()=>q(S),children:[e.jsx(nl,{className:"h-4 w-4 mr-1"}),V?.operation==="install"&&V?.plugin_id===S.id?"安装中...":"安装"]})]})})]},S.id))}),e.jsx(Os,{open:r!==null,onOpenChange:y,children:r&&r.manifest&&e.jsxs(Es,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(zs,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(Ms,{className:"text-2xl",children:r.manifest.name}),e.jsxs($s,{children:["作者: ",r.manifest.author?.name||"Unknown",r.manifest.author?.url&&e.jsx("a",{href:r.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-primary hover:underline",children:e.jsx(dr,{className:"h-3 w-3 inline"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[r.manifest.categories&&r.manifest.categories[0]&&e.jsx(Xe,{variant:"secondary",children:gp[r.manifest.categories[0]]||r.manifest.categories[0]}),ye(r)]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(C2,{pluginId:r.id}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["v",r.manifest?.version||"unknown"]}),r.installed&&r.installed_version&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["已安装: v",r.installed_version]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"下载量"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(D[r.id]?.downloads??r.downloads??0).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"评分"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(D[r.id]?.rating??r.rating??0).toFixed(1)," (",D[r.id]?.rating_count??r.review_count??0,")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"许可证"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.manifest.license||"Unknown"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"支持版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.manifest.host_application?.min_version||"未知",r.manifest.host_application?.max_version?` - ${r.manifest.host_application.max_version}`:" - 最新版本"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"关键词"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.manifest.keywords&&r.manifest.keywords.map(S=>e.jsx(Xe,{variant:"outline",children:S},S))})]}),r.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"详细说明"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:r.detailed_description})]}),!r.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"说明"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.manifest.description||"无描述"})]}),e.jsxs("div",{className:"space-y-2",children:[r.manifest.homepage_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"主页: "}),e.jsx("a",{href:r.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:r.manifest.homepage_url})]}),r.manifest.repository_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"仓库: "}),e.jsx("a",{href:r.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:r.manifest.repository_url})]})]})]}),e.jsxs(Is,{children:[r.manifest.homepage_url&&e.jsxs(N,{onClick:()=>window.open(r.manifest.homepage_url,"_blank"),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"访问主页"]}),r.manifest.repository_url&&e.jsxs(N,{variant:"outline",onClick:()=>window.open(r.manifest.repository_url,"_blank"),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"查看仓库"]})]})]})})]})})}const Gu=Fy,Vu=Qy,Fu=$y;function T2({field:n,value:r,onChange:c}){const[d,h]=u.useState(!1);switch(n.ui_type){case"switch":return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:n.label}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]}),e.jsx(qe,{checked:!!r,onCheckedChange:c,disabled:n.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(ce,{type:"number",value:r??n.default,onChange:x=>c(parseFloat(x.target.value)||0),min:n.min,max:n.max,step:n.step??1,placeholder:n.placeholder,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"slider":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:n.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:r??n.default})]}),e.jsx(za,{value:[r??n.default],onValueChange:x=>c(x[0]),min:n.min??0,max:n.max??100,step:n.step??1,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsxs(Qe,{value:String(r??n.default),onValueChange:c,disabled:n.disabled,children:[e.jsx(Ge,{children:e.jsx($e,{placeholder:n.placeholder??"请选择"})}),e.jsx(Ve,{children:n.choices?.map(x=>e.jsx(ue,{value:String(x),children:String(x)},String(x)))})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(Us,{value:r??n.default,onChange:x=>c(x.target.value),placeholder:n.placeholder,rows:n.rows??3,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{type:d?"text":"password",value:r??"",onChange:x=>c(x.target.value),placeholder:n.placeholder,disabled:n.disabled,className:"pr-10"}),e.jsx(N,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>h(!d),children:d?e.jsx(mr,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:n.label}),e.jsx(ce,{type:"text",value:r??n.default??"",onChange:x=>c(x.target.value),placeholder:n.placeholder,maxLength:n.max_length,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]})}}function jp({section:n,config:r,onChange:c}){const[d,h]=u.useState(!n.collapsed),x=Object.entries(n.fields).filter(([,f])=>!f.hidden).sort(([,f],[,j])=>f.order-j.order);return e.jsx(Gu,{open:d,onOpenChange:h,children:e.jsxs(Be,{children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(gs,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsx(Ll,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(il,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(js,{className:"text-lg",children:n.title})]}),e.jsxs(Xe,{variant:"secondary",className:"text-xs",children:[x.length," 项"]})]}),n.description&&e.jsx(Zs,{className:"ml-6",children:n.description})]})}),e.jsx(Fu,{children:e.jsx(bs,{className:"space-y-4 pt-0",children:x.map(([f,j])=>e.jsx(T2,{field:j,value:r[n.name]?.[f],onChange:g=>c(n.name,f,g),sectionName:n.name},f))})})]})})}function E2({plugin:n,onBack:r}){const{toast:c}=Bs(),[d,h]=u.useState(null),[x,f]=u.useState({}),[j,g]=u.useState({}),[_,v]=u.useState(!0),[k,z]=u.useState(!1),[T,L]=u.useState(!1),[K,U]=u.useState(!1),R=u.useCallback(async()=>{v(!0);try{const[D,te]=await Promise.all([p2(n.id),g2(n.id)]);h(D),f(te),g(JSON.parse(JSON.stringify(te)))}catch(D){c({title:"加载配置失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}finally{v(!1)}},[n.id,c]);u.useEffect(()=>{R()},[R]),u.useEffect(()=>{L(JSON.stringify(x)!==JSON.stringify(j))},[x,j]);const ee=(D,te,xe)=>{f(be=>({...be,[D]:{...be[D]||{},[te]:xe}}))},V=async()=>{z(!0);try{await j2(n.id,x),g(JSON.parse(JSON.stringify(x))),c({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(D){c({title:"保存失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}finally{z(!1)}},E=async()=>{try{await v2(n.id),c({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),U(!1),R()}catch(D){c({title:"重置失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}},B=async()=>{try{const D=await y2(n.id);c({title:D.message,description:D.note}),R()}catch(D){c({title:"切换状态失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}};if(_)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!d)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 space-y-4",children:[e.jsx(Aa,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(N,{onClick:r,variant:"outline",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"返回"]})]});const X=Object.values(d.sections).sort((D,te)=>D.order-te.order),w=x.plugin?.enabled!==!1;return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(N,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:d.plugin_info.name||n.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Xe,{variant:w?"default":"secondary",children:w?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",d.plugin_info.version||n.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:B,children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),w?"禁用":"启用"]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>U(!0),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(N,{size:"sm",onClick:V,disabled:!T||k,children:[k?e.jsx(vt,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),T&&e.jsx(Be,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(bs,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xt,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),d.layout.type==="tabs"&&d.layout.tabs.length>0?e.jsxs(Kt,{defaultValue:d.layout.tabs[0]?.id,children:[e.jsx(Rt,{children:d.layout.tabs.map(D=>e.jsxs(He,{value:D.id,children:[D.title,D.badge&&e.jsx(Xe,{variant:"secondary",className:"ml-2 text-xs",children:D.badge})]},D.id))}),d.layout.tabs.map(D=>e.jsx(We,{value:D.id,className:"space-y-4 mt-4",children:D.sections.map(te=>{const xe=d.sections[te];return xe?e.jsx(jp,{section:xe,config:x,onChange:ee},te):null})},D.id))]}):e.jsx("div",{className:"space-y-4",children:X.map(D=>e.jsx(jp,{section:D,config:x,onChange:ee},D.name))}),e.jsx(Os,{open:K,onOpenChange:U,children:e.jsxs(Es,{children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"确认重置配置"}),e.jsx($s,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>U(!1),children:"取消"}),e.jsx(N,{variant:"destructive",onClick:E,children:"确认重置"})]})]})})]})}function z2(){const{toast:n}=Bs(),[r,c]=u.useState([]),[d,h]=u.useState(!0),[x,f]=u.useState(""),[j,g]=u.useState(null),_=async()=>{h(!0);try{const T=await cr();c(T)}catch(T){n({title:"加载插件列表失败",description:T instanceof Error?T.message:"未知错误",variant:"destructive"})}finally{h(!1)}};u.useEffect(()=>{_()},[]);const v=r.filter(T=>{const L=x.toLowerCase();return T.id.toLowerCase().includes(L)||T.manifest.name.toLowerCase().includes(L)||T.manifest.description?.toLowerCase().includes(L)}),k=r.length,z=0;return j?e.jsx(es,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(E2,{plugin:j,onBack:()=>g(null)})})}):e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理和配置已安装的插件"})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:_,children:[e.jsx(ft,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"刷新"]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d?"正在加载...":"个插件"})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已启用"}),e.jsx(xa,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Be,{children:[e.jsxs(gs,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(js,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Aa,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(bs,{children:[e.jsx("div",{className:"text-2xl font-bold",children:z}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:x,onChange:T=>f(T.target.value),className:"pl-9"})]}),e.jsxs(Be,{children:[e.jsxs(gs,{children:[e.jsx(js,{children:"已安装的插件"}),e.jsx(Zs,{children:"点击插件查看和编辑配置"})]}),e.jsx(bs,{children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):v.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(rn,{className:"h-16 w-16 text-muted-foreground/50"}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-lg font-medium text-muted-foreground",children:x?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:v.map(T=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>g(T),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(rn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium truncate",children:T.manifest.name}),e.jsxs(Xe,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",T.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(N,{variant:"ghost",size:"sm",children:e.jsx(Rl,{className:"h-4 w-4"})}),e.jsx(il,{className:"h-4 w-4 text-muted-foreground"})]})]},T.id))})})]})]})})}function M2(){const n=It(),{toast:r}=Bs(),[c,d]=u.useState([]),[h,x]=u.useState(!0),[f,j]=u.useState(null),[g,_]=u.useState(null),[v,k]=u.useState(!1),[z,T]=u.useState(!1),[L,K]=u.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),U=u.useCallback(async()=>{try{x(!0),j(null);const w=localStorage.getItem("access-token"),D=await fetch("/api/webui/plugins/mirrors",{headers:{Authorization:`Bearer ${w}`}});if(!D.ok)throw new Error("获取镜像源列表失败");const te=await D.json();d(te.mirrors||[])}catch(w){const D=w instanceof Error?w.message:"加载镜像源失败";j(D),r({title:"加载失败",description:D,variant:"destructive"})}finally{x(!1)}},[r]);u.useEffect(()=>{U()},[U]);const R=async()=>{try{const w=localStorage.getItem("access-token"),D=await fetch("/api/webui/plugins/mirrors",{method:"POST",headers:{Authorization:`Bearer ${w}`,"Content-Type":"application/json"},body:JSON.stringify(L)});if(!D.ok){const te=await D.json();throw new Error(te.detail||"添加镜像源失败")}r({title:"添加成功",description:"镜像源已添加"}),k(!1),K({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),U()}catch(w){r({title:"添加失败",description:w instanceof Error?w.message:"未知错误",variant:"destructive"})}},ee=async()=>{if(g)try{const w=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${g.id}`,{method:"PUT",headers:{Authorization:`Bearer ${w}`,"Content-Type":"application/json"},body:JSON.stringify({name:L.name,raw_prefix:L.raw_prefix,clone_prefix:L.clone_prefix,enabled:L.enabled,priority:L.priority})})).ok)throw new Error("更新镜像源失败");r({title:"更新成功",description:"镜像源已更新"}),T(!1),_(null),U()}catch(w){r({title:"更新失败",description:w instanceof Error?w.message:"未知错误",variant:"destructive"})}},V=async w=>{if(confirm("确定要删除这个镜像源吗?"))try{const D=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${w}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}})).ok)throw new Error("删除镜像源失败");r({title:"删除成功",description:"镜像源已删除"}),U()}catch(D){r({title:"删除失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}},E=async w=>{try{const D=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${w.id}`,{method:"PUT",headers:{Authorization:`Bearer ${D}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:!w.enabled})})).ok)throw new Error("更新状态失败");U()}catch(D){r({title:"更新失败",description:D instanceof Error?D.message:"未知错误",variant:"destructive"})}},B=w=>{_(w),K({id:w.id,name:w.name,raw_prefix:w.raw_prefix,clone_prefix:w.clone_prefix,enabled:w.enabled,priority:w.priority}),T(!0)},X=async(w,D)=>{const te=D==="up"?w.priority-1:w.priority+1;if(!(te<1))try{const xe=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${w.id}`,{method:"PUT",headers:{Authorization:`Bearer ${xe}`,"Content-Type":"application/json"},body:JSON.stringify({priority:te})})).ok)throw new Error("更新优先级失败");U()}catch(xe){r({title:"更新失败",description:xe instanceof Error?xe.message:"未知错误",variant:"destructive"})}};return e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>n({to:"/plugins"}),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"镜像源配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 Git 克隆和文件下载的镜像源"})]})]}),e.jsxs(N,{onClick:()=>k(!0),children:[e.jsx(gt,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),h?e.jsx(Be,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(vt,{className:"h-8 w-8 animate-spin text-primary"})})}):f?e.jsx(Be,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ya,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),e.jsx(N,{onClick:U,children:"重新加载"})]})}):e.jsxs(Be,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ii,{children:[e.jsx(ri,{children:e.jsxs(pt,{children:[e.jsx(ls,{children:"状态"}),e.jsx(ls,{children:"名称"}),e.jsx(ls,{children:"ID"}),e.jsx(ls,{children:"优先级"}),e.jsx(ls,{className:"text-right",children:"操作"})]})}),e.jsx(ci,{children:c.map(w=>e.jsxs(pt,{children:[e.jsx(Ye,{children:e.jsx(qe,{checked:w.enabled,onCheckedChange:()=>E(w)})}),e.jsx(Ye,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",w.raw_prefix]})]})}),e.jsx(Ye,{children:e.jsx(Xe,{variant:"outline",children:w.id})}),e.jsx(Ye,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:w.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(N,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>X(w,"up"),disabled:w.priority===1,children:e.jsx(fr,{className:"h-3 w-3"})}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>X(w,"down"),children:e.jsx(Ll,{className:"h-3 w-3"})})]})]})}),e.jsx(Ye,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>B(w),children:e.jsx(nn,{className:"h-4 w-4"})}),e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>V(w.id),children:e.jsx(ns,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:c.map(w=>e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:w.name}),w.enabled&&e.jsx(Xe,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(Xe,{variant:"outline",className:"mt-1 text-xs",children:w.id})]}),e.jsx(qe,{checked:w.enabled,onCheckedChange:()=>E(w)})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Raw: "}),e.jsx("span",{className:"break-all",children:w.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:w.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(N,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>B(w),children:[e.jsx(nn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>X(w,"up"),disabled:w.priority===1,children:e.jsx(fr,{className:"h-4 w-4"})}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>X(w,"down"),children:e.jsx(Ll,{className:"h-4 w-4"})}),e.jsx(N,{variant:"destructive",size:"sm",onClick:()=>V(w.id),children:e.jsx(ns,{className:"h-4 w-4"})})]})]})},w.id))})]}),e.jsx(Os,{open:v,onOpenChange:k,children:e.jsxs(Es,{className:"max-w-lg",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"添加镜像源"}),e.jsx($s,{children:"添加新的 Git 镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(ce,{id:"add-id",placeholder:"例如: my-mirror",value:L.id,onChange:w=>K({...L,id:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ce,{id:"add-name",placeholder:"例如: 我的镜像源",value:L.name,onChange:w=>K({...L,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"add-raw",placeholder:"https://example.com/raw",value:L.raw_prefix,onChange:w=>K({...L,raw_prefix:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"add-clone",placeholder:"https://example.com/clone",value:L.clone_prefix,onChange:w=>K({...L,clone_prefix:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ce,{id:"add-priority",type:"number",min:"1",value:L.priority,onChange:w=>K({...L,priority:parseInt(w.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"add-enabled",checked:L.enabled,onCheckedChange:w=>K({...L,enabled:w})}),e.jsx(b,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsx(N,{onClick:R,children:"添加"})]})]})}),e.jsx(Os,{open:z,onOpenChange:T,children:e.jsxs(Es,{className:"max-w-lg",children:[e.jsxs(zs,{children:[e.jsx(Ms,{children:"编辑镜像源"}),e.jsx($s,{children:"修改镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"镜像源 ID"}),e.jsx(ce,{value:L.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ce,{id:"edit-name",value:L.name,onChange:w=>K({...L,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"edit-raw",value:L.raw_prefix,onChange:w=>K({...L,raw_prefix:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"edit-clone",value:L.clone_prefix,onChange:w=>K({...L,clone_prefix:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ce,{id:"edit-priority",type:"number",min:"1",value:L.priority,onChange:w=>K({...L,priority:parseInt(w.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qe,{id:"edit-enabled",checked:L.enabled,onCheckedChange:w=>K({...L,enabled:w})}),e.jsx(b,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(Is,{children:[e.jsx(N,{variant:"outline",onClick:()=>T(!1),children:"取消"}),e.jsx(N,{onClick:ee,children:"保存"})]})]})})]})})}const Jc=u.forwardRef(({className:n,...r},c)=>e.jsx(Lp,{ref:c,className:$("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",n),...r}));Jc.displayName=Lp.displayName;const A2=u.forwardRef(({className:n,...r},c)=>e.jsx(Up,{ref:c,className:$("aspect-square h-full w-full",n),...r}));A2.displayName=Up.displayName;const Pc=u.forwardRef(({className:n,...r},c)=>e.jsx(Bp,{ref:c,className:$("flex h-full w-full items-center justify-center rounded-full bg-muted",n),...r}));Pc.displayName=Bp.displayName;function D2(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function O2(){const n="maibot_webui_user_id";let r=localStorage.getItem(n);return r||(r=D2(),localStorage.setItem(n,r)),r}function R2(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function L2(n){localStorage.setItem("maibot_webui_user_name",n)}function U2(){const[n,r]=u.useState([]),[c,d]=u.useState(""),[h,x]=u.useState(!1),[f,j]=u.useState(!1),[g,_]=u.useState(!1),[v,k]=u.useState(!0),[z,T]=u.useState(R2()),[L,K]=u.useState(!1),[U,R]=u.useState(""),[ee,V]=u.useState({}),E=u.useRef(O2()),B=u.useRef(null),X=u.useRef(null),w=u.useRef(null),D=u.useRef(0),te=u.useRef(new Set),{toast:xe}=Bs(),be=Q=>(D.current+=1,`${Q}-${Date.now()}-${D.current}-${Math.random().toString(36).substr(2,9)}`),ye=u.useCallback(()=>{X.current?.scrollIntoView({behavior:"smooth"})},[]);u.useEffect(()=>{ye()},[n,ye]);const ve=u.useCallback(async()=>{k(!0);try{const Q=`/api/chat/history?user_id=${E.current}&limit=50`;console.log("[Chat] 正在加载历史消息:",Q);const oe=await fetch(Q);if(console.log("[Chat] 历史消息响应状态:",oe.status,oe.statusText),console.log("[Chat] 响应 Content-Type:",oe.headers.get("content-type")),oe.ok){const ge=await oe.text();console.log("[Chat] 响应内容前100字符:",ge.substring(0,100));try{const le=JSON.parse(ge);if(console.log("[Chat] 解析后的数据:",le),le.messages&&le.messages.length>0){const O=le.messages.map(F=>({id:F.id,type:F.type,content:F.content,timestamp:F.timestamp,sender:{name:F.sender_name||(F.is_bot?"麦麦":"WebUI用户"),user_id:F.user_id,is_bot:F.is_bot}}));r(O),console.log("[Chat] 已加载历史消息数量:",O.length),O.forEach(F=>{if(F.type==="bot"){const A=`bot-${F.content}-${Math.floor(F.timestamp*1e3)}`;te.current.add(A)}})}else console.log("[Chat] 没有历史消息")}catch(le){console.error("[Chat] JSON 解析失败:",le),console.error("[Chat] 原始响应内容:",ge)}}else{console.error("[Chat] 响应失败:",oe.status);const ge=await oe.text();console.error("[Chat] 错误响应内容:",ge.substring(0,200))}}catch(Q){console.error("[Chat] 加载历史消息失败:",Q)}finally{k(!1)}},[]),pe=u.useCallback(()=>{if(B.current?.readyState===WebSocket.OPEN||B.current?.readyState===WebSocket.CONNECTING){console.log("WebSocket 已存在,跳过连接");return}j(!0);const oe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/chat/ws?user_id=${encodeURIComponent(E.current)}&user_name=${encodeURIComponent(z)}`;console.log("正在连接 WebSocket:",oe);try{const ge=new WebSocket(oe);B.current=ge,ge.onopen=()=>{x(!0),j(!1),console.log("WebSocket 已连接")},ge.onmessage=le=>{try{const O=JSON.parse(le.data);switch(O.type){case"session_info":V({session_id:O.session_id,user_id:O.user_id,user_name:O.user_name,bot_name:O.bot_name});break;case"system":r(F=>[...F,{id:be("sys"),type:"system",content:O.content||"",timestamp:O.timestamp||Date.now()/1e3}]);break;case"user_message":r(F=>[...F,{id:O.message_id||be("user"),type:"user",content:O.content||"",timestamp:O.timestamp||Date.now()/1e3,sender:O.sender}]);break;case"bot_message":{_(!1);const F=`bot-${O.content}-${Math.floor((O.timestamp||0)*1e3)}`;if(te.current.has(F)){console.log("跳过重复的机器人消息");break}if(te.current.add(F),te.current.size>100){const A=te.current.values().next().value;A&&te.current.delete(A)}r(A=>[...A,{id:be("bot"),type:"bot",content:O.content||"",timestamp:O.timestamp||Date.now()/1e3,sender:O.sender}]);break}case"typing":_(O.is_typing||!1);break;case"error":r(F=>[...F,{id:be("error"),type:"error",content:O.content||"发生错误",timestamp:O.timestamp||Date.now()/1e3}]),xe({title:"错误",description:O.content,variant:"destructive"});break;case"pong":break;default:console.log("未知消息类型:",O.type)}}catch(O){console.error("解析消息失败:",O)}},ge.onclose=()=>{x(!1),j(!1),B.current=null,console.log("WebSocket 已断开"),w.current&&clearTimeout(w.current),w.current=window.setTimeout(()=>{Ne.current||pe()},5e3)},ge.onerror=le=>{console.error("WebSocket 错误:",le),j(!1)}}catch(ge){console.error("创建 WebSocket 失败:",ge),j(!1)}},[xe,z]),Ne=u.useRef(!1);u.useEffect(()=>{Ne.current=!1,ve();const Q=setTimeout(()=>{Ne.current||pe()},100),oe=setInterval(()=>{B.current?.readyState===WebSocket.OPEN&&B.current.send(JSON.stringify({type:"ping"}))},3e4);return()=>{Ne.current=!0,clearTimeout(Q),clearInterval(oe),w.current&&(clearTimeout(w.current),w.current=null),B.current&&(B.current.close(),B.current=null)}},[pe,ve]);const y=u.useCallback(()=>{!c.trim()||!B.current||B.current.readyState!==WebSocket.OPEN||(B.current.send(JSON.stringify({type:"message",content:c.trim(),user_name:z})),d(""))},[c,z]),q=Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),y())},H=()=>{R(z),K(!0)},ne=()=>{const Q=U.trim()||"WebUI用户";T(Q),L2(Q),K(!1),B.current?.readyState===WebSocket.OPEN&&B.current.send(JSON.stringify({type:"update_nickname",user_name:Q}))},S=()=>{R(""),K(!1)},me=Q=>new Date(Q*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),he=()=>{B.current&&B.current.close(),pe()};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"shrink-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0",children:[e.jsx(Jc,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(Pc,{className:"bg-primary/10 text-primary",children:e.jsx(ir,{className:"h-4 w-4 sm:h-5 sm:w-5"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-base sm:text-lg font-semibold truncate",children:ee.bot_name||"麦麦"}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:h?e.jsxs(e.Fragment,{children:[e.jsx(QN,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"已连接"})]}):f?e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx($N,{className:"h-3 w-3 text-red-500"}),e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"未连接"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v&&e.jsx(vt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:he,disabled:f,title:"重新连接",children:e.jsx(ft,{className:$("h-4 w-4",f&&"animate-spin")})})]})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 mt-2 text-sm text-muted-foreground",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),L?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:U,onChange:Q=>R(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&ne(),Q.key==="Escape"&&S()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(N,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:ne,children:"保存"}),e.jsx(N,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:S,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:z}),e.jsx(N,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:H,title:"修改昵称",children:e.jsx(YN,{className:"h-3 w-3"})})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(es,{className:"h-full",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto space-y-3 sm:space-y-4",children:[n.length===0&&!v&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(ir,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",ee.bot_name||"麦麦"," 对话吧!"]})]}),n.map(Q=>e.jsxs("div",{className:$("flex gap-2 sm:gap-3",Q.type==="user"&&"flex-row-reverse",Q.type==="system"&&"justify-center",Q.type==="error"&&"justify-center"),children:[Q.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:Q.content}),Q.type==="error"&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 bg-red-100 dark:bg-red-900/30 px-3 py-1 rounded-full max-w-[90%]",children:Q.content}),(Q.type==="user"||Q.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(Jc,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Pc,{className:$("text-xs",Q.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:Q.type==="bot"?e.jsx(ir,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(to,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:$("flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",Q.type==="user"&&"items-end"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] sm:text-xs text-muted-foreground",children:[e.jsx("span",{className:"hidden sm:inline",children:Q.sender?.name||(Q.type==="bot"?ee.bot_name:z)}),e.jsx("span",{children:me(Q.timestamp)})]}),e.jsx("div",{className:$("rounded-2xl px-3 py-2 text-sm whitespace-pre-wrap break-words",Q.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:Q.content})]})]})]},Q.id)),g&&e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsx(Jc,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Pc,{className:"bg-primary/10 text-primary",children:e.jsx(ir,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsx("div",{className:"bg-muted rounded-2xl rounded-tl-sm px-4 py-3",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})})]}),e.jsx("div",{ref:X})]})})}),e.jsx("div",{className:"shrink-0 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsx("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:c,onChange:Q=>d(Q.target.value),onKeyDown:q,placeholder:h?"输入消息...":"等待连接...",disabled:!h,className:"flex-1 h-10 sm:h-10"}),e.jsx(N,{onClick:y,disabled:!h||!c.trim(),size:"icon",className:"h-10 w-10 shrink-0",children:e.jsx(XN,{className:"h-4 w-4"})})]})})})]})}const B2=ai("pointer-events-none inline-flex select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono font-medium opacity-100",{variants:{size:{sm:"h-5 text-[10px]",default:"h-6 text-xs",lg:"h-7 text-sm"}},defaultVariants:{size:"default"}}),Yg=u.forwardRef(({className:n,size:r,abbrTitle:c,children:d,...h},x)=>e.jsx("kbd",{className:$(B2({size:r,className:n})),ref:x,...h,children:c?e.jsx("abbr",{title:c,children:d}):d}));Yg.displayName="Kbd";const H2=[{icon:xr,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:Ma,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:vg,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:yg,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:Qu,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:si,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:Ng,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:KN,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:rn,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:ao,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:Rl,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function q2({open:n,onOpenChange:r}){const[c,d]=u.useState(""),[h,x]=u.useState(0),f=It(),j=H2.filter(v=>v.title.toLowerCase().includes(c.toLowerCase())||v.description.toLowerCase().includes(c.toLowerCase())||v.category.toLowerCase().includes(c.toLowerCase()));u.useEffect(()=>{n&&(d(""),x(0))},[n]);const g=u.useCallback(v=>{f({to:v}),r(!1)},[f,r]),_=u.useCallback(v=>{v.key==="ArrowDown"?(v.preventDefault(),x(k=>(k+1)%j.length)):v.key==="ArrowUp"?(v.preventDefault(),x(k=>(k-1+j.length)%j.length)):v.key==="Enter"&&j[h]&&(v.preventDefault(),g(j[h].path))},[j,h,g]);return e.jsx(Os,{open:n,onOpenChange:r,children:e.jsxs(Es,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(zs,{className:"px-4 pt-4 pb-0",children:[e.jsx(Ms,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ce,{value:c,onChange:v=>{d(v.target.value),x(0)},onKeyDown:_,placeholder:"搜索页面...",className:"h-12 pl-11 text-base border-0 focus-visible:ring-0 shadow-none",autoFocus:!0})]})]}),e.jsx("div",{className:"border-t",children:e.jsx(es,{className:"h-[400px]",children:j.length>0?e.jsx("div",{className:"p-2",children:j.map((v,k)=>{const z=v.icon;return e.jsxs("button",{onClick:()=>g(v.path),onMouseEnter:()=>x(k),className:$("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",k===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[e.jsx(z,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:v.title}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:v.description})]}),e.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:v.category})]},v.path)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(St,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),e.jsx("div",{className:"border-t px-4 py-3 flex items-center justify-between text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↑"}),e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↓"}),"导航"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Enter"}),"选择"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Esc"}),"关闭"]})]})})]})})}const G2=Xy,V2=Ky,F2=Zy,Xg=u.forwardRef(({className:n,inset:r,children:c,...d},h)=>e.jsxs(Hp,{ref:h,className:$("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",n),...d,children:[c,e.jsx(il,{className:"ml-auto h-4 w-4"})]}));Xg.displayName=Hp.displayName;const Kg=u.forwardRef(({className:n,...r},c)=>e.jsx(qp,{ref:c,className:$("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",n),...r}));Kg.displayName=qp.displayName;const Zg=u.forwardRef(({className:n,...r},c)=>e.jsx(Yy,{children:e.jsx(Gp,{ref:c,className:$("z-50 max-h-[--radix-context-menu-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",n),...r})}));Zg.displayName=Gp.displayName;const va=u.forwardRef(({className:n,inset:r,...c},d)=>e.jsx(Vp,{ref:d,className:$("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r&&"pl-8",n),...c}));va.displayName=Vp.displayName;const Q2=u.forwardRef(({className:n,children:r,checked:c,...d},h)=>e.jsxs(Fp,{ref:h,className:$("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),checked:c,...d,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Qp,{children:e.jsx(ha,{className:"h-4 w-4"})})}),r]}));Q2.displayName=Fp.displayName;const $2=u.forwardRef(({className:n,children:r,...c},d)=>e.jsxs($p,{ref:d,className:$("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Qp,{children:e.jsx(ZN,{className:"h-2 w-2 fill-current"})})}),r]}));$2.displayName=$p.displayName;const Y2=u.forwardRef(({className:n,inset:r,...c},d)=>e.jsx(Yp,{ref:d,className:$("px-2 py-1.5 text-sm font-semibold text-foreground",r&&"pl-8",n),...c}));Y2.displayName=Yp.displayName;const or=u.forwardRef(({className:n,...r},c)=>e.jsx(Xp,{ref:c,className:$("-mx-1 my-1 h-px bg-border",n),...r}));or.displayName=Xp.displayName;const Jn=({className:n,...r})=>e.jsx("span",{className:$("ml-auto text-xs tracking-widest text-muted-foreground",n),...r});Jn.displayName="ContextMenuShortcut";const X2=gN,K2=jN,Z2=vN,Ig=u.forwardRef(({className:n,sideOffset:r=4,...c},d)=>e.jsx(pN,{children:e.jsx(cg,{ref:d,sideOffset:r,className:$("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",n),...c})}));Ig.displayName=cg.displayName;function I2({children:n}){y0();const[r,c]=u.useState(!0),[d,h]=u.useState(!1),[x,f]=u.useState(!1),{theme:j,setTheme:g}=Yu(),_=py(),v=It();u.useEffect(()=>{const K=U=>{(U.metaKey||U.ctrlKey)&&U.key==="k"&&(U.preventDefault(),f(!0))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[]);const k=[{title:"概览",items:[{icon:xr,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:Ma,label:"麦麦主程序配置",path:"/config/bot"},{icon:vg,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:yg,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:Kf,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:Qu,label:"表情包管理",path:"/resource/emoji"},{icon:si,label:"表达方式管理",path:"/resource/expression"},{icon:Ng,label:"人物信息管理",path:"/resource/person"},{icon:jg,label:"知识库图谱可视化",path:"/resource/knowledge-graph"}]},{title:"扩展与监控",items:[{icon:rn,label:"插件市场",path:"/plugins"},{icon:Kf,label:"插件配置",path:"/plugin-config"},{icon:ao,label:"日志查看器",path:"/logs"},{icon:si,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:Rl,label:"系统设置",path:"/settings"}]}],T=j==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":j,L=()=>{localStorage.removeItem("access-token"),v({to:"/auth"})};return e.jsx(X2,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:$("fixed inset-y-0 left-0 z-50 flex flex-col border-r bg-card transition-all duration-300 lg:relative lg:z-0","w-64 lg:w-auto",r?"lg:w-64":"lg:w-16",d?"translate-x-0":"-translate-x-full lg:translate-x-0"),children:[e.jsx("div",{className:"flex h-16 items-center border-b px-4",children:e.jsxs("div",{className:$("relative flex items-center justify-center flex-1 transition-all overflow-hidden","lg:flex-1",!r&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:$("flex items-baseline gap-2",!r&&"lg:hidden"),children:[e.jsx("span",{className:"font-bold text-xl text-primary-gradient whitespace-nowrap",children:"MaiBot WebUI"}),e.jsx("span",{className:"text-xs text-primary/60 whitespace-nowrap",children:a0()})]}),!r&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(es,{className:$("flex-1 overflow-x-hidden",!r&&"lg:w-16"),children:e.jsx("nav",{className:$("p-4",!r&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:$("space-y-6",!r&&"lg:space-y-3 lg:w-full"),children:k.map((K,U)=>e.jsxs("li",{children:[e.jsx("div",{className:$("px-3 h-[1.25rem]","mb-2",!r&&"lg:mb-1 lg:invisible"),children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:K.title})}),!r&&U>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:K.items.map(R=>{const ee=_({to:R.path}),V=R.icon,E=e.jsxs(e.Fragment,{children:[ee&&e.jsx("div",{className:"absolute left-0 top-1/2 h-8 w-1 -translate-y-1/2 rounded-r-full bg-primary transition-opacity duration-300"}),e.jsxs("div",{className:$("flex items-center transition-all duration-300",r?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(V,{className:$("h-5 w-5 flex-shrink-0",ee&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:$("text-sm font-medium whitespace-nowrap transition-all duration-300",ee&&"font-semibold",r?"opacity-100 max-w-[200px]":"opacity-100 max-w-[200px] lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:R.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(K2,{children:[e.jsx(Z2,{asChild:!0,children:e.jsx(Kc,{to:R.path,"data-tour":R.tourId,className:$("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",ee?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground",r?"px-3":"px-3 lg:px-0 lg:justify-center lg:w-12 lg:mx-auto"),onClick:()=>h(!1),children:E})}),!r&&e.jsx(Ig,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:R.label})})]})},R.path)})})]},K.title))})})})]}),d&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>h(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"flex h-16 items-center justify-between border-b bg-card/80 backdrop-blur-md px-4 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>h(!d),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(IN,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>c(!r),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:r?"收起侧边栏":"展开侧边栏",children:e.jsx(cn,{className:$("h-5 w-5 transition-transform",!r&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>f(!0),className:"relative hidden md:flex items-center w-64 h-9 pl-9 pr-16 bg-background/50 border rounded-md hover:bg-accent/50 transition-colors text-left",children:[e.jsx(St,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"搜索..."}),e.jsxs(Yg,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(q2,{open:x,onOpenChange:f}),e.jsxs(N,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(JN,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:K=>{Pb(T==="dark"?"light":"dark",g,K)},className:"rounded-lg p-2 hover:bg-accent",title:T==="dark"?"切换到浅色模式":"切换到深色模式",children:T==="dark"?e.jsx(Ou,{className:"h-5 w-5"}):e.jsx(Ru,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(N,{variant:"ghost",size:"sm",onClick:L,className:"gap-2",title:"登出系统",children:[e.jsx(Zf,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsxs(G2,{children:[e.jsx(V2,{asChild:!0,children:e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:n})}),e.jsxs(Zg,{className:"w-64",children:[e.jsxs(va,{onClick:()=>v({to:"/"}),children:[e.jsx(xr,{className:"mr-2 h-4 w-4"}),"首页"]}),e.jsxs(va,{onClick:()=>v({to:"/settings"}),children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"系统设置"]}),e.jsxs(va,{onClick:()=>v({to:"/logs"}),children:[e.jsx(ao,{className:"mr-2 h-4 w-4"}),"日志查看器"]}),e.jsx(or,{}),e.jsxs(F2,{children:[e.jsxs(Xg,{children:[e.jsx(fg,{className:"mr-2 h-4 w-4"}),"切换主题"]}),e.jsxs(Kg,{className:"w-48",children:[e.jsxs(va,{onClick:()=>g("light"),disabled:j==="light",children:[e.jsx(Ou,{className:"mr-2 h-4 w-4"}),"浅色",j==="light"&&e.jsx(Jn,{children:"✓"})]}),e.jsxs(va,{onClick:()=>g("dark"),disabled:j==="dark",children:[e.jsx(Ru,{className:"mr-2 h-4 w-4"}),"深色",j==="dark"&&e.jsx(Jn,{children:"✓"})]}),e.jsxs(va,{onClick:()=>g("system"),disabled:j==="system",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"跟随系统",j==="system"&&e.jsx(Jn,{children:"✓"})]})]})]}),e.jsx(or,{}),e.jsxs(va,{onClick:()=>window.location.reload(),children:[e.jsx(PN,{className:"mr-2 h-4 w-4"}),"刷新页面",e.jsx(Jn,{children:"⌘R"})]}),e.jsxs(va,{onClick:()=>f(!0),children:[e.jsx(St,{className:"mr-2 h-4 w-4"}),"搜索",e.jsx(Jn,{children:"⌘K"})]}),e.jsx(or,{}),e.jsxs(va,{onClick:()=>window.open("https://docs.mai-mai.org","_blank"),children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),"麦麦文档"]}),e.jsx(or,{}),e.jsxs(va,{onClick:L,className:"text-destructive focus:text-destructive",children:[e.jsx(Zf,{className:"mr-2 h-4 w-4"}),"登出系统"]})]})]})]})]})})}function J2(n){const r=n.split(` -`).slice(1),c=[];for(const d of r){const h=d.trim();if(!h.startsWith("at "))continue;const x=h.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);x?c.push({functionName:x[1]||"",fileName:x[2],lineNumber:x[3],columnNumber:x[4],raw:h}):c.push({functionName:"",fileName:"",lineNumber:"",columnNumber:"",raw:h})}return c}function P2({error:n,errorInfo:r}){const[c,d]=u.useState(!0),[h,x]=u.useState(!1),[f,j]=u.useState(!1),g=n.stack?J2(n.stack):[],_=async()=>{const v=` -Error: ${n.name} -Message: ${n.message} - -Stack Trace: -${n.stack||"No stack trace available"} - -Component Stack: -${r?.componentStack||"No component stack available"} - -URL: ${window.location.href} -User Agent: ${navigator.userAgent} -Time: ${new Date().toISOString()} - `.trim();try{await navigator.clipboard.writeText(v),j(!0),setTimeout(()=>j(!1),2e3)}catch(k){console.error("Failed to copy:",k)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ua,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(ya,{className:"h-4 w-4"}),e.jsxs(ma,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[n.name,":"]})," ",n.message]})]}),g.length>0&&e.jsxs(Gu,{open:c,onOpenChange:d,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(N,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(WN,{className:"h-4 w-4"}),"Stack Trace (",g.length," frames)"]}),c?e.jsx(fr,{className:"h-4 w-4"}):e.jsx(Ll,{className:"h-4 w-4"})]})}),e.jsx(Fu,{children:e.jsx(es,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:g.map((v,k)=>e.jsx("div",{className:"font-mono text-xs p-2 rounded hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"text-muted-foreground w-6 text-right flex-shrink-0",children:[k+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-primary font-medium",children:v.functionName}),v.fileName&&e.jsxs("div",{className:"text-muted-foreground mt-0.5 break-all",children:[v.fileName,v.lineNumber&&e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:[":",v.lineNumber,":",v.columnNumber]})]})]})]})},k))})})})]}),r?.componentStack&&e.jsxs(Gu,{open:h,onOpenChange:x,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(N,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(ya,{className:"h-4 w-4"}),"Component Stack"]}),h?e.jsx(fr,{className:"h-4 w-4"}):e.jsx(Ll,{className:"h-4 w-4"})]})}),e.jsx(Fu,{children:e.jsx(es,{className:"h-[200px] rounded-md border bg-muted/30",children:e.jsx("pre",{className:"p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground",children:r.componentStack})})})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:_,className:"w-full",children:f?e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(so,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function Jg({error:n,errorInfo:r}){const c=()=>{window.location.href="/"},d=()=>{window.location.reload()};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Be,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(gs,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30 mb-4",children:e.jsx(ya,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(js,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(Zs,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(bs,{className:"space-y-4",children:[e.jsx(P2,{error:n,errorInfo:r}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:[e.jsxs(N,{onClick:d,className:"flex-1",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(N,{onClick:c,variant:"outline",className:"flex-1",children:[e.jsx(xr,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class W2 extends u.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,c){console.error("ErrorBoundary caught an error:",r,c),this.setState({errorInfo:c})}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:e.jsx(Jg,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function Pg({error:n}){return e.jsx(Jg,{error:n,errorInfo:null})}const kr=gy({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(vp,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!Dg())throw vy({to:"/auth"})}}),e_=lt({getParentRoute:()=>kr,path:"/auth",component:N0}),s_=lt({getParentRoute:()=>kr,path:"/setup",component:B0}),Nt=lt({getParentRoute:()=>kr,id:"protected",component:()=>e.jsx(I2,{children:e.jsx(vp,{})}),errorComponent:({error:n})=>e.jsx(Pg,{error:n})}),t_=lt({getParentRoute:()=>Nt,path:"/",component:Ib}),a_=lt({getParentRoute:()=>Nt,path:"/config/bot",component:J0}),l_=lt({getParentRoute:()=>Nt,path:"/config/modelProvider",component:Nw}),n_=lt({getParentRoute:()=>Nt,path:"/config/model",component:Sw}),i_=lt({getParentRoute:()=>Nt,path:"/config/adapter",component:kw}),r_=lt({getParentRoute:()=>Nt,path:"/resource/emoji",component:Kw}),c_=lt({getParentRoute:()=>Nt,path:"/resource/expression",component:i1}),o_=lt({getParentRoute:()=>Nt,path:"/resource/person",component:g1}),d_=lt({getParentRoute:()=>Nt,path:"/resource/knowledge-graph",component:C1}),u_=lt({getParentRoute:()=>Nt,path:"/logs",component:a2}),m_=lt({getParentRoute:()=>Nt,path:"/chat",component:U2}),h_=lt({getParentRoute:()=>Nt,path:"/plugins",component:k2}),x_=lt({getParentRoute:()=>Nt,path:"/plugin-config",component:z2}),f_=lt({getParentRoute:()=>Nt,path:"/plugin-mirrors",component:M2}),p_=lt({getParentRoute:()=>Nt,path:"/settings",component:h0}),g_=lt({getParentRoute:()=>kr,path:"*",component:Og}),j_=kr.addChildren([e_,s_,Nt.addChildren([t_,a_,l_,n_,i_,r_,c_,o_,d_,h_,x_,f_,u_,m_,p_]),g_]),v_=jy({routeTree:j_,defaultNotFoundComponent:Og,defaultErrorComponent:({error:n})=>e.jsx(Pg,{error:n})});function y_({children:n,defaultTheme:r="system",storageKey:c="ui-theme",...d}){const[h,x]=u.useState(()=>localStorage.getItem(c)||r);u.useEffect(()=>{const j=window.document.documentElement;if(j.classList.remove("light","dark"),h==="system"){const g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";j.classList.add(g);return}j.classList.add(h)},[h]),u.useEffect(()=>{const j=localStorage.getItem("accent-color");if(j){const g=document.documentElement,v={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[j];v&&(g.style.setProperty("--primary",v.hsl),v.gradient?(g.style.setProperty("--primary-gradient",v.gradient),g.classList.add("has-gradient")):(g.style.removeProperty("--primary-gradient"),g.classList.remove("has-gradient")))}},[]);const f={theme:h,setTheme:j=>{localStorage.setItem(c,j),x(j)}};return e.jsx(kg.Provider,{...d,value:f,children:n})}function N_({children:n,defaultEnabled:r=!0,defaultWavesEnabled:c=!0,storageKey:d="enable-animations",wavesStorageKey:h="enable-waves-background"}){const[x,f]=u.useState(()=>{const v=localStorage.getItem(d);return v!==null?v==="true":r}),[j,g]=u.useState(()=>{const v=localStorage.getItem(h);return v!==null?v==="true":c});u.useEffect(()=>{const v=document.documentElement;x?v.classList.remove("no-animations"):v.classList.add("no-animations"),localStorage.setItem(d,String(x))},[x,d]),u.useEffect(()=>{localStorage.setItem(h,String(j))},[j,h]);const _={enableAnimations:x,setEnableAnimations:f,enableWavesBackground:j,setEnableWavesBackground:g};return e.jsx(Tg.Provider,{value:_,children:n})}const b_=yN,Wg=u.forwardRef(({className:n,...r},c)=>e.jsx(og,{ref:c,className:$("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px] gap-2",n),...r}));Wg.displayName=og.displayName;const w_=ai("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-slide-in-from-right data-[state=open]:animate-fade-in data-[state=closed]:animate-slide-out-to-right data-[state=closed]:animate-fade-out data-[swipe=end]:animate-slide-out-to-right",{variants:{variant:{default:"border bg-primary/5 text-foreground backdrop-blur-sm",destructive:"destructive group border-destructive bg-destructive/10 text-destructive-foreground backdrop-blur-sm"}},defaultVariants:{variant:"default"}}),ej=u.forwardRef(({className:n,variant:r,...c},d)=>e.jsx(dg,{ref:d,className:$(w_({variant:r}),n),...c}));ej.displayName=dg.displayName;const __=u.forwardRef(({className:n,...r},c)=>e.jsx(ug,{ref:c,className:$("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",n),...r}));__.displayName=ug.displayName;const sj=u.forwardRef(({className:n,...r},c)=>e.jsx(mg,{ref:c,className:$("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",n),"toast-close":"",...r,children:e.jsx(li,{className:"h-4 w-4"})}));sj.displayName=mg.displayName;const tj=u.forwardRef(({className:n,...r},c)=>e.jsx(hg,{ref:c,className:$("text-sm font-semibold [&+div]:text-xs",n),...r}));tj.displayName=hg.displayName;const aj=u.forwardRef(({className:n,...r},c)=>e.jsx(xg,{ref:c,className:$("text-sm opacity-90",n),...r}));aj.displayName=xg.displayName;function S_(){const{toasts:n}=Bs();return e.jsxs(b_,{children:[n.map(function({id:r,title:c,description:d,action:h,...x}){return e.jsxs(ej,{...x,children:[e.jsxs("div",{className:"grid gap-1",children:[c&&e.jsx(tj,{children:c}),d&&e.jsx(aj,{children:d})]}),h,e.jsx(sj,{})]},r)}),e.jsx(Wg,{})]})}Bb.createRoot(document.getElementById("root")).render(e.jsx(u.StrictMode,{children:e.jsx(W2,{children:e.jsx(y_,{defaultTheme:"system",children:e.jsx(N_,{children:e.jsxs(pw,{children:[e.jsx(yy,{router:v_}),e.jsx(vw,{}),e.jsx(S_,{})]})})})})})); diff --git a/webui/dist/index.html b/webui/dist/index.html index 08e50d5d..3c556267 100644 --- a/webui/dist/index.html +++ b/webui/dist/index.html @@ -7,7 +7,7 @@ MaiBot Dashboard - +