MaiBot/webui/dist/assets/index-BmRC0BFx.js

91 lines
862 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{r as x,j as e,L as br,e as xa,R as Ms,b as Iy,f as qy,g as Vy,h as Fy,k as rt,l as Ky,m as Qy,O as vg,n as Yy}from"./router-Bz250laD.js";import{a as Xy,b as Jy,g as Zy}from"./react-vendor-BmxF9s7Q.js";import{N as Wy,c as e0,O as Mr,P as s0,g as lm}from"./utils-BXc2jIuz.js";import{L as Ng,T as bg,C as yg,R as t0,a as wg,V as a0,b as l0,S as _g,c as n0,d as Sg,I as r0,e as Cg,f as i0,g as kg,h as c0,i as o0,j as d0,O as Tg,P as u0,k as Eg,l as Mg,D as Ag,A as zg,m as Dg,n as m0,o as x0,p as Og,q as h0,r as Rg,s as f0,t as p0,u as Lg,v as g0,w as j0,x as Ug,y as Bg,F as $g,z as Hg,B as v0,E as N0,G as Gg,H as b0,J as y0,K as w0,M as _0,N as S0,Q as C0,U as k0,W as T0,X as E0,Y as M0,Z as A0,_ as z0,$ as D0,a0 as O0,a1 as R0,a2 as Pg,a3 as L0,a4 as U0}from"./radix-extra-Dp24oM_w.js";import{R as B0,T as $0,L as H0,g as G0,C as oo,X as uo,Y as Si,h as P0,B as nm,j as mo,P as I0,k as q0,l as V0}from"./charts-DbiuC1q1.js";import{S as F0,H as Ig,O as qg,o as K0,C as Vg,p as Q0,T as Fg,D as Kg,R as Y0,q as X0,I as Qg,J as J0,K as Yg,L as Xg,M as Z0,N as Jg,V as W0,Q as Zg,U as Wg,X as ew,Y as sw,Z as ej,_ as tw,$ as aw,a0 as sj,a1 as lw,e as tj,f as zo,c as Do,P as zn,d as Oo,b as Wl,h as nw,l as rw,m as iw,u as _m,r as cw,a as ow,a2 as dw,a3 as aj,a4 as uw,a5 as mw,a6 as xw,a7 as lj,a8 as nj,a9 as rj,aa as ij,ab as cj,ac as oj,ad as hw}from"./radix-core-C_kRl1e_.js";import{R as At,a as Li,C as Ut,b as ua,L as Xs,P as Vi,Z as Cn,F as Ga,c as fw,S as Dn,d as pw,M as en,A as gw,D as jw,e as wo,f as bl,T as vw,X as Ja,g as Nw,h as bw,I as Qt,i as oa,j as yt,k as _o,E as Ui,l as Yt,m as dj,H as yw,n as rs,o as Kt,U as Bi,p as uj,q as mj,r as Ip,K as zm,s as xj,t as ww,u as jo,v as _w,B as Ei,w as Cr,x as Dm,y as Sw,z as Cw,G as Vt,J as Ro,N as sn,O as ft,Q as Ra,V as kr,W as Om,Y as hj,_ as Fi,$ as kw,a0 as Tw,a1 as kn,a2 as Ar,a3 as el,a4 as wa,a5 as zr,a6 as Rm,a7 as fj,a8 as da,a9 as wl,aa as Tn,ab as En,ac as Lm,ad as Ew,ae as Mw,af as Aw,ag as pj,ah as vo,ai as Mn,aj as zw,ak as Tr,al as Dw,am as Sm,an as Cm,ao as gj,ap as Ow,aq as Rw,ar as qp,as as Lw,at as Nl,au as rm,av as Vp,aw as jj,ax as Uw,ay as vj,az as im,aA as Bw,aB as $w,aC as Hw,aD as Gw,aE as Nj,aF as bj,aG as So,aH as Pw,aI as yj,aJ as wj,aK as Iw,aL as Fp,aM as qw,aN as Vw,aO as Fw,aP as Kw}from"./icons-c7mD83Va.js";import{S as Qw,p as Yw,j as Xw,a as Jw,E as Kp,R as Zw,o as Ww}from"./codemirror-BEE0n9kQ.js";import{u as _j,a as Co,s as Sj,K as Cj,P as kj,b as Tj,D as Ej,c as Mj,S as Aj,v as e1,d as zj,C as Dj,h as s1}from"./dnd-B_gmzEl7.js";import{_ as ha,c as t1,g as Oj,D as a1,z as xo}from"./misc-ChwNwoVu.js";import{D as l1,U as n1}from"./uppy-CcUbCiwl.js";import{M as r1,r as i1,a as c1,b as o1}from"./markdown-kUhwkcQP.js";import{c as d1,H as ko,P as To,u as u1,d as m1,R as x1,B as h1,e as f1,C as p1,M as g1,f as j1}from"./reactflow-DLoXAt4c.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))c(u);new MutationObserver(u=>{for(const m of u)if(m.type==="childList")for(const h of m.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function i(u){const m={};return u.integrity&&(m.integrity=u.integrity),u.referrerPolicy&&(m.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?m.credentials="include":u.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function c(u){if(u.ep)return;u.ep=!0;const m=i(u);fetch(u.href,m)}})();var cm={exports:{}},Ci={},om={exports:{}},dm={};var Qp;function v1(){return Qp||(Qp=1,(function(l){function n(z,Q){var J=z.length;z.push(Q);e:for(;0<J;){var U=J-1>>>1,G=z[U];if(0<u(G,Q))z[U]=Q,z[J]=G,J=U;else break e}}function i(z){return z.length===0?null:z[0]}function c(z){if(z.length===0)return null;var Q=z[0],J=z.pop();if(J!==Q){z[0]=J;e:for(var U=0,G=z.length,Ce=G>>>1;U<Ce;){var be=2*(U+1)-1,ke=z[be],I=be+1,we=z[I];if(0>u(ke,J))I<G&&0>u(we,ke)?(z[U]=we,z[I]=J,U=I):(z[U]=ke,z[be]=J,U=be);else if(I<G&&0>u(we,J))z[U]=we,z[I]=J,U=I;else break e}}return Q}function u(z,Q){var J=z.sortIndex-Q.sortIndex;return J!==0?J:z.id-Q.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;l.unstable_now=function(){return m.now()}}else{var h=Date,f=h.now();l.unstable_now=function(){return h.now()-f}}var p=[],j=[],v=1,N=null,b=3,S=!1,w=!1,O=!1,M=!1,D=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function _(z){for(var Q=i(j);Q!==null;){if(Q.callback===null)c(j);else if(Q.startTime<=z)c(j),Q.sortIndex=Q.expirationTime,n(p,Q);else break;Q=i(j)}}function T(z){if(O=!1,_(z),!w)if(i(p)!==null)w=!0,P||(P=!0,ye());else{var Q=i(j);Q!==null&&je(T,Q.startTime-z)}}var P=!1,A=-1,ee=5,H=-1;function Z(){return M?!0:!(l.unstable_now()-H<ee)}function re(){if(M=!1,P){var z=l.unstable_now();H=z;var Q=!0;try{e:{w=!1,O&&(O=!1,$(A),A=-1),S=!0;var J=b;try{s:{for(_(z),N=i(p);N!==null&&!(N.expirationTime>z&&Z());){var U=N.callback;if(typeof U=="function"){N.callback=null,b=N.priorityLevel;var G=U(N.expirationTime<=z);if(z=l.unstable_now(),typeof G=="function"){N.callback=G,_(z),Q=!0;break s}N===i(p)&&c(p),_(z)}else c(p);N=i(p)}if(N!==null)Q=!0;else{var Ce=i(j);Ce!==null&&je(T,Ce.startTime-z),Q=!1}}break e}finally{N=null,b=J,S=!1}Q=void 0}}finally{Q?ye():P=!1}}}var ye;if(typeof E=="function")ye=function(){E(re)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,ge=de.port2;de.port1.onmessage=re,ye=function(){ge.postMessage(null)}}else ye=function(){D(re,0)};function je(z,Q){A=D(function(){z(l.unstable_now())},Q)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(z){z.callback=null},l.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ee=0<z?Math.floor(1e3/z):5},l.unstable_getCurrentPriorityLevel=function(){return b},l.unstable_next=function(z){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var J=b;b=Q;try{return z()}finally{b=J}},l.unstable_requestPaint=function(){M=!0},l.unstable_runWithPriority=function(z,Q){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var J=b;b=z;try{return Q()}finally{b=J}},l.unstable_scheduleCallback=function(z,Q,J){var U=l.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?U+J:U):J=U,z){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=J+G,z={id:v++,callback:Q,priorityLevel:z,startTime:J,expirationTime:G,sortIndex:-1},J>U?(z.sortIndex=J,n(j,z),i(p)===null&&z===i(j)&&(O?($(A),A=-1):O=!0,je(T,J-U))):(z.sortIndex=G,n(p,z),w||S||(w=!0,P||(P=!0,ye()))),z},l.unstable_shouldYield=Z,l.unstable_wrapCallback=function(z){var Q=b;return function(){var J=b;b=Q;try{return z.apply(this,arguments)}finally{b=J}}}})(dm)),dm}var Yp;function N1(){return Yp||(Yp=1,om.exports=v1()),om.exports}var Xp;function b1(){if(Xp)return Ci;Xp=1;var l=N1(),n=Xy(),i=Jy();function c(s){var t="https://react.dev/errors/"+s;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+s+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function m(s){var t=s,a=s;if(s.alternate)for(;t.return;)t=t.return;else{s=t;do t=s,(t.flags&4098)!==0&&(a=t.return),s=t.return;while(s)}return t.tag===3?a:null}function h(s){if(s.tag===13){var t=s.memoizedState;if(t===null&&(s=s.alternate,s!==null&&(t=s.memoizedState)),t!==null)return t.dehydrated}return null}function f(s){if(s.tag===31){var t=s.memoizedState;if(t===null&&(s=s.alternate,s!==null&&(t=s.memoizedState)),t!==null)return t.dehydrated}return null}function p(s){if(m(s)!==s)throw Error(c(188))}function j(s){var t=s.alternate;if(!t){if(t=m(s),t===null)throw Error(c(188));return t!==s?null:s}for(var a=s,r=t;;){var o=a.return;if(o===null)break;var d=o.alternate;if(d===null){if(r=o.return,r!==null){a=r;continue}break}if(o.child===d.child){for(d=o.child;d;){if(d===a)return p(o),s;if(d===r)return p(o),t;d=d.sibling}throw Error(c(188))}if(a.return!==r.return)a=o,r=d;else{for(var g=!1,y=o.child;y;){if(y===a){g=!0,a=o,r=d;break}if(y===r){g=!0,r=o,a=d;break}y=y.sibling}if(!g){for(y=d.child;y;){if(y===a){g=!0,a=d,r=o;break}if(y===r){g=!0,r=d,a=o;break}y=y.sibling}if(!g)throw Error(c(189))}}if(a.alternate!==r)throw Error(c(190))}if(a.tag!==3)throw Error(c(188));return a.stateNode.current===a?s:t}function v(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s;for(s=s.child;s!==null;){if(t=v(s),t!==null)return t;s=s.sibling}return null}var N=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),E=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),H=Symbol.for("react.activity"),Z=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function ye(s){return s===null||typeof s!="object"?null:(s=re&&s[re]||s["@@iterator"],typeof s=="function"?s:null)}var de=Symbol.for("react.client.reference");function ge(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===de?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case O:return"Fragment";case D:return"Profiler";case M:return"StrictMode";case T:return"Suspense";case P:return"SuspenseList";case H:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case w:return"Portal";case E:return s.displayName||"Context";case $:return(s._context.displayName||"Context")+".Consumer";case _:var t=s.render;return s=s.displayName,s||(s=t.displayName||t.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case A:return t=s.displayName||null,t!==null?t:ge(s.type)||"Memo";case ee:t=s._payload,s=s._init;try{return ge(s(t))}catch{}}return null}var je=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},U=[],G=-1;function Ce(s){return{current:s}}function be(s){0>G||(s.current=U[G],U[G]=null,G--)}function ke(s,t){G++,U[G]=s.current,s.current=t}var I=Ce(null),we=Ce(null),q=Ce(null),oe=Ce(null);function Te(s,t){switch(ke(q,t),ke(we,s),ke(I,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?mp(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=mp(t),s=xp(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}be(I),ke(I,s)}function X(){be(I),be(we),be(q)}function ne(s){s.memoizedState!==null&&ke(oe,s);var t=I.current,a=xp(t,s.type);t!==a&&(ke(we,s),ke(I,a))}function Ie(s){we.current===s&&(be(I),be(we)),oe.current===s&&(be(oe),bi._currentValue=J)}var Je,pe;function as(s){if(Je===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Je=t&&t[1]||"",pe=-1<a.stack.indexOf(`
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Je+s+pe}var F=!1;function ze(s,t){if(!s||F)return"";F=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(ie){var te=ie}Reflect.construct(s,[],fe)}else{try{fe.call()}catch(ie){te=ie}s.call(fe.prototype)}}else{try{throw Error()}catch(ie){te=ie}(fe=s())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(ie){if(ie&&te&&typeof ie.stack=="string")return[ie.stack,te.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=r.DetermineComponentFrameRoot(),g=d[0],y=d[1];if(g&&y){var R=g.split(`
`),se=y.split(`
`);for(o=r=0;r<R.length&&!R[r].includes("DetermineComponentFrameRoot");)r++;for(;o<se.length&&!se[o].includes("DetermineComponentFrameRoot");)o++;if(r===R.length||o===se.length)for(r=R.length-1,o=se.length-1;1<=r&&0<=o&&R[r]!==se[o];)o--;for(;1<=r&&0<=o;r--,o--)if(R[r]!==se[o]){if(r!==1||o!==1)do if(r--,o--,0>o||R[r]!==se[o]){var me=`
`+R[r].replace(" at new "," at ");return s.displayName&&me.includes("<anonymous>")&&(me=me.replace("<anonymous>",s.displayName)),me}while(1<=r&&0<=o);break}}}finally{F=!1,Error.prepareStackTrace=a}return(a=s?s.displayName||s.name:"")?as(a):""}function ue(s,t){switch(s.tag){case 26:case 27:case 5:return as(s.type);case 16:return as("Lazy");case 13:return s.child!==t&&t!==null?as("Suspense Fallback"):as("Suspense");case 19:return as("SuspenseList");case 0:case 15:return ze(s.type,!1);case 11:return ze(s.type.render,!1);case 1:return ze(s.type,!0);case 31:return as("Activity");default:return""}}function ve(s){try{var t="",a=null;do t+=ue(s,a),a=s,s=s.return;while(s);return t}catch(r){return`
Error generating stack: `+r.message+`
`+r.stack}}var Me=Object.prototype.hasOwnProperty,Ke=l.unstable_scheduleCallback,qe=l.unstable_cancelCallback,Zt=l.unstable_shouldYield,Et=l.unstable_requestPaint,ot=l.unstable_now,K=l.unstable_getCurrentPriorityLevel,Pe=l.unstable_ImmediatePriority,Be=l.unstable_UserBlockingPriority,_e=l.unstable_NormalPriority,gs=l.unstable_LowPriority,is=l.unstable_IdlePriority,As=l.log,Ds=l.unstable_setDisableYieldValue,Gs=null,ls=null;function es(s){if(typeof As=="function"&&Ds(s),ls&&typeof ls.setStrictMode=="function")try{ls.setStrictMode(Gs,s)}catch{}}var Ze=Math.clz32?Math.clz32:st,Us=Math.log,zt=Math.LN2;function st(s){return s>>>=0,s===0?32:31-(Us(s)/zt|0)|0}var Cs=256,jt=262144,ae=4194304;function xe(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 ys(s,t,a){var r=s.pendingLanes;if(r===0)return 0;var o=0,d=s.suspendedLanes,g=s.pingedLanes;s=s.warmLanes;var y=r&134217727;return y!==0?(r=y&~d,r!==0?o=xe(r):(g&=y,g!==0?o=xe(g):a||(a=y&~s,a!==0&&(o=xe(a))))):(y=r&~d,y!==0?o=xe(y):g!==0?o=xe(g):a||(a=r&~s,a!==0&&(o=xe(a)))),o===0?0:t!==0&&t!==o&&(t&d)===0&&(d=o&-o,a=t&-t,d>=a||d===32&&(a&4194048)!==0)?t:o}function Dt(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function Ot(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 Y(){var s=ae;return ae<<=1,(ae&62914560)===0&&(ae=4194304),s}function Ne(s){for(var t=[],a=0;31>a;a++)t.push(s);return t}function Ee(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Ps(s,t,a,r,o,d){var g=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 y=s.entanglements,R=s.expirationTimes,se=s.hiddenUpdates;for(a=g&~a;0<a;){var me=31-Ze(a),fe=1<<me;y[me]=0,R[me]=-1;var te=se[me];if(te!==null)for(se[me]=null,me=0;me<te.length;me++){var ie=te[me];ie!==null&&(ie.lane&=-536870913)}a&=~fe}r!==0&&qa(s,r,0),d!==0&&o===0&&s.tag!==0&&(s.suspendedLanes|=d&~(g&~t))}function qa(s,t,a){s.pendingLanes|=t,s.suspendedLanes&=~t;var r=31-Ze(t);s.entangledLanes|=t,s.entanglements[r]=s.entanglements[r]|1073741824|a&261930}function Wt(s,t){var a=s.entangledLanes|=t;for(s=s.entanglements;a;){var r=31-Ze(a),o=1<<r;o&t|s[r]&t&&(s[r]|=t),a&=~o}}function dt(s,t){var a=t&-t;return a=(a&42)!==0?1:ea(a),(a&(s.suspendedLanes|t))!==0?0:a}function ea(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function vt(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function nn(){var s=Q.p;return s!==0?s:(s=window.event,s===void 0?32:Lp(s.type))}function Xi(s,t){var a=Q.p;try{return Q.p=s,t()}finally{Q.p=a}}var Tl=Math.random().toString(36).slice(2),Bt="__reactFiber$"+Tl,sa="__reactProps$"+Tl,Ln="__reactContainer$"+Tl,Yo="__reactEvents$"+Tl,zN="__reactListeners$"+Tl,DN="__reactHandles$"+Tl,Zm="__reactResources$"+Tl,Lr="__reactMarker$"+Tl;function Xo(s){delete s[Bt],delete s[sa],delete s[Yo],delete s[zN],delete s[DN]}function Un(s){var t=s[Bt];if(t)return t;for(var a=s.parentNode;a;){if(t=a[Ln]||a[Bt]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(s=Np(s);s!==null;){if(a=s[Bt])return a;s=Np(s)}return t}s=a,a=s.parentNode}return null}function Bn(s){if(s=s[Bt]||s[Ln]){var t=s.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return s}return null}function Ur(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s.stateNode;throw Error(c(33))}function $n(s){var t=s[Zm];return t||(t=s[Zm]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Rt(s){s[Lr]=!0}var Wm=new Set,ex={};function rn(s,t){Hn(s,t),Hn(s+"Capture",t)}function Hn(s,t){for(ex[s]=t,s=0;s<t.length;s++)Wm.add(t[s])}var ON=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),sx={},tx={};function RN(s){return Me.call(tx,s)?!0:Me.call(sx,s)?!1:ON.test(s)?tx[s]=!0:(sx[s]=!0,!1)}function Ji(s,t,a){if(RN(t))if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":s.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){s.removeAttribute(t);return}}s.setAttribute(t,""+a)}}function Zi(s,t,a){if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(t);return}s.setAttribute(t,""+a)}}function sl(s,t,a,r){if(r===null)s.removeAttribute(a);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(a);return}s.setAttributeNS(t,a,""+r)}}function _a(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ax(s){var t=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function LN(s,t,a){var r=Object.getOwnPropertyDescriptor(s.constructor.prototype,t);if(!s.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var o=r.get,d=r.set;return Object.defineProperty(s,t,{configurable:!0,get:function(){return o.call(this)},set:function(g){a=""+g,d.call(this,g)}}),Object.defineProperty(s,t,{enumerable:r.enumerable}),{getValue:function(){return a},setValue:function(g){a=""+g},stopTracking:function(){s._valueTracker=null,delete s[t]}}}}function Jo(s){if(!s._valueTracker){var t=ax(s)?"checked":"value";s._valueTracker=LN(s,t,""+s[t])}}function lx(s){if(!s)return!1;var t=s._valueTracker;if(!t)return!0;var a=t.getValue(),r="";return s&&(r=ax(s)?s.checked?"true":"false":s.value),s=r,s!==a?(t.setValue(s),!0):!1}function Wi(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var UN=/[\n"\\]/g;function Sa(s){return s.replace(UN,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Zo(s,t,a,r,o,d,g,y){s.name="",g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"?s.type=g:s.removeAttribute("type"),t!=null?g==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+_a(t)):s.value!==""+_a(t)&&(s.value=""+_a(t)):g!=="submit"&&g!=="reset"||s.removeAttribute("value"),t!=null?Wo(s,g,_a(t)):a!=null?Wo(s,g,_a(a)):r!=null&&s.removeAttribute("value"),o==null&&d!=null&&(s.defaultChecked=!!d),o!=null&&(s.checked=o&&typeof o!="function"&&typeof o!="symbol"),y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?s.name=""+_a(y):s.removeAttribute("name")}function nx(s,t,a,r,o,d,g,y){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(s.type=d),t!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){Jo(s);return}a=a!=null?""+_a(a):"",t=t!=null?""+_a(t):a,y||t===s.value||(s.value=t),s.defaultValue=t}r=r??o,r=typeof r!="function"&&typeof r!="symbol"&&!!r,s.checked=y?s.checked:!!r,s.defaultChecked=!!r,g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(s.name=g),Jo(s)}function Wo(s,t,a){t==="number"&&Wi(s.ownerDocument)===s||s.defaultValue===""+a||(s.defaultValue=""+a)}function Gn(s,t,a,r){if(s=s.options,t){t={};for(var o=0;o<a.length;o++)t["$"+a[o]]=!0;for(a=0;a<s.length;a++)o=t.hasOwnProperty("$"+s[a].value),s[a].selected!==o&&(s[a].selected=o),o&&r&&(s[a].defaultSelected=!0)}else{for(a=""+_a(a),t=null,o=0;o<s.length;o++){if(s[o].value===a){s[o].selected=!0,r&&(s[o].defaultSelected=!0);return}t!==null||s[o].disabled||(t=s[o])}t!==null&&(t.selected=!0)}}function rx(s,t,a){if(t!=null&&(t=""+_a(t),t!==s.value&&(s.value=t),a==null)){s.defaultValue!==t&&(s.defaultValue=t);return}s.defaultValue=a!=null?""+_a(a):""}function ix(s,t,a,r){if(t==null){if(r!=null){if(a!=null)throw Error(c(92));if(je(r)){if(1<r.length)throw Error(c(93));r=r[0]}a=r}a==null&&(a=""),t=a}a=_a(t),s.defaultValue=a,r=s.textContent,r===a&&r!==""&&r!==null&&(s.value=r),Jo(s)}function Pn(s,t){if(t){var a=s.firstChild;if(a&&a===s.lastChild&&a.nodeType===3){a.nodeValue=t;return}}s.textContent=t}var BN=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function cx(s,t,a){var r=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?r?s.setProperty(t,""):t==="float"?s.cssFloat="":s[t]="":r?s.setProperty(t,a):typeof a!="number"||a===0||BN.has(t)?t==="float"?s.cssFloat=a:s[t]=(""+a).trim():s[t]=a+"px"}function ox(s,t,a){if(t!=null&&typeof t!="object")throw Error(c(62));if(s=s.style,a!=null){for(var r in a)!a.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?s.setProperty(r,""):r==="float"?s.cssFloat="":s[r]="");for(var o in t)r=t[o],t.hasOwnProperty(o)&&a[o]!==r&&cx(s,o,r)}else for(var d in t)t.hasOwnProperty(d)&&cx(s,d,t[d])}function ed(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var $N=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),HN=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ec(s){return HN.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function tl(){}var sd=null;function td(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var In=null,qn=null;function dx(s){var t=Bn(s);if(t&&(s=t.stateNode)){var a=s[sa]||null;e:switch(s=t.stateNode,t.type){case"input":if(Zo(s,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=s;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Sa(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var r=a[t];if(r!==s&&r.form===s.form){var o=r[sa]||null;if(!o)throw Error(c(90));Zo(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name)}}for(t=0;t<a.length;t++)r=a[t],r.form===s.form&&lx(r)}break e;case"textarea":rx(s,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&Gn(s,!!a.multiple,t,!1)}}}var ad=!1;function ux(s,t,a){if(ad)return s(t,a);ad=!0;try{var r=s(t);return r}finally{if(ad=!1,(In!==null||qn!==null)&&(Gc(),In&&(t=In,s=qn,qn=In=null,dx(t),s)))for(t=0;t<s.length;t++)dx(s[t])}}function Br(s,t){var a=s.stateNode;if(a===null)return null;var r=a[sa]||null;if(r===null)return null;a=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(s=s.type,r=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!r;break e;default:s=!1}if(s)return null;if(a&&typeof a!="function")throw Error(c(231,t,typeof a));return a}var al=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ld=!1;if(al)try{var $r={};Object.defineProperty($r,"passive",{get:function(){ld=!0}}),window.addEventListener("test",$r,$r),window.removeEventListener("test",$r,$r)}catch{ld=!1}var El=null,nd=null,sc=null;function mx(){if(sc)return sc;var s,t=nd,a=t.length,r,o="value"in El?El.value:El.textContent,d=o.length;for(s=0;s<a&&t[s]===o[s];s++);var g=a-s;for(r=1;r<=g&&t[a-r]===o[d-r];r++);return sc=o.slice(s,1<r?1-r:void 0)}function tc(s){var t=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&t===13&&(s=13)):s=t,s===10&&(s=13),32<=s||s===13?s:0}function ac(){return!0}function xx(){return!1}function ta(s){function t(a,r,o,d,g){this._reactName=a,this._targetInst=o,this.type=r,this.nativeEvent=d,this.target=g,this.currentTarget=null;for(var y in s)s.hasOwnProperty(y)&&(a=s[y],this[y]=a?a(d):d[y]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?ac:xx,this.isPropagationStopped=xx,this}return N(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ac)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ac)},persist:function(){},isPersistent:ac}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lc=ta(cn),Hr=N({},cn,{view:0,detail:0}),GN=ta(Hr),rd,id,Gr,nc=N({},Hr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:od,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Gr&&(Gr&&s.type==="mousemove"?(rd=s.screenX-Gr.screenX,id=s.screenY-Gr.screenY):id=rd=0,Gr=s),rd)},movementY:function(s){return"movementY"in s?s.movementY:id}}),hx=ta(nc),PN=N({},nc,{dataTransfer:0}),IN=ta(PN),qN=N({},Hr,{relatedTarget:0}),cd=ta(qN),VN=N({},cn,{animationName:0,elapsedTime:0,pseudoElement:0}),FN=ta(VN),KN=N({},cn,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),QN=ta(KN),YN=N({},cn,{data:0}),fx=ta(YN),XN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},JN={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ZN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function WN(s){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(s):(s=ZN[s])?!!t[s]:!1}function od(){return WN}var eb=N({},Hr,{key:function(s){if(s.key){var t=XN[s.key]||s.key;if(t!=="Unidentified")return t}return s.type==="keypress"?(s=tc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?JN[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:od,charCode:function(s){return s.type==="keypress"?tc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?tc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),sb=ta(eb),tb=N({},nc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),px=ta(tb),ab=N({},Hr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:od}),lb=ta(ab),nb=N({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0}),rb=ta(nb),ib=N({},nc,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),cb=ta(ib),ob=N({},cn,{newState:0,oldState:0}),db=ta(ob),ub=[9,13,27,32],dd=al&&"CompositionEvent"in window,Pr=null;al&&"documentMode"in document&&(Pr=document.documentMode);var mb=al&&"TextEvent"in window&&!Pr,gx=al&&(!dd||Pr&&8<Pr&&11>=Pr),jx=" ",vx=!1;function Nx(s,t){switch(s){case"keyup":return ub.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bx(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Vn=!1;function xb(s,t){switch(s){case"compositionend":return bx(t);case"keypress":return t.which!==32?null:(vx=!0,jx);case"textInput":return s=t.data,s===jx&&vx?null:s;default:return null}}function hb(s,t){if(Vn)return s==="compositionend"||!dd&&Nx(s,t)?(s=mx(),sc=nd=El=null,Vn=!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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return gx&&t.locale!=="ko"?null:t.data;default:return null}}var fb={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function yx(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t==="input"?!!fb[s.type]:t==="textarea"}function wx(s,t,a,r){In?qn?qn.push(r):qn=[r]:In=r,t=Qc(t,"onChange"),0<t.length&&(a=new lc("onChange","change",null,a,r),s.push({event:a,listeners:t}))}var Ir=null,qr=null;function pb(s){rp(s,0)}function rc(s){var t=Ur(s);if(lx(t))return s}function _x(s,t){if(s==="change")return t}var Sx=!1;if(al){var ud;if(al){var md="oninput"in document;if(!md){var Cx=document.createElement("div");Cx.setAttribute("oninput","return;"),md=typeof Cx.oninput=="function"}ud=md}else ud=!1;Sx=ud&&(!document.documentMode||9<document.documentMode)}function kx(){Ir&&(Ir.detachEvent("onpropertychange",Tx),qr=Ir=null)}function Tx(s){if(s.propertyName==="value"&&rc(qr)){var t=[];wx(t,qr,s,td(s)),ux(pb,t)}}function gb(s,t,a){s==="focusin"?(kx(),Ir=t,qr=a,Ir.attachEvent("onpropertychange",Tx)):s==="focusout"&&kx()}function jb(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return rc(qr)}function vb(s,t){if(s==="click")return rc(t)}function Nb(s,t){if(s==="input"||s==="change")return rc(t)}function bb(s,t){return s===t&&(s!==0||1/s===1/t)||s!==s&&t!==t}var fa=typeof Object.is=="function"?Object.is:bb;function Vr(s,t){if(fa(s,t))return!0;if(typeof s!="object"||s===null||typeof t!="object"||t===null)return!1;var a=Object.keys(s),r=Object.keys(t);if(a.length!==r.length)return!1;for(r=0;r<a.length;r++){var o=a[r];if(!Me.call(t,o)||!fa(s[o],t[o]))return!1}return!0}function Ex(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Mx(s,t){var a=Ex(s);s=0;for(var r;a;){if(a.nodeType===3){if(r=s+a.textContent.length,s<=t&&r>=t)return{node:a,offset:t-s};s=r}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ex(a)}}function Ax(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?Ax(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function zx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=Wi(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=Wi(s.document)}return t}function xd(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 yb=al&&"documentMode"in document&&11>=document.documentMode,Fn=null,hd=null,Fr=null,fd=!1;function Dx(s,t,a){var r=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;fd||Fn==null||Fn!==Wi(r)||(r=Fn,"selectionStart"in r&&xd(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fr&&Vr(Fr,r)||(Fr=r,r=Qc(hd,"onSelect"),0<r.length&&(t=new lc("onSelect","select",null,t,a),s.push({event:t,listeners:r}),t.target=Fn)))}function on(s,t){var a={};return a[s.toLowerCase()]=t.toLowerCase(),a["Webkit"+s]="webkit"+t,a["Moz"+s]="moz"+t,a}var Kn={animationend:on("Animation","AnimationEnd"),animationiteration:on("Animation","AnimationIteration"),animationstart:on("Animation","AnimationStart"),transitionrun:on("Transition","TransitionRun"),transitionstart:on("Transition","TransitionStart"),transitioncancel:on("Transition","TransitionCancel"),transitionend:on("Transition","TransitionEnd")},pd={},Ox={};al&&(Ox=document.createElement("div").style,"AnimationEvent"in window||(delete Kn.animationend.animation,delete Kn.animationiteration.animation,delete Kn.animationstart.animation),"TransitionEvent"in window||delete Kn.transitionend.transition);function dn(s){if(pd[s])return pd[s];if(!Kn[s])return s;var t=Kn[s],a;for(a in t)if(t.hasOwnProperty(a)&&a in Ox)return pd[s]=t[a];return s}var Rx=dn("animationend"),Lx=dn("animationiteration"),Ux=dn("animationstart"),wb=dn("transitionrun"),_b=dn("transitionstart"),Sb=dn("transitioncancel"),Bx=dn("transitionend"),$x=new Map,gd="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");gd.push("scrollEnd");function Ua(s,t){$x.set(s,t),rn(t,[s])}var ic=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},Ca=[],Qn=0,jd=0;function cc(){for(var s=Qn,t=jd=Qn=0;t<s;){var a=Ca[t];Ca[t++]=null;var r=Ca[t];Ca[t++]=null;var o=Ca[t];Ca[t++]=null;var d=Ca[t];if(Ca[t++]=null,r!==null&&o!==null){var g=r.pending;g===null?o.next=o:(o.next=g.next,g.next=o),r.pending=o}d!==0&&Hx(a,o,d)}}function oc(s,t,a,r){Ca[Qn++]=s,Ca[Qn++]=t,Ca[Qn++]=a,Ca[Qn++]=r,jd|=r,s.lanes|=r,s=s.alternate,s!==null&&(s.lanes|=r)}function vd(s,t,a,r){return oc(s,t,a,r),dc(s)}function un(s,t){return oc(s,null,null,t),dc(s)}function Hx(s,t,a){s.lanes|=a;var r=s.alternate;r!==null&&(r.lanes|=a);for(var o=!1,d=s.return;d!==null;)d.childLanes|=a,r=d.alternate,r!==null&&(r.childLanes|=a),d.tag===22&&(s=d.stateNode,s===null||s._visibility&1||(o=!0)),s=d,d=d.return;return s.tag===3?(d=s.stateNode,o&&t!==null&&(o=31-Ze(a),s=d.hiddenUpdates,r=s[o],r===null?s[o]=[t]:r.push(t),t.lane=a|536870912),d):null}function dc(s){if(50<hi)throw hi=0,Tu=null,Error(c(185));for(var t=s.return;t!==null;)s=t,t=s.return;return s.tag===3?s.stateNode:null}var Yn={};function Cb(s,t,a,r){this.tag=s,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function pa(s,t,a,r){return new Cb(s,t,a,r)}function Nd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function ll(s,t){var a=s.alternate;return a===null?(a=pa(s.tag,t,s.key,s.mode),a.elementType=s.elementType,a.type=s.type,a.stateNode=s.stateNode,a.alternate=s,s.alternate=a):(a.pendingProps=t,a.type=s.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=s.flags&65011712,a.childLanes=s.childLanes,a.lanes=s.lanes,a.child=s.child,a.memoizedProps=s.memoizedProps,a.memoizedState=s.memoizedState,a.updateQueue=s.updateQueue,t=s.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=s.sibling,a.index=s.index,a.ref=s.ref,a.refCleanup=s.refCleanup,a}function Gx(s,t){s.flags&=65011714;var a=s.alternate;return a===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=a.childLanes,s.lanes=a.lanes,s.child=a.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=a.memoizedProps,s.memoizedState=a.memoizedState,s.updateQueue=a.updateQueue,s.type=a.type,t=a.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),s}function uc(s,t,a,r,o,d){var g=0;if(r=s,typeof s=="function")Nd(s)&&(g=1);else if(typeof s=="string")g=Ay(s,a,I.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case H:return s=pa(31,a,t,o),s.elementType=H,s.lanes=d,s;case O:return mn(a.children,o,d,t);case M:g=8,o|=24;break;case D:return s=pa(12,a,t,o|2),s.elementType=D,s.lanes=d,s;case T:return s=pa(13,a,t,o),s.elementType=T,s.lanes=d,s;case P:return s=pa(19,a,t,o),s.elementType=P,s.lanes=d,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case E:g=10;break e;case $:g=9;break e;case _:g=11;break e;case A:g=14;break e;case ee:g=16,r=null;break e}g=29,a=Error(c(130,s===null?"null":typeof s,"")),r=null}return t=pa(g,a,t,o),t.elementType=s,t.type=r,t.lanes=d,t}function mn(s,t,a,r){return s=pa(7,s,r,t),s.lanes=a,s}function bd(s,t,a){return s=pa(6,s,null,t),s.lanes=a,s}function Px(s){var t=pa(18,null,null,0);return t.stateNode=s,t}function yd(s,t,a){return t=pa(4,s.children!==null?s.children:[],s.key,t),t.lanes=a,t.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},t}var Ix=new WeakMap;function ka(s,t){if(typeof s=="object"&&s!==null){var a=Ix.get(s);return a!==void 0?a:(t={value:s,source:t,stack:ve(t)},Ix.set(s,t),t)}return{value:s,source:t,stack:ve(t)}}var Xn=[],Jn=0,mc=null,Kr=0,Ta=[],Ea=0,Ml=null,Va=1,Fa="";function nl(s,t){Xn[Jn++]=Kr,Xn[Jn++]=mc,mc=s,Kr=t}function qx(s,t,a){Ta[Ea++]=Va,Ta[Ea++]=Fa,Ta[Ea++]=Ml,Ml=s;var r=Va;s=Fa;var o=32-Ze(r)-1;r&=~(1<<o),a+=1;var d=32-Ze(t)+o;if(30<d){var g=o-o%5;d=(r&(1<<g)-1).toString(32),r>>=g,o-=g,Va=1<<32-Ze(t)+o|a<<o|r,Fa=d+s}else Va=1<<d|a<<o|r,Fa=s}function wd(s){s.return!==null&&(nl(s,1),qx(s,1,0))}function _d(s){for(;s===mc;)mc=Xn[--Jn],Xn[Jn]=null,Kr=Xn[--Jn],Xn[Jn]=null;for(;s===Ml;)Ml=Ta[--Ea],Ta[Ea]=null,Fa=Ta[--Ea],Ta[Ea]=null,Va=Ta[--Ea],Ta[Ea]=null}function Vx(s,t){Ta[Ea++]=Va,Ta[Ea++]=Fa,Ta[Ea++]=Ml,Va=t.id,Fa=t.overflow,Ml=s}var $t=null,tt=null,ks=!1,Al=null,Ma=!1,Sd=Error(c(519));function zl(s){var t=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qr(ka(t,s)),Sd}function Fx(s){var t=s.stateNode,a=s.type,r=s.memoizedProps;switch(t[Bt]=s,t[sa]=r,a){case"dialog":Ns("cancel",t),Ns("close",t);break;case"iframe":case"object":case"embed":Ns("load",t);break;case"video":case"audio":for(a=0;a<pi.length;a++)Ns(pi[a],t);break;case"source":Ns("error",t);break;case"img":case"image":case"link":Ns("error",t),Ns("load",t);break;case"details":Ns("toggle",t);break;case"input":Ns("invalid",t),nx(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":Ns("invalid",t);break;case"textarea":Ns("invalid",t),ix(t,r.value,r.defaultValue,r.children)}a=r.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||r.suppressHydrationWarning===!0||dp(t.textContent,a)?(r.popover!=null&&(Ns("beforetoggle",t),Ns("toggle",t)),r.onScroll!=null&&Ns("scroll",t),r.onScrollEnd!=null&&Ns("scrollend",t),r.onClick!=null&&(t.onclick=tl),t=!0):t=!1,t||zl(s,!0)}function Kx(s){for($t=s.return;$t;)switch($t.tag){case 5:case 31:case 13:Ma=!1;return;case 27:case 3:Ma=!0;return;default:$t=$t.return}}function Zn(s){if(s!==$t)return!1;if(!ks)return Kx(s),ks=!0,!1;var t=s.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=s.type,a=!(a!=="form"&&a!=="button")||Iu(s.type,s.memoizedProps)),a=!a),a&&tt&&zl(s),Kx(s),t===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));tt=vp(s)}else if(t===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));tt=vp(s)}else t===27?(t=tt,Fl(s.type)?(s=Qu,Qu=null,tt=s):tt=t):tt=$t?za(s.stateNode.nextSibling):null;return!0}function xn(){tt=$t=null,ks=!1}function Cd(){var s=Al;return s!==null&&(ra===null?ra=s:ra.push.apply(ra,s),Al=null),s}function Qr(s){Al===null?Al=[s]:Al.push(s)}var kd=Ce(null),hn=null,rl=null;function Dl(s,t,a){ke(kd,t._currentValue),t._currentValue=a}function il(s){s._currentValue=kd.current,be(kd)}function Td(s,t,a){for(;s!==null;){var r=s.alternate;if((s.childLanes&t)!==t?(s.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),s===a)break;s=s.return}}function Ed(s,t,a,r){var o=s.child;for(o!==null&&(o.return=s);o!==null;){var d=o.dependencies;if(d!==null){var g=o.child;d=d.firstContext;e:for(;d!==null;){var y=d;d=o;for(var R=0;R<t.length;R++)if(y.context===t[R]){d.lanes|=a,y=d.alternate,y!==null&&(y.lanes|=a),Td(d.return,a,s),r||(g=null);break e}d=y.next}}else if(o.tag===18){if(g=o.return,g===null)throw Error(c(341));g.lanes|=a,d=g.alternate,d!==null&&(d.lanes|=a),Td(g,a,s),g=null}else g=o.child;if(g!==null)g.return=o;else for(g=o;g!==null;){if(g===s){g=null;break}if(o=g.sibling,o!==null){o.return=g.return,g=o;break}g=g.return}o=g}}function Wn(s,t,a,r){s=null;for(var o=t,d=!1;o!==null;){if(!d){if((o.flags&524288)!==0)d=!0;else if((o.flags&262144)!==0)break}if(o.tag===10){var g=o.alternate;if(g===null)throw Error(c(387));if(g=g.memoizedProps,g!==null){var y=o.type;fa(o.pendingProps.value,g.value)||(s!==null?s.push(y):s=[y])}}else if(o===oe.current){if(g=o.alternate,g===null)throw Error(c(387));g.memoizedState.memoizedState!==o.memoizedState.memoizedState&&(s!==null?s.push(bi):s=[bi])}o=o.return}s!==null&&Ed(t,s,a,r),t.flags|=262144}function xc(s){for(s=s.firstContext;s!==null;){if(!fa(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function fn(s){hn=s,rl=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Ht(s){return Qx(hn,s)}function hc(s,t){return hn===null&&fn(s),Qx(s,t)}function Qx(s,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},rl===null){if(s===null)throw Error(c(308));rl=t,s.dependencies={lanes:0,firstContext:t},s.flags|=524288}else rl=rl.next=t;return a}var kb=typeof AbortController<"u"?AbortController:function(){var s=[],t=this.signal={aborted:!1,addEventListener:function(a,r){s.push(r)}};this.abort=function(){t.aborted=!0,s.forEach(function(a){return a()})}},Tb=l.unstable_scheduleCallback,Eb=l.unstable_NormalPriority,St={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Md(){return{controller:new kb,data:new Map,refCount:0}}function Yr(s){s.refCount--,s.refCount===0&&Tb(Eb,function(){s.controller.abort()})}var Xr=null,Ad=0,er=0,sr=null;function Mb(s,t){if(Xr===null){var a=Xr=[];Ad=0,er=Ou(),sr={status:"pending",value:void 0,then:function(r){a.push(r)}}}return Ad++,t.then(Yx,Yx),t}function Yx(){if(--Ad===0&&Xr!==null){sr!==null&&(sr.status="fulfilled");var s=Xr;Xr=null,er=0,sr=null;for(var t=0;t<s.length;t++)(0,s[t])()}}function Ab(s,t){var a=[],r={status:"pending",value:null,reason:null,then:function(o){a.push(o)}};return s.then(function(){r.status="fulfilled",r.value=t;for(var o=0;o<a.length;o++)(0,a[o])(t)},function(o){for(r.status="rejected",r.reason=o,o=0;o<a.length;o++)(0,a[o])(void 0)}),r}var Xx=z.S;z.S=function(s,t){Of=ot(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Mb(s,t),Xx!==null&&Xx(s,t)};var pn=Ce(null);function zd(){var s=pn.current;return s!==null?s:Fs.pooledCache}function fc(s,t){t===null?ke(pn,pn.current):ke(pn,t.pool)}function Jx(){var s=zd();return s===null?null:{parent:St._currentValue,pool:s}}var tr=Error(c(460)),Dd=Error(c(474)),pc=Error(c(542)),gc={then:function(){}};function Zx(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Wx(s,t,a){switch(a=s[a],a===void 0?s.push(t):a!==t&&(t.then(tl,tl),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,sh(s),s;default:if(typeof t.status=="string")t.then(tl,tl);else{if(s=Fs,s!==null&&100<s.shellSuspendCounter)throw Error(c(482));s=t,s.status="pending",s.then(function(r){if(t.status==="pending"){var o=t;o.status="fulfilled",o.value=r}},function(r){if(t.status==="pending"){var o=t;o.status="rejected",o.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,sh(s),s}throw jn=t,tr}}function gn(s){try{var t=s._init;return t(s._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(jn=a,tr):a}}var jn=null;function eh(){if(jn===null)throw Error(c(459));var s=jn;return jn=null,s}function sh(s){if(s===tr||s===pc)throw Error(c(483))}var ar=null,Jr=0;function jc(s){var t=Jr;return Jr+=1,ar===null&&(ar=[]),Wx(ar,s,t)}function Zr(s,t){t=t.props.ref,s.ref=t!==void 0?t:null}function vc(s,t){throw t.$$typeof===b?Error(c(525)):(s=Object.prototype.toString.call(t),Error(c(31,s==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":s)))}function th(s){function t(V,B){if(s){var W=V.deletions;W===null?(V.deletions=[B],V.flags|=16):W.push(B)}}function a(V,B){if(!s)return null;for(;B!==null;)t(V,B),B=B.sibling;return null}function r(V){for(var B=new Map;V!==null;)V.key!==null?B.set(V.key,V):B.set(V.index,V),V=V.sibling;return B}function o(V,B){return V=ll(V,B),V.index=0,V.sibling=null,V}function d(V,B,W){return V.index=W,s?(W=V.alternate,W!==null?(W=W.index,W<B?(V.flags|=67108866,B):W):(V.flags|=67108866,B)):(V.flags|=1048576,B)}function g(V){return s&&V.alternate===null&&(V.flags|=67108866),V}function y(V,B,W,he){return B===null||B.tag!==6?(B=bd(W,V.mode,he),B.return=V,B):(B=o(B,W),B.return=V,B)}function R(V,B,W,he){var Ve=W.type;return Ve===O?me(V,B,W.props.children,he,W.key):B!==null&&(B.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===ee&&gn(Ve)===B.type)?(B=o(B,W.props),Zr(B,W),B.return=V,B):(B=uc(W.type,W.key,W.props,null,V.mode,he),Zr(B,W),B.return=V,B)}function se(V,B,W,he){return B===null||B.tag!==4||B.stateNode.containerInfo!==W.containerInfo||B.stateNode.implementation!==W.implementation?(B=yd(W,V.mode,he),B.return=V,B):(B=o(B,W.children||[]),B.return=V,B)}function me(V,B,W,he,Ve){return B===null||B.tag!==7?(B=mn(W,V.mode,he,Ve),B.return=V,B):(B=o(B,W),B.return=V,B)}function fe(V,B,W){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=bd(""+B,V.mode,W),B.return=V,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case S:return W=uc(B.type,B.key,B.props,null,V.mode,W),Zr(W,B),W.return=V,W;case w:return B=yd(B,V.mode,W),B.return=V,B;case ee:return B=gn(B),fe(V,B,W)}if(je(B)||ye(B))return B=mn(B,V.mode,W,null),B.return=V,B;if(typeof B.then=="function")return fe(V,jc(B),W);if(B.$$typeof===E)return fe(V,hc(V,B),W);vc(V,B)}return null}function te(V,B,W,he){var Ve=B!==null?B.key:null;if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return Ve!==null?null:y(V,B,""+W,he);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return W.key===Ve?R(V,B,W,he):null;case w:return W.key===Ve?se(V,B,W,he):null;case ee:return W=gn(W),te(V,B,W,he)}if(je(W)||ye(W))return Ve!==null?null:me(V,B,W,he,null);if(typeof W.then=="function")return te(V,B,jc(W),he);if(W.$$typeof===E)return te(V,B,hc(V,W),he);vc(V,W)}return null}function ie(V,B,W,he,Ve){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return V=V.get(W)||null,y(B,V,""+he,Ve);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case S:return V=V.get(he.key===null?W:he.key)||null,R(B,V,he,Ve);case w:return V=V.get(he.key===null?W:he.key)||null,se(B,V,he,Ve);case ee:return he=gn(he),ie(V,B,W,he,Ve)}if(je(he)||ye(he))return V=V.get(W)||null,me(B,V,he,Ve,null);if(typeof he.then=="function")return ie(V,B,W,jc(he),Ve);if(he.$$typeof===E)return ie(V,B,W,hc(B,he),Ve);vc(B,he)}return null}function De(V,B,W,he){for(var Ve=null,Ts=null,Re=B,os=B=0,_s=null;Re!==null&&os<W.length;os++){Re.index>os?(_s=Re,Re=null):_s=Re.sibling;var Es=te(V,Re,W[os],he);if(Es===null){Re===null&&(Re=_s);break}s&&Re&&Es.alternate===null&&t(V,Re),B=d(Es,B,os),Ts===null?Ve=Es:Ts.sibling=Es,Ts=Es,Re=_s}if(os===W.length)return a(V,Re),ks&&nl(V,os),Ve;if(Re===null){for(;os<W.length;os++)Re=fe(V,W[os],he),Re!==null&&(B=d(Re,B,os),Ts===null?Ve=Re:Ts.sibling=Re,Ts=Re);return ks&&nl(V,os),Ve}for(Re=r(Re);os<W.length;os++)_s=ie(Re,V,os,W[os],he),_s!==null&&(s&&_s.alternate!==null&&Re.delete(_s.key===null?os:_s.key),B=d(_s,B,os),Ts===null?Ve=_s:Ts.sibling=_s,Ts=_s);return s&&Re.forEach(function(Jl){return t(V,Jl)}),ks&&nl(V,os),Ve}function Qe(V,B,W,he){if(W==null)throw Error(c(151));for(var Ve=null,Ts=null,Re=B,os=B=0,_s=null,Es=W.next();Re!==null&&!Es.done;os++,Es=W.next()){Re.index>os?(_s=Re,Re=null):_s=Re.sibling;var Jl=te(V,Re,Es.value,he);if(Jl===null){Re===null&&(Re=_s);break}s&&Re&&Jl.alternate===null&&t(V,Re),B=d(Jl,B,os),Ts===null?Ve=Jl:Ts.sibling=Jl,Ts=Jl,Re=_s}if(Es.done)return a(V,Re),ks&&nl(V,os),Ve;if(Re===null){for(;!Es.done;os++,Es=W.next())Es=fe(V,Es.value,he),Es!==null&&(B=d(Es,B,os),Ts===null?Ve=Es:Ts.sibling=Es,Ts=Es);return ks&&nl(V,os),Ve}for(Re=r(Re);!Es.done;os++,Es=W.next())Es=ie(Re,V,os,Es.value,he),Es!==null&&(s&&Es.alternate!==null&&Re.delete(Es.key===null?os:Es.key),B=d(Es,B,os),Ts===null?Ve=Es:Ts.sibling=Es,Ts=Es);return s&&Re.forEach(function(Py){return t(V,Py)}),ks&&nl(V,os),Ve}function Vs(V,B,W,he){if(typeof W=="object"&&W!==null&&W.type===O&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case S:e:{for(var Ve=W.key;B!==null;){if(B.key===Ve){if(Ve=W.type,Ve===O){if(B.tag===7){a(V,B.sibling),he=o(B,W.props.children),he.return=V,V=he;break e}}else if(B.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===ee&&gn(Ve)===B.type){a(V,B.sibling),he=o(B,W.props),Zr(he,W),he.return=V,V=he;break e}a(V,B);break}else t(V,B);B=B.sibling}W.type===O?(he=mn(W.props.children,V.mode,he,W.key),he.return=V,V=he):(he=uc(W.type,W.key,W.props,null,V.mode,he),Zr(he,W),he.return=V,V=he)}return g(V);case w:e:{for(Ve=W.key;B!==null;){if(B.key===Ve)if(B.tag===4&&B.stateNode.containerInfo===W.containerInfo&&B.stateNode.implementation===W.implementation){a(V,B.sibling),he=o(B,W.children||[]),he.return=V,V=he;break e}else{a(V,B);break}else t(V,B);B=B.sibling}he=yd(W,V.mode,he),he.return=V,V=he}return g(V);case ee:return W=gn(W),Vs(V,B,W,he)}if(je(W))return De(V,B,W,he);if(ye(W)){if(Ve=ye(W),typeof Ve!="function")throw Error(c(150));return W=Ve.call(W),Qe(V,B,W,he)}if(typeof W.then=="function")return Vs(V,B,jc(W),he);if(W.$$typeof===E)return Vs(V,B,hc(V,W),he);vc(V,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,B!==null&&B.tag===6?(a(V,B.sibling),he=o(B,W),he.return=V,V=he):(a(V,B),he=bd(W,V.mode,he),he.return=V,V=he),g(V)):a(V,B)}return function(V,B,W,he){try{Jr=0;var Ve=Vs(V,B,W,he);return ar=null,Ve}catch(Re){if(Re===tr||Re===pc)throw Re;var Ts=pa(29,Re,null,V.mode);return Ts.lanes=he,Ts.return=V,Ts}finally{}}}var vn=th(!0),ah=th(!1),Ol=!1;function Od(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Rd(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 Rl(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Ll(s,t,a){var r=s.updateQueue;if(r===null)return null;if(r=r.shared,(zs&2)!==0){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,t=dc(s),Hx(s,null,a),t}return oc(s,r,t,a),dc(s)}function Wr(s,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var r=t.lanes;r&=s.pendingLanes,a|=r,t.lanes=a,Wt(s,a)}}function Ld(s,t){var a=s.updateQueue,r=s.alternate;if(r!==null&&(r=r.updateQueue,a===r)){var o=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var g={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?o=d=g:d=d.next=g,a=a.next}while(a!==null);d===null?o=d=t:d=d.next=t}else o=d=t;a={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:d,shared:r.shared,callbacks:r.callbacks},s.updateQueue=a;return}s=a.lastBaseUpdate,s===null?a.firstBaseUpdate=t:s.next=t,a.lastBaseUpdate=t}var Ud=!1;function ei(){if(Ud){var s=sr;if(s!==null)throw s}}function si(s,t,a,r){Ud=!1;var o=s.updateQueue;Ol=!1;var d=o.firstBaseUpdate,g=o.lastBaseUpdate,y=o.shared.pending;if(y!==null){o.shared.pending=null;var R=y,se=R.next;R.next=null,g===null?d=se:g.next=se,g=R;var me=s.alternate;me!==null&&(me=me.updateQueue,y=me.lastBaseUpdate,y!==g&&(y===null?me.firstBaseUpdate=se:y.next=se,me.lastBaseUpdate=R))}if(d!==null){var fe=o.baseState;g=0,me=se=R=null,y=d;do{var te=y.lane&-536870913,ie=te!==y.lane;if(ie?(ws&te)===te:(r&te)===te){te!==0&&te===er&&(Ud=!0),me!==null&&(me=me.next={lane:0,tag:y.tag,payload:y.payload,callback:null,next:null});e:{var De=s,Qe=y;te=t;var Vs=a;switch(Qe.tag){case 1:if(De=Qe.payload,typeof De=="function"){fe=De.call(Vs,fe,te);break e}fe=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=Qe.payload,te=typeof De=="function"?De.call(Vs,fe,te):De,te==null)break e;fe=N({},fe,te);break e;case 2:Ol=!0}}te=y.callback,te!==null&&(s.flags|=64,ie&&(s.flags|=8192),ie=o.callbacks,ie===null?o.callbacks=[te]:ie.push(te))}else ie={lane:te,tag:y.tag,payload:y.payload,callback:y.callback,next:null},me===null?(se=me=ie,R=fe):me=me.next=ie,g|=te;if(y=y.next,y===null){if(y=o.shared.pending,y===null)break;ie=y,y=ie.next,ie.next=null,o.lastBaseUpdate=ie,o.shared.pending=null}}while(!0);me===null&&(R=fe),o.baseState=R,o.firstBaseUpdate=se,o.lastBaseUpdate=me,d===null&&(o.shared.lanes=0),Gl|=g,s.lanes=g,s.memoizedState=fe}}function lh(s,t){if(typeof s!="function")throw Error(c(191,s));s.call(t)}function nh(s,t){var a=s.callbacks;if(a!==null)for(s.callbacks=null,s=0;s<a.length;s++)lh(a[s],t)}var lr=Ce(null),Nc=Ce(0);function rh(s,t){s=pl,ke(Nc,s),ke(lr,t),pl=s|t.baseLanes}function Bd(){ke(Nc,pl),ke(lr,lr.current)}function $d(){pl=Nc.current,be(lr),be(Nc)}var ga=Ce(null),Aa=null;function Ul(s){var t=s.alternate;ke(Nt,Nt.current&1),ke(ga,s),Aa===null&&(t===null||lr.current!==null||t.memoizedState!==null)&&(Aa=s)}function Hd(s){ke(Nt,Nt.current),ke(ga,s),Aa===null&&(Aa=s)}function ih(s){s.tag===22?(ke(Nt,Nt.current),ke(ga,s),Aa===null&&(Aa=s)):Bl()}function Bl(){ke(Nt,Nt.current),ke(ga,ga.current)}function ja(s){be(ga),Aa===s&&(Aa=null),be(Nt)}var Nt=Ce(0);function bc(s){for(var t=s;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Fu(a)||Ku(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var cl=0,cs=null,Is=null,Ct=null,yc=!1,nr=!1,Nn=!1,wc=0,ti=0,rr=null,zb=0;function ut(){throw Error(c(321))}function Gd(s,t){if(t===null)return!1;for(var a=0;a<t.length&&a<s.length;a++)if(!fa(s[a],t[a]))return!1;return!0}function Pd(s,t,a,r,o,d){return cl=d,cs=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=s===null||s.memoizedState===null?qh:au,Nn=!1,d=a(r,o),Nn=!1,nr&&(d=oh(t,a,r,o)),ch(s),d}function ch(s){z.H=ni;var t=Is!==null&&Is.next!==null;if(cl=0,Ct=Is=cs=null,yc=!1,ti=0,rr=null,t)throw Error(c(300));s===null||kt||(s=s.dependencies,s!==null&&xc(s)&&(kt=!0))}function oh(s,t,a,r){cs=s;var o=0;do{if(nr&&(rr=null),ti=0,nr=!1,25<=o)throw Error(c(301));if(o+=1,Ct=Is=null,s.updateQueue!=null){var d=s.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}z.H=Vh,d=t(a,r)}while(nr);return d}function Db(){var s=z.H,t=s.useState()[0];return t=typeof t.then=="function"?ai(t):t,s=s.useState()[0],(Is!==null?Is.memoizedState:null)!==s&&(cs.flags|=1024),t}function Id(){var s=wc!==0;return wc=0,s}function qd(s,t,a){t.updateQueue=s.updateQueue,t.flags&=-2053,s.lanes&=~a}function Vd(s){if(yc){for(s=s.memoizedState;s!==null;){var t=s.queue;t!==null&&(t.pending=null),s=s.next}yc=!1}cl=0,Ct=Is=cs=null,nr=!1,ti=wc=0,rr=null}function Ft(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ct===null?cs.memoizedState=Ct=s:Ct=Ct.next=s,Ct}function bt(){if(Is===null){var s=cs.alternate;s=s!==null?s.memoizedState:null}else s=Is.next;var t=Ct===null?cs.memoizedState:Ct.next;if(t!==null)Ct=t,Is=s;else{if(s===null)throw cs.alternate===null?Error(c(467)):Error(c(310));Is=s,s={memoizedState:Is.memoizedState,baseState:Is.baseState,baseQueue:Is.baseQueue,queue:Is.queue,next:null},Ct===null?cs.memoizedState=Ct=s:Ct=Ct.next=s}return Ct}function _c(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ai(s){var t=ti;return ti+=1,rr===null&&(rr=[]),s=Wx(rr,s,t),t=cs,(Ct===null?t.memoizedState:Ct.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?qh:au),s}function Sc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return ai(s);if(s.$$typeof===E)return Ht(s)}throw Error(c(438,String(s)))}function Fd(s){var t=null,a=cs.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var r=cs.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(o){return o.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=_c(),cs.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(s),r=0;r<s;r++)a[r]=Z;return t.index++,a}function ol(s,t){return typeof t=="function"?t(s):t}function Cc(s){var t=bt();return Kd(t,Is,s)}function Kd(s,t,a){var r=s.queue;if(r===null)throw Error(c(311));r.lastRenderedReducer=a;var o=s.baseQueue,d=r.pending;if(d!==null){if(o!==null){var g=o.next;o.next=d.next,d.next=g}t.baseQueue=o=d,r.pending=null}if(d=s.baseState,o===null)s.memoizedState=d;else{t=o.next;var y=g=null,R=null,se=t,me=!1;do{var fe=se.lane&-536870913;if(fe!==se.lane?(ws&fe)===fe:(cl&fe)===fe){var te=se.revertLane;if(te===0)R!==null&&(R=R.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),fe===er&&(me=!0);else if((cl&te)===te){se=se.next,te===er&&(me=!0);continue}else fe={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},R===null?(y=R=fe,g=d):R=R.next=fe,cs.lanes|=te,Gl|=te;fe=se.action,Nn&&a(d,fe),d=se.hasEagerState?se.eagerState:a(d,fe)}else te={lane:fe,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},R===null?(y=R=te,g=d):R=R.next=te,cs.lanes|=fe,Gl|=fe;se=se.next}while(se!==null&&se!==t);if(R===null?g=d:R.next=y,!fa(d,s.memoizedState)&&(kt=!0,me&&(a=sr,a!==null)))throw a;s.memoizedState=d,s.baseState=g,s.baseQueue=R,r.lastRenderedState=d}return o===null&&(r.lanes=0),[s.memoizedState,r.dispatch]}function Qd(s){var t=bt(),a=t.queue;if(a===null)throw Error(c(311));a.lastRenderedReducer=s;var r=a.dispatch,o=a.pending,d=t.memoizedState;if(o!==null){a.pending=null;var g=o=o.next;do d=s(d,g.action),g=g.next;while(g!==o);fa(d,t.memoizedState)||(kt=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),a.lastRenderedState=d}return[d,r]}function dh(s,t,a){var r=cs,o=bt(),d=ks;if(d){if(a===void 0)throw Error(c(407));a=a()}else a=t();var g=!fa((Is||o).memoizedState,a);if(g&&(o.memoizedState=a,kt=!0),o=o.queue,Jd(xh.bind(null,r,o,s),[s]),o.getSnapshot!==t||g||Ct!==null&&Ct.memoizedState.tag&1){if(r.flags|=2048,ir(9,{destroy:void 0},mh.bind(null,r,o,a,t),null),Fs===null)throw Error(c(349));d||(cl&127)!==0||uh(r,t,a)}return a}function uh(s,t,a){s.flags|=16384,s={getSnapshot:t,value:a},t=cs.updateQueue,t===null?(t=_c(),cs.updateQueue=t,t.stores=[s]):(a=t.stores,a===null?t.stores=[s]:a.push(s))}function mh(s,t,a,r){t.value=a,t.getSnapshot=r,hh(t)&&fh(s)}function xh(s,t,a){return a(function(){hh(t)&&fh(s)})}function hh(s){var t=s.getSnapshot;s=s.value;try{var a=t();return!fa(s,a)}catch{return!0}}function fh(s){var t=un(s,2);t!==null&&ia(t,s,2)}function Yd(s){var t=Ft();if(typeof s=="function"){var a=s;if(s=a(),Nn){es(!0);try{a()}finally{es(!1)}}}return t.memoizedState=t.baseState=s,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:s},t}function ph(s,t,a,r){return s.baseState=a,Kd(s,Is,typeof r=="function"?r:ol)}function Ob(s,t,a,r,o){if(Ec(s))throw Error(c(485));if(s=t.action,s!==null){var d={payload:o,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(g){d.listeners.push(g)}};z.T!==null?a(!0):d.isTransition=!1,r(d),a=t.pending,a===null?(d.next=t.pending=d,gh(t,d)):(d.next=a.next,t.pending=a.next=d)}}function gh(s,t){var a=t.action,r=t.payload,o=s.state;if(t.isTransition){var d=z.T,g={};z.T=g;try{var y=a(o,r),R=z.S;R!==null&&R(g,y),jh(s,t,y)}catch(se){Xd(s,t,se)}finally{d!==null&&g.types!==null&&(d.types=g.types),z.T=d}}else try{d=a(o,r),jh(s,t,d)}catch(se){Xd(s,t,se)}}function jh(s,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(r){vh(s,t,r)},function(r){return Xd(s,t,r)}):vh(s,t,a)}function vh(s,t,a){t.status="fulfilled",t.value=a,Nh(t),s.state=a,t=s.pending,t!==null&&(a=t.next,a===t?s.pending=null:(a=a.next,t.next=a,gh(s,a)))}function Xd(s,t,a){var r=s.pending;if(s.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=a,Nh(t),t=t.next;while(t!==r)}s.action=null}function Nh(s){s=s.listeners;for(var t=0;t<s.length;t++)(0,s[t])()}function bh(s,t){return t}function yh(s,t){if(ks){var a=Fs.formState;if(a!==null){e:{var r=cs;if(ks){if(tt){s:{for(var o=tt,d=Ma;o.nodeType!==8;){if(!d){o=null;break s}if(o=za(o.nextSibling),o===null){o=null;break s}}d=o.data,o=d==="F!"||d==="F"?o:null}if(o){tt=za(o.nextSibling),r=o.data==="F!";break e}}zl(r)}r=!1}r&&(t=a[0])}}return a=Ft(),a.memoizedState=a.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bh,lastRenderedState:t},a.queue=r,a=Gh.bind(null,cs,r),r.dispatch=a,r=Yd(!1),d=tu.bind(null,cs,!1,r.queue),r=Ft(),o={state:t,dispatch:null,action:s,pending:null},r.queue=o,a=Ob.bind(null,cs,o,d,a),o.dispatch=a,r.memoizedState=s,[t,a,!1]}function wh(s){var t=bt();return _h(t,Is,s)}function _h(s,t,a){if(t=Kd(s,t,bh)[0],s=Cc(ol)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=ai(t)}catch(g){throw g===tr?pc:g}else r=t;t=bt();var o=t.queue,d=o.dispatch;return a!==t.memoizedState&&(cs.flags|=2048,ir(9,{destroy:void 0},Rb.bind(null,o,a),null)),[r,d,s]}function Rb(s,t){s.action=t}function Sh(s){var t=bt(),a=Is;if(a!==null)return _h(t,a,s);bt(),t=t.memoizedState,a=bt();var r=a.queue.dispatch;return a.memoizedState=s,[t,r,!1]}function ir(s,t,a,r){return s={tag:s,create:a,deps:r,inst:t,next:null},t=cs.updateQueue,t===null&&(t=_c(),cs.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=s.next=s:(r=a.next,a.next=s,s.next=r,t.lastEffect=s),s}function Ch(){return bt().memoizedState}function kc(s,t,a,r){var o=Ft();cs.flags|=s,o.memoizedState=ir(1|t,{destroy:void 0},a,r===void 0?null:r)}function Tc(s,t,a,r){var o=bt();r=r===void 0?null:r;var d=o.memoizedState.inst;Is!==null&&r!==null&&Gd(r,Is.memoizedState.deps)?o.memoizedState=ir(t,d,a,r):(cs.flags|=s,o.memoizedState=ir(1|t,d,a,r))}function kh(s,t){kc(8390656,8,s,t)}function Jd(s,t){Tc(2048,8,s,t)}function Lb(s){cs.flags|=4;var t=cs.updateQueue;if(t===null)t=_c(),cs.updateQueue=t,t.events=[s];else{var a=t.events;a===null?t.events=[s]:a.push(s)}}function Th(s){var t=bt().memoizedState;return Lb({ref:t,nextImpl:s}),function(){if((zs&2)!==0)throw Error(c(440));return t.impl.apply(void 0,arguments)}}function Eh(s,t){return Tc(4,2,s,t)}function Mh(s,t){return Tc(4,4,s,t)}function Ah(s,t){if(typeof t=="function"){s=s();var a=t(s);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return s=s(),t.current=s,function(){t.current=null}}function zh(s,t,a){a=a!=null?a.concat([s]):null,Tc(4,4,Ah.bind(null,t,s),a)}function Zd(){}function Dh(s,t){var a=bt();t=t===void 0?null:t;var r=a.memoizedState;return t!==null&&Gd(t,r[1])?r[0]:(a.memoizedState=[s,t],s)}function Oh(s,t){var a=bt();t=t===void 0?null:t;var r=a.memoizedState;if(t!==null&&Gd(t,r[1]))return r[0];if(r=s(),Nn){es(!0);try{s()}finally{es(!1)}}return a.memoizedState=[r,t],r}function Wd(s,t,a){return a===void 0||(cl&1073741824)!==0&&(ws&261930)===0?s.memoizedState=t:(s.memoizedState=a,s=Lf(),cs.lanes|=s,Gl|=s,a)}function Rh(s,t,a,r){return fa(a,t)?a:lr.current!==null?(s=Wd(s,a,r),fa(s,t)||(kt=!0),s):(cl&42)===0||(cl&1073741824)!==0&&(ws&261930)===0?(kt=!0,s.memoizedState=a):(s=Lf(),cs.lanes|=s,Gl|=s,t)}function Lh(s,t,a,r,o){var d=Q.p;Q.p=d!==0&&8>d?d:8;var g=z.T,y={};z.T=y,tu(s,!1,t,a);try{var R=o(),se=z.S;if(se!==null&&se(y,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var me=Ab(R,r);li(s,t,me,ba(s))}else li(s,t,r,ba(s))}catch(fe){li(s,t,{then:function(){},status:"rejected",reason:fe},ba())}finally{Q.p=d,g!==null&&y.types!==null&&(g.types=y.types),z.T=g}}function Ub(){}function eu(s,t,a,r){if(s.tag!==5)throw Error(c(476));var o=Uh(s).queue;Lh(s,o,t,J,a===null?Ub:function(){return Bh(s),a(r)})}function Uh(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:a},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function Bh(s){var t=Uh(s);t.next===null&&(t=s.alternate.memoizedState),li(s,t.next.queue,{},ba())}function su(){return Ht(bi)}function $h(){return bt().memoizedState}function Hh(){return bt().memoizedState}function Bb(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var a=ba();s=Rl(a);var r=Ll(t,s,a);r!==null&&(ia(r,t,a),Wr(r,t,a)),t={cache:Md()},s.payload=t;return}t=t.return}}function $b(s,t,a){var r=ba();a={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ec(s)?Ph(t,a):(a=vd(s,t,a,r),a!==null&&(ia(a,s,r),Ih(a,t,r)))}function Gh(s,t,a){var r=ba();li(s,t,a,r)}function li(s,t,a,r){var o={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ec(s))Ph(t,o);else{var d=s.alternate;if(s.lanes===0&&(d===null||d.lanes===0)&&(d=t.lastRenderedReducer,d!==null))try{var g=t.lastRenderedState,y=d(g,a);if(o.hasEagerState=!0,o.eagerState=y,fa(y,g))return oc(s,t,o,0),Fs===null&&cc(),!1}catch{}finally{}if(a=vd(s,t,o,r),a!==null)return ia(a,s,r),Ih(a,t,r),!0}return!1}function tu(s,t,a,r){if(r={lane:2,revertLane:Ou(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ec(s)){if(t)throw Error(c(479))}else t=vd(s,a,r,2),t!==null&&ia(t,s,2)}function Ec(s){var t=s.alternate;return s===cs||t!==null&&t===cs}function Ph(s,t){nr=yc=!0;var a=s.pending;a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t}function Ih(s,t,a){if((a&4194048)!==0){var r=t.lanes;r&=s.pendingLanes,a|=r,t.lanes=a,Wt(s,a)}}var ni={readContext:Ht,use:Sc,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useLayoutEffect:ut,useInsertionEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useSyncExternalStore:ut,useId:ut,useHostTransitionStatus:ut,useFormState:ut,useActionState:ut,useOptimistic:ut,useMemoCache:ut,useCacheRefresh:ut};ni.useEffectEvent=ut;var qh={readContext:Ht,use:Sc,useCallback:function(s,t){return Ft().memoizedState=[s,t===void 0?null:t],s},useContext:Ht,useEffect:kh,useImperativeHandle:function(s,t,a){a=a!=null?a.concat([s]):null,kc(4194308,4,Ah.bind(null,t,s),a)},useLayoutEffect:function(s,t){return kc(4194308,4,s,t)},useInsertionEffect:function(s,t){kc(4,2,s,t)},useMemo:function(s,t){var a=Ft();t=t===void 0?null:t;var r=s();if(Nn){es(!0);try{s()}finally{es(!1)}}return a.memoizedState=[r,t],r},useReducer:function(s,t,a){var r=Ft();if(a!==void 0){var o=a(t);if(Nn){es(!0);try{a(t)}finally{es(!1)}}}else o=t;return r.memoizedState=r.baseState=o,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:o},r.queue=s,s=s.dispatch=$b.bind(null,cs,s),[r.memoizedState,s]},useRef:function(s){var t=Ft();return s={current:s},t.memoizedState=s},useState:function(s){s=Yd(s);var t=s.queue,a=Gh.bind(null,cs,t);return t.dispatch=a,[s.memoizedState,a]},useDebugValue:Zd,useDeferredValue:function(s,t){var a=Ft();return Wd(a,s,t)},useTransition:function(){var s=Yd(!1);return s=Lh.bind(null,cs,s.queue,!0,!1),Ft().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,a){var r=cs,o=Ft();if(ks){if(a===void 0)throw Error(c(407));a=a()}else{if(a=t(),Fs===null)throw Error(c(349));(ws&127)!==0||uh(r,t,a)}o.memoizedState=a;var d={value:a,getSnapshot:t};return o.queue=d,kh(xh.bind(null,r,d,s),[s]),r.flags|=2048,ir(9,{destroy:void 0},mh.bind(null,r,d,a,t),null),a},useId:function(){var s=Ft(),t=Fs.identifierPrefix;if(ks){var a=Fa,r=Va;a=(r&~(1<<32-Ze(r)-1)).toString(32)+a,t="_"+t+"R_"+a,a=wc++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=zb++,t="_"+t+"r_"+a.toString(32)+"_";return s.memoizedState=t},useHostTransitionStatus:su,useFormState:yh,useActionState:yh,useOptimistic:function(s){var t=Ft();t.memoizedState=t.baseState=s;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=tu.bind(null,cs,!0,a),a.dispatch=t,[s,t]},useMemoCache:Fd,useCacheRefresh:function(){return Ft().memoizedState=Bb.bind(null,cs)},useEffectEvent:function(s){var t=Ft(),a={impl:s};return t.memoizedState=a,function(){if((zs&2)!==0)throw Error(c(440));return a.impl.apply(void 0,arguments)}}},au={readContext:Ht,use:Sc,useCallback:Dh,useContext:Ht,useEffect:Jd,useImperativeHandle:zh,useInsertionEffect:Eh,useLayoutEffect:Mh,useMemo:Oh,useReducer:Cc,useRef:Ch,useState:function(){return Cc(ol)},useDebugValue:Zd,useDeferredValue:function(s,t){var a=bt();return Rh(a,Is.memoizedState,s,t)},useTransition:function(){var s=Cc(ol)[0],t=bt().memoizedState;return[typeof s=="boolean"?s:ai(s),t]},useSyncExternalStore:dh,useId:$h,useHostTransitionStatus:su,useFormState:wh,useActionState:wh,useOptimistic:function(s,t){var a=bt();return ph(a,Is,s,t)},useMemoCache:Fd,useCacheRefresh:Hh};au.useEffectEvent=Th;var Vh={readContext:Ht,use:Sc,useCallback:Dh,useContext:Ht,useEffect:Jd,useImperativeHandle:zh,useInsertionEffect:Eh,useLayoutEffect:Mh,useMemo:Oh,useReducer:Qd,useRef:Ch,useState:function(){return Qd(ol)},useDebugValue:Zd,useDeferredValue:function(s,t){var a=bt();return Is===null?Wd(a,s,t):Rh(a,Is.memoizedState,s,t)},useTransition:function(){var s=Qd(ol)[0],t=bt().memoizedState;return[typeof s=="boolean"?s:ai(s),t]},useSyncExternalStore:dh,useId:$h,useHostTransitionStatus:su,useFormState:Sh,useActionState:Sh,useOptimistic:function(s,t){var a=bt();return Is!==null?ph(a,Is,s,t):(a.baseState=s,[s,a.queue.dispatch])},useMemoCache:Fd,useCacheRefresh:Hh};Vh.useEffectEvent=Th;function lu(s,t,a,r){t=s.memoizedState,a=a(r,t),a=a==null?t:N({},t,a),s.memoizedState=a,s.lanes===0&&(s.updateQueue.baseState=a)}var nu={enqueueSetState:function(s,t,a){s=s._reactInternals;var r=ba(),o=Rl(r);o.payload=t,a!=null&&(o.callback=a),t=Ll(s,o,r),t!==null&&(ia(t,s,r),Wr(t,s,r))},enqueueReplaceState:function(s,t,a){s=s._reactInternals;var r=ba(),o=Rl(r);o.tag=1,o.payload=t,a!=null&&(o.callback=a),t=Ll(s,o,r),t!==null&&(ia(t,s,r),Wr(t,s,r))},enqueueForceUpdate:function(s,t){s=s._reactInternals;var a=ba(),r=Rl(a);r.tag=2,t!=null&&(r.callback=t),t=Ll(s,r,a),t!==null&&(ia(t,s,a),Wr(t,s,a))}};function Fh(s,t,a,r,o,d,g){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(r,d,g):t.prototype&&t.prototype.isPureReactComponent?!Vr(a,r)||!Vr(o,d):!0}function Kh(s,t,a,r){s=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,r),t.state!==s&&nu.enqueueReplaceState(t,t.state,null)}function bn(s,t){var a=t;if("ref"in t){a={};for(var r in t)r!=="ref"&&(a[r]=t[r])}if(s=s.defaultProps){a===t&&(a=N({},a));for(var o in s)a[o]===void 0&&(a[o]=s[o])}return a}function Qh(s){ic(s)}function Yh(s){console.error(s)}function Xh(s){ic(s)}function Mc(s,t){try{var a=s.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function Jh(s,t,a){try{var r=s.onCaughtError;r(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(o){setTimeout(function(){throw o})}}function ru(s,t,a){return a=Rl(a),a.tag=3,a.payload={element:null},a.callback=function(){Mc(s,t)},a}function Zh(s){return s=Rl(s),s.tag=3,s}function Wh(s,t,a,r){var o=a.type.getDerivedStateFromError;if(typeof o=="function"){var d=r.value;s.payload=function(){return o(d)},s.callback=function(){Jh(t,a,r)}}var g=a.stateNode;g!==null&&typeof g.componentDidCatch=="function"&&(s.callback=function(){Jh(t,a,r),typeof o!="function"&&(Pl===null?Pl=new Set([this]):Pl.add(this));var y=r.stack;this.componentDidCatch(r.value,{componentStack:y!==null?y:""})})}function Hb(s,t,a,r,o){if(a.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=a.alternate,t!==null&&Wn(t,a,o,!0),a=ga.current,a!==null){switch(a.tag){case 31:case 13:return Aa===null?Pc():a.alternate===null&&mt===0&&(mt=3),a.flags&=-257,a.flags|=65536,a.lanes=o,r===gc?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([r]):t.add(r),Au(s,r,o)),!1;case 22:return a.flags|=65536,r===gc?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([r]):a.add(r)),Au(s,r,o)),!1}throw Error(c(435,a.tag))}return Au(s,r,o),Pc(),!1}if(ks)return t=ga.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=o,r!==Sd&&(s=Error(c(422),{cause:r}),Qr(ka(s,a)))):(r!==Sd&&(t=Error(c(423),{cause:r}),Qr(ka(t,a))),s=s.current.alternate,s.flags|=65536,o&=-o,s.lanes|=o,r=ka(r,a),o=ru(s.stateNode,r,o),Ld(s,o),mt!==4&&(mt=2)),!1;var d=Error(c(520),{cause:r});if(d=ka(d,a),xi===null?xi=[d]:xi.push(d),mt!==4&&(mt=2),t===null)return!0;r=ka(r,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,s=o&-o,a.lanes|=s,s=ru(a.stateNode,r,s),Ld(a,s),!1;case 1:if(t=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(Pl===null||!Pl.has(d))))return a.flags|=65536,o&=-o,a.lanes|=o,o=Zh(o),Wh(o,s,a,r),Ld(a,o),!1}a=a.return}while(a!==null);return!1}var iu=Error(c(461)),kt=!1;function Gt(s,t,a,r){t.child=s===null?ah(t,null,a,r):vn(t,s.child,a,r)}function ef(s,t,a,r,o){a=a.render;var d=t.ref;if("ref"in r){var g={};for(var y in r)y!=="ref"&&(g[y]=r[y])}else g=r;return fn(t),r=Pd(s,t,a,g,d,o),y=Id(),s!==null&&!kt?(qd(s,t,o),dl(s,t,o)):(ks&&y&&wd(t),t.flags|=1,Gt(s,t,r,o),t.child)}function sf(s,t,a,r,o){if(s===null){var d=a.type;return typeof d=="function"&&!Nd(d)&&d.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=d,tf(s,t,d,r,o)):(s=uc(a.type,null,r,t,t.mode,o),s.ref=t.ref,s.return=t,t.child=s)}if(d=s.child,!fu(s,o)){var g=d.memoizedProps;if(a=a.compare,a=a!==null?a:Vr,a(g,r)&&s.ref===t.ref)return dl(s,t,o)}return t.flags|=1,s=ll(d,r),s.ref=t.ref,s.return=t,t.child=s}function tf(s,t,a,r,o){if(s!==null){var d=s.memoizedProps;if(Vr(d,r)&&s.ref===t.ref)if(kt=!1,t.pendingProps=r=d,fu(s,o))(s.flags&131072)!==0&&(kt=!0);else return t.lanes=s.lanes,dl(s,t,o)}return cu(s,t,a,r,o)}function af(s,t,a,r){var o=r.children,d=s!==null?s.memoizedState:null;if(s===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode==="hidden"){if((t.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,s!==null){for(r=t.child=s.child,o=0;r!==null;)o=o|r.lanes|r.childLanes,r=r.sibling;r=o&~d}else r=0,t.child=null;return lf(s,t,d,a,r)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},s!==null&&fc(t,d!==null?d.cachePool:null),d!==null?rh(t,d):Bd(),ih(t);else return r=t.lanes=536870912,lf(s,t,d!==null?d.baseLanes|a:a,a,r)}else d!==null?(fc(t,d.cachePool),rh(t,d),Bl(),t.memoizedState=null):(s!==null&&fc(t,null),Bd(),Bl());return Gt(s,t,o,a),t.child}function ri(s,t){return s!==null&&s.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lf(s,t,a,r,o){var d=zd();return d=d===null?null:{parent:St._currentValue,pool:d},t.memoizedState={baseLanes:a,cachePool:d},s!==null&&fc(t,null),Bd(),ih(t),s!==null&&Wn(s,t,r,!0),t.childLanes=o,null}function Ac(s,t){return t=Dc({mode:t.mode,children:t.children},s.mode),t.ref=s.ref,s.child=t,t.return=s,t}function nf(s,t,a){return vn(t,s.child,null,a),s=Ac(t,t.pendingProps),s.flags|=2,ja(t),t.memoizedState=null,s}function Gb(s,t,a){var r=t.pendingProps,o=(t.flags&128)!==0;if(t.flags&=-129,s===null){if(ks){if(r.mode==="hidden")return s=Ac(t,r),t.lanes=536870912,ri(null,s);if(Hd(t),(s=tt)?(s=jp(s,Ma),s=s!==null&&s.data==="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Ml!==null?{id:Va,overflow:Fa}:null,retryLane:536870912,hydrationErrors:null},a=Px(s),a.return=t,t.child=a,$t=t,tt=null)):s=null,s===null)throw zl(t);return t.lanes=536870912,null}return Ac(t,r)}var d=s.memoizedState;if(d!==null){var g=d.dehydrated;if(Hd(t),o)if(t.flags&256)t.flags&=-257,t=nf(s,t,a);else if(t.memoizedState!==null)t.child=s.child,t.flags|=128,t=null;else throw Error(c(558));else if(kt||Wn(s,t,a,!1),o=(a&s.childLanes)!==0,kt||o){if(r=Fs,r!==null&&(g=dt(r,a),g!==0&&g!==d.retryLane))throw d.retryLane=g,un(s,g),ia(r,s,g),iu;Pc(),t=nf(s,t,a)}else s=d.treeContext,tt=za(g.nextSibling),$t=t,ks=!0,Al=null,Ma=!1,s!==null&&Vx(t,s),t=Ac(t,r),t.flags|=4096;return t}return s=ll(s.child,{mode:r.mode,children:r.children}),s.ref=t.ref,t.child=s,s.return=t,s}function zc(s,t){var a=t.ref;if(a===null)s!==null&&s.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(c(284));(s===null||s.ref!==a)&&(t.flags|=4194816)}}function cu(s,t,a,r,o){return fn(t),a=Pd(s,t,a,r,void 0,o),r=Id(),s!==null&&!kt?(qd(s,t,o),dl(s,t,o)):(ks&&r&&wd(t),t.flags|=1,Gt(s,t,a,o),t.child)}function rf(s,t,a,r,o,d){return fn(t),t.updateQueue=null,a=oh(t,r,a,o),ch(s),r=Id(),s!==null&&!kt?(qd(s,t,d),dl(s,t,d)):(ks&&r&&wd(t),t.flags|=1,Gt(s,t,a,d),t.child)}function cf(s,t,a,r,o){if(fn(t),t.stateNode===null){var d=Yn,g=a.contextType;typeof g=="object"&&g!==null&&(d=Ht(g)),d=new a(r,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=nu,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=r,d.state=t.memoizedState,d.refs={},Od(t),g=a.contextType,d.context=typeof g=="object"&&g!==null?Ht(g):Yn,d.state=t.memoizedState,g=a.getDerivedStateFromProps,typeof g=="function"&&(lu(t,a,g,r),d.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(g=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),g!==d.state&&nu.enqueueReplaceState(d,d.state,null),si(t,r,d,o),ei(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(s===null){d=t.stateNode;var y=t.memoizedProps,R=bn(a,y);d.props=R;var se=d.context,me=a.contextType;g=Yn,typeof me=="object"&&me!==null&&(g=Ht(me));var fe=a.getDerivedStateFromProps;me=typeof fe=="function"||typeof d.getSnapshotBeforeUpdate=="function",y=t.pendingProps!==y,me||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(y||se!==g)&&Kh(t,d,r,g),Ol=!1;var te=t.memoizedState;d.state=te,si(t,r,d,o),ei(),se=t.memoizedState,y||te!==se||Ol?(typeof fe=="function"&&(lu(t,a,fe,r),se=t.memoizedState),(R=Ol||Fh(t,a,R,r,te,se,g))?(me||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(t.flags|=4194308)):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=se),d.props=r,d.state=se,d.context=g,r=R):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{d=t.stateNode,Rd(s,t),g=t.memoizedProps,me=bn(a,g),d.props=me,fe=t.pendingProps,te=d.context,se=a.contextType,R=Yn,typeof se=="object"&&se!==null&&(R=Ht(se)),y=a.getDerivedStateFromProps,(se=typeof y=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(g!==fe||te!==R)&&Kh(t,d,r,R),Ol=!1,te=t.memoizedState,d.state=te,si(t,r,d,o),ei();var ie=t.memoizedState;g!==fe||te!==ie||Ol||s!==null&&s.dependencies!==null&&xc(s.dependencies)?(typeof y=="function"&&(lu(t,a,y,r),ie=t.memoizedState),(me=Ol||Fh(t,a,me,r,te,ie,R)||s!==null&&s.dependencies!==null&&xc(s.dependencies))?(se||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(r,ie,R),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(r,ie,R)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||g===s.memoizedProps&&te===s.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||g===s.memoizedProps&&te===s.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=ie),d.props=r,d.state=ie,d.context=R,r=me):(typeof d.componentDidUpdate!="function"||g===s.memoizedProps&&te===s.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||g===s.memoizedProps&&te===s.memoizedState||(t.flags|=1024),r=!1)}return d=r,zc(s,t),r=(t.flags&128)!==0,d||r?(d=t.stateNode,a=r&&typeof a.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,s!==null&&r?(t.child=vn(t,s.child,null,o),t.child=vn(t,null,a,o)):Gt(s,t,a,o),t.memoizedState=d.state,s=t.child):s=dl(s,t,o),s}function of(s,t,a,r){return xn(),t.flags|=256,Gt(s,t,a,r),t.child}var ou={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function du(s){return{baseLanes:s,cachePool:Jx()}}function uu(s,t,a){return s=s!==null?s.childLanes&~a:0,t&&(s|=Na),s}function df(s,t,a){var r=t.pendingProps,o=!1,d=(t.flags&128)!==0,g;if((g=d)||(g=s!==null&&s.memoizedState===null?!1:(Nt.current&2)!==0),g&&(o=!0,t.flags&=-129),g=(t.flags&32)!==0,t.flags&=-33,s===null){if(ks){if(o?Ul(t):Bl(),(s=tt)?(s=jp(s,Ma),s=s!==null&&s.data!=="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Ml!==null?{id:Va,overflow:Fa}:null,retryLane:536870912,hydrationErrors:null},a=Px(s),a.return=t,t.child=a,$t=t,tt=null)):s=null,s===null)throw zl(t);return Ku(s)?t.lanes=32:t.lanes=536870912,null}var y=r.children;return r=r.fallback,o?(Bl(),o=t.mode,y=Dc({mode:"hidden",children:y},o),r=mn(r,o,a,null),y.return=t,r.return=t,y.sibling=r,t.child=y,r=t.child,r.memoizedState=du(a),r.childLanes=uu(s,g,a),t.memoizedState=ou,ri(null,r)):(Ul(t),mu(t,y))}var R=s.memoizedState;if(R!==null&&(y=R.dehydrated,y!==null)){if(d)t.flags&256?(Ul(t),t.flags&=-257,t=xu(s,t,a)):t.memoizedState!==null?(Bl(),t.child=s.child,t.flags|=128,t=null):(Bl(),y=r.fallback,o=t.mode,r=Dc({mode:"visible",children:r.children},o),y=mn(y,o,a,null),y.flags|=2,r.return=t,y.return=t,r.sibling=y,t.child=r,vn(t,s.child,null,a),r=t.child,r.memoizedState=du(a),r.childLanes=uu(s,g,a),t.memoizedState=ou,t=ri(null,r));else if(Ul(t),Ku(y)){if(g=y.nextSibling&&y.nextSibling.dataset,g)var se=g.dgst;g=se,r=Error(c(419)),r.stack="",r.digest=g,Qr({value:r,source:null,stack:null}),t=xu(s,t,a)}else if(kt||Wn(s,t,a,!1),g=(a&s.childLanes)!==0,kt||g){if(g=Fs,g!==null&&(r=dt(g,a),r!==0&&r!==R.retryLane))throw R.retryLane=r,un(s,r),ia(g,s,r),iu;Fu(y)||Pc(),t=xu(s,t,a)}else Fu(y)?(t.flags|=192,t.child=s.child,t=null):(s=R.treeContext,tt=za(y.nextSibling),$t=t,ks=!0,Al=null,Ma=!1,s!==null&&Vx(t,s),t=mu(t,r.children),t.flags|=4096);return t}return o?(Bl(),y=r.fallback,o=t.mode,R=s.child,se=R.sibling,r=ll(R,{mode:"hidden",children:r.children}),r.subtreeFlags=R.subtreeFlags&65011712,se!==null?y=ll(se,y):(y=mn(y,o,a,null),y.flags|=2),y.return=t,r.return=t,r.sibling=y,t.child=r,ri(null,r),r=t.child,y=s.child.memoizedState,y===null?y=du(a):(o=y.cachePool,o!==null?(R=St._currentValue,o=o.parent!==R?{parent:R,pool:R}:o):o=Jx(),y={baseLanes:y.baseLanes|a,cachePool:o}),r.memoizedState=y,r.childLanes=uu(s,g,a),t.memoizedState=ou,ri(s.child,r)):(Ul(t),a=s.child,s=a.sibling,a=ll(a,{mode:"visible",children:r.children}),a.return=t,a.sibling=null,s!==null&&(g=t.deletions,g===null?(t.deletions=[s],t.flags|=16):g.push(s)),t.child=a,t.memoizedState=null,a)}function mu(s,t){return t=Dc({mode:"visible",children:t},s.mode),t.return=s,s.child=t}function Dc(s,t){return s=pa(22,s,null,t),s.lanes=0,s}function xu(s,t,a){return vn(t,s.child,null,a),s=mu(t,t.pendingProps.children),s.flags|=2,t.memoizedState=null,s}function uf(s,t,a){s.lanes|=t;var r=s.alternate;r!==null&&(r.lanes|=t),Td(s.return,t,a)}function hu(s,t,a,r,o,d){var g=s.memoizedState;g===null?s.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:a,tailMode:o,treeForkCount:d}:(g.isBackwards=t,g.rendering=null,g.renderingStartTime=0,g.last=r,g.tail=a,g.tailMode=o,g.treeForkCount=d)}function mf(s,t,a){var r=t.pendingProps,o=r.revealOrder,d=r.tail;r=r.children;var g=Nt.current,y=(g&2)!==0;if(y?(g=g&1|2,t.flags|=128):g&=1,ke(Nt,g),Gt(s,t,r,a),r=ks?Kr:0,!y&&s!==null&&(s.flags&128)!==0)e:for(s=t.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&uf(s,a,t);else if(s.tag===19)uf(s,a,t);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(o){case"forwards":for(a=t.child,o=null;a!==null;)s=a.alternate,s!==null&&bc(s)===null&&(o=a),a=a.sibling;a=o,a===null?(o=t.child,t.child=null):(o=a.sibling,a.sibling=null),hu(t,!1,o,a,d,r);break;case"backwards":case"unstable_legacy-backwards":for(a=null,o=t.child,t.child=null;o!==null;){if(s=o.alternate,s!==null&&bc(s)===null){t.child=o;break}s=o.sibling,o.sibling=a,a=o,o=s}hu(t,!0,a,null,d,r);break;case"together":hu(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function dl(s,t,a){if(s!==null&&(t.dependencies=s.dependencies),Gl|=t.lanes,(a&t.childLanes)===0)if(s!==null){if(Wn(s,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(s!==null&&t.child!==s.child)throw Error(c(153));if(t.child!==null){for(s=t.child,a=ll(s,s.pendingProps),t.child=a,a.return=t;s.sibling!==null;)s=s.sibling,a=a.sibling=ll(s,s.pendingProps),a.return=t;a.sibling=null}return t.child}function fu(s,t){return(s.lanes&t)!==0?!0:(s=s.dependencies,!!(s!==null&&xc(s)))}function Pb(s,t,a){switch(t.tag){case 3:Te(t,t.stateNode.containerInfo),Dl(t,St,s.memoizedState.cache),xn();break;case 27:case 5:ne(t);break;case 4:Te(t,t.stateNode.containerInfo);break;case 10:Dl(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Hd(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(Ul(t),t.flags|=128,null):(a&t.child.childLanes)!==0?df(s,t,a):(Ul(t),s=dl(s,t,a),s!==null?s.sibling:null);Ul(t);break;case 19:var o=(s.flags&128)!==0;if(r=(a&t.childLanes)!==0,r||(Wn(s,t,a,!1),r=(a&t.childLanes)!==0),o){if(r)return mf(s,t,a);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),ke(Nt,Nt.current),r)break;return null;case 22:return t.lanes=0,af(s,t,a,t.pendingProps);case 24:Dl(t,St,s.memoizedState.cache)}return dl(s,t,a)}function xf(s,t,a){if(s!==null)if(s.memoizedProps!==t.pendingProps)kt=!0;else{if(!fu(s,a)&&(t.flags&128)===0)return kt=!1,Pb(s,t,a);kt=(s.flags&131072)!==0}else kt=!1,ks&&(t.flags&1048576)!==0&&qx(t,Kr,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(s=gn(t.elementType),t.type=s,typeof s=="function")Nd(s)?(r=bn(s,r),t.tag=1,t=cf(null,t,s,r,a)):(t.tag=0,t=cu(null,t,s,r,a));else{if(s!=null){var o=s.$$typeof;if(o===_){t.tag=11,t=ef(null,t,s,r,a);break e}else if(o===A){t.tag=14,t=sf(null,t,s,r,a);break e}}throw t=ge(s)||s,Error(c(306,t,""))}}return t;case 0:return cu(s,t,t.type,t.pendingProps,a);case 1:return r=t.type,o=bn(r,t.pendingProps),cf(s,t,r,o,a);case 3:e:{if(Te(t,t.stateNode.containerInfo),s===null)throw Error(c(387));r=t.pendingProps;var d=t.memoizedState;o=d.element,Rd(s,t),si(t,r,null,a);var g=t.memoizedState;if(r=g.cache,Dl(t,St,r),r!==d.cache&&Ed(t,[St],a,!0),ei(),r=g.element,d.isDehydrated)if(d={element:r,isDehydrated:!1,cache:g.cache},t.updateQueue.baseState=d,t.memoizedState=d,t.flags&256){t=of(s,t,r,a);break e}else if(r!==o){o=ka(Error(c(424)),t),Qr(o),t=of(s,t,r,a);break e}else{switch(s=t.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(tt=za(s.firstChild),$t=t,ks=!0,Al=null,Ma=!0,a=ah(t,null,r,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(xn(),r===o){t=dl(s,t,a);break e}Gt(s,t,r,a)}t=t.child}return t;case 26:return zc(s,t),s===null?(a=_p(t.type,null,t.pendingProps,null))?t.memoizedState=a:ks||(a=t.type,s=t.pendingProps,r=Yc(q.current).createElement(a),r[Bt]=t,r[sa]=s,Pt(r,a,s),Rt(r),t.stateNode=r):t.memoizedState=_p(t.type,s.memoizedProps,t.pendingProps,s.memoizedState),null;case 27:return ne(t),s===null&&ks&&(r=t.stateNode=bp(t.type,t.pendingProps,q.current),$t=t,Ma=!0,o=tt,Fl(t.type)?(Qu=o,tt=za(r.firstChild)):tt=o),Gt(s,t,t.pendingProps.children,a),zc(s,t),s===null&&(t.flags|=4194304),t.child;case 5:return s===null&&ks&&((o=r=tt)&&(r=jy(r,t.type,t.pendingProps,Ma),r!==null?(t.stateNode=r,$t=t,tt=za(r.firstChild),Ma=!1,o=!0):o=!1),o||zl(t)),ne(t),o=t.type,d=t.pendingProps,g=s!==null?s.memoizedProps:null,r=d.children,Iu(o,d)?r=null:g!==null&&Iu(o,g)&&(t.flags|=32),t.memoizedState!==null&&(o=Pd(s,t,Db,null,null,a),bi._currentValue=o),zc(s,t),Gt(s,t,r,a),t.child;case 6:return s===null&&ks&&((s=a=tt)&&(a=vy(a,t.pendingProps,Ma),a!==null?(t.stateNode=a,$t=t,tt=null,s=!0):s=!1),s||zl(t)),null;case 13:return df(s,t,a);case 4:return Te(t,t.stateNode.containerInfo),r=t.pendingProps,s===null?t.child=vn(t,null,r,a):Gt(s,t,r,a),t.child;case 11:return ef(s,t,t.type,t.pendingProps,a);case 7:return Gt(s,t,t.pendingProps,a),t.child;case 8:return Gt(s,t,t.pendingProps.children,a),t.child;case 12:return Gt(s,t,t.pendingProps.children,a),t.child;case 10:return r=t.pendingProps,Dl(t,t.type,r.value),Gt(s,t,r.children,a),t.child;case 9:return o=t.type._context,r=t.pendingProps.children,fn(t),o=Ht(o),r=r(o),t.flags|=1,Gt(s,t,r,a),t.child;case 14:return sf(s,t,t.type,t.pendingProps,a);case 15:return tf(s,t,t.type,t.pendingProps,a);case 19:return mf(s,t,a);case 31:return Gb(s,t,a);case 22:return af(s,t,a,t.pendingProps);case 24:return fn(t),r=Ht(St),s===null?(o=zd(),o===null&&(o=Fs,d=Md(),o.pooledCache=d,d.refCount++,d!==null&&(o.pooledCacheLanes|=a),o=d),t.memoizedState={parent:r,cache:o},Od(t),Dl(t,St,o)):((s.lanes&a)!==0&&(Rd(s,t),si(t,null,null,a),ei()),o=s.memoizedState,d=t.memoizedState,o.parent!==r?(o={parent:r,cache:r},t.memoizedState=o,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=o),Dl(t,St,r)):(r=d.cache,Dl(t,St,r),r!==o.cache&&Ed(t,[St],a,!0))),Gt(s,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(c(156,t.tag))}function ul(s){s.flags|=4}function pu(s,t,a,r,o){if((t=(s.mode&32)!==0)&&(t=!1),t){if(s.flags|=16777216,(o&335544128)===o)if(s.stateNode.complete)s.flags|=8192;else if(Hf())s.flags|=8192;else throw jn=gc,Dd}else s.flags&=-16777217}function hf(s,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Ep(t))if(Hf())s.flags|=8192;else throw jn=gc,Dd}function Oc(s,t){t!==null&&(s.flags|=4),s.flags&16384&&(t=s.tag!==22?Y():536870912,s.lanes|=t,ur|=t)}function ii(s,t){if(!ks)switch(s.tailMode){case"hidden":t=s.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?s.tail=null:a.sibling=null;break;case"collapsed":a=s.tail;for(var r=null;a!==null;)a.alternate!==null&&(r=a),a=a.sibling;r===null?t||s.tail===null?s.tail=null:s.tail.sibling=null:r.sibling=null}}function at(s){var t=s.alternate!==null&&s.alternate.child===s.child,a=0,r=0;if(t)for(var o=s.child;o!==null;)a|=o.lanes|o.childLanes,r|=o.subtreeFlags&65011712,r|=o.flags&65011712,o.return=s,o=o.sibling;else for(o=s.child;o!==null;)a|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=s,o=o.sibling;return s.subtreeFlags|=r,s.childLanes=a,t}function Ib(s,t,a){var r=t.pendingProps;switch(_d(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return a=t.stateNode,r=null,s!==null&&(r=s.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),il(St),X(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(s===null||s.child===null)&&(Zn(t)?ul(t):s===null||s.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Cd())),at(t),null;case 26:var o=t.type,d=t.memoizedState;return s===null?(ul(t),d!==null?(at(t),hf(t,d)):(at(t),pu(t,o,null,r,a))):d?d!==s.memoizedState?(ul(t),at(t),hf(t,d)):(at(t),t.flags&=-16777217):(s=s.memoizedProps,s!==r&&ul(t),at(t),pu(t,o,s,r,a)),null;case 27:if(Ie(t),a=q.current,o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==r&&ul(t);else{if(!r){if(t.stateNode===null)throw Error(c(166));return at(t),null}s=I.current,Zn(t)?Fx(t):(s=bp(o,r,a),t.stateNode=s,ul(t))}return at(t),null;case 5:if(Ie(t),o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==r&&ul(t);else{if(!r){if(t.stateNode===null)throw Error(c(166));return at(t),null}if(d=I.current,Zn(t))Fx(t);else{var g=Yc(q.current);switch(d){case 1:d=g.createElementNS("http://www.w3.org/2000/svg",o);break;case 2:d=g.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;default:switch(o){case"svg":d=g.createElementNS("http://www.w3.org/2000/svg",o);break;case"math":d=g.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;case"script":d=g.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof r.is=="string"?g.createElement("select",{is:r.is}):g.createElement("select"),r.multiple?d.multiple=!0:r.size&&(d.size=r.size);break;default:d=typeof r.is=="string"?g.createElement(o,{is:r.is}):g.createElement(o)}}d[Bt]=t,d[sa]=r;e:for(g=t.child;g!==null;){if(g.tag===5||g.tag===6)d.appendChild(g.stateNode);else if(g.tag!==4&&g.tag!==27&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===t)break e;for(;g.sibling===null;){if(g.return===null||g.return===t)break e;g=g.return}g.sibling.return=g.return,g=g.sibling}t.stateNode=d;e:switch(Pt(d,o,r),o){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&ul(t)}}return at(t),pu(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,a),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==r&&ul(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(c(166));if(s=q.current,Zn(t)){if(s=t.stateNode,a=t.memoizedProps,r=null,o=$t,o!==null)switch(o.tag){case 27:case 5:r=o.memoizedProps}s[Bt]=t,s=!!(s.nodeValue===a||r!==null&&r.suppressHydrationWarning===!0||dp(s.nodeValue,a)),s||zl(t,!0)}else s=Yc(s).createTextNode(r),s[Bt]=t,t.stateNode=s}return at(t),null;case 31:if(a=t.memoizedState,s===null||s.memoizedState!==null){if(r=Zn(t),a!==null){if(s===null){if(!r)throw Error(c(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(557));s[Bt]=t}else xn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),s=!1}else a=Cd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=a),s=!0;if(!s)return t.flags&256?(ja(t),t):(ja(t),null);if((t.flags&128)!==0)throw Error(c(558))}return at(t),null;case 13:if(r=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(o=Zn(t),r!==null&&r.dehydrated!==null){if(s===null){if(!o)throw Error(c(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(c(317));o[Bt]=t}else xn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),o=!1}else o=Cd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=o),o=!0;if(!o)return t.flags&256?(ja(t),t):(ja(t),null)}return ja(t),(t.flags&128)!==0?(t.lanes=a,t):(a=r!==null,s=s!==null&&s.memoizedState!==null,a&&(r=t.child,o=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(o=r.alternate.memoizedState.cachePool.pool),d=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),d!==o&&(r.flags|=2048)),a!==s&&a&&(t.child.flags|=8192),Oc(t,t.updateQueue),at(t),null);case 4:return X(),s===null&&Bu(t.stateNode.containerInfo),at(t),null;case 10:return il(t.type),at(t),null;case 19:if(be(Nt),r=t.memoizedState,r===null)return at(t),null;if(o=(t.flags&128)!==0,d=r.rendering,d===null)if(o)ii(r,!1);else{if(mt!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(d=bc(s),d!==null){for(t.flags|=128,ii(r,!1),s=d.updateQueue,t.updateQueue=s,Oc(t,s),t.subtreeFlags=0,s=a,a=t.child;a!==null;)Gx(a,s),a=a.sibling;return ke(Nt,Nt.current&1|2),ks&&nl(t,r.treeForkCount),t.child}s=s.sibling}r.tail!==null&&ot()>$c&&(t.flags|=128,o=!0,ii(r,!1),t.lanes=4194304)}else{if(!o)if(s=bc(d),s!==null){if(t.flags|=128,o=!0,s=s.updateQueue,t.updateQueue=s,Oc(t,s),ii(r,!0),r.tail===null&&r.tailMode==="hidden"&&!d.alternate&&!ks)return at(t),null}else 2*ot()-r.renderingStartTime>$c&&a!==536870912&&(t.flags|=128,o=!0,ii(r,!1),t.lanes=4194304);r.isBackwards?(d.sibling=t.child,t.child=d):(s=r.last,s!==null?s.sibling=d:t.child=d,r.last=d)}return r.tail!==null?(s=r.tail,r.rendering=s,r.tail=s.sibling,r.renderingStartTime=ot(),s.sibling=null,a=Nt.current,ke(Nt,o?a&1|2:a&1),ks&&nl(t,r.treeForkCount),s):(at(t),null);case 22:case 23:return ja(t),$d(),r=t.memoizedState!==null,s!==null?s.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(a&536870912)!==0&&(t.flags&128)===0&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),a=t.updateQueue,a!==null&&Oc(t,a.retryQueue),a=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==a&&(t.flags|=2048),s!==null&&be(pn),null;case 24:return a=null,s!==null&&(a=s.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),il(St),at(t),null;case 25:return null;case 30:return null}throw Error(c(156,t.tag))}function qb(s,t){switch(_d(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return il(St),X(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return Ie(t),null;case 31:if(t.memoizedState!==null){if(ja(t),t.alternate===null)throw Error(c(340));xn()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(ja(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(c(340));xn()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return be(Nt),null;case 4:return X(),null;case 10:return il(t.type),null;case 22:case 23:return ja(t),$d(),s!==null&&be(pn),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return il(St),null;case 25:return null;default:return null}}function ff(s,t){switch(_d(t),t.tag){case 3:il(St),X();break;case 26:case 27:case 5:Ie(t);break;case 4:X();break;case 31:t.memoizedState!==null&&ja(t);break;case 13:ja(t);break;case 19:be(Nt);break;case 10:il(t.type);break;case 22:case 23:ja(t),$d(),s!==null&&be(pn);break;case 24:il(St)}}function ci(s,t){try{var a=t.updateQueue,r=a!==null?a.lastEffect:null;if(r!==null){var o=r.next;a=o;do{if((a.tag&s)===s){r=void 0;var d=a.create,g=a.inst;r=d(),g.destroy=r}a=a.next}while(a!==o)}}catch(y){$s(t,t.return,y)}}function $l(s,t,a){try{var r=t.updateQueue,o=r!==null?r.lastEffect:null;if(o!==null){var d=o.next;r=d;do{if((r.tag&s)===s){var g=r.inst,y=g.destroy;if(y!==void 0){g.destroy=void 0,o=t;var R=a,se=y;try{se()}catch(me){$s(o,R,me)}}}r=r.next}while(r!==d)}}catch(me){$s(t,t.return,me)}}function pf(s){var t=s.updateQueue;if(t!==null){var a=s.stateNode;try{nh(t,a)}catch(r){$s(s,s.return,r)}}}function gf(s,t,a){a.props=bn(s.type,s.memoizedProps),a.state=s.memoizedState;try{a.componentWillUnmount()}catch(r){$s(s,t,r)}}function oi(s,t){try{var a=s.ref;if(a!==null){switch(s.tag){case 26:case 27:case 5:var r=s.stateNode;break;case 30:r=s.stateNode;break;default:r=s.stateNode}typeof a=="function"?s.refCleanup=a(r):a.current=r}}catch(o){$s(s,t,o)}}function Ka(s,t){var a=s.ref,r=s.refCleanup;if(a!==null)if(typeof r=="function")try{r()}catch(o){$s(s,t,o)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(o){$s(s,t,o)}else a.current=null}function jf(s){var t=s.type,a=s.memoizedProps,r=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&r.focus();break e;case"img":a.src?r.src=a.src:a.srcSet&&(r.srcset=a.srcSet)}}catch(o){$s(s,s.return,o)}}function gu(s,t,a){try{var r=s.stateNode;my(r,s.type,a,t),r[sa]=t}catch(o){$s(s,s.return,o)}}function vf(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Fl(s.type)||s.tag===4}function ju(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||vf(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&&Fl(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 vu(s,t,a){var r=s.tag;if(r===5||r===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=tl));else if(r!==4&&(r===27&&Fl(s.type)&&(a=s.stateNode,t=null),s=s.child,s!==null))for(vu(s,t,a),s=s.sibling;s!==null;)vu(s,t,a),s=s.sibling}function Rc(s,t,a){var r=s.tag;if(r===5||r===6)s=s.stateNode,t?a.insertBefore(s,t):a.appendChild(s);else if(r!==4&&(r===27&&Fl(s.type)&&(a=s.stateNode),s=s.child,s!==null))for(Rc(s,t,a),s=s.sibling;s!==null;)Rc(s,t,a),s=s.sibling}function Nf(s){var t=s.stateNode,a=s.memoizedProps;try{for(var r=s.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);Pt(t,r,a),t[Bt]=s,t[sa]=a}catch(d){$s(s,s.return,d)}}var ml=!1,Tt=!1,Nu=!1,bf=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function Vb(s,t){if(s=s.containerInfo,Gu=to,s=zx(s),xd(s)){if("selectionStart"in s)var a={start:s.selectionStart,end:s.selectionEnd};else e:{a=(a=s.ownerDocument)&&a.defaultView||window;var r=a.getSelection&&a.getSelection();if(r&&r.rangeCount!==0){a=r.anchorNode;var o=r.anchorOffset,d=r.focusNode;r=r.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var g=0,y=-1,R=-1,se=0,me=0,fe=s,te=null;s:for(;;){for(var ie;fe!==a||o!==0&&fe.nodeType!==3||(y=g+o),fe!==d||r!==0&&fe.nodeType!==3||(R=g+r),fe.nodeType===3&&(g+=fe.nodeValue.length),(ie=fe.firstChild)!==null;)te=fe,fe=ie;for(;;){if(fe===s)break s;if(te===a&&++se===o&&(y=g),te===d&&++me===r&&(R=g),(ie=fe.nextSibling)!==null)break;fe=te,te=fe.parentNode}fe=ie}a=y===-1||R===-1?null:{start:y,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(Pu={focusedElem:s,selectionRange:a},to=!1,Lt=t;Lt!==null;)if(t=Lt,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,Lt=s;else for(;Lt!==null;){switch(t=Lt,d=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<s.length;a++)o=s[a],o.ref.impl=o.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&d!==null){s=void 0,a=t,o=d.memoizedProps,d=d.memoizedState,r=a.stateNode;try{var De=bn(a.type,o);s=r.getSnapshotBeforeUpdate(De,d),r.__reactInternalSnapshotBeforeUpdate=s}catch(Qe){$s(a,a.return,Qe)}}break;case 3:if((s&1024)!==0){if(s=t.stateNode.containerInfo,a=s.nodeType,a===9)Vu(s);else if(a===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Vu(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(c(163))}if(s=t.sibling,s!==null){s.return=t.return,Lt=s;break}Lt=t.return}}function yf(s,t,a){var r=a.flags;switch(a.tag){case 0:case 11:case 15:hl(s,a),r&4&&ci(5,a);break;case 1:if(hl(s,a),r&4)if(s=a.stateNode,t===null)try{s.componentDidMount()}catch(g){$s(a,a.return,g)}else{var o=bn(a.type,t.memoizedProps);t=t.memoizedState;try{s.componentDidUpdate(o,t,s.__reactInternalSnapshotBeforeUpdate)}catch(g){$s(a,a.return,g)}}r&64&&pf(a),r&512&&oi(a,a.return);break;case 3:if(hl(s,a),r&64&&(s=a.updateQueue,s!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{nh(s,t)}catch(g){$s(a,a.return,g)}}break;case 27:t===null&&r&4&&Nf(a);case 26:case 5:hl(s,a),t===null&&r&4&&jf(a),r&512&&oi(a,a.return);break;case 12:hl(s,a);break;case 31:hl(s,a),r&4&&Sf(s,a);break;case 13:hl(s,a),r&4&&Cf(s,a),r&64&&(s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(a=ey.bind(null,a),Ny(s,a))));break;case 22:if(r=a.memoizedState!==null||ml,!r){t=t!==null&&t.memoizedState!==null||Tt,o=ml;var d=Tt;ml=r,(Tt=t)&&!d?fl(s,a,(a.subtreeFlags&8772)!==0):hl(s,a),ml=o,Tt=d}break;case 30:break;default:hl(s,a)}}function wf(s){var t=s.alternate;t!==null&&(s.alternate=null,wf(t)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(t=s.stateNode,t!==null&&Xo(t)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var it=null,aa=!1;function xl(s,t,a){for(a=a.child;a!==null;)_f(s,t,a),a=a.sibling}function _f(s,t,a){if(ls&&typeof ls.onCommitFiberUnmount=="function")try{ls.onCommitFiberUnmount(Gs,a)}catch{}switch(a.tag){case 26:Tt||Ka(a,t),xl(s,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Tt||Ka(a,t);var r=it,o=aa;Fl(a.type)&&(it=a.stateNode,aa=!1),xl(s,t,a),ji(a.stateNode),it=r,aa=o;break;case 5:Tt||Ka(a,t);case 6:if(r=it,o=aa,it=null,xl(s,t,a),it=r,aa=o,it!==null)if(aa)try{(it.nodeType===9?it.body:it.nodeName==="HTML"?it.ownerDocument.body:it).removeChild(a.stateNode)}catch(d){$s(a,t,d)}else try{it.removeChild(a.stateNode)}catch(d){$s(a,t,d)}break;case 18:it!==null&&(aa?(s=it,pp(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,a.stateNode),vr(s)):pp(it,a.stateNode));break;case 4:r=it,o=aa,it=a.stateNode.containerInfo,aa=!0,xl(s,t,a),it=r,aa=o;break;case 0:case 11:case 14:case 15:$l(2,a,t),Tt||$l(4,a,t),xl(s,t,a);break;case 1:Tt||(Ka(a,t),r=a.stateNode,typeof r.componentWillUnmount=="function"&&gf(a,t,r)),xl(s,t,a);break;case 21:xl(s,t,a);break;case 22:Tt=(r=Tt)||a.memoizedState!==null,xl(s,t,a),Tt=r;break;default:xl(s,t,a)}}function Sf(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{vr(s)}catch(a){$s(t,t.return,a)}}}function Cf(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{vr(s)}catch(a){$s(t,t.return,a)}}function Fb(s){switch(s.tag){case 31:case 13:case 19:var t=s.stateNode;return t===null&&(t=s.stateNode=new bf),t;case 22:return s=s.stateNode,t=s._retryCache,t===null&&(t=s._retryCache=new bf),t;default:throw Error(c(435,s.tag))}}function Lc(s,t){var a=Fb(s);t.forEach(function(r){if(!a.has(r)){a.add(r);var o=sy.bind(null,s,r);r.then(o,o)}})}function la(s,t){var a=t.deletions;if(a!==null)for(var r=0;r<a.length;r++){var o=a[r],d=s,g=t,y=g;e:for(;y!==null;){switch(y.tag){case 27:if(Fl(y.type)){it=y.stateNode,aa=!1;break e}break;case 5:it=y.stateNode,aa=!1;break e;case 3:case 4:it=y.stateNode.containerInfo,aa=!0;break e}y=y.return}if(it===null)throw Error(c(160));_f(d,g,o),it=null,aa=!1,d=o.alternate,d!==null&&(d.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)kf(t,s),t=t.sibling}var Ba=null;function kf(s,t){var a=s.alternate,r=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:la(t,s),na(s),r&4&&($l(3,s,s.return),ci(3,s),$l(5,s,s.return));break;case 1:la(t,s),na(s),r&512&&(Tt||a===null||Ka(a,a.return)),r&64&&ml&&(s=s.updateQueue,s!==null&&(r=s.callbacks,r!==null&&(a=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=a===null?r:a.concat(r))));break;case 26:var o=Ba;if(la(t,s),na(s),r&512&&(Tt||a===null||Ka(a,a.return)),r&4){var d=a!==null?a.memoizedState:null;if(r=s.memoizedState,a===null)if(r===null)if(s.stateNode===null){e:{r=s.type,a=s.memoizedProps,o=o.ownerDocument||o;s:switch(r){case"title":d=o.getElementsByTagName("title")[0],(!d||d[Lr]||d[Bt]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=o.createElement(r),o.head.insertBefore(d,o.querySelector("head > title"))),Pt(d,r,a),d[Bt]=s,Rt(d),r=d;break e;case"link":var g=kp("link","href",o).get(r+(a.href||""));if(g){for(var y=0;y<g.length;y++)if(d=g[y],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){g.splice(y,1);break s}}d=o.createElement(r),Pt(d,r,a),o.head.appendChild(d);break;case"meta":if(g=kp("meta","content",o).get(r+(a.content||""))){for(y=0;y<g.length;y++)if(d=g[y],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){g.splice(y,1);break s}}d=o.createElement(r),Pt(d,r,a),o.head.appendChild(d);break;default:throw Error(c(468,r))}d[Bt]=s,Rt(d),r=d}s.stateNode=r}else Tp(o,s.type,s.stateNode);else s.stateNode=Cp(o,r,s.memoizedProps);else d!==r?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,r===null?Tp(o,s.type,s.stateNode):Cp(o,r,s.memoizedProps)):r===null&&s.stateNode!==null&&gu(s,s.memoizedProps,a.memoizedProps)}break;case 27:la(t,s),na(s),r&512&&(Tt||a===null||Ka(a,a.return)),a!==null&&r&4&&gu(s,s.memoizedProps,a.memoizedProps);break;case 5:if(la(t,s),na(s),r&512&&(Tt||a===null||Ka(a,a.return)),s.flags&32){o=s.stateNode;try{Pn(o,"")}catch(De){$s(s,s.return,De)}}r&4&&s.stateNode!=null&&(o=s.memoizedProps,gu(s,o,a!==null?a.memoizedProps:o)),r&1024&&(Nu=!0);break;case 6:if(la(t,s),na(s),r&4){if(s.stateNode===null)throw Error(c(162));r=s.memoizedProps,a=s.stateNode;try{a.nodeValue=r}catch(De){$s(s,s.return,De)}}break;case 3:if(Zc=null,o=Ba,Ba=Xc(t.containerInfo),la(t,s),Ba=o,na(s),r&4&&a!==null&&a.memoizedState.isDehydrated)try{vr(t.containerInfo)}catch(De){$s(s,s.return,De)}Nu&&(Nu=!1,Tf(s));break;case 4:r=Ba,Ba=Xc(s.stateNode.containerInfo),la(t,s),na(s),Ba=r;break;case 12:la(t,s),na(s);break;case 31:la(t,s),na(s),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Lc(s,r)));break;case 13:la(t,s),na(s),s.child.flags&8192&&s.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Bc=ot()),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Lc(s,r)));break;case 22:o=s.memoizedState!==null;var R=a!==null&&a.memoizedState!==null,se=ml,me=Tt;if(ml=se||o,Tt=me||R,la(t,s),Tt=me,ml=se,na(s),r&8192)e:for(t=s.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,o&&(a===null||R||ml||Tt||yn(s)),a=null,t=s;;){if(t.tag===5||t.tag===26){if(a===null){R=a=t;try{if(d=R.stateNode,o)g=d.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none";else{y=R.stateNode;var fe=R.memoizedProps.style,te=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;y.style.display=te==null||typeof te=="boolean"?"":(""+te).trim()}}catch(De){$s(R,R.return,De)}}}else if(t.tag===6){if(a===null){R=t;try{R.stateNode.nodeValue=o?"":R.memoizedProps}catch(De){$s(R,R.return,De)}}}else if(t.tag===18){if(a===null){R=t;try{var ie=R.stateNode;o?gp(ie,!0):gp(R.stateNode,!1)}catch(De){$s(R,R.return,De)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===s)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=s.updateQueue,r!==null&&(a=r.retryQueue,a!==null&&(r.retryQueue=null,Lc(s,a))));break;case 19:la(t,s),na(s),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Lc(s,r)));break;case 30:break;case 21:break;default:la(t,s),na(s)}}function na(s){var t=s.flags;if(t&2){try{for(var a,r=s.return;r!==null;){if(vf(r)){a=r;break}r=r.return}if(a==null)throw Error(c(160));switch(a.tag){case 27:var o=a.stateNode,d=ju(s);Rc(s,d,o);break;case 5:var g=a.stateNode;a.flags&32&&(Pn(g,""),a.flags&=-33);var y=ju(s);Rc(s,y,g);break;case 3:case 4:var R=a.stateNode.containerInfo,se=ju(s);vu(s,se,R);break;default:throw Error(c(161))}}catch(me){$s(s,s.return,me)}s.flags&=-3}t&4096&&(s.flags&=-4097)}function Tf(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var t=s;Tf(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),s=s.sibling}}function hl(s,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)yf(s,t.alternate,t),t=t.sibling}function yn(s){for(s=s.child;s!==null;){var t=s;switch(t.tag){case 0:case 11:case 14:case 15:$l(4,t,t.return),yn(t);break;case 1:Ka(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&gf(t,t.return,a),yn(t);break;case 27:ji(t.stateNode);case 26:case 5:Ka(t,t.return),yn(t);break;case 22:t.memoizedState===null&&yn(t);break;case 30:yn(t);break;default:yn(t)}s=s.sibling}}function fl(s,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,o=s,d=t,g=d.flags;switch(d.tag){case 0:case 11:case 15:fl(o,d,a),ci(4,d);break;case 1:if(fl(o,d,a),r=d,o=r.stateNode,typeof o.componentDidMount=="function")try{o.componentDidMount()}catch(se){$s(r,r.return,se)}if(r=d,o=r.updateQueue,o!==null){var y=r.stateNode;try{var R=o.shared.hiddenCallbacks;if(R!==null)for(o.shared.hiddenCallbacks=null,o=0;o<R.length;o++)lh(R[o],y)}catch(se){$s(r,r.return,se)}}a&&g&64&&pf(d),oi(d,d.return);break;case 27:Nf(d);case 26:case 5:fl(o,d,a),a&&r===null&&g&4&&jf(d),oi(d,d.return);break;case 12:fl(o,d,a);break;case 31:fl(o,d,a),a&&g&4&&Sf(o,d);break;case 13:fl(o,d,a),a&&g&4&&Cf(o,d);break;case 22:d.memoizedState===null&&fl(o,d,a),oi(d,d.return);break;case 30:break;default:fl(o,d,a)}t=t.sibling}}function bu(s,t){var a=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==a&&(s!=null&&s.refCount++,a!=null&&Yr(a))}function yu(s,t){s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&Yr(s))}function $a(s,t,a,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ef(s,t,a,r),t=t.sibling}function Ef(s,t,a,r){var o=t.flags;switch(t.tag){case 0:case 11:case 15:$a(s,t,a,r),o&2048&&ci(9,t);break;case 1:$a(s,t,a,r);break;case 3:$a(s,t,a,r),o&2048&&(s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&Yr(s)));break;case 12:if(o&2048){$a(s,t,a,r),s=t.stateNode;try{var d=t.memoizedProps,g=d.id,y=d.onPostCommit;typeof y=="function"&&y(g,t.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(R){$s(t,t.return,R)}}else $a(s,t,a,r);break;case 31:$a(s,t,a,r);break;case 13:$a(s,t,a,r);break;case 23:break;case 22:d=t.stateNode,g=t.alternate,t.memoizedState!==null?d._visibility&2?$a(s,t,a,r):di(s,t):d._visibility&2?$a(s,t,a,r):(d._visibility|=2,cr(s,t,a,r,(t.subtreeFlags&10256)!==0||!1)),o&2048&&bu(g,t);break;case 24:$a(s,t,a,r),o&2048&&yu(t.alternate,t);break;default:$a(s,t,a,r)}}function cr(s,t,a,r,o){for(o=o&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=s,g=t,y=a,R=r,se=g.flags;switch(g.tag){case 0:case 11:case 15:cr(d,g,y,R,o),ci(8,g);break;case 23:break;case 22:var me=g.stateNode;g.memoizedState!==null?me._visibility&2?cr(d,g,y,R,o):di(d,g):(me._visibility|=2,cr(d,g,y,R,o)),o&&se&2048&&bu(g.alternate,g);break;case 24:cr(d,g,y,R,o),o&&se&2048&&yu(g.alternate,g);break;default:cr(d,g,y,R,o)}t=t.sibling}}function di(s,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=s,r=t,o=r.flags;switch(r.tag){case 22:di(a,r),o&2048&&bu(r.alternate,r);break;case 24:di(a,r),o&2048&&yu(r.alternate,r);break;default:di(a,r)}t=t.sibling}}var ui=8192;function or(s,t,a){if(s.subtreeFlags&ui)for(s=s.child;s!==null;)Mf(s,t,a),s=s.sibling}function Mf(s,t,a){switch(s.tag){case 26:or(s,t,a),s.flags&ui&&s.memoizedState!==null&&zy(a,Ba,s.memoizedState,s.memoizedProps);break;case 5:or(s,t,a);break;case 3:case 4:var r=Ba;Ba=Xc(s.stateNode.containerInfo),or(s,t,a),Ba=r;break;case 22:s.memoizedState===null&&(r=s.alternate,r!==null&&r.memoizedState!==null?(r=ui,ui=16777216,or(s,t,a),ui=r):or(s,t,a));break;default:or(s,t,a)}}function Af(s){var t=s.alternate;if(t!==null&&(s=t.child,s!==null)){t.child=null;do t=s.sibling,s.sibling=null,s=t;while(s!==null)}}function mi(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Lt=r,Df(r,s)}Af(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)zf(s),s=s.sibling}function zf(s){switch(s.tag){case 0:case 11:case 15:mi(s),s.flags&2048&&$l(9,s,s.return);break;case 3:mi(s);break;case 12:mi(s);break;case 22:var t=s.stateNode;s.memoizedState!==null&&t._visibility&2&&(s.return===null||s.return.tag!==13)?(t._visibility&=-3,Uc(s)):mi(s);break;default:mi(s)}}function Uc(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Lt=r,Df(r,s)}Af(s)}for(s=s.child;s!==null;){switch(t=s,t.tag){case 0:case 11:case 15:$l(8,t,t.return),Uc(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,Uc(t));break;default:Uc(t)}s=s.sibling}}function Df(s,t){for(;Lt!==null;){var a=Lt;switch(a.tag){case 0:case 11:case 15:$l(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var r=a.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Yr(a.memoizedState.cache)}if(r=a.child,r!==null)r.return=a,Lt=r;else e:for(a=s;Lt!==null;){r=Lt;var o=r.sibling,d=r.return;if(wf(r),r===a){Lt=null;break e}if(o!==null){o.return=d,Lt=o;break e}Lt=d}}}var Kb={getCacheForType:function(s){var t=Ht(St),a=t.data.get(s);return a===void 0&&(a=s(),t.data.set(s,a)),a},cacheSignal:function(){return Ht(St).controller.signal}},Qb=typeof WeakMap=="function"?WeakMap:Map,zs=0,Fs=null,vs=null,ws=0,Bs=0,va=null,Hl=!1,dr=!1,wu=!1,pl=0,mt=0,Gl=0,wn=0,_u=0,Na=0,ur=0,xi=null,ra=null,Su=!1,Bc=0,Of=0,$c=1/0,Hc=null,Pl=null,Mt=0,Il=null,mr=null,gl=0,Cu=0,ku=null,Rf=null,hi=0,Tu=null;function ba(){return(zs&2)!==0&&ws!==0?ws&-ws:z.T!==null?Ou():nn()}function Lf(){if(Na===0)if((ws&536870912)===0||ks){var s=jt;jt<<=1,(jt&3932160)===0&&(jt=262144),Na=s}else Na=536870912;return s=ga.current,s!==null&&(s.flags|=32),Na}function ia(s,t,a){(s===Fs&&(Bs===2||Bs===9)||s.cancelPendingCommit!==null)&&(xr(s,0),ql(s,ws,Na,!1)),Ee(s,a),((zs&2)===0||s!==Fs)&&(s===Fs&&((zs&2)===0&&(wn|=a),mt===4&&ql(s,ws,Na,!1)),Qa(s))}function Uf(s,t,a){if((zs&6)!==0)throw Error(c(327));var r=!a&&(t&127)===0&&(t&s.expiredLanes)===0||Dt(s,t),o=r?Jb(s,t):Mu(s,t,!0),d=r;do{if(o===0){dr&&!r&&ql(s,t,0,!1);break}else{if(a=s.current.alternate,d&&!Yb(a)){o=Mu(s,t,!1),d=!1;continue}if(o===2){if(d=t,s.errorRecoveryDisabledLanes&d)var g=0;else g=s.pendingLanes&-536870913,g=g!==0?g:g&536870912?536870912:0;if(g!==0){t=g;e:{var y=s;o=xi;var R=y.current.memoizedState.isDehydrated;if(R&&(xr(y,g).flags|=256),g=Mu(y,g,!1),g!==2){if(wu&&!R){y.errorRecoveryDisabledLanes|=d,wn|=d,o=4;break e}d=ra,ra=o,d!==null&&(ra===null?ra=d:ra.push.apply(ra,d))}o=g}if(d=!1,o!==2)continue}}if(o===1){xr(s,0),ql(s,t,0,!0);break}e:{switch(r=s,d=o,d){case 0:case 1:throw Error(c(345));case 4:if((t&4194048)!==t)break;case 6:ql(r,t,Na,!Hl);break e;case 2:ra=null;break;case 3:case 5:break;default:throw Error(c(329))}if((t&62914560)===t&&(o=Bc+300-ot(),10<o)){if(ql(r,t,Na,!Hl),ys(r,0,!0)!==0)break e;gl=t,r.timeoutHandle=hp(Bf.bind(null,r,a,ra,Hc,Su,t,Na,wn,ur,Hl,d,"Throttled",-0,0),o);break e}Bf(r,a,ra,Hc,Su,t,Na,wn,ur,Hl,d,null,-0,0)}}break}while(!0);Qa(s)}function Bf(s,t,a,r,o,d,g,y,R,se,me,fe,te,ie){if(s.timeoutHandle=-1,fe=t.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:tl},Mf(t,d,fe);var De=(d&62914560)===d?Bc-ot():(d&4194048)===d?Of-ot():0;if(De=Dy(fe,De),De!==null){gl=d,s.cancelPendingCommit=De(Ff.bind(null,s,t,d,a,r,o,g,y,R,me,fe,null,te,ie)),ql(s,d,g,!se);return}}Ff(s,t,d,a,r,o,g,y,R)}function Yb(s){for(var t=s;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var r=0;r<a.length;r++){var o=a[r],d=o.getSnapshot;o=o.value;try{if(!fa(d(),o))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ql(s,t,a,r){t&=~_u,t&=~wn,s.suspendedLanes|=t,s.pingedLanes&=~t,r&&(s.warmLanes|=t),r=s.expirationTimes;for(var o=t;0<o;){var d=31-Ze(o),g=1<<d;r[d]=-1,o&=~g}a!==0&&qa(s,a,t)}function Gc(){return(zs&6)===0?(fi(0),!1):!0}function Eu(){if(vs!==null){if(Bs===0)var s=vs.return;else s=vs,rl=hn=null,Vd(s),ar=null,Jr=0,s=vs;for(;s!==null;)ff(s.alternate,s),s=s.return;vs=null}}function xr(s,t){var a=s.timeoutHandle;a!==-1&&(s.timeoutHandle=-1,fy(a)),a=s.cancelPendingCommit,a!==null&&(s.cancelPendingCommit=null,a()),gl=0,Eu(),Fs=s,vs=a=ll(s.current,null),ws=t,Bs=0,va=null,Hl=!1,dr=Dt(s,t),wu=!1,ur=Na=_u=wn=Gl=mt=0,ra=xi=null,Su=!1,(t&8)!==0&&(t|=t&32);var r=s.entangledLanes;if(r!==0)for(s=s.entanglements,r&=t;0<r;){var o=31-Ze(r),d=1<<o;t|=s[o],r&=~d}return pl=t,cc(),a}function $f(s,t){cs=null,z.H=ni,t===tr||t===pc?(t=eh(),Bs=3):t===Dd?(t=eh(),Bs=4):Bs=t===iu?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,va=t,vs===null&&(mt=1,Mc(s,ka(t,s.current)))}function Hf(){var s=ga.current;return s===null?!0:(ws&4194048)===ws?Aa===null:(ws&62914560)===ws||(ws&536870912)!==0?s===Aa:!1}function Gf(){var s=z.H;return z.H=ni,s===null?ni:s}function Pf(){var s=z.A;return z.A=Kb,s}function Pc(){mt=4,Hl||(ws&4194048)!==ws&&ga.current!==null||(dr=!0),(Gl&134217727)===0&&(wn&134217727)===0||Fs===null||ql(Fs,ws,Na,!1)}function Mu(s,t,a){var r=zs;zs|=2;var o=Gf(),d=Pf();(Fs!==s||ws!==t)&&(Hc=null,xr(s,t)),t=!1;var g=mt;e:do try{if(Bs!==0&&vs!==null){var y=vs,R=va;switch(Bs){case 8:Eu(),g=6;break e;case 3:case 2:case 9:case 6:ga.current===null&&(t=!0);var se=Bs;if(Bs=0,va=null,hr(s,y,R,se),a&&dr){g=0;break e}break;default:se=Bs,Bs=0,va=null,hr(s,y,R,se)}}Xb(),g=mt;break}catch(me){$f(s,me)}while(!0);return t&&s.shellSuspendCounter++,rl=hn=null,zs=r,z.H=o,z.A=d,vs===null&&(Fs=null,ws=0,cc()),g}function Xb(){for(;vs!==null;)If(vs)}function Jb(s,t){var a=zs;zs|=2;var r=Gf(),o=Pf();Fs!==s||ws!==t?(Hc=null,$c=ot()+500,xr(s,t)):dr=Dt(s,t);e:do try{if(Bs!==0&&vs!==null){t=vs;var d=va;s:switch(Bs){case 1:Bs=0,va=null,hr(s,t,d,1);break;case 2:case 9:if(Zx(d)){Bs=0,va=null,qf(t);break}t=function(){Bs!==2&&Bs!==9||Fs!==s||(Bs=7),Qa(s)},d.then(t,t);break e;case 3:Bs=7;break e;case 4:Bs=5;break e;case 7:Zx(d)?(Bs=0,va=null,qf(t)):(Bs=0,va=null,hr(s,t,d,7));break;case 5:var g=null;switch(vs.tag){case 26:g=vs.memoizedState;case 5:case 27:var y=vs;if(g?Ep(g):y.stateNode.complete){Bs=0,va=null;var R=y.sibling;if(R!==null)vs=R;else{var se=y.return;se!==null?(vs=se,Ic(se)):vs=null}break s}}Bs=0,va=null,hr(s,t,d,5);break;case 6:Bs=0,va=null,hr(s,t,d,6);break;case 8:Eu(),mt=6;break e;default:throw Error(c(462))}}Zb();break}catch(me){$f(s,me)}while(!0);return rl=hn=null,z.H=r,z.A=o,zs=a,vs!==null?0:(Fs=null,ws=0,cc(),mt)}function Zb(){for(;vs!==null&&!Zt();)If(vs)}function If(s){var t=xf(s.alternate,s,pl);s.memoizedProps=s.pendingProps,t===null?Ic(s):vs=t}function qf(s){var t=s,a=t.alternate;switch(t.tag){case 15:case 0:t=rf(a,t,t.pendingProps,t.type,void 0,ws);break;case 11:t=rf(a,t,t.pendingProps,t.type.render,t.ref,ws);break;case 5:Vd(t);default:ff(a,t),t=vs=Gx(t,pl),t=xf(a,t,pl)}s.memoizedProps=s.pendingProps,t===null?Ic(s):vs=t}function hr(s,t,a,r){rl=hn=null,Vd(t),ar=null,Jr=0;var o=t.return;try{if(Hb(s,o,t,a,ws)){mt=1,Mc(s,ka(a,s.current)),vs=null;return}}catch(d){if(o!==null)throw vs=o,d;mt=1,Mc(s,ka(a,s.current)),vs=null;return}t.flags&32768?(ks||r===1?s=!0:dr||(ws&536870912)!==0?s=!1:(Hl=s=!0,(r===2||r===9||r===3||r===6)&&(r=ga.current,r!==null&&r.tag===13&&(r.flags|=16384))),Vf(t,s)):Ic(t)}function Ic(s){var t=s;do{if((t.flags&32768)!==0){Vf(t,Hl);return}s=t.return;var a=Ib(t.alternate,t,pl);if(a!==null){vs=a;return}if(t=t.sibling,t!==null){vs=t;return}vs=t=s}while(t!==null);mt===0&&(mt=5)}function Vf(s,t){do{var a=qb(s.alternate,s);if(a!==null){a.flags&=32767,vs=a;return}if(a=s.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(s=s.sibling,s!==null)){vs=s;return}vs=s=a}while(s!==null);mt=6,vs=null}function Ff(s,t,a,r,o,d,g,y,R){s.cancelPendingCommit=null;do qc();while(Mt!==0);if((zs&6)!==0)throw Error(c(327));if(t!==null){if(t===s.current)throw Error(c(177));if(d=t.lanes|t.childLanes,d|=jd,Ps(s,a,d,g,y,R),s===Fs&&(vs=Fs=null,ws=0),mr=t,Il=s,gl=a,Cu=d,ku=o,Rf=r,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,ty(_e,function(){return Jf(),null})):(s.callbackNode=null,s.callbackPriority=0),r=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||r){r=z.T,z.T=null,o=Q.p,Q.p=2,g=zs,zs|=4;try{Vb(s,t,a)}finally{zs=g,Q.p=o,z.T=r}}Mt=1,Kf(),Qf(),Yf()}}function Kf(){if(Mt===1){Mt=0;var s=Il,t=mr,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=z.T,z.T=null;var r=Q.p;Q.p=2;var o=zs;zs|=4;try{kf(t,s);var d=Pu,g=zx(s.containerInfo),y=d.focusedElem,R=d.selectionRange;if(g!==y&&y&&y.ownerDocument&&Ax(y.ownerDocument.documentElement,y)){if(R!==null&&xd(y)){var se=R.start,me=R.end;if(me===void 0&&(me=se),"selectionStart"in y)y.selectionStart=se,y.selectionEnd=Math.min(me,y.value.length);else{var fe=y.ownerDocument||document,te=fe&&fe.defaultView||window;if(te.getSelection){var ie=te.getSelection(),De=y.textContent.length,Qe=Math.min(R.start,De),Vs=R.end===void 0?Qe:Math.min(R.end,De);!ie.extend&&Qe>Vs&&(g=Vs,Vs=Qe,Qe=g);var V=Mx(y,Qe),B=Mx(y,Vs);if(V&&B&&(ie.rangeCount!==1||ie.anchorNode!==V.node||ie.anchorOffset!==V.offset||ie.focusNode!==B.node||ie.focusOffset!==B.offset)){var W=fe.createRange();W.setStart(V.node,V.offset),ie.removeAllRanges(),Qe>Vs?(ie.addRange(W),ie.extend(B.node,B.offset)):(W.setEnd(B.node,B.offset),ie.addRange(W))}}}}for(fe=[],ie=y;ie=ie.parentNode;)ie.nodeType===1&&fe.push({element:ie,left:ie.scrollLeft,top:ie.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<fe.length;y++){var he=fe[y];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}to=!!Gu,Pu=Gu=null}finally{zs=o,Q.p=r,z.T=a}}s.current=t,Mt=2}}function Qf(){if(Mt===2){Mt=0;var s=Il,t=mr,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=z.T,z.T=null;var r=Q.p;Q.p=2;var o=zs;zs|=4;try{yf(s,t.alternate,t)}finally{zs=o,Q.p=r,z.T=a}}Mt=3}}function Yf(){if(Mt===4||Mt===3){Mt=0,Et();var s=Il,t=mr,a=gl,r=Rf;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Mt=5:(Mt=0,mr=Il=null,Xf(s,s.pendingLanes));var o=s.pendingLanes;if(o===0&&(Pl=null),vt(a),t=t.stateNode,ls&&typeof ls.onCommitFiberRoot=="function")try{ls.onCommitFiberRoot(Gs,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=z.T,o=Q.p,Q.p=2,z.T=null;try{for(var d=s.onRecoverableError,g=0;g<r.length;g++){var y=r[g];d(y.value,{componentStack:y.stack})}}finally{z.T=t,Q.p=o}}(gl&3)!==0&&qc(),Qa(s),o=s.pendingLanes,(a&261930)!==0&&(o&42)!==0?s===Tu?hi++:(hi=0,Tu=s):hi=0,fi(0)}}function Xf(s,t){(s.pooledCacheLanes&=t)===0&&(t=s.pooledCache,t!=null&&(s.pooledCache=null,Yr(t)))}function qc(){return Kf(),Qf(),Yf(),Jf()}function Jf(){if(Mt!==5)return!1;var s=Il,t=Cu;Cu=0;var a=vt(gl),r=z.T,o=Q.p;try{Q.p=32>a?32:a,z.T=null,a=ku,ku=null;var d=Il,g=gl;if(Mt=0,mr=Il=null,gl=0,(zs&6)!==0)throw Error(c(331));var y=zs;if(zs|=4,zf(d.current),Ef(d,d.current,g,a),zs=y,fi(0,!1),ls&&typeof ls.onPostCommitFiberRoot=="function")try{ls.onPostCommitFiberRoot(Gs,d)}catch{}return!0}finally{Q.p=o,z.T=r,Xf(s,t)}}function Zf(s,t,a){t=ka(a,t),t=ru(s.stateNode,t,2),s=Ll(s,t,2),s!==null&&(Ee(s,2),Qa(s))}function $s(s,t,a){if(s.tag===3)Zf(s,s,a);else for(;t!==null;){if(t.tag===3){Zf(t,s,a);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Pl===null||!Pl.has(r))){s=ka(a,s),a=Zh(2),r=Ll(t,a,2),r!==null&&(Wh(a,r,t,s),Ee(r,2),Qa(r));break}}t=t.return}}function Au(s,t,a){var r=s.pingCache;if(r===null){r=s.pingCache=new Qb;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(a)||(wu=!0,o.add(a),s=Wb.bind(null,s,t,a),t.then(s,s))}function Wb(s,t,a){var r=s.pingCache;r!==null&&r.delete(t),s.pingedLanes|=s.suspendedLanes&a,s.warmLanes&=~a,Fs===s&&(ws&a)===a&&(mt===4||mt===3&&(ws&62914560)===ws&&300>ot()-Bc?(zs&2)===0&&xr(s,0):_u|=a,ur===ws&&(ur=0)),Qa(s)}function Wf(s,t){t===0&&(t=Y()),s=un(s,t),s!==null&&(Ee(s,t),Qa(s))}function ey(s){var t=s.memoizedState,a=0;t!==null&&(a=t.retryLane),Wf(s,a)}function sy(s,t){var a=0;switch(s.tag){case 31:case 13:var r=s.stateNode,o=s.memoizedState;o!==null&&(a=o.retryLane);break;case 19:r=s.stateNode;break;case 22:r=s.stateNode._retryCache;break;default:throw Error(c(314))}r!==null&&r.delete(t),Wf(s,a)}function ty(s,t){return Ke(s,t)}var Vc=null,fr=null,zu=!1,Fc=!1,Du=!1,Vl=0;function Qa(s){s!==fr&&s.next===null&&(fr===null?Vc=fr=s:fr=fr.next=s),Fc=!0,zu||(zu=!0,ly())}function fi(s,t){if(!Du&&Fc){Du=!0;do for(var a=!1,r=Vc;r!==null;){if(s!==0){var o=r.pendingLanes;if(o===0)var d=0;else{var g=r.suspendedLanes,y=r.pingedLanes;d=(1<<31-Ze(42|s)+1)-1,d&=o&~(g&~y),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,ap(r,d))}else d=ws,d=ys(r,r===Fs?d:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(d&3)===0||Dt(r,d)||(a=!0,ap(r,d));r=r.next}while(a);Du=!1}}function ay(){ep()}function ep(){Fc=zu=!1;var s=0;Vl!==0&&hy()&&(s=Vl);for(var t=ot(),a=null,r=Vc;r!==null;){var o=r.next,d=sp(r,t);d===0?(r.next=null,a===null?Vc=o:a.next=o,o===null&&(fr=a)):(a=r,(s!==0||(d&3)!==0)&&(Fc=!0)),r=o}Mt!==0&&Mt!==5||fi(s),Vl!==0&&(Vl=0)}function sp(s,t){for(var a=s.suspendedLanes,r=s.pingedLanes,o=s.expirationTimes,d=s.pendingLanes&-62914561;0<d;){var g=31-Ze(d),y=1<<g,R=o[g];R===-1?((y&a)===0||(y&r)!==0)&&(o[g]=Ot(y,t)):R<=t&&(s.expiredLanes|=y),d&=~y}if(t=Fs,a=ws,a=ys(s,s===t?a:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),r=s.callbackNode,a===0||s===t&&(Bs===2||Bs===9)||s.cancelPendingCommit!==null)return r!==null&&r!==null&&qe(r),s.callbackNode=null,s.callbackPriority=0;if((a&3)===0||Dt(s,a)){if(t=a&-a,t===s.callbackPriority)return t;switch(r!==null&&qe(r),vt(a)){case 2:case 8:a=Be;break;case 32:a=_e;break;case 268435456:a=is;break;default:a=_e}return r=tp.bind(null,s),a=Ke(a,r),s.callbackPriority=t,s.callbackNode=a,t}return r!==null&&r!==null&&qe(r),s.callbackPriority=2,s.callbackNode=null,2}function tp(s,t){if(Mt!==0&&Mt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var a=s.callbackNode;if(qc()&&s.callbackNode!==a)return null;var r=ws;return r=ys(s,s===Fs?r:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),r===0?null:(Uf(s,r,t),sp(s,ot()),s.callbackNode!=null&&s.callbackNode===a?tp.bind(null,s):null)}function ap(s,t){if(qc())return null;Uf(s,t,!0)}function ly(){py(function(){(zs&6)!==0?Ke(Pe,ay):ep()})}function Ou(){if(Vl===0){var s=er;s===0&&(s=Cs,Cs<<=1,(Cs&261888)===0&&(Cs=256)),Vl=s}return Vl}function lp(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:ec(""+s)}function np(s,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,s.id&&a.setAttribute("form",s.id),t.parentNode.insertBefore(a,t),s=new FormData(s),a.parentNode.removeChild(a),s}function ny(s,t,a,r,o){if(t==="submit"&&a&&a.stateNode===o){var d=lp((o[sa]||null).action),g=r.submitter;g&&(t=(t=g[sa]||null)?lp(t.formAction):g.getAttribute("formAction"),t!==null&&(d=t,g=null));var y=new lc("action","action",null,r,o);s.push({event:y,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Vl!==0){var R=g?np(o,g):new FormData(o);eu(a,{pending:!0,data:R,method:o.method,action:d},null,R)}}else typeof d=="function"&&(y.preventDefault(),R=g?np(o,g):new FormData(o),eu(a,{pending:!0,data:R,method:o.method,action:d},d,R))},currentTarget:o}]})}}for(var Ru=0;Ru<gd.length;Ru++){var Lu=gd[Ru],ry=Lu.toLowerCase(),iy=Lu[0].toUpperCase()+Lu.slice(1);Ua(ry,"on"+iy)}Ua(Rx,"onAnimationEnd"),Ua(Lx,"onAnimationIteration"),Ua(Ux,"onAnimationStart"),Ua("dblclick","onDoubleClick"),Ua("focusin","onFocus"),Ua("focusout","onBlur"),Ua(wb,"onTransitionRun"),Ua(_b,"onTransitionStart"),Ua(Sb,"onTransitionCancel"),Ua(Bx,"onTransitionEnd"),Hn("onMouseEnter",["mouseout","mouseover"]),Hn("onMouseLeave",["mouseout","mouseover"]),Hn("onPointerEnter",["pointerout","pointerover"]),Hn("onPointerLeave",["pointerout","pointerover"]),rn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),rn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),rn("onBeforeInput",["compositionend","keypress","textInput","paste"]),rn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),rn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),rn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var pi="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),cy=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(pi));function rp(s,t){t=(t&4)!==0;for(var a=0;a<s.length;a++){var r=s[a],o=r.event;r=r.listeners;e:{var d=void 0;if(t)for(var g=r.length-1;0<=g;g--){var y=r[g],R=y.instance,se=y.currentTarget;if(y=y.listener,R!==d&&o.isPropagationStopped())break e;d=y,o.currentTarget=se;try{d(o)}catch(me){ic(me)}o.currentTarget=null,d=R}else for(g=0;g<r.length;g++){if(y=r[g],R=y.instance,se=y.currentTarget,y=y.listener,R!==d&&o.isPropagationStopped())break e;d=y,o.currentTarget=se;try{d(o)}catch(me){ic(me)}o.currentTarget=null,d=R}}}}function Ns(s,t){var a=t[Yo];a===void 0&&(a=t[Yo]=new Set);var r=s+"__bubble";a.has(r)||(ip(t,s,2,!1),a.add(r))}function Uu(s,t,a){var r=0;t&&(r|=4),ip(a,s,r,t)}var Kc="_reactListening"+Math.random().toString(36).slice(2);function Bu(s){if(!s[Kc]){s[Kc]=!0,Wm.forEach(function(a){a!=="selectionchange"&&(cy.has(a)||Uu(a,!1,s),Uu(a,!0,s))});var t=s.nodeType===9?s:s.ownerDocument;t===null||t[Kc]||(t[Kc]=!0,Uu("selectionchange",!1,t))}}function ip(s,t,a,r){switch(Lp(t)){case 2:var o=Ly;break;case 8:o=Uy;break;default:o=Wu}a=o.bind(null,t,a,s),o=void 0,!ld||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),r?o!==void 0?s.addEventListener(t,a,{capture:!0,passive:o}):s.addEventListener(t,a,!0):o!==void 0?s.addEventListener(t,a,{passive:o}):s.addEventListener(t,a,!1)}function $u(s,t,a,r,o){var d=r;if((t&1)===0&&(t&2)===0&&r!==null)e:for(;;){if(r===null)return;var g=r.tag;if(g===3||g===4){var y=r.stateNode.containerInfo;if(y===o)break;if(g===4)for(g=r.return;g!==null;){var R=g.tag;if((R===3||R===4)&&g.stateNode.containerInfo===o)return;g=g.return}for(;y!==null;){if(g=Un(y),g===null)return;if(R=g.tag,R===5||R===6||R===26||R===27){r=d=g;continue e}y=y.parentNode}}r=r.return}ux(function(){var se=d,me=td(a),fe=[];e:{var te=$x.get(s);if(te!==void 0){var ie=lc,De=s;switch(s){case"keypress":if(tc(a)===0)break e;case"keydown":case"keyup":ie=sb;break;case"focusin":De="focus",ie=cd;break;case"focusout":De="blur",ie=cd;break;case"beforeblur":case"afterblur":ie=cd;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ie=hx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ie=IN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ie=lb;break;case Rx:case Lx:case Ux:ie=FN;break;case Bx:ie=rb;break;case"scroll":case"scrollend":ie=GN;break;case"wheel":ie=cb;break;case"copy":case"cut":case"paste":ie=QN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ie=px;break;case"toggle":case"beforetoggle":ie=db}var Qe=(t&4)!==0,Vs=!Qe&&(s==="scroll"||s==="scrollend"),V=Qe?te!==null?te+"Capture":null:te;Qe=[];for(var B=se,W;B!==null;){var he=B;if(W=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||W===null||V===null||(he=Br(B,V),he!=null&&Qe.push(gi(B,he,W))),Vs)break;B=B.return}0<Qe.length&&(te=new ie(te,De,null,a,me),fe.push({event:te,listeners:Qe}))}}if((t&7)===0){e:{if(te=s==="mouseover"||s==="pointerover",ie=s==="mouseout"||s==="pointerout",te&&a!==sd&&(De=a.relatedTarget||a.fromElement)&&(Un(De)||De[Ln]))break e;if((ie||te)&&(te=me.window===me?me:(te=me.ownerDocument)?te.defaultView||te.parentWindow:window,ie?(De=a.relatedTarget||a.toElement,ie=se,De=De?Un(De):null,De!==null&&(Vs=m(De),Qe=De.tag,De!==Vs||Qe!==5&&Qe!==27&&Qe!==6)&&(De=null)):(ie=null,De=se),ie!==De)){if(Qe=hx,he="onMouseLeave",V="onMouseEnter",B="mouse",(s==="pointerout"||s==="pointerover")&&(Qe=px,he="onPointerLeave",V="onPointerEnter",B="pointer"),Vs=ie==null?te:Ur(ie),W=De==null?te:Ur(De),te=new Qe(he,B+"leave",ie,a,me),te.target=Vs,te.relatedTarget=W,he=null,Un(me)===se&&(Qe=new Qe(V,B+"enter",De,a,me),Qe.target=W,Qe.relatedTarget=Vs,he=Qe),Vs=he,ie&&De)s:{for(Qe=oy,V=ie,B=De,W=0,he=V;he;he=Qe(he))W++;he=0;for(var Ve=B;Ve;Ve=Qe(Ve))he++;for(;0<W-he;)V=Qe(V),W--;for(;0<he-W;)B=Qe(B),he--;for(;W--;){if(V===B||B!==null&&V===B.alternate){Qe=V;break s}V=Qe(V),B=Qe(B)}Qe=null}else Qe=null;ie!==null&&cp(fe,te,ie,Qe,!1),De!==null&&Vs!==null&&cp(fe,Vs,De,Qe,!0)}}e:{if(te=se?Ur(se):window,ie=te.nodeName&&te.nodeName.toLowerCase(),ie==="select"||ie==="input"&&te.type==="file")var Ts=_x;else if(yx(te))if(Sx)Ts=Nb;else{Ts=jb;var Re=gb}else ie=te.nodeName,!ie||ie.toLowerCase()!=="input"||te.type!=="checkbox"&&te.type!=="radio"?se&&ed(se.elementType)&&(Ts=_x):Ts=vb;if(Ts&&(Ts=Ts(s,se))){wx(fe,Ts,a,me);break e}Re&&Re(s,te,se),s==="focusout"&&se&&te.type==="number"&&se.memoizedProps.value!=null&&Wo(te,"number",te.value)}switch(Re=se?Ur(se):window,s){case"focusin":(yx(Re)||Re.contentEditable==="true")&&(Fn=Re,hd=se,Fr=null);break;case"focusout":Fr=hd=Fn=null;break;case"mousedown":fd=!0;break;case"contextmenu":case"mouseup":case"dragend":fd=!1,Dx(fe,a,me);break;case"selectionchange":if(yb)break;case"keydown":case"keyup":Dx(fe,a,me)}var os;if(dd)e:{switch(s){case"compositionstart":var _s="onCompositionStart";break e;case"compositionend":_s="onCompositionEnd";break e;case"compositionupdate":_s="onCompositionUpdate";break e}_s=void 0}else Vn?Nx(s,a)&&(_s="onCompositionEnd"):s==="keydown"&&a.keyCode===229&&(_s="onCompositionStart");_s&&(gx&&a.locale!=="ko"&&(Vn||_s!=="onCompositionStart"?_s==="onCompositionEnd"&&Vn&&(os=mx()):(El=me,nd="value"in El?El.value:El.textContent,Vn=!0)),Re=Qc(se,_s),0<Re.length&&(_s=new fx(_s,s,null,a,me),fe.push({event:_s,listeners:Re}),os?_s.data=os:(os=bx(a),os!==null&&(_s.data=os)))),(os=mb?xb(s,a):hb(s,a))&&(_s=Qc(se,"onBeforeInput"),0<_s.length&&(Re=new fx("onBeforeInput","beforeinput",null,a,me),fe.push({event:Re,listeners:_s}),Re.data=os)),ny(fe,s,se,a,me)}rp(fe,t)})}function gi(s,t,a){return{instance:s,listener:t,currentTarget:a}}function Qc(s,t){for(var a=t+"Capture",r=[];s!==null;){var o=s,d=o.stateNode;if(o=o.tag,o!==5&&o!==26&&o!==27||d===null||(o=Br(s,a),o!=null&&r.unshift(gi(s,o,d)),o=Br(s,t),o!=null&&r.push(gi(s,o,d))),s.tag===3)return r;s=s.return}return[]}function oy(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function cp(s,t,a,r,o){for(var d=t._reactName,g=[];a!==null&&a!==r;){var y=a,R=y.alternate,se=y.stateNode;if(y=y.tag,R!==null&&R===r)break;y!==5&&y!==26&&y!==27||se===null||(R=se,o?(se=Br(a,d),se!=null&&g.unshift(gi(a,se,R))):o||(se=Br(a,d),se!=null&&g.push(gi(a,se,R)))),a=a.return}g.length!==0&&s.push({event:t,listeners:g})}var dy=/\r\n?/g,uy=/\u0000|\uFFFD/g;function op(s){return(typeof s=="string"?s:""+s).replace(dy,`
`).replace(uy,"")}function dp(s,t){return t=op(t),op(s)===t}function qs(s,t,a,r,o,d){switch(a){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||Pn(s,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&Pn(s,""+r);break;case"className":Zi(s,"class",r);break;case"tabIndex":Zi(s,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":Zi(s,a,r);break;case"style":ox(s,r,d);break;case"data":if(t!=="object"){Zi(s,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||a!=="href")){s.removeAttribute(a);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){s.removeAttribute(a);break}r=ec(""+r),s.setAttribute(a,r);break;case"action":case"formAction":if(typeof r=="function"){s.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="formAction"?(t!=="input"&&qs(s,t,"name",o.name,o,null),qs(s,t,"formEncType",o.formEncType,o,null),qs(s,t,"formMethod",o.formMethod,o,null),qs(s,t,"formTarget",o.formTarget,o,null)):(qs(s,t,"encType",o.encType,o,null),qs(s,t,"method",o.method,o,null),qs(s,t,"target",o.target,o,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){s.removeAttribute(a);break}r=ec(""+r),s.setAttribute(a,r);break;case"onClick":r!=null&&(s.onclick=tl);break;case"onScroll":r!=null&&Ns("scroll",s);break;case"onScrollEnd":r!=null&&Ns("scrollend",s);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(c(61));if(a=r.__html,a!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=a}}break;case"multiple":s.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":s.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){s.removeAttribute("xlink:href");break}a=ec(""+r),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,""+r):s.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,""):s.removeAttribute(a);break;case"capture":case"download":r===!0?s.setAttribute(a,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,r):s.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?s.setAttribute(a,r):s.removeAttribute(a);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?s.removeAttribute(a):s.setAttribute(a,r);break;case"popover":Ns("beforetoggle",s),Ns("toggle",s),Ji(s,"popover",r);break;case"xlinkActuate":sl(s,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":sl(s,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":sl(s,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":sl(s,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":sl(s,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":sl(s,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":sl(s,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":sl(s,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":sl(s,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":Ji(s,"is",r);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=$N.get(a)||a,Ji(s,a,r))}}function Hu(s,t,a,r,o,d){switch(a){case"style":ox(s,r,d);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(c(61));if(a=r.__html,a!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=a}}break;case"children":typeof r=="string"?Pn(s,r):(typeof r=="number"||typeof r=="bigint")&&Pn(s,""+r);break;case"onScroll":r!=null&&Ns("scroll",s);break;case"onScrollEnd":r!=null&&Ns("scrollend",s);break;case"onClick":r!=null&&(s.onclick=tl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ex.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(o=a.endsWith("Capture"),t=a.slice(2,o?a.length-7:void 0),d=s[sa]||null,d=d!=null?d[a]:null,typeof d=="function"&&s.removeEventListener(t,d,o),typeof r=="function")){typeof d!="function"&&d!==null&&(a in s?s[a]=null:s.hasAttribute(a)&&s.removeAttribute(a)),s.addEventListener(t,r,o);break e}a in s?s[a]=r:r===!0?s.setAttribute(a,""):Ji(s,a,r)}}}function Pt(s,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ns("error",s),Ns("load",s);var r=!1,o=!1,d;for(d in a)if(a.hasOwnProperty(d)){var g=a[d];if(g!=null)switch(d){case"src":r=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:qs(s,t,d,g,a,null)}}o&&qs(s,t,"srcSet",a.srcSet,a,null),r&&qs(s,t,"src",a.src,a,null);return;case"input":Ns("invalid",s);var y=d=g=o=null,R=null,se=null;for(r in a)if(a.hasOwnProperty(r)){var me=a[r];if(me!=null)switch(r){case"name":o=me;break;case"type":g=me;break;case"checked":R=me;break;case"defaultChecked":se=me;break;case"value":d=me;break;case"defaultValue":y=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(c(137,t));break;default:qs(s,t,r,me,a,null)}}nx(s,d,y,R,se,g,o,!1);return;case"select":Ns("invalid",s),r=g=d=null;for(o in a)if(a.hasOwnProperty(o)&&(y=a[o],y!=null))switch(o){case"value":d=y;break;case"defaultValue":g=y;break;case"multiple":r=y;default:qs(s,t,o,y,a,null)}t=d,a=g,s.multiple=!!r,t!=null?Gn(s,!!r,t,!1):a!=null&&Gn(s,!!r,a,!0);return;case"textarea":Ns("invalid",s),d=o=r=null;for(g in a)if(a.hasOwnProperty(g)&&(y=a[g],y!=null))switch(g){case"value":r=y;break;case"defaultValue":o=y;break;case"children":d=y;break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(c(91));break;default:qs(s,t,g,y,a,null)}ix(s,r,o,d);return;case"option":for(R in a)if(a.hasOwnProperty(R)&&(r=a[R],r!=null))switch(R){case"selected":s.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:qs(s,t,R,r,a,null)}return;case"dialog":Ns("beforetoggle",s),Ns("toggle",s),Ns("cancel",s),Ns("close",s);break;case"iframe":case"object":Ns("load",s);break;case"video":case"audio":for(r=0;r<pi.length;r++)Ns(pi[r],s);break;case"image":Ns("error",s),Ns("load",s);break;case"details":Ns("toggle",s);break;case"embed":case"source":case"link":Ns("error",s),Ns("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(se in a)if(a.hasOwnProperty(se)&&(r=a[se],r!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:qs(s,t,se,r,a,null)}return;default:if(ed(t)){for(me in a)a.hasOwnProperty(me)&&(r=a[me],r!==void 0&&Hu(s,t,me,r,a,void 0));return}}for(y in a)a.hasOwnProperty(y)&&(r=a[y],r!=null&&qs(s,t,y,r,a,null))}function my(s,t,a,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,d=null,g=null,y=null,R=null,se=null,me=null;for(ie in a){var fe=a[ie];if(a.hasOwnProperty(ie)&&fe!=null)switch(ie){case"checked":break;case"value":break;case"defaultValue":R=fe;default:r.hasOwnProperty(ie)||qs(s,t,ie,null,r,fe)}}for(var te in r){var ie=r[te];if(fe=a[te],r.hasOwnProperty(te)&&(ie!=null||fe!=null))switch(te){case"type":d=ie;break;case"name":o=ie;break;case"checked":se=ie;break;case"defaultChecked":me=ie;break;case"value":g=ie;break;case"defaultValue":y=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(c(137,t));break;default:ie!==fe&&qs(s,t,te,ie,r,fe)}}Zo(s,g,y,R,se,me,d,o);return;case"select":ie=g=y=te=null;for(d in a)if(R=a[d],a.hasOwnProperty(d)&&R!=null)switch(d){case"value":break;case"multiple":ie=R;default:r.hasOwnProperty(d)||qs(s,t,d,null,r,R)}for(o in r)if(d=r[o],R=a[o],r.hasOwnProperty(o)&&(d!=null||R!=null))switch(o){case"value":te=d;break;case"defaultValue":y=d;break;case"multiple":g=d;default:d!==R&&qs(s,t,o,d,r,R)}t=y,a=g,r=ie,te!=null?Gn(s,!!a,te,!1):!!r!=!!a&&(t!=null?Gn(s,!!a,t,!0):Gn(s,!!a,a?[]:"",!1));return;case"textarea":ie=te=null;for(y in a)if(o=a[y],a.hasOwnProperty(y)&&o!=null&&!r.hasOwnProperty(y))switch(y){case"value":break;case"children":break;default:qs(s,t,y,null,r,o)}for(g in r)if(o=r[g],d=a[g],r.hasOwnProperty(g)&&(o!=null||d!=null))switch(g){case"value":te=o;break;case"defaultValue":ie=o;break;case"children":break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(c(91));break;default:o!==d&&qs(s,t,g,o,r,d)}rx(s,te,ie);return;case"option":for(var De in a)if(te=a[De],a.hasOwnProperty(De)&&te!=null&&!r.hasOwnProperty(De))switch(De){case"selected":s.selected=!1;break;default:qs(s,t,De,null,r,te)}for(R in r)if(te=r[R],ie=a[R],r.hasOwnProperty(R)&&te!==ie&&(te!=null||ie!=null))switch(R){case"selected":s.selected=te&&typeof te!="function"&&typeof te!="symbol";break;default:qs(s,t,R,te,r,ie)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Qe in a)te=a[Qe],a.hasOwnProperty(Qe)&&te!=null&&!r.hasOwnProperty(Qe)&&qs(s,t,Qe,null,r,te);for(se in r)if(te=r[se],ie=a[se],r.hasOwnProperty(se)&&te!==ie&&(te!=null||ie!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(c(137,t));break;default:qs(s,t,se,te,r,ie)}return;default:if(ed(t)){for(var Vs in a)te=a[Vs],a.hasOwnProperty(Vs)&&te!==void 0&&!r.hasOwnProperty(Vs)&&Hu(s,t,Vs,void 0,r,te);for(me in r)te=r[me],ie=a[me],!r.hasOwnProperty(me)||te===ie||te===void 0&&ie===void 0||Hu(s,t,me,te,r,ie);return}}for(var V in a)te=a[V],a.hasOwnProperty(V)&&te!=null&&!r.hasOwnProperty(V)&&qs(s,t,V,null,r,te);for(fe in r)te=r[fe],ie=a[fe],!r.hasOwnProperty(fe)||te===ie||te==null&&ie==null||qs(s,t,fe,te,r,ie)}function up(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function xy(){if(typeof performance.getEntriesByType=="function"){for(var s=0,t=0,a=performance.getEntriesByType("resource"),r=0;r<a.length;r++){var o=a[r],d=o.transferSize,g=o.initiatorType,y=o.duration;if(d&&y&&up(g)){for(g=0,y=o.responseEnd,r+=1;r<a.length;r++){var R=a[r],se=R.startTime;if(se>y)break;var me=R.transferSize,fe=R.initiatorType;me&&up(fe)&&(R=R.responseEnd,g+=me*(R<y?1:(y-se)/(R-se)))}if(--r,t+=8*(d+g)/(o.duration/1e3),s++,10<s)break}}if(0<s)return t/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var Gu=null,Pu=null;function Yc(s){return s.nodeType===9?s:s.ownerDocument}function mp(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function xp(s,t){if(s===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&t==="foreignObject"?0:s}function Iu(s,t){return s==="textarea"||s==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var qu=null;function hy(){var s=window.event;return s&&s.type==="popstate"?s===qu?!1:(qu=s,!0):(qu=null,!1)}var hp=typeof setTimeout=="function"?setTimeout:void 0,fy=typeof clearTimeout=="function"?clearTimeout:void 0,fp=typeof Promise=="function"?Promise:void 0,py=typeof queueMicrotask=="function"?queueMicrotask:typeof fp<"u"?function(s){return fp.resolve(null).then(s).catch(gy)}:hp;function gy(s){setTimeout(function(){throw s})}function Fl(s){return s==="head"}function pp(s,t){var a=t,r=0;do{var o=a.nextSibling;if(s.removeChild(a),o&&o.nodeType===8)if(a=o.data,a==="/$"||a==="/&"){if(r===0){s.removeChild(o),vr(t);return}r--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")r++;else if(a==="html")ji(s.ownerDocument.documentElement);else if(a==="head"){a=s.ownerDocument.head,ji(a);for(var d=a.firstChild;d;){var g=d.nextSibling,y=d.nodeName;d[Lr]||y==="SCRIPT"||y==="STYLE"||y==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=g}}else a==="body"&&ji(s.ownerDocument.body);a=o}while(a);vr(t)}function gp(s,t){var a=s;s=0;do{var r=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),r&&r.nodeType===8)if(a=r.data,a==="/$"){if(s===0)break;s--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||s++;a=r}while(a)}function Vu(s){var t=s.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Vu(a),Xo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}s.removeChild(a)}}function jy(s,t,a,r){for(;s.nodeType===1;){var o=a;if(s.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(r){if(!s[Lr])switch(t){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(d=s.getAttribute("rel"),d==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(d!==o.rel||s.getAttribute("href")!==(o.href==null||o.href===""?null:o.href)||s.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin)||s.getAttribute("title")!==(o.title==null?null:o.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(d=s.getAttribute("src"),(d!==(o.src==null?null:o.src)||s.getAttribute("type")!==(o.type==null?null:o.type)||s.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin))&&d&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(t==="input"&&s.type==="hidden"){var d=o.name==null?null:""+o.name;if(o.type==="hidden"&&s.getAttribute("name")===d)return s}else return s;if(s=za(s.nextSibling),s===null)break}return null}function vy(s,t,a){if(t==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!a||(s=za(s.nextSibling),s===null))return null;return s}function jp(s,t){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!t||(s=za(s.nextSibling),s===null))return null;return s}function Fu(s){return s.data==="$?"||s.data==="$~"}function Ku(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function Ny(s,t){var a=s.ownerDocument;if(s.data==="$~")s._reactRetry=t;else if(s.data!=="$?"||a.readyState!=="loading")t();else{var r=function(){t(),a.removeEventListener("DOMContentLoaded",r)};a.addEventListener("DOMContentLoaded",r),s._reactRetry=r}}function za(s){for(;s!=null;s=s.nextSibling){var t=s.nodeType;if(t===1||t===3)break;if(t===8){if(t=s.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return s}var Qu=null;function vp(s){s=s.nextSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="/$"||a==="/&"){if(t===0)return za(s.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}s=s.nextSibling}return null}function Np(s){s=s.previousSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return s;t--}else a!=="/$"&&a!=="/&"||t++}s=s.previousSibling}return null}function bp(s,t,a){switch(t=Yc(a),s){case"html":if(s=t.documentElement,!s)throw Error(c(452));return s;case"head":if(s=t.head,!s)throw Error(c(453));return s;case"body":if(s=t.body,!s)throw Error(c(454));return s;default:throw Error(c(451))}}function ji(s){for(var t=s.attributes;t.length;)s.removeAttributeNode(t[0]);Xo(s)}var Da=new Map,yp=new Set;function Xc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var jl=Q.d;Q.d={f:by,r:yy,D:wy,C:_y,L:Sy,m:Cy,X:Ty,S:ky,M:Ey};function by(){var s=jl.f(),t=Gc();return s||t}function yy(s){var t=Bn(s);t!==null&&t.tag===5&&t.type==="form"?Bh(t):jl.r(s)}var pr=typeof document>"u"?null:document;function wp(s,t,a){var r=pr;if(r&&typeof t=="string"&&t){var o=Sa(t);o='link[rel="'+s+'"][href="'+o+'"]',typeof a=="string"&&(o+='[crossorigin="'+a+'"]'),yp.has(o)||(yp.add(o),s={rel:s,crossOrigin:a,href:t},r.querySelector(o)===null&&(t=r.createElement("link"),Pt(t,"link",s),Rt(t),r.head.appendChild(t)))}}function wy(s){jl.D(s),wp("dns-prefetch",s,null)}function _y(s,t){jl.C(s,t),wp("preconnect",s,t)}function Sy(s,t,a){jl.L(s,t,a);var r=pr;if(r&&s&&t){var o='link[rel="preload"][as="'+Sa(t)+'"]';t==="image"&&a&&a.imageSrcSet?(o+='[imagesrcset="'+Sa(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(o+='[imagesizes="'+Sa(a.imageSizes)+'"]')):o+='[href="'+Sa(s)+'"]';var d=o;switch(t){case"style":d=gr(s);break;case"script":d=jr(s)}Da.has(d)||(s=N({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:s,as:t},a),Da.set(d,s),r.querySelector(o)!==null||t==="style"&&r.querySelector(vi(d))||t==="script"&&r.querySelector(Ni(d))||(t=r.createElement("link"),Pt(t,"link",s),Rt(t),r.head.appendChild(t)))}}function Cy(s,t){jl.m(s,t);var a=pr;if(a&&s){var r=t&&typeof t.as=="string"?t.as:"script",o='link[rel="modulepreload"][as="'+Sa(r)+'"][href="'+Sa(s)+'"]',d=o;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=jr(s)}if(!Da.has(d)&&(s=N({rel:"modulepreload",href:s},t),Da.set(d,s),a.querySelector(o)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ni(d)))return}r=a.createElement("link"),Pt(r,"link",s),Rt(r),a.head.appendChild(r)}}}function ky(s,t,a){jl.S(s,t,a);var r=pr;if(r&&s){var o=$n(r).hoistableStyles,d=gr(s);t=t||"default";var g=o.get(d);if(!g){var y={loading:0,preload:null};if(g=r.querySelector(vi(d)))y.loading=5;else{s=N({rel:"stylesheet",href:s,"data-precedence":t},a),(a=Da.get(d))&&Yu(s,a);var R=g=r.createElement("link");Rt(R),Pt(R,"link",s),R._p=new Promise(function(se,me){R.onload=se,R.onerror=me}),R.addEventListener("load",function(){y.loading|=1}),R.addEventListener("error",function(){y.loading|=2}),y.loading|=4,Jc(g,t,r)}g={type:"stylesheet",instance:g,count:1,state:y},o.set(d,g)}}}function Ty(s,t){jl.X(s,t);var a=pr;if(a&&s){var r=$n(a).hoistableScripts,o=jr(s),d=r.get(o);d||(d=a.querySelector(Ni(o)),d||(s=N({src:s,async:!0},t),(t=Da.get(o))&&Xu(s,t),d=a.createElement("script"),Rt(d),Pt(d,"link",s),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},r.set(o,d))}}function Ey(s,t){jl.M(s,t);var a=pr;if(a&&s){var r=$n(a).hoistableScripts,o=jr(s),d=r.get(o);d||(d=a.querySelector(Ni(o)),d||(s=N({src:s,async:!0,type:"module"},t),(t=Da.get(o))&&Xu(s,t),d=a.createElement("script"),Rt(d),Pt(d,"link",s),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},r.set(o,d))}}function _p(s,t,a,r){var o=(o=q.current)?Xc(o):null;if(!o)throw Error(c(446));switch(s){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=gr(a.href),a=$n(o).hoistableStyles,r=a.get(t),r||(r={type:"style",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){s=gr(a.href);var d=$n(o).hoistableStyles,g=d.get(s);if(g||(o=o.ownerDocument||o,g={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(s,g),(d=o.querySelector(vi(s)))&&!d._p&&(g.instance=d,g.state.loading=5),Da.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},Da.set(s,a),d||My(o,s,a,g.state))),t&&r===null)throw Error(c(528,""));return g}if(t&&r!==null)throw Error(c(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=jr(a),a=$n(o).hoistableScripts,r=a.get(t),r||(r={type:"script",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,s))}}function gr(s){return'href="'+Sa(s)+'"'}function vi(s){return'link[rel="stylesheet"]['+s+"]"}function Sp(s){return N({},s,{"data-precedence":s.precedence,precedence:null})}function My(s,t,a,r){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=s.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),Pt(t,"link",a),Rt(t),s.head.appendChild(t))}function jr(s){return'[src="'+Sa(s)+'"]'}function Ni(s){return"script[async]"+s}function Cp(s,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var r=s.querySelector('style[data-href~="'+Sa(a.href)+'"]');if(r)return t.instance=r,Rt(r),r;var o=N({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return r=(s.ownerDocument||s).createElement("style"),Rt(r),Pt(r,"style",o),Jc(r,a.precedence,s),t.instance=r;case"stylesheet":o=gr(a.href);var d=s.querySelector(vi(o));if(d)return t.state.loading|=4,t.instance=d,Rt(d),d;r=Sp(a),(o=Da.get(o))&&Yu(r,o),d=(s.ownerDocument||s).createElement("link"),Rt(d);var g=d;return g._p=new Promise(function(y,R){g.onload=y,g.onerror=R}),Pt(d,"link",r),t.state.loading|=4,Jc(d,a.precedence,s),t.instance=d;case"script":return d=jr(a.src),(o=s.querySelector(Ni(d)))?(t.instance=o,Rt(o),o):(r=a,(o=Da.get(d))&&(r=N({},a),Xu(r,o)),s=s.ownerDocument||s,o=s.createElement("script"),Rt(o),Pt(o,"link",r),s.head.appendChild(o),t.instance=o);case"void":return null;default:throw Error(c(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(r=t.instance,t.state.loading|=4,Jc(r,a.precedence,s));return t.instance}function Jc(s,t,a){for(var r=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),o=r.length?r[r.length-1]:null,d=o,g=0;g<r.length;g++){var y=r[g];if(y.dataset.precedence===t)d=y;else if(d!==o)break}d?d.parentNode.insertBefore(s,d.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(s,t.firstChild))}function Yu(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.title==null&&(s.title=t.title)}function Xu(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.integrity==null&&(s.integrity=t.integrity)}var Zc=null;function kp(s,t,a){if(Zc===null){var r=new Map,o=Zc=new Map;o.set(a,r)}else o=Zc,r=o.get(a),r||(r=new Map,o.set(a,r));if(r.has(s))return r;for(r.set(s,null),a=a.getElementsByTagName(s),o=0;o<a.length;o++){var d=a[o];if(!(d[Lr]||d[Bt]||s==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var g=d.getAttribute(t)||"";g=s+g;var y=r.get(g);y?y.push(d):r.set(g,[d])}}return r}function Tp(s,t,a){s=s.ownerDocument||s,s.head.insertBefore(a,t==="title"?s.querySelector("head > 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 Ep(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function zy(s,t,a,r){if(a.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var o=gr(r.href),d=t.querySelector(vi(o));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=Wc.bind(s),t.then(s,s)),a.state.loading|=4,a.instance=d,Rt(d);return}d=t.ownerDocument||t,r=Sp(r),(o=Da.get(o))&&Yu(r,o),d=d.createElement("link"),Rt(d);var g=d;g._p=new Promise(function(y,R){g.onload=y,g.onerror=R}),Pt(d,"link",r),a.instance=d}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(s.count++,a=Wc.bind(s),t.addEventListener("load",a),t.addEventListener("error",a))}}var Ju=0;function Dy(s,t){return s.stylesheets&&s.count===0&&so(s,s.stylesheets),0<s.count||0<s.imgCount?function(a){var r=setTimeout(function(){if(s.stylesheets&&so(s,s.stylesheets),s.unsuspend){var d=s.unsuspend;s.unsuspend=null,d()}},6e4+t);0<s.imgBytes&&Ju===0&&(Ju=62500*xy());var o=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&so(s,s.stylesheets),s.unsuspend)){var d=s.unsuspend;s.unsuspend=null,d()}},(s.imgBytes>Ju?50:800)+t);return s.unsuspend=a,function(){s.unsuspend=null,clearTimeout(r),clearTimeout(o)}}:null}function Wc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)so(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var eo=null;function so(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,eo=new Map,t.forEach(Oy,s),eo=null,Wc.call(s))}function Oy(s,t){if(!(t.state.loading&4)){var a=eo.get(s);if(a)var r=a.get(null);else{a=new Map,eo.set(s,a);for(var o=s.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<o.length;d++){var g=o[d];(g.nodeName==="LINK"||g.getAttribute("media")!=="not all")&&(a.set(g.dataset.precedence,g),r=g)}r&&a.set(null,r)}o=t.instance,g=o.getAttribute("data-precedence"),d=a.get(g)||r,d===r&&a.set(null,o),a.set(g,o),this.count++,r=Wc.bind(this),o.addEventListener("load",r),o.addEventListener("error",r),d?d.parentNode.insertBefore(o,d.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(o,s.firstChild)),t.state.loading|=4}}var bi={$$typeof:E,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function Ry(s,t,a,r,o,d,g,y,R){this.tag=1,this.containerInfo=s,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ne(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ne(0),this.hiddenUpdates=Ne(null),this.identifierPrefix=r,this.onUncaughtError=o,this.onCaughtError=d,this.onRecoverableError=g,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=R,this.incompleteTransitions=new Map}function Mp(s,t,a,r,o,d,g,y,R,se,me,fe){return s=new Ry(s,t,a,g,R,se,me,fe,y),t=1,d===!0&&(t|=24),d=pa(3,null,null,t),s.current=d,d.stateNode=s,t=Md(),t.refCount++,s.pooledCache=t,t.refCount++,d.memoizedState={element:r,isDehydrated:a,cache:t},Od(d),s}function Ap(s){return s?(s=Yn,s):Yn}function zp(s,t,a,r,o,d){o=Ap(o),r.context===null?r.context=o:r.pendingContext=o,r=Rl(t),r.payload={element:a},d=d===void 0?null:d,d!==null&&(r.callback=d),a=Ll(s,r,t),a!==null&&(ia(a,s,t),Wr(a,s,t))}function Dp(s,t){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var a=s.retryLane;s.retryLane=a!==0&&a<t?a:t}}function Zu(s,t){Dp(s,t),(s=s.alternate)&&Dp(s,t)}function Op(s){if(s.tag===13||s.tag===31){var t=un(s,67108864);t!==null&&ia(t,s,67108864),Zu(s,67108864)}}function Rp(s){if(s.tag===13||s.tag===31){var t=ba();t=ea(t);var a=un(s,t);a!==null&&ia(a,s,t),Zu(s,t)}}var to=!0;function Ly(s,t,a,r){var o=z.T;z.T=null;var d=Q.p;try{Q.p=2,Wu(s,t,a,r)}finally{Q.p=d,z.T=o}}function Uy(s,t,a,r){var o=z.T;z.T=null;var d=Q.p;try{Q.p=8,Wu(s,t,a,r)}finally{Q.p=d,z.T=o}}function Wu(s,t,a,r){if(to){var o=em(r);if(o===null)$u(s,t,r,ao,a),Up(s,r);else if($y(o,s,t,a,r))r.stopPropagation();else if(Up(s,r),t&4&&-1<By.indexOf(s)){for(;o!==null;){var d=Bn(o);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var g=xe(d.pendingLanes);if(g!==0){var y=d;for(y.pendingLanes|=2,y.entangledLanes|=2;g;){var R=1<<31-Ze(g);y.entanglements[1]|=R,g&=~R}Qa(d),(zs&6)===0&&($c=ot()+500,fi(0))}}break;case 31:case 13:y=un(d,2),y!==null&&ia(y,d,2),Gc(),Zu(d,2)}if(d=em(r),d===null&&$u(s,t,r,ao,a),d===o)break;o=d}o!==null&&r.stopPropagation()}else $u(s,t,r,null,a)}}function em(s){return s=td(s),sm(s)}var ao=null;function sm(s){if(ao=null,s=Un(s),s!==null){var t=m(s);if(t===null)s=null;else{var a=t.tag;if(a===13){if(s=h(t),s!==null)return s;s=null}else if(a===31){if(s=f(t),s!==null)return s;s=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;s=null}else t!==s&&(s=null)}}return ao=s,null}function Lp(s){switch(s){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(K()){case Pe:return 2;case Be:return 8;case _e:case gs:return 32;case is:return 268435456;default:return 32}default:return 32}}var tm=!1,Kl=null,Ql=null,Yl=null,yi=new Map,wi=new Map,Xl=[],By="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Up(s,t){switch(s){case"focusin":case"focusout":Kl=null;break;case"dragenter":case"dragleave":Ql=null;break;case"mouseover":case"mouseout":Yl=null;break;case"pointerover":case"pointerout":yi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":wi.delete(t.pointerId)}}function _i(s,t,a,r,o,d){return s===null||s.nativeEvent!==d?(s={blockedOn:t,domEventName:a,eventSystemFlags:r,nativeEvent:d,targetContainers:[o]},t!==null&&(t=Bn(t),t!==null&&Op(t)),s):(s.eventSystemFlags|=r,t=s.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),s)}function $y(s,t,a,r,o){switch(t){case"focusin":return Kl=_i(Kl,s,t,a,r,o),!0;case"dragenter":return Ql=_i(Ql,s,t,a,r,o),!0;case"mouseover":return Yl=_i(Yl,s,t,a,r,o),!0;case"pointerover":var d=o.pointerId;return yi.set(d,_i(yi.get(d)||null,s,t,a,r,o)),!0;case"gotpointercapture":return d=o.pointerId,wi.set(d,_i(wi.get(d)||null,s,t,a,r,o)),!0}return!1}function Bp(s){var t=Un(s.target);if(t!==null){var a=m(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){s.blockedOn=t,Xi(s.priority,function(){Rp(a)});return}}else if(t===31){if(t=f(a),t!==null){s.blockedOn=t,Xi(s.priority,function(){Rp(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){s.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}s.blockedOn=null}function lo(s){if(s.blockedOn!==null)return!1;for(var t=s.targetContainers;0<t.length;){var a=em(s.nativeEvent);if(a===null){a=s.nativeEvent;var r=new a.constructor(a.type,a);sd=r,a.target.dispatchEvent(r),sd=null}else return t=Bn(a),t!==null&&Op(t),s.blockedOn=a,!1;t.shift()}return!0}function $p(s,t,a){lo(s)&&a.delete(t)}function Hy(){tm=!1,Kl!==null&&lo(Kl)&&(Kl=null),Ql!==null&&lo(Ql)&&(Ql=null),Yl!==null&&lo(Yl)&&(Yl=null),yi.forEach($p),wi.forEach($p)}function no(s,t){s.blockedOn===t&&(s.blockedOn=null,tm||(tm=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,Hy)))}var ro=null;function Hp(s){ro!==s&&(ro=s,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){ro===s&&(ro=null);for(var t=0;t<s.length;t+=3){var a=s[t],r=s[t+1],o=s[t+2];if(typeof r!="function"){if(sm(r||a)===null)continue;break}var d=Bn(a);d!==null&&(s.splice(t,3),t-=3,eu(d,{pending:!0,data:o,method:a.method,action:r},r,o))}}))}function vr(s){function t(R){return no(R,s)}Kl!==null&&no(Kl,s),Ql!==null&&no(Ql,s),Yl!==null&&no(Yl,s),yi.forEach(t),wi.forEach(t);for(var a=0;a<Xl.length;a++){var r=Xl[a];r.blockedOn===s&&(r.blockedOn=null)}for(;0<Xl.length&&(a=Xl[0],a.blockedOn===null);)Bp(a),a.blockedOn===null&&Xl.shift();if(a=(s.ownerDocument||s).$$reactFormReplay,a!=null)for(r=0;r<a.length;r+=3){var o=a[r],d=a[r+1],g=o[sa]||null;if(typeof d=="function")g||Hp(a);else if(g){var y=null;if(d&&d.hasAttribute("formAction")){if(o=d,g=d[sa]||null)y=g.formAction;else if(sm(o)!==null)continue}else y=g.action;typeof y=="function"?a[r+1]=y:(a.splice(r,3),r-=3),Hp(a)}}}function Gp(){function s(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(g){return o=g})},focusReset:"manual",scroll:"manual"})}function t(){o!==null&&(o(),o=null),r||setTimeout(a,20)}function a(){if(!r&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var r=!1,o=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){r=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),o!==null&&(o(),o=null)}}}function am(s){this._internalRoot=s}io.prototype.render=am.prototype.render=function(s){var t=this._internalRoot;if(t===null)throw Error(c(409));var a=t.current,r=ba();zp(a,r,s,t,null,null)},io.prototype.unmount=am.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var t=s.containerInfo;zp(s.current,2,null,s,null,null),Gc(),t[Ln]=null}};function io(s){this._internalRoot=s}io.prototype.unstable_scheduleHydration=function(s){if(s){var t=nn();s={blockedOn:null,target:s,priority:t};for(var a=0;a<Xl.length&&t!==0&&t<Xl[a].priority;a++);Xl.splice(a,0,s),a===0&&Bp(s)}};var Pp=n.version;if(Pp!=="19.2.1")throw Error(c(527,Pp,"19.2.1"));Q.findDOMNode=function(s){var t=s._reactInternals;if(t===void 0)throw typeof s.render=="function"?Error(c(188)):(s=Object.keys(s).join(","),Error(c(268,s)));return s=j(t),s=s!==null?v(s):null,s=s===null?null:s.stateNode,s};var Gy={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var co=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!co.isDisabled&&co.supportsFiber)try{Gs=co.inject(Gy),ls=co}catch{}}return Ci.createRoot=function(s,t){if(!u(s))throw Error(c(299));var a=!1,r="",o=Qh,d=Yh,g=Xh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(g=t.onRecoverableError)),t=Mp(s,1,!1,null,null,a,r,null,o,d,g,Gp),s[Ln]=t.current,Bu(s),new am(t)},Ci.hydrateRoot=function(s,t,a){if(!u(s))throw Error(c(299));var r=!1,o="",d=Qh,g=Yh,y=Xh,R=null;return a!=null&&(a.unstable_strictMode===!0&&(r=!0),a.identifierPrefix!==void 0&&(o=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(g=a.onCaughtError),a.onRecoverableError!==void 0&&(y=a.onRecoverableError),a.formState!==void 0&&(R=a.formState)),t=Mp(s,1,!0,t,a??null,r,o,R,d,g,y,Gp),t.context=Ap(null),a=t.current,r=ba(),r=ea(r),o=Rl(r),o.callback=null,Ll(a,o,r),a=r,t.current.lanes=a,Ee(t,a),Qa(t),s[Ln]=t.current,Bu(s),new io(t)},Ci.version="19.2.1",Ci}var Jp;function y1(){if(Jp)return cm.exports;Jp=1;function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),cm.exports=b1(),cm.exports}var w1=y1();function L(...l){return Wy(e0(l))}const Oe=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("rounded-xl border bg-card text-card-foreground shadow",l),...n}));Oe.displayName="Card";const ts=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("flex flex-col space-y-1.5 p-6",l),...n}));ts.displayName="CardHeader";const ns=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("font-semibold leading-none tracking-tight",l),...n}));ns.displayName="CardTitle";const Qs=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("text-sm text-muted-foreground",l),...n}));Qs.displayName="CardDescription";const We=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("p-6 pt-0",l),...n}));We.displayName="CardContent";const Lo=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("flex items-center p-6 pt-0",l),...n}));Lo.displayName="CardFooter";const ma=t0,Xt=x.forwardRef(({className:l,...n},i)=>e.jsx(Ng,{ref:i,className:L("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",l),...n}));Xt.displayName=Ng.displayName;const ss=x.forwardRef(({className:l,...n},i)=>e.jsx(bg,{ref:i,className:L("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",l),...n}));ss.displayName=bg.displayName;const Ss=x.forwardRef(({className:l,...n},i)=>e.jsx(yg,{ref:i,className:L("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",l),...n}));Ss.displayName=yg.displayName;const Xe=x.forwardRef(({className:l,children:n,viewportRef:i,...c},u)=>e.jsxs(wg,{ref:u,className:L("relative overflow-hidden",l),...c,children:[e.jsx(a0,{ref:i,className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(km,{}),e.jsx(km,{orientation:"horizontal"}),e.jsx(l0,{})]}));Xe.displayName=wg.displayName;const km=x.forwardRef(({className:l,orientation:n="vertical",...i},c)=>e.jsx(_g,{ref:c,orientation:n,className:L("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",l),...i,children:e.jsx(n0,{className:"relative flex-1 rounded-full bg-border"})}));km.displayName=_g.displayName;function Ks({className:l,...n}){return e.jsx("div",{className:L("animate-pulse rounded-md bg-primary/10",l),...n})}const An=x.forwardRef(({className:l,value:n,...i},c)=>e.jsx(Sg,{ref:c,className:L("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",l),...i,children:e.jsx(r0,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));An.displayName=Sg.displayName;async function Se(l,n){const c=n?.body instanceof FormData?{...n?.headers}:{"Content-Type":"application/json",...n?.headers},u={...n,credentials:"include",headers:c},m=await fetch(l,u);if(m.status===401)throw window.location.href="/auth",new Error("认证失败,请重新登录");return m}function Zs(){return{"Content-Type":"application/json"}}async function _1(){try{await fetch("/api/webui/auth/logout",{method:"POST",credentials:"include"})}catch(l){console.error("登出请求失败:",l)}window.location.href="/auth"}async function $i(){try{return(await(await fetch("/api/webui/auth/check",{method:"GET",credentials:"include"})).json()).authenticated===!0}catch{return!1}}const S1={light:"",dark:".dark"},Rj=x.createContext(null);function Lj(){const l=x.useContext(Rj);if(!l)throw new Error("useChart must be used within a <ChartContainer />");return l}const yr=x.forwardRef(({id:l,className:n,children:i,config:c,...u},m)=>{const h=x.useId(),f=`chart-${l||h.replace(/:/g,"")}`;return e.jsx(Rj.Provider,{value:{config:c},children:e.jsxs("div",{"data-chart":f,ref:m,className:L("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",n),...u,children:[e.jsx(C1,{id:f,config:c}),e.jsx(B0,{children:i})]})})});yr.displayName="Chart";const C1=({id:l,config:n})=>{const i=Object.entries(n).filter(([,c])=>c.theme||c.color);return i.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(S1).map(([c,u])=>`
${u} [data-chart=${l}] {
${i.map(([m,h])=>{const f=h.theme?.[c]||h.color;return f?` --color-${m}: ${f};`:null}).join(`
`)}
}
`).join(`
`)}}):null},ki=$0,wr=x.forwardRef(({active:l,payload:n,className:i,indicator:c="dot",hideLabel:u=!1,hideIndicator:m=!1,label:h,labelFormatter:f,labelClassName:p,formatter:j,color:v,nameKey:N,labelKey:b},S)=>{const{config:w}=Lj(),O=x.useMemo(()=>{if(u||!n?.length)return null;const[D]=n,$=`${b||D?.dataKey||D?.name||"value"}`,E=Tm(w,D,$),_=!b&&typeof h=="string"?w[h]?.label||h:E?.label;return f?e.jsx("div",{className:L("font-medium",p),children:f(_,n)}):_?e.jsx("div",{className:L("font-medium",p),children:_}):null},[h,f,n,u,p,w,b]);if(!l||!n?.length)return null;const M=n.length===1&&c!=="dot";return e.jsxs("div",{ref:S,className:L("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",i),children:[M?null:O,e.jsx("div",{className:"grid gap-1.5",children:n.filter(D=>D.type!=="none").map((D,$)=>{const E=`${N||D.name||D.dataKey||"value"}`,_=Tm(w,D,E),T=v||D.payload.fill||D.color;return e.jsx("div",{className:L("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",c==="dot"&&"items-center"),children:j&&D?.value!==void 0&&D.name?j(D.value,D.name,D,$,D.payload):e.jsxs(e.Fragment,{children:[_?.icon?e.jsx(_.icon,{}):!m&&e.jsx("div",{className:L("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":c==="dot","w-1":c==="line","w-0 border-[1.5px] border-dashed bg-transparent":c==="dashed","my-0.5":M&&c==="dashed"}),style:{"--color-bg":T,"--color-border":T}}),e.jsxs("div",{className:L("flex flex-1 justify-between leading-none",M?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[M?O:null,e.jsx("span",{className:"text-muted-foreground",children:_?.label||D.name})]}),D.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:D.value.toLocaleString()})]})]})},D.dataKey)})})]})});wr.displayName="ChartTooltip";const k1=H0,Uj=x.forwardRef(({className:l,hideIcon:n=!1,payload:i,verticalAlign:c="bottom",nameKey:u},m)=>{const{config:h}=Lj();return i?.length?e.jsx("div",{ref:m,className:L("flex items-center justify-center gap-4",c==="top"?"pb-3":"pt-3",l),children:i.filter(f=>f.type!=="none").map(f=>{const p=`${u||f.dataKey||"value"}`,j=Tm(h,f,p);return e.jsxs("div",{className:L("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[j?.icon&&!n?e.jsx(j.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:f.color}}),j?.label]},f.value)})}):null});Uj.displayName="ChartLegend";function Tm(l,n,i){if(typeof n!="object"||n===null)return;const c="payload"in n&&typeof n.payload=="object"&&n.payload!==null?n.payload:void 0;let u=i;return i in n&&typeof n[i]=="string"?u=n[i]:c&&i in c&&typeof c[i]=="string"&&(u=c[i]),u in l?l[u]:l[i]}const Er=Mr("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"}}),C=x.forwardRef(({className:l,variant:n,size:i,asChild:c=!1,...u},m)=>{const h=c?F0:"button";return e.jsx(h,{className:L(Er({variant:n,size:i,className:l})),ref:m,...u})});C.displayName="Button";const T1=Mr("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 Ae({className:l,variant:n,...i}){return e.jsx("div",{className:L(T1({variant:n}),l),...i})}async function E1(){const l=await Se("/api/webui/system/restart",{method:"POST",headers:Zs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"重启失败")}return await l.json()}async function M1(){const l=await Se("/api/webui/system/status",{method:"GET",headers:Zs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取状态失败")}return await l.json()}const Nr={INITIAL_DELAY:3e3,CHECK_INTERVAL:2e3,CHECK_TIMEOUT:3e3,MAX_ATTEMPTS:60,PROGRESS_INTERVAL:200,SUCCESS_REDIRECT_DELAY:1500},Bj=x.createContext(null);function On({children:l,onRestartComplete:n,onRestartFailed:i,healthCheckUrl:c="/api/webui/system/status",maxAttempts:u=Nr.MAX_ATTEMPTS}){const[m,h]=x.useState({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u}),[f,p]=x.useState({}),j=x.useCallback(()=>{f.progress&&clearInterval(f.progress),f.elapsed&&clearInterval(f.elapsed),f.check&&clearTimeout(f.check),p({})},[f]),v=x.useCallback(()=>{j(),h({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u})},[j,u]),N=x.useCallback(async()=>{try{const M=new AbortController,D=setTimeout(()=>M.abort(),Nr.CHECK_TIMEOUT),$=await fetch(c,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include",signal:M.signal});return clearTimeout(D),$.ok}catch{return!1}},[c]),b=x.useCallback(()=>{let M=0;const D=async()=>{if(M++,h(E=>({...E,status:"checking",checkAttempts:M})),await N())j(),h(E=>({...E,status:"success",progress:100})),setTimeout(()=>{n?.(),window.location.href="/auth"},Nr.SUCCESS_REDIRECT_DELAY);else if(M>=u){j();const E=`健康检查超时 (${M}/${u})`;h(_=>({..._,status:"failed",error:E})),i?.(E)}else{const E=setTimeout(D,Nr.CHECK_INTERVAL);p(_=>({..._,check:E}))}};D()},[N,j,u,n,i]),S=x.useCallback(()=>{h(M=>({...M,status:"checking",checkAttempts:0,error:void 0})),b()},[b]),w=x.useCallback(async M=>{const{delay:D=0,skipApiCall:$=!1}=M??{};if(m.status!=="idle"&&m.status!=="failed")return;if(j(),h({status:"requesting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u}),D>0&&await new Promise(T=>setTimeout(T,D)),$)h(T=>({...T,status:"restarting"}));else try{h(T=>({...T,status:"restarting"})),await Promise.race([E1(),new Promise(T=>setTimeout(T,5e3))])}catch{}const E=setInterval(()=>{h(T=>({...T,progress:T.progress>=90?T.progress:T.progress+1}))},Nr.PROGRESS_INTERVAL),_=setInterval(()=>{h(T=>({...T,elapsedTime:T.elapsedTime+1}))},1e3);p({progress:E,elapsed:_}),setTimeout(()=>{b()},Nr.INITIAL_DELAY)},[m.status,j,u,b]),O={state:m,isRestarting:m.status!=="idle",triggerRestart:w,resetState:v,retryHealthCheck:S};return e.jsx(Bj.Provider,{value:O,children:l})}function tn(){const l=x.useContext(Bj);if(!l)throw new Error("useRestart must be used within a RestartProvider");return l}const A1=(l,n,i,c,u)=>({idle:{icon:null,title:"",description:"",tip:""},requesting:{icon:e.jsx(Xs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"准备重启",description:u??"正在发送重启请求...",tip:"🔄 正在准备重启麦麦..."},restarting:{icon:e.jsx(Xs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"正在重启麦麦",description:u??"请稍候,麦麦正在重启中...",tip:"🔄 配置已保存,正在重启主程序..."},checking:{icon:e.jsx(Xs,{className:"h-16 w-16 text-primary animate-spin"}),title:"检查服务状态",description:`等待服务恢复... (${n}/${i})`,tip:"⏳ 正在等待服务恢复,请勿关闭页面..."},success:{icon:e.jsx(ua,{className:"h-16 w-16 text-green-500"}),title:"重启成功",description:"正在跳转到登录页面...",tip:"✅ 配置已生效,服务运行正常"},failed:{icon:e.jsx(Ut,{className:"h-16 w-16 text-destructive"}),title:"重启超时",description:"服务未能在预期时间内恢复",tip:"⚠️ 如果长时间无响应,请尝试手动重启"}})[l];function Rn({visible:l,onComplete:n,onFailed:i,title:c,description:u,showAnimation:m=!0,className:h}){let f=null;try{f=tn()}catch{}return(f?f.isRestarting:l)?f?e.jsx($j,{state:f.state,onRetry:f.retryHealthCheck,onComplete:n,onFailed:i,title:c,description:u,showAnimation:m,className:h}):e.jsx(z1,{onComplete:n,onFailed:i,title:c,description:u,showAnimation:m,className:h}):null}function $j({state:l,onRetry:n,onComplete:i,onFailed:c,title:u,description:m,showAnimation:h,className:f}){const{status:p,progress:j,elapsedTime:v,checkAttempts:N,maxAttempts:b}=l;x.useEffect(()=>{p==="success"&&i?i():p==="failed"&&c&&c()},[p,i,c]);const S=A1(p,N,b,u,m),w=O=>{const M=Math.floor(O/60),D=O%60;return`${M}:${D.toString().padStart(2,"0")}`};return e.jsxs("div",{className:L("fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",f),children:[h&&e.jsx(D1,{}),e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8 relative z-10",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsxs("div",{className:"relative",children:[S.icon,(p==="restarting"||p==="checking")&&e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),e.jsx("h2",{className:"text-2xl font-bold",children:S.title}),e.jsx("p",{className:"text-muted-foreground text-center",children:S.description})]}),p!=="failed"&&p!=="idle"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(An,{value:j,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[j,"%"]}),e.jsxs("span",{children:["已用时: ",w(v)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:S.tip})}),p==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{onClick:()=>window.location.reload(),variant:"default",className:"flex-1",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(C,{onClick:n,variant:"secondary",className:"flex-1",children:[e.jsx(Li,{className:"mr-2 h-4 w-4"}),"重试检测"]})]})]})]})}function z1({onComplete:l,onFailed:n,title:i,description:c,showAnimation:u,className:m}){const[h,f]=x.useState({status:"restarting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:60}),p=x.useCallback(()=>{let j=0;const v=60,N=async()=>{j++,f(b=>({...b,status:"checking",checkAttempts:j}));try{if((await fetch("/api/webui/system/status",{method:"GET",signal:AbortSignal.timeout(3e3)})).ok){f(S=>({...S,status:"success",progress:100})),setTimeout(()=>{l?.(),window.location.href="/auth"},1500);return}}catch{}j>=v?(f(b=>({...b,status:"failed"})),n?.()):setTimeout(N,2e3)};N()},[l,n]);return x.useEffect(()=>{const j=setInterval(()=>{f(b=>({...b,progress:b.progress>=90?b.progress:b.progress+1}))},200),v=setInterval(()=>{f(b=>({...b,elapsedTime:b.elapsedTime+1}))},1e3),N=setTimeout(()=>{p()},3e3);return()=>{clearInterval(j),clearInterval(v),clearTimeout(N)}},[p]),e.jsx($j,{state:h,onRetry:p,onComplete:l,onFailed:n,title:i,description:c,showAnimation:u,className:m})}function D1(){return e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px]",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite]"}),e.jsx("div",{className:"absolute inset-8 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite_0.5s]"}),e.jsx("div",{className:"absolute inset-16 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite_1s]"})]}),e.jsx("div",{className:"absolute top-1/4 left-1/4 w-2 h-2 bg-primary/20 rounded-full animate-bounce"}),e.jsx("div",{className:"absolute top-3/4 right-1/4 w-3 h-3 bg-primary/15 rounded-full animate-bounce delay-150"}),e.jsx("div",{className:"absolute top-1/2 right-1/3 w-2 h-2 bg-primary/20 rounded-full animate-bounce delay-300"})]})}function O1(){return e.jsx(On,{children:e.jsx(L1,{})})}const R1=l=>{const n=[];for(let i=0;i<l;i++){const c=i*137.508%360;n.push(`hsl(${c}, 70%, 55%)`)}return n};function L1(){const[l,n]=x.useState(null),[i,c]=x.useState(!0),[u,m]=x.useState(0),[h,f]=x.useState(24),[p,j]=x.useState(!0),[v,N]=x.useState(null),[b,S]=x.useState(!0),[w,O]=x.useState(null),{triggerRestart:M,isRestarting:D}=tn(),$=x.useCallback(async()=>{try{S(!0);const U=await s0.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");N({hitokoto:U.data.hitokoto,from:U.data.from||U.data.from_who||"未知"})}catch(U){console.error("获取一言失败:",U),N({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{S(!1)}},[]),E=x.useCallback(async()=>{try{const U=await Se("/api/webui/system/status");if(U.ok){const G=await U.json();O(G)}else O(null)}catch(U){console.error("获取机器人状态失败:",U),O(null)}},[]),_=async()=>{await M()},T=x.useCallback(async()=>{try{const U=await Se(`/api/webui/statistics/dashboard?hours=${h}`);if(U.ok){const G=await U.json();n(G)}c(!1),m(100)}catch(U){console.error("Failed to fetch dashboard data:",U),c(!1),m(100)}},[h]);if(x.useEffect(()=>{if(!i)return;m(0);const U=setTimeout(()=>m(15),200),G=setTimeout(()=>m(30),800),Ce=setTimeout(()=>m(45),2e3),be=setTimeout(()=>m(60),4e3),ke=setTimeout(()=>m(75),6500),I=setTimeout(()=>m(85),9e3),we=setTimeout(()=>m(92),11e3);return()=>{clearTimeout(U),clearTimeout(G),clearTimeout(Ce),clearTimeout(be),clearTimeout(ke),clearTimeout(I),clearTimeout(we)}},[i]),x.useEffect(()=>{T(),$(),E()},[T,$,E]),x.useEffect(()=>{if(!p)return;const U=setInterval(()=>{T(),E()},3e4);return()=>clearInterval(U)},[p,T,E]),i||!l)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(At,{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(An,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u,"%"]})]})]})});const{summary:P,model_stats:A=[],hourly_data:ee=[],daily_data:H=[],recent_activity:Z=[]}=l,re=P??{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},ye=U=>{const G=Math.floor(U/3600),Ce=Math.floor(U%3600/60);return`${G}小时${Ce}分钟`},de=U=>{const G=U.toLocaleString("zh-CN");return U>=1e9?{display:`${(U/1e9).toFixed(2)}B`,exact:G,needsExact:!0}:U>=1e6?{display:`${(U/1e6).toFixed(2)}M`,exact:G,needsExact:!0}:U>=1e4?{display:`${(U/1e3).toFixed(1)}K`,exact:G,needsExact:!0}:U>=1e3?{display:`${(U/1e3).toFixed(2)}K`,exact:G,needsExact:!0}:{display:G,exact:G,needsExact:!1}},ge=U=>{const G=`¥${U.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`;return U>=1e6?{display:`¥${(U/1e6).toFixed(2)}M`,exact:G,needsExact:!0}:U>=1e4?{display:`¥${(U/1e3).toFixed(1)}K`,exact:G,needsExact:!0}:U>=1e3?{display:`¥${(U/1e3).toFixed(2)}K`,exact:G,needsExact:!0}:{display:G,exact:G,needsExact:!1}},je=U=>new Date(U).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),z=R1(A.length),Q=A.map((U,G)=>({name:U.model_name,value:U.request_count,fill:z[G]})),J={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(Xe,{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(ma,{value:h.toString(),onValueChange:U=>f(Number(U)),children:e.jsxs(Xt,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(ss,{value:"24",children:"24小时"}),e.jsx(ss,{value:"168",children:"7天"}),e.jsx(ss,{value:"720",children:"30天"})]})}),e.jsxs(C,{variant:p?"default":"outline",size:"sm",onClick:()=>j(!p),className:"gap-2",children:[e.jsx(At,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:T,children:e.jsx(At,{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:[b?e.jsx(Ks,{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(C,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:$,disabled:b,children:e.jsx(At,{className:`h-3.5 w-3.5 ${b?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Oe,{className:"lg:col-span-1",children:[e.jsx(ts,{className:"pb-3",children:e.jsxs(ns,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(We,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:w?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Ae,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(ua,{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(Ae,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Ut,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),w&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",w.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",ye(w.uptime)]})]})]})})]}),e.jsxs(Oe,{children:[e.jsx(ts,{className:"pb-3",children:e.jsxs(ns,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(We,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:_,disabled:D,className:"gap-2",children:[e.jsx(Li,{className:`h-4 w-4 ${D?"animate-spin":""}`}),D?"重启中...":"重启麦麦"]}),e.jsx(C,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(br,{to:"/logs",children:[e.jsx(Ga,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(C,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(br,{to:"/plugins",children:[e.jsx(fw,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(C,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(br,{to:"/settings",children:[e.jsx(Dn,{className:"h-4 w-4"}),"系统设置"]})})]})})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"pb-3",children:[e.jsxs(ns,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pw,{className:"h-4 w-4"}),"反馈问卷"]}),e.jsx(Qs,{className:"text-xs",children:"帮助我们改进产品体验"})]}),e.jsx(We,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(br,{to:"/survey/webui-feedback",children:[e.jsx(Ga,{className:"h-4 w-4"}),"WebUI 反馈"]})}),e.jsx(C,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(br,{to:"/survey/maibot-feedback",children:[e.jsx(en,{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(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(gw,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[de(re.total_requests).display,de(re.total_requests).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",de(re.total_requests).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",h<48?h+"小时":Math.floor(h/24)+"天"]})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"总花费"}),e.jsx(jw,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ge(re.total_cost).display,ge(re.total_cost).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ge(re.total_cost).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:re.cost_per_hour>0?`¥${re.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(wo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[de(re.total_tokens).display,de(re.total_tokens).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",de(re.total_tokens).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:re.tokens_per_hour>0?`${de(re.tokens_per_hour).display}/小时`:"暂无数据"})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[re.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(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(bl,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(We,{children:e.jsxs("div",{className:"text-xl font-bold",children:[ye(re.online_time),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",re.online_time.toLocaleString(),"秒)"]})]})})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(en,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsxs("div",{className:"text-xl font-bold",children:[de(re.total_messages).display,de(re.total_messages).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",de(re.total_messages).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",de(re.total_replies).display,de(re.total_replies).needsExact&&e.jsxs("span",{children:["(",de(re.total_replies).exact,")"]})," 条"]})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(vw,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsx("div",{className:"text-xl font-bold",children:re.total_messages>0?`¥${(re.total_cost/re.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(ma,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(ss,{value:"trends",children:"趋势"}),e.jsx(ss,{value:"models",children:"模型"}),e.jsx(ss,{value:"activity",children:"活动"}),e.jsx(ss,{value:"daily",children:"日统计"})]}),e.jsxs(Ss,{value:"trends",className:"space-y-4",children:[e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"请求趋势"}),e.jsxs(Qs,{children:["最近",h,"小时的请求量变化"]})]}),e.jsx(We,{children:e.jsx(yr,{config:J,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(G0,{data:ee,children:[e.jsx(oo,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(uo,{dataKey:"timestamp",tickFormatter:U=>je(U),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Si,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ki,{content:e.jsx(wr,{labelFormatter:U=>je(U)})}),e.jsx(P0,{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(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"花费趋势"}),e.jsx(Qs,{children:"API调用成本变化"})]}),e.jsx(We,{children:e.jsx(yr,{config:J,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(nm,{data:ee,children:[e.jsx(oo,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(uo,{dataKey:"timestamp",tickFormatter:U=>je(U),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Si,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ki,{content:e.jsx(wr,{labelFormatter:U=>je(U)})}),e.jsx(mo,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"Token消耗"}),e.jsx(Qs,{children:"Token使用量变化"})]}),e.jsx(We,{children:e.jsx(yr,{config:J,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(nm,{data:ee,children:[e.jsx(oo,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(uo,{dataKey:"timestamp",tickFormatter:U=>je(U),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Si,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ki,{content:e.jsx(wr,{labelFormatter:U=>je(U)})}),e.jsx(mo,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(Ss,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"模型请求分布"}),e.jsxs(Qs,{children:["各模型使用占比 (共 ",A.length," 个模型)"]})]}),e.jsx(We,{children:e.jsx(yr,{config:Object.fromEntries(A.map((U,G)=>[U.model_name,{label:U.model_name,color:z[G]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(I0,{children:[e.jsx(ki,{content:e.jsx(wr,{})}),e.jsx(q0,{data:Q,cx:"50%",cy:"50%",labelLine:!1,label:({name:U,percent:G})=>G&&G<.05?"":`${U} ${G?(G*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:Q.map((U,G)=>e.jsx(V0,{fill:U.fill},`cell-${G}`))})]})})})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"模型详细统计"}),e.jsx(Qs,{children:"请求数、花费和性能"})]}),e.jsx(We,{children:e.jsx(Xe,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:A.map((U,G)=>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:U.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${G%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:U.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",U.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:[(U.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:[U.avg_response_time.toFixed(2),"s"]})]})]})]},G))})})})]})]})}),e.jsx(Ss,{value:"activity",children:e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"最近活动"}),e.jsx(Qs,{children:"最新的API调用记录"})]}),e.jsx(We,{children:e.jsx(Xe,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:Z.map((U,G)=>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:U.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:U.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:je(U.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:U.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",U.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[U.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${U.status==="success"?"text-green-600":"text-red-600"}`,children:U.status})]})]})]},G))})})})]})}),e.jsx(Ss,{value:"daily",children:e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"每日统计"}),e.jsx(Qs,{children:"最近7天的数据汇总"})]}),e.jsx(We,{children:e.jsx(yr,{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(nm,{data:H,children:[e.jsx(oo,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(uo,{dataKey:"timestamp",tickFormatter:U=>{const G=new Date(U);return`${G.getMonth()+1}/${G.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Si,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Si,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ki,{content:e.jsx(wr,{labelFormatter:U=>new Date(U).toLocaleDateString("zh-CN")})}),e.jsx(k1,{content:e.jsx(Uj,{})}),e.jsx(mo,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(mo,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]}),e.jsx(Rn,{})]})})}const U1={theme:"system",setTheme:()=>null},Hj=x.createContext(U1),Um=()=>{const l=x.useContext(Hj);if(l===void 0)throw new Error("useTheme must be used within a ThemeProvider");return l},B1=(l,n,i)=>{const c=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||c){n(l);return}const u=i.clientX,m=i.clientY,h=Math.hypot(Math.max(u,innerWidth-u),Math.max(m,innerHeight-m));document.startViewTransition(()=>{n(l)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${u}px ${m}px)`,`circle(${h}px at ${u}px ${m}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},Gj=x.createContext(void 0),Pj=()=>{const l=x.useContext(Gj);if(l===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return l},Fe=x.forwardRef(({className:l,...n},i)=>e.jsx(Cg,{className:L("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",l),...n,ref:i,children:e.jsx(i0,{className:L("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")})}));Fe.displayName=Cg.displayName;const $1=Mr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),k=x.forwardRef(({className:l,...n},i)=>e.jsx(Ig,{ref:i,className:L($1(),l),...n}));k.displayName=Ig.displayName;const ce=x.forwardRef(({className:l,type:n,...i},c)=>e.jsx("input",{type:n,className:L("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",l),ref:c,...i}));ce.displayName="Input";const H1=5,G1=5e3;let um=0;function P1(){return um=(um+1)%Number.MAX_SAFE_INTEGER,um.toString()}const mm=new Map,Zp=l=>{if(mm.has(l))return;const n=setTimeout(()=>{mm.delete(l),Oi({type:"REMOVE_TOAST",toastId:l})},G1);mm.set(l,n)},I1=(l,n)=>{switch(n.type){case"ADD_TOAST":return{...l,toasts:[n.toast,...l.toasts].slice(0,H1)};case"UPDATE_TOAST":return{...l,toasts:l.toasts.map(i=>i.id===n.toast.id?{...i,...n.toast}:i)};case"DISMISS_TOAST":{const{toastId:i}=n;return i?Zp(i):l.toasts.forEach(c=>{Zp(c.id)}),{...l,toasts:l.toasts.map(c=>c.id===i||i===void 0?{...c,open:!1}:c)}}case"REMOVE_TOAST":return n.toastId===void 0?{...l,toasts:[]}:{...l,toasts:l.toasts.filter(i=>i.id!==n.toastId)}}},No=[];let bo={toasts:[]};function Oi(l){bo=I1(bo,l),No.forEach(n=>{n(bo)})}function qt({...l}){const n=P1(),i=u=>Oi({type:"UPDATE_TOAST",toast:{...u,id:n}}),c=()=>Oi({type:"DISMISS_TOAST",toastId:n});return Oi({type:"ADD_TOAST",toast:{...l,id:n,open:!0,onOpenChange:u=>{u||c()}}}),{id:n,dismiss:c,update:i}}function et(){const[l,n]=x.useState(bo);return x.useEffect(()=>(No.push(n),()=>{const i=No.indexOf(n);i>-1&&No.splice(i,1)}),[l]),{...l,toast:qt,dismiss:i=>Oi({type:"DISMISS_TOAST",toastId:i})}}const q1=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:l=>l.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:l=>/[A-Z]/.test(l)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:l=>/[a-z]/.test(l)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:l=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(l)}];function V1(l){const n=q1.map(c=>({id:c.id,label:c.label,description:c.description,passed:c.validate(l)}));return{isValid:n.every(c=>c.passed),rules:n}}const Uo="0.12.0",Bm="MaiBot Dashboard",F1=`${Bm} v${Uo}`,K1=(l="v")=>`${l}${Uo}`,ca={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"},Xa={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function ht(l){const n=Ij(l),i=localStorage.getItem(n);if(i===null)return Xa[l];const c=Xa[l];if(typeof c=="boolean")return i==="true";if(typeof c=="number"){const u=parseFloat(i);return isNaN(u)?c:u}return i}function _r(l,n){const i=Ij(l);localStorage.setItem(i,String(n)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:l,value:n}}))}function Q1(){return{theme:ht("theme"),accentColor:ht("accentColor"),enableAnimations:ht("enableAnimations"),enableWavesBackground:ht("enableWavesBackground"),logCacheSize:ht("logCacheSize"),logAutoScroll:ht("logAutoScroll"),logFontSize:ht("logFontSize"),logLineSpacing:ht("logLineSpacing"),dataSyncInterval:ht("dataSyncInterval"),wsReconnectInterval:ht("wsReconnectInterval"),wsMaxReconnectAttempts:ht("wsMaxReconnectAttempts")}}function Y1(){const l=Q1(),n=localStorage.getItem(ca.COMPLETED_TOURS),i=n?JSON.parse(n):[];return{...l,completedTours:i}}function X1(l){const n=[],i=[];for(const[c,u]of Object.entries(l)){if(c==="completedTours"){Array.isArray(u)?(localStorage.setItem(ca.COMPLETED_TOURS,JSON.stringify(u)),n.push("completedTours")):i.push("completedTours");continue}if(c in Xa){const m=c,h=Xa[m];if(typeof u==typeof h){if(m==="theme"&&!["light","dark","system"].includes(u)){i.push(c);continue}if(m==="logFontSize"&&!["xs","sm","base"].includes(u)){i.push(c);continue}_r(m,u),n.push(c)}else i.push(c)}else i.push(c)}return{success:n.length>0,imported:n,skipped:i}}function J1(){for(const l of Object.keys(Xa))_r(l,Xa[l]);localStorage.removeItem(ca.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function Z1(){const l=[],n=[],i=[];for(let c=0;c<localStorage.length;c++){const u=localStorage.key(c);u&&(u.startsWith("maibot")||u.startsWith("accent-color")||u==="access-token")&&i.push(u)}for(const c of i)localStorage.removeItem(c),l.push(c);return{clearedKeys:l,preservedKeys:n}}function Wp(){let l=0;const n=[];for(let i=0;i<localStorage.length;i++){const c=localStorage.key(i);if(c){const u=localStorage.getItem(c)||"",m=(c.length+u.length)*2;l+=m,n.push({key:c,size:m})}}return n.sort((i,c)=>c.size-i.size),{used:l,items:localStorage.length,details:n}}function W1(l){if(l===0)return"0 B";const n=1024,i=["B","KB","MB"],c=Math.floor(Math.log(l)/Math.log(n));return parseFloat((l/Math.pow(n,c)).toFixed(2))+" "+i[c]}function Ij(l){return{theme:ca.THEME,accentColor:ca.ACCENT_COLOR,enableAnimations:ca.ENABLE_ANIMATIONS,enableWavesBackground:ca.ENABLE_WAVES_BACKGROUND,logCacheSize:ca.LOG_CACHE_SIZE,logAutoScroll:ca.LOG_AUTO_SCROLL,logFontSize:ca.LOG_FONT_SIZE,logLineSpacing:ca.LOG_LINE_SPACING,dataSyncInterval:ca.DATA_SYNC_INTERVAL,wsReconnectInterval:ca.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:ca.WS_MAX_RECONNECT_ATTEMPTS}[l]}const ya=x.forwardRef(({className:l,...n},i)=>e.jsxs(kg,{ref:i,className:L("relative flex w-full touch-none select-none items-center",l),...n,children:[e.jsx(c0,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(o0,{className:"absolute h-full bg-primary"})}),e.jsx(d0,{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"})]}));ya.displayName=kg.displayName;class e2{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return ht("logCacheSize")}getMaxReconnectAttempts(){return ht("wsMaxReconnectAttempts")}getReconnectInterval(){return ht("wsReconnectInterval")}getWebSocketUrl(n){let i;{const c=window.location.protocol==="https:"?"wss:":"ws:",u=window.location.host;i=`${c}//${u}/ws/logs`}return n?`${i}?token=${encodeURIComponent(n)}`:i}async getWsToken(){try{const n=await Se("/api/webui/ws-token",{method:"GET",credentials:"include"});if(!n.ok)return console.error("获取 WebSocket token 失败:",n.status),null;const i=await n.json();return i.success&&i.token?i.token:null}catch(n){return console.error("获取 WebSocket token 失败:",n),null}}async connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;if(window.location.pathname==="/auth"){console.log("📡 在登录页面,跳过 WebSocket 连接");return}if(!await $i()){console.log("📡 未登录,跳过 WebSocket 连接");return}const i=await this.getWsToken();if(!i){console.log("📡 无法获取 WebSocket token跳过连接");return}const c=this.getWebSocketUrl(i);try{this.ws=new WebSocket(c),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=u=>{try{if(u.data==="pong")return;const m=JSON.parse(u.data);this.notifyLog(m)}catch(m){console.error("解析日志消息失败:",m)}},this.ws.onerror=u=>{console.error("❌ WebSocket 错误:",u),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(u){console.error("创建 WebSocket 连接失败:",u),this.attemptReconnect()}}attemptReconnect(){const n=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=n)return;this.reconnectAttempts+=1;const i=this.getReconnectInterval(),c=Math.min(i*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},c)}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(n){return this.logCallbacks.add(n),()=>this.logCallbacks.delete(n)}onConnectionChange(n){return this.connectionCallbacks.add(n),n(this.isConnected),()=>this.connectionCallbacks.delete(n)}notifyLog(n){if(!this.logCache.some(c=>c.id===n.id)){this.logCache.push(n);const c=this.getMaxCacheSize();this.logCache.length>c&&(this.logCache=this.logCache.slice(-c)),this.logCallbacks.forEach(u=>{try{u(n)}catch(m){console.error("日志回调执行失败:",m)}})}}notifyConnection(n){this.connectionCallbacks.forEach(i=>{try{i(n)}catch(c){console.error("连接状态回调执行失败:",c)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const _n=new e2;typeof window<"u"&&setTimeout(()=>{_n.connect()},100);const Hs=Y0,Bo=X0,s2=K0,qj=x.forwardRef(({className:l,...n},i)=>e.jsx(qg,{ref:i,className:L("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",l),...n}));qj.displayName=qg.displayName;const Os=x.forwardRef(({className:l,children:n,preventOutsideClose:i=!1,...c},u)=>e.jsxs(s2,{children:[e.jsx(qj,{}),e.jsxs(Vg,{ref:u,className:L("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",l),onPointerDownOutside:i?m=>m.preventDefault():void 0,onInteractOutside:i?m=>m.preventDefault():void 0,...c,children:[n,e.jsxs(Q0,{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(Ja,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Os.displayName=Vg.displayName;const Rs=({className:l,...n})=>e.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",l),...n});Rs.displayName="DialogHeader";const nt=({className:l,...n})=>e.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",l),...n});nt.displayName="DialogFooter";const Ls=x.forwardRef(({className:l,...n},i)=>e.jsx(Fg,{ref:i,className:L("text-lg font-semibold leading-none tracking-tight",l),...n}));Ls.displayName=Fg.displayName;const Ws=x.forwardRef(({className:l,...n},i)=>e.jsx(Kg,{ref:i,className:L("text-sm text-muted-foreground",l),...n}));Ws.displayName=Kg.displayName;const js=m0,pt=x0,t2=u0,Vj=x.forwardRef(({className:l,...n},i)=>e.jsx(Tg,{className:L("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",l),...n,ref:i}));Vj.displayName=Tg.displayName;const ds=x.forwardRef(({className:l,...n},i)=>e.jsxs(t2,{children:[e.jsx(Vj,{}),e.jsx(Eg,{ref:i,className:L("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",l),...n})]}));ds.displayName=Eg.displayName;const us=({className:l,...n})=>e.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",l),...n});us.displayName="AlertDialogHeader";const ms=({className:l,...n})=>e.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",l),...n});ms.displayName="AlertDialogFooter";const xs=x.forwardRef(({className:l,...n},i)=>e.jsx(Mg,{ref:i,className:L("text-lg font-semibold",l),...n}));xs.displayName=Mg.displayName;const hs=x.forwardRef(({className:l,...n},i)=>e.jsx(Ag,{ref:i,className:L("text-sm text-muted-foreground",l),...n}));hs.displayName=Ag.displayName;const fs=x.forwardRef(({className:l,...n},i)=>e.jsx(zg,{ref:i,className:L(Er(),l),...n}));fs.displayName=zg.displayName;const ps=x.forwardRef(({className:l,...n},i)=>e.jsx(Dg,{ref:i,className:L(Er({variant:"outline"}),"mt-2 sm:mt-0",l),...n}));ps.displayName=Dg.displayName;function a2(){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(ma,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(ss,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Nw,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(ss,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(bw,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(ss,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Dn,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(ss,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Qt,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(Xe,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Ss,{value:"appearance",className:"mt-0",children:e.jsx(l2,{})}),e.jsx(Ss,{value:"security",className:"mt-0",children:e.jsx(n2,{})}),e.jsx(Ss,{value:"other",className:"mt-0",children:e.jsx(r2,{})}),e.jsx(Ss,{value:"about",className:"mt-0",children:e.jsx(i2,{})})]})]})]})}function eg(l){const n=document.documentElement,c={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%)"}}[l];if(c)n.style.setProperty("--primary",c.hsl),c.gradient?(n.style.setProperty("--primary-gradient",c.gradient),n.classList.add("has-gradient")):(n.style.removeProperty("--primary-gradient"),n.classList.remove("has-gradient"));else if(l.startsWith("#")){const u=m=>{m=m.replace("#","");const h=parseInt(m.substring(0,2),16)/255,f=parseInt(m.substring(2,4),16)/255,p=parseInt(m.substring(4,6),16)/255,j=Math.max(h,f,p),v=Math.min(h,f,p);let N=0,b=0;const S=(j+v)/2;if(j!==v){const w=j-v;switch(b=S>.5?w/(2-j-v):w/(j+v),j){case h:N=((f-p)/w+(f<p?6:0))/6;break;case f:N=((p-h)/w+2)/6;break;case p:N=((h-f)/w+4)/6;break}}return`${Math.round(N*360)} ${Math.round(b*100)}% ${Math.round(S*100)}%`};n.style.setProperty("--primary",u(l)),n.style.removeProperty("--primary-gradient"),n.classList.remove("has-gradient")}}function l2(){const{theme:l,setTheme:n}=Um(),{enableAnimations:i,setEnableAnimations:c,enableWavesBackground:u,setEnableWavesBackground:m}=Pj(),[h,f]=x.useState(()=>localStorage.getItem("accent-color")||"blue");x.useEffect(()=>{const j=localStorage.getItem("accent-color")||"blue";eg(j)},[]);const p=j=>{f(j),localStorage.setItem("accent-color",j),eg(j)};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(xm,{value:"light",current:l,onChange:n,label:"浅色",description:"始终使用浅色主题"}),e.jsx(xm,{value:"dark",current:l,onChange:n,label:"深色",description:"始终使用深色主题"}),e.jsx(xm,{value:"system",current:l,onChange:n,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(Oa,{value:"blue",current:h,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(Oa,{value:"purple",current:h,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(Oa,{value:"green",current:h,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(Oa,{value:"orange",current:h,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(Oa,{value:"pink",current:h,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(Oa,{value:"red",current:h,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(Oa,{value:"gradient-sunset",current:h,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(Oa,{value:"gradient-ocean",current:h,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(Oa,{value:"gradient-forest",current:h,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(Oa,{value:"gradient-aurora",current:h,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(Oa,{value:"gradient-fire",current:h,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(Oa,{value:"gradient-twilight",current:h,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:h.startsWith("#")?h:"#3b82f6",onChange:j=>p(j.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:h,onChange:j=>p(j.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(k,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Fe,{id:"animations",checked:i,onCheckedChange:c})]})}),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(k,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Fe,{id:"waves-background",checked:u,onCheckedChange:m})]})})]})]})]})}function n2(){const l=xa(),[n,i]=x.useState(""),[c,u]=x.useState(""),[m,h]=x.useState(!1),[f,p]=x.useState(!1),[j,v]=x.useState(!1),[N,b]=x.useState(!1),[S,w]=x.useState(!1),[O,M]=x.useState(!1),[D,$]=x.useState(""),[E,_]=x.useState(!1),{toast:T}=et(),P=x.useMemo(()=>V1(c),[c]),A=async de=>{if(!n){T({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(de),w(!0),T({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>w(!1),2e3)}catch{T({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},ee=async()=>{if(!c.trim()){T({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!P.isValid){const de=P.rules.filter(ge=>!ge.passed).map(ge=>ge.label).join(", ");T({title:"格式错误",description:`Token 不符合要求: ${de}`,variant:"destructive"});return}v(!0);try{const de=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:c.trim()})}),ge=await de.json();de.ok&&ge.success?(u(""),i(c.trim()),T({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{l({to:"/auth"})},1500)):T({title:"更新失败",description:ge.message||"无法更新 Token",variant:"destructive"})}catch(de){console.error("更新 Token 错误:",de),T({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{v(!1)}},H=async()=>{b(!0);try{const de=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),ge=await de.json();de.ok&&ge.success?(i(ge.token),$(ge.token),M(!0),_(!1),T({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):T({title:"生成失败",description:ge.message||"无法生成新 Token",variant:"destructive"})}catch(de){console.error("生成 Token 错误:",de),T({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{b(!1)}},Z=async()=>{try{await navigator.clipboard.writeText(D),_(!0),T({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{T({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},re=()=>{M(!1),setTimeout(()=>{$(""),_(!1)},300),setTimeout(()=>{l({to:"/auth"})},500)},ye=de=>{de||re()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Hs,{open:O,onOpenChange:ye,children:e.jsxs(Os,{className:"sm:max-w-md",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(oa,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Ws,{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(k,{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:D})]}),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(oa,{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(nt,{className:"gap-2 sm:gap-0",children:[e.jsx(C,{variant:"outline",onClick:Z,className:"gap-2",children:E?e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(_o,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(C,{onClick:re,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(k,{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:m?"text":"password",value:n||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{n?h(!m):T({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:m?"隐藏":"显示",children:m?e.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Yt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(C,{variant:"outline",size:"icon",onClick:()=>A(n),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!n,children:S?e.jsx(yt,{className:"h-4 w-4 text-green-500"}):e.jsx(_o,{className:"h-4 w-4"})}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"outline",disabled:N,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(At,{className:L("h-4 w-4",N&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重新生成 Token"}),e.jsx(hs,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:H,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(k,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"new-token",type:f?"text":"password",value:c,onChange:de=>u(de.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!f),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:f?"隐藏":"显示",children:f?e.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Yt,{className:"h-4 w-4 text-muted-foreground"})})]}),c&&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:P.rules.map(de=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[de.passed?e.jsx(ua,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(dj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:L(de.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:de.label})]},de.id))}),P.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(yt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(C,{onClick:ee,disabled:j||!P.isValid||!c,className:"w-full sm:w-auto",children:j?"更新中...":"更新自定义 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 r2(){const l=xa(),{toast:n}=et(),[i,c]=x.useState(!1),[u,m]=x.useState(!1),[h,f]=x.useState(()=>ht("logCacheSize")),[p,j]=x.useState(()=>ht("wsReconnectInterval")),[v,N]=x.useState(()=>ht("wsMaxReconnectAttempts")),[b,S]=x.useState(()=>ht("dataSyncInterval")),[w,O]=x.useState(()=>Wp()),[M,D]=x.useState(!1),[$,E]=x.useState(!1),_=x.useRef(null);if(u)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const T=()=>{O(Wp())},P=z=>{const Q=z[0];f(Q),_r("logCacheSize",Q)},A=z=>{const Q=z[0];j(Q),_r("wsReconnectInterval",Q)},ee=z=>{const Q=z[0];N(Q),_r("wsMaxReconnectAttempts",Q)},H=z=>{const Q=z[0];S(Q),_r("dataSyncInterval",Q)},Z=()=>{_n.clearLogs(),n({title:"日志已清除",description:"日志缓存已清空"})},re=()=>{const z=Z1();T(),n({title:"缓存已清除",description:`已清除 ${z.clearedKeys.length} 项缓存数据`})},ye=()=>{D(!0);try{const z=Y1(),Q=JSON.stringify(z,null,2),J=new Blob([Q],{type:"application/json"}),U=URL.createObjectURL(J),G=document.createElement("a");G.href=U,G.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(U),n({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(z){console.error("导出设置失败:",z),n({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{D(!1)}},de=z=>{const Q=z.target.files?.[0];if(!Q)return;E(!0);const J=new FileReader;J.onload=U=>{try{const G=U.target?.result,Ce=JSON.parse(G),be=X1(Ce);be.success?(f(ht("logCacheSize")),j(ht("wsReconnectInterval")),N(ht("wsMaxReconnectAttempts")),S(ht("dataSyncInterval")),T(),n({title:"导入成功",description:`成功导入 ${be.imported.length} 项设置${be.skipped.length>0?`,跳过 ${be.skipped.length}`:""}`}),(be.imported.includes("theme")||be.imported.includes("accentColor"))&&n({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):n({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(G){console.error("导入设置失败:",G),n({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{E(!1),_.current&&(_.current.value="")}},J.readAsText(Q)},ge=()=>{J1(),f(Xa.logCacheSize),j(Xa.wsReconnectInterval),N(Xa.wsMaxReconnectAttempts),S(Xa.dataSyncInterval),T(),n({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},je=async()=>{c(!0);try{const z=await Se("/api/webui/setup/reset",{method:"POST"}),Q=await z.json();z.ok&&Q.success?(n({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{l({to:"/setup"})},1e3)):n({title:"重置失败",description:Q.message||"无法重置配置状态",variant:"destructive"})}catch(z){console.error("重置配置状态错误:",z),n({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{c(!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(wo,{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(yw,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:T,className:"h-7 px-2",children:e.jsx(At,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:W1(w.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[w.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h," 条"]})]}),e.jsx(ya,{value:[h],onValueChange:P,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(k,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[b," 秒"]})]}),e.jsx(ya,{value:[b],onValueChange:H,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(k,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[p/1e3," 秒"]})]}),e.jsx(ya,{value:[p],onValueChange:A,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(k,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[v," 次"]})]}),e.jsx(ya,{value:[v],onValueChange:ee,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(C,{variant:"outline",size:"sm",onClick:Z,className:"gap-2",children:[e.jsx(rs,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(rs,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认清除本地缓存"}),e.jsx(hs,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:re,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(Kt,{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(C,{variant:"outline",onClick:ye,disabled:M,className:"gap-2",children:[e.jsx(Kt,{className:"h-4 w-4"}),M?"导出中...":"导出设置"]}),e.jsx("input",{ref:_,type:"file",accept:".json",onChange:de,className:"hidden"}),e.jsxs(C,{variant:"outline",onClick:()=>_.current?.click(),disabled:$,className:"gap-2",children:[e.jsx(Bi,{className:"h-4 w-4"}),$?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Li,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重置所有设置"}),e.jsx(hs,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:ge,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(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"outline",disabled:i,className:"gap-2",children:[e.jsx(Li,{className:L("h-4 w-4",i&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重新配置"}),e.jsx(hs,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:je,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(oa,{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(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"destructive",className:"gap-2",children:[e.jsx(oa,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认触发错误"}),e.jsx(hs,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>m(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function i2(){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:L("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:["关于 ",Bm]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Uo]}),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(Xe,{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(ct,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(ct,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(ct,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(ct,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(ct,{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(ct,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(ct,{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(ct,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(ct,{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(ct,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(ct,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(ct,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(ct,{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(ct,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(ct,{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(ct,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(ct,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(ct,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(ct,{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(ct,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(ct,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(ct,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(ct,{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 ct({name:l,description:n,license:i}){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:l}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:n})]}),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:i})]})}function xm({value:l,current:n,onChange:i,label:c,description:u}){const m=n===l;return e.jsxs("button",{onClick:()=>i(l),className:L("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",m?"border-primary bg-accent":"border-border"),children:[m&&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:c}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:u})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[l==="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"})]}),l==="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"})]}),l==="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 Oa({value:l,current:n,onChange:i,label:c,colorClass:u}){const m=n===l;return e.jsxs("button",{onClick:()=>i(l),className:L("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",m?"border-primary bg-accent":"border-border"),children:[m&&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:L("h-8 w-8 sm:h-10 sm:w-10 rounded-full",u)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:c})]})]})}class c2{grad3;p;perm;constructor(n=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 i=0;i<256;i++)this.p[i]=Math.floor(Math.random()*256);this.perm=[];for(let i=0;i<512;i++)this.perm[i]=this.p[i&255]}dot(n,i,c){return n[0]*i+n[1]*c}mix(n,i,c){return(1-c)*n+c*i}fade(n){return n*n*n*(n*(n*6-15)+10)}perlin2(n,i){const c=Math.floor(n)&255,u=Math.floor(i)&255;n-=Math.floor(n),i-=Math.floor(i);const m=this.fade(n),h=this.fade(i),f=this.perm[c]+u,p=this.perm[f],j=this.perm[f+1],v=this.perm[c+1]+u,N=this.perm[v],b=this.perm[v+1];return this.mix(this.mix(this.dot(this.grad3[p%12],n,i),this.dot(this.grad3[N%12],n-1,i),m),this.mix(this.dot(this.grad3[j%12],n,i-1),this.dot(this.grad3[b%12],n-1,i-1),m),h)}}function sg(){const l=x.useRef(null),n=x.useRef(null),i=x.useRef(void 0),c=x.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 c2(Math.random()),bounding:null});return x.useEffect(()=>{const u=n.current,m=l.current;if(!u||!m)return;const h=c.current,f=()=>{const O=u.getBoundingClientRect();h.bounding=O,m.style.width=`${O.width}px`,m.style.height=`${O.height}px`},p=()=>{if(!h.bounding)return;const{width:O,height:M}=h.bounding;h.lines=[],h.paths.forEach(H=>H.remove()),h.paths=[];const D=10,$=32,E=O+200,_=M+30,T=Math.ceil(E/D),P=Math.ceil(_/$),A=(O-D*T)/2,ee=(M-$*P)/2;for(let H=0;H<=T;H++){const Z=[];for(let ye=0;ye<=P;ye++){const de={x:A+D*H,y:ee+$*ye,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};Z.push(de)}const re=document.createElementNS("http://www.w3.org/2000/svg","path");m.appendChild(re),h.paths.push(re),h.lines.push(Z)}},j=O=>{const{lines:M,mouse:D,noise:$}=h;M.forEach(E=>{E.forEach(_=>{const T=$.perlin2((_.x+O*.0125)*.002,(_.y+O*.005)*.0015)*12;_.wave.x=Math.cos(T)*32,_.wave.y=Math.sin(T)*16;const P=_.x-D.sx,A=_.y-D.sy,ee=Math.hypot(P,A),H=Math.max(175,D.vs);if(ee<H){const Z=1-ee/H,re=Math.cos(ee*.001)*Z;_.cursor.vx+=Math.cos(D.a)*re*H*D.vs*65e-5,_.cursor.vy+=Math.sin(D.a)*re*H*D.vs*65e-5}_.cursor.vx+=(0-_.cursor.x)*.005,_.cursor.vy+=(0-_.cursor.y)*.005,_.cursor.vx*=.925,_.cursor.vy*=.925,_.cursor.x+=_.cursor.vx*2,_.cursor.y+=_.cursor.vy*2,_.cursor.x=Math.min(100,Math.max(-100,_.cursor.x)),_.cursor.y=Math.min(100,Math.max(-100,_.cursor.y))})})},v=(O,M=!0)=>{const D={x:O.x+O.wave.x+(M?O.cursor.x:0),y:O.y+O.wave.y+(M?O.cursor.y:0)};return D.x=Math.round(D.x*10)/10,D.y=Math.round(D.y*10)/10,D},N=()=>{const{lines:O,paths:M}=h;O.forEach((D,$)=>{let E=v(D[0],!1),_=`M ${E.x} ${E.y}`;D.forEach((T,P)=>{const A=P===D.length-1;E=v(T,!A),_+=`L ${E.x} ${E.y}`}),M[$].setAttribute("d",_)})},b=O=>{const{mouse:M}=h;M.sx+=(M.x-M.sx)*.1,M.sy+=(M.y-M.sy)*.1;const D=M.x-M.lx,$=M.y-M.ly,E=Math.hypot(D,$);M.v=E,M.vs+=(E-M.vs)*.1,M.vs=Math.min(100,M.vs),M.lx=M.x,M.ly=M.y,M.a=Math.atan2($,D),u&&(u.style.setProperty("--x",`${M.sx}px`),u.style.setProperty("--y",`${M.sy}px`)),j(O),N(),i.current=requestAnimationFrame(b)},S=O=>{if(!h.bounding)return;const{mouse:M}=h;M.x=O.pageX-h.bounding.left,M.y=O.pageY-h.bounding.top+window.scrollY,M.set||(M.sx=M.x,M.sy=M.y,M.lx=M.x,M.ly=M.y,M.set=!0)},w=()=>{f(),p()};return f(),p(),window.addEventListener("resize",w),window.addEventListener("mousemove",S),i.current=requestAnimationFrame(b),()=>{window.removeEventListener("resize",w),window.removeEventListener("mousemove",S),i.current&&cancelAnimationFrame(i.current)}},[]),e.jsxs("div",{ref:n,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:l,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 o2(){const[l,n]=x.useState(""),[i,c]=x.useState(!1),[u,m]=x.useState(""),[h,f]=x.useState(!0),p=xa(),{enableWavesBackground:j,setEnableWavesBackground:v}=Pj(),{theme:N,setTheme:b}=Um();x.useEffect(()=>{(async()=>{try{await $i()&&p({to:"/"})}catch{}finally{f(!1)}})()},[p]);const w=N==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":N,O=()=>{b(w==="dark"?"light":"dark")},M=async D=>{if(D.preventDefault(),m(""),!l.trim()){m("请输入 Access Token");return}c(!0),console.log("开始验证 token...");try{const $=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:l.trim()})});console.log("Token 验证响应状态:",$.status);const E=await $.json();if(console.log("Token 验证响应数据:",E),$.ok&&E.valid){console.log("Token 验证成功,准备跳转..."),console.log("is_first_setup:",E.is_first_setup),await new Promise(T=>setTimeout(T,100));const _=await $i();console.log("跳转前认证状态检查:",_),E.is_first_setup?(console.log("跳转到首次配置页面"),p({to:"/setup"})):(console.log("跳转到首页"),p({to:"/"}))}else console.error("Token 验证失败:",E.message),m(E.message||"Token 验证失败,请检查后重试")}catch($){console.error("Token 验证错误:",$),m("连接服务器失败,请检查网络连接")}finally{c(!1)}};return h?e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[j&&e.jsx(sg,{}),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:[j&&e.jsx(sg,{}),e.jsxs(Oe,{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:O,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:w==="dark"?"切换到浅色模式":"切换到深色模式",children:w==="dark"?e.jsx(uj,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(mj,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(ts,{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(Ip,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ns,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(Qs,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(We,{children:e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(zm,{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:l,onChange:D=>n(D.target.value),className:L("pl-10",u&&"border-red-500 focus-visible:ring-red-500"),disabled:i,autoFocus:!0,autoComplete:"off"})]})]}),u&&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(Ut,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:u})]}),e.jsx(C,{type:"submit",className:"w-full",disabled:i,children:i?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(Hs,{children:[e.jsx(Bo,{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(xj,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token我该去哪里获得 Token"]})}),e.jsxs(Os,{className:"sm:max-w-md",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(Ip,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx(Ws,{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(ww,{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(Ga,{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(Ut,{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(js,{children:[e.jsx(pt,{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(Cn,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsxs(xs,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(hs,{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(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{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:F1})})]})}const Ys=x.forwardRef(({className:l,...n},i)=>e.jsx("textarea",{className:L("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",l),ref:i,...n}));Ys.displayName="Textarea";const Dr=x.forwardRef(({className:l,orientation:n="horizontal",decorative:i=!0,...c},u)=>e.jsx(Og,{ref:u,decorative:i,orientation:n,className:L("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",l),...c}));Dr.displayName=Og.displayName;function d2({config:l,onChange:n}){const i=u=>{u.trim()&&!l.alias_names.includes(u.trim())&&n({...l,alias_names:[...l.alias_names,u.trim()]})},c=u=>{n({...l,alias_names:l.alias_names.filter((m,h)=>h!==u)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(ce,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:l.qq_account||"",onChange:u=>n({...l,qq_account:Number(u.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(ce,{id:"nickname",placeholder:"请输入机器人的昵称",value:l.nickname,onChange:u=>n({...l,nickname:u.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.alias_names.map((u,m)=>e.jsxs(Ae,{variant:"secondary",className:"gap-1",children:[u,e.jsx("button",{type:"button",onClick:()=>c(m),className:"ml-1 hover:text-destructive",children:e.jsx(Ja,{className:"h-3 w-3"})})]},m))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:u=>{u.key==="Enter"&&(i(u.target.value),u.target.value="")}}),e.jsx(C,{type:"button",variant:"outline",onClick:()=>{const u=document.getElementById("alias_input");u&&(i(u.value),u.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function u2({config:l,onChange:n}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(Ys,{id:"personality",placeholder:"描述机器人的人格特质和身份特征建议120字以内",value:l.personality,onChange:i=>n({...l,personality:i.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:是一个女大学生,现在在读大二,会刷贴吧"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(Ys,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:l.reply_style,onChange:i=>n({...l,reply_style:i.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:回复平淡一些,简短一些,说中文,参考贴吧、知乎和微博的回复风格"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(Ys,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:l.interest,onChange:i=>n({...l,interest:i.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(Dr,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(Ys,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:l.plan_style,onChange:i=>n({...l,plan_style:i.target.value}),rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在群聊中如何行动,例如回复频率、条件等"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(Ys,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:l.private_plan_style,onChange:i=>n({...l,private_plan_style:i.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function m2({config:l,onChange:n}){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(k,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(l.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ce,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:l.emoji_chance,onChange:i=>n({...l,emoji_chance:Number(i.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人发送表情包的概率"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",max:"200",value:l.max_reg_num,onChange:i=>n({...l,max_reg_num:Number(i.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(k,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(Fe,{id:"do_replace",checked:l.do_replace,onCheckedChange:i=>n({...l,do_replace:i})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",max:"120",value:l.check_interval,onChange:i=>n({...l,check_interval:Number(i.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(Dr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(Fe,{id:"steal_emoji",checked:l.steal_emoji,onCheckedChange:i=>n({...l,steal_emoji:i})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(Fe,{id:"content_filtration",checked:l.content_filtration,onCheckedChange:i=>n({...l,content_filtration:i})})]}),l.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:l.filtration_prompt,onChange:i=>n({...l,filtration_prompt:i.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function x2({config:l,onChange:n}){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(k,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(Fe,{id:"enable_tool",checked:l.enable_tool,onCheckedChange:i=>n({...l,enable_tool:i})})]}),e.jsx(Dr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(Fe,{id:"all_global",checked:l.all_global,onCheckedChange:i=>n({...l,all_global:i})})]})]})}function h2({config:l,onChange:n}){const[i,c]=x.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(jo,{className:"h-3 w-3"})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{htmlFor:"siliconflow_api_key",children:"SiliconFlow API Key *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{id:"siliconflow_api_key",type:i?"text":"password",placeholder:"sk-...",value:l.api_key,onChange:u=>n({api_key:u.target.value}),className:"font-mono pr-10"}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>c(!i),children:i?e.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Yt,{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 f2(){const l=await Se("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取Bot配置失败");const i=(await l.json()).config.bot||{};return{qq_account:i.qq_account||0,nickname:i.nickname||"",alias_names:i.alias_names||[]}}async function p2(){const l=await Se("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取人格配置失败");const i=(await l.json()).config.personality||{};return{personality:i.personality||"",reply_style:i.reply_style||"",interest:i.interest||"",plan_style:i.plan_style||"",private_plan_style:i.private_plan_style||""}}async function g2(){const l=await Se("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取表情包配置失败");const i=(await l.json()).config.emoji||{};return{emoji_chance:i.emoji_chance??.4,max_reg_num:i.max_reg_num??40,do_replace:i.do_replace??!0,check_interval:i.check_interval??10,steal_emoji:i.steal_emoji??!0,content_filtration:i.content_filtration??!1,filtration_prompt:i.filtration_prompt||""}}async function j2(){const l=await Se("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取其他配置失败");const i=(await l.json()).config,c=i.tool||{},u=i.expression||{};return{enable_tool:c.enable_tool??!0,all_global:u.all_global_jargon??!0}}async function v2(){const l=await Se("/api/webui/config/model",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取模型配置失败");return{api_key:((await l.json()).config.api_providers||[]).find(m=>m.name==="SiliconFlow")?.api_key||""}}async function N2(l){const n=await Se("/api/webui/config/bot/section/bot",{method:"POST",headers:Zs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存Bot基础配置失败")}return await n.json()}async function b2(l){const n=await Se("/api/webui/config/bot/section/personality",{method:"POST",headers:Zs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存人格配置失败")}return await n.json()}async function y2(l){const n=await Se("/api/webui/config/bot/section/emoji",{method:"POST",headers:Zs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存表情包配置失败")}return await n.json()}async function w2(l){const n=[];n.push(Se("/api/webui/config/bot/section/tool",{method:"POST",headers:Zs(),body:JSON.stringify({enable_tool:l.enable_tool})})),n.push(Se("/api/webui/config/bot/section/expression",{method:"POST",headers:Zs(),body:JSON.stringify({all_global_jargon:l.all_global})}));const i=await Promise.all(n);for(const c of i)if(!c.ok){const u=await c.json();throw new Error(u.detail||"保存其他配置失败")}return{success:!0}}async function _2(l){const n=await Se("/api/webui/config/model",{method:"GET",headers:Zs()});if(!n.ok)throw new Error("读取模型配置失败");const c=(await n.json()).config,u=c.api_providers||[],m=u.findIndex(p=>p.name==="SiliconFlow");m>=0?u[m]={...u[m],api_key:l.api_key}:u.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:l.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const h={...c,api_providers:u},f=await Se("/api/webui/config/model",{method:"POST",headers:Zs(),body:JSON.stringify(h)});if(!f.ok){const p=await f.json();throw new Error(p.detail||"保存模型配置失败")}return await f.json()}async function tg(){const l=await Se("/api/webui/setup/complete",{method:"POST"});if(!l.ok){const n=await l.json();throw new Error(n.message||"标记配置完成失败")}return await l.json()}function S2(){return e.jsx(On,{children:e.jsx(C2,{})})}function C2(){const l=xa(),{toast:n}=et(),{triggerRestart:i}=tn(),[c,u]=x.useState(0),[m,h]=x.useState(!1),[f,p]=x.useState(!1),[j,v]=x.useState(!0),[N,b]=x.useState({qq_account:0,nickname:"",alias_names:[]}),[S,w]=x.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.请控制你的发言频率,不要太过频繁的发言
4.如果有人对你感到厌烦,请减少回复
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.某句话如果已经被回复过,不要重复回复`}),[O,M]=x.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[D,$]=x.useState({enable_tool:!0,all_global:!0}),[E,_]=x.useState({api_key:""}),T=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:Ei},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:Cr},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:Dm},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:Dn},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:zm}],P=(c+1)/T.length*100;x.useEffect(()=>{(async()=>{try{v(!0);const[ge,je,z,Q,J]=await Promise.all([f2(),p2(),g2(),j2(),v2()]);b(ge),w(je),M(z),$(Q),_(J)}catch(ge){n({title:"加载配置失败",description:ge instanceof Error?ge.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{v(!1)}})()},[n]);const A=async()=>{p(!0);try{switch(c){case 0:await N2(N);break;case 1:await b2(S);break;case 2:await y2(O);break;case 3:await w2(D);break;case 4:await _2(E);break}return n({title:"保存成功",description:`${T[c].title}配置已保存`}),!0}catch(de){return n({title:"保存失败",description:de instanceof Error?de.message:"未知错误",variant:"destructive"}),!1}finally{p(!1)}},ee=async()=>{await A()&&c<T.length-1&&u(c+1)},H=()=>{c>0&&u(c-1)},Z=async()=>{h(!0);try{if(!await A()){h(!1);return}await tg(),n({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),await i()}catch(de){n({title:"配置失败",description:de instanceof Error?de.message:"未知错误",variant:"destructive"})}finally{h(!1)}},re=async()=>{try{await tg(),l({to:"/"})}catch(de){n({title:"跳过失败",description:de instanceof Error?de.message:"未知错误",variant:"destructive"})}},ye=()=>{switch(c){case 0:return e.jsx(d2,{config:N,onChange:b});case 1:return e.jsx(u2,{config:S,onChange:w});case 2:return e.jsx(m2,{config:O,onChange:M});case 3:return e.jsx(x2,{config:D,onChange:$});case 4:return e.jsx(h2,{config:E,onChange:_});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.jsx(Rn,{}),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"})]}),j?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(_w,{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:["让我们一起完成 ",Bm," 的初始配置"]})]}),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," / ",T.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(P),"%"]})]}),e.jsx(An,{value:P,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:T.map((de,ge)=>{const je=de.icon;return e.jsxs("div",{className:L("flex flex-1 flex-col items-center gap-1 md:gap-2",ge<T.length-1&&"relative"),children:[ge<T.length-1&&e.jsx("div",{className:L("absolute left-1/2 top-3 md:top-4 h-0.5 w-full",ge<c?"bg-primary":"bg-border")}),e.jsx("div",{className:L("relative z-10 flex h-6 w-6 md:h-8 md:w-8 items-center justify-center rounded-full border-2 transition-all",ge===c||ge<c?"border-primary bg-primary text-primary-foreground":"border-border bg-background text-muted-foreground"),children:ge<c?e.jsx(ua,{className:"h-3 w-3 md:h-4 md:w-4",strokeWidth:2.5,fill:"none"}):e.jsx(je,{className:"h-3 w-3 md:h-4 md:w-4"})}),e.jsx("span",{className:L("text-[10px] md:text-xs text-center max-w-[60px] md:max-w-none truncate md:whitespace-normal",ge===c?"font-medium text-foreground":"text-muted-foreground"),title:de.title,children:de.title})]},de.id)})}),e.jsx(Oe,{className:"mb-6 md:mb-8 shadow-lg",children:e.jsx(We,{className:"p-4 md:p-8",children:e.jsxs("div",{className:"min-h-[300px] md:min-h-[400px]",children:[e.jsxs("div",{className:"mb-4 md:mb-6",children:[e.jsx("h2",{className:"mb-2 text-xl md:text-2xl font-semibold",children:T[c].title}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:T[c].description})]}),e.jsx(Xe,{className:"h-[400px] md:h-[500px]",children:e.jsx("div",{className:"pr-2",children:ye()})})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 sm:gap-0",children:[e.jsx(C,{variant:"outline",onClick:H,disabled:c===0||f,className:"w-full sm:w-auto order-2 sm:order-1",children:"上一步"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto order-1 sm:order-2",children:[e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{variant:"ghost",className:"flex-1 sm:flex-none gap-2",disabled:f||m,children:[e.jsx(Sw,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"跳过向导"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认跳过配置向导"}),e.jsx(hs,{children:"您可以随时在系统设置中重新进入配置向导。确定要跳过吗?"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:re,children:"确认跳过"})]})]})]}),c===T.length-1?e.jsx(C,{onClick:Z,disabled:m||f,className:"flex-1 sm:flex-none",children:m||f?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"}),f?"保存中...":"完成中..."]}):e.jsxs(e.Fragment,{children:["完成配置",e.jsx(ua,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})}):e.jsx(C,{onClick:ee,disabled:f,className:"flex-1 sm:flex-none",children:f?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(e.Fragment,{children:["下一步",e.jsx(Cw,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})})]})]})]}),e.jsx("div",{className:"relative z-10 mt-6 md:mt-8 text-center text-xs text-muted-foreground",children:e.jsx("p",{children:"您可以随时在设置中修改这些配置"})})]})]})}function Fj(){const l=xa();return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("h1",{className:"text-[150px] font-black leading-none text-primary/10 select-none sm:text-[200px]",children:"404"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(Vt,{className:"h-20 w-20 text-primary/30 sm:h-24 sm:w-24"})})]}),e.jsxs("div",{className:"space-y-4 mb-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground sm:text-3xl",children:"页面未找到"}),e.jsx("p",{className:"text-base text-muted-foreground sm:text-lg max-w-md mx-auto",children:"抱歉,您访问的页面不存在或已被移除。请检查 URL 是否正确,或返回首页继续浏览。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs(C,{size:"lg",onClick:()=>l({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(Ro,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(C,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx(sn,{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 k2=Ms.memo(function({config:n,onChange:i}){const c=()=>{i({...n,platforms:[...n.platforms,""]})},u=j=>{i({...n,platforms:n.platforms.filter((v,N)=>N!==j)})},m=(j,v)=>{const N=[...n.platforms];N[j]=v,i({...n,platforms:N})},h=()=>{i({...n,alias_names:[...n.alias_names,""]})},f=j=>{i({...n,alias_names:n.alias_names.filter((v,N)=>N!==j)})},p=(j,v)=>{const N=[...n.alias_names];N[j]=v,i({...n,alias_names:N})};return e.jsx("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 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"platform",children:"平台"}),e.jsx(ce,{id:"platform",value:n.platform,onChange:j=>i({...n,platform:j.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ce,{id:"qq_account",value:n.qq_account,onChange:j=>i({...n,qq_account:j.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:n.nickname,onChange:j=>i({...n,nickname:j.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{children:"其他平台账号"}),e.jsxs(C,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.platforms.map((j,v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:j,onChange:N=>m(v,N.target.value),placeholder:"wx:114514"}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除平台账号 "',j||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>u(v),children:"删除"})]})]})]})]},v)),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(k,{children:"别名"}),e.jsxs(C,{onClick:h,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[n.alias_names.map((j,v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:j,onChange:N=>p(v,N.target.value),placeholder:"小麦"}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除别名 "',j||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>f(v),children:"删除"})]})]})]})]},v)),n.alias_names.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无别名"})]})]})]})]})})}),T2=Ms.memo(function({config:n,onChange:i}){const c=()=>{i({...n,states:[...n.states,""]})},u=h=>{i({...n,states:n.states.filter((f,p)=>p!==h)})},m=(h,f)=>{const p=[...n.states];p[h]=f,i({...n,states:p})};return e.jsx("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 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"personality",children:"人格特质"}),e.jsx(Ys,{id:"personality",value:n.personality,onChange:h=>i({...n,personality:h.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(k,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(Ys,{id:"reply_style",value:n.reply_style,onChange:h=>i({...n,reply_style:h.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"interest",children:"兴趣"}),e.jsx(Ys,{id:"interest",value:n.interest,onChange:h=>i({...n,interest:h.target.value}),placeholder:"会影响麦麦对什么话题进行回复",rows:2})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(Ys,{id:"plan_style",value:n.plan_style,onChange:h=>i({...n,plan_style:h.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(Ys,{id:"visual_style",value:n.visual_style,onChange:h=>i({...n,visual_style:h.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(Ys,{id:"private_plan_style",value:n.private_plan_style,onChange:h=>i({...n,private_plan_style:h.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(k,{children:"状态列表(人格多样性)"}),e.jsxs(C,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加状态"]})]}),e.jsx("div",{className:"space-y-2",children:n.states.map((h,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ys,{value:h,onChange:p=>m(f,p.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsx(hs,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>u(f),children:"删除"})]})]})]})]},f))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"state_probability",children:"状态替换概率"}),e.jsx(ce,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:n.state_probability,onChange:h=>i({...n,state_probability:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时替换 personality 的概率0.0-1.0"})]})]})]})})}),$e=tw,He=aw,Le=x.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(Qg,{ref:c,className:L("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",l),...i,children:[n,e.jsx(J0,{asChild:!0,children:e.jsx(Ra,{className:"h-4 w-4 opacity-50"})})]}));Le.displayName=Qg.displayName;const Kj=x.forwardRef(({className:l,...n},i)=>e.jsx(Yg,{ref:i,className:L("flex cursor-default items-center justify-center py-1",l),...n,children:e.jsx(kr,{className:"h-4 w-4"})}));Kj.displayName=Yg.displayName;const Qj=x.forwardRef(({className:l,...n},i)=>e.jsx(Xg,{ref:i,className:L("flex cursor-default items-center justify-center py-1",l),...n,children:e.jsx(Ra,{className:"h-4 w-4"})}));Qj.displayName=Xg.displayName;const Ue=x.forwardRef(({className:l,children:n,position:i="popper",...c},u)=>e.jsx(Z0,{children:e.jsxs(Jg,{ref:u,className:L("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]",i==="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",l),position:i,...c,children:[e.jsx(Kj,{}),e.jsx(W0,{className:L("p-1",i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Qj,{})]})}));Ue.displayName=Jg.displayName;const E2=x.forwardRef(({className:l,...n},i)=>e.jsx(Zg,{ref:i,className:L("px-2 py-1.5 text-sm font-semibold",l),...n}));E2.displayName=Zg.displayName;const le=x.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(Wg,{ref:c,className:L("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",l),...i,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ew,{children:e.jsx(yt,{className:"h-4 w-4"})})}),e.jsx(sw,{children:n})]}));le.displayName=Wg.displayName;const M2=x.forwardRef(({className:l,...n},i)=>e.jsx(ej,{ref:i,className:L("-mx-1 my-1 h-px bg-muted",l),...n}));M2.displayName=ej.displayName;const Za=f0,Wa=p0,Pa=x.forwardRef(({className:l,align:n="center",sideOffset:i=4,...c},u)=>e.jsx(h0,{children:e.jsx(Rg,{ref:u,align:n,sideOffset:i,className:L("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]",l),...c})}));Pa.displayName=Rg.displayName;const A2=Ms.memo(function({value:n,onChange:i}){const[c,u]=x.useState("00"),[m,h]=x.useState("00"),[f,p]=x.useState("23"),[j,v]=x.useState("59");x.useEffect(()=>{const b=n.split("-");if(b.length===2){const[S,w]=b,[O,M]=S.split(":"),[D,$]=w.split(":");O&&u(O.padStart(2,"0")),M&&h(M.padStart(2,"0")),D&&p(D.padStart(2,"0")),$&&v($.padStart(2,"0"))}},[n]);const N=(b,S,w,O)=>{const M=`${b}:${S}-${w}:${O}`;i(M)};return e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(bl,{className:"h-4 w-4 mr-2"}),n||"选择时间段"]})}),e.jsx(Pa,{className:"w-72 sm: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(k,{className:"text-xs",children:"小时"}),e.jsxs($e,{value:c,onValueChange:b=>{u(b),N(b,m,f,j)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:Array.from({length:24},(b,S)=>S).map(b=>e.jsx(le,{value:b.toString().padStart(2,"0"),children:b.toString().padStart(2,"0")},b))})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"分钟"}),e.jsxs($e,{value:m,onValueChange:b=>{h(b),N(c,b,f,j)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:Array.from({length:60},(b,S)=>S).map(b=>e.jsx(le,{value:b.toString().padStart(2,"0"),children:b.toString().padStart(2,"0")},b))})]})]})]})]}),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(k,{className:"text-xs",children:"小时"}),e.jsxs($e,{value:f,onValueChange:b=>{p(b),N(c,m,b,j)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:Array.from({length:24},(b,S)=>S).map(b=>e.jsx(le,{value:b.toString().padStart(2,"0"),children:b.toString().padStart(2,"0")},b))})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"分钟"}),e.jsxs($e,{value:j,onValueChange:b=>{v(b),N(c,m,f,b)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:Array.from({length:60},(b,S)=>S).map(b=>e.jsx(le,{value:b.toString().padStart(2,"0"),children:b.toString().padStart(2,"0")},b))})]})]})]})]})]})})]})}),z2=Ms.memo(function({rule:n}){const i=`{ target = "${n.target}", time = "${n.time}", value = ${n.value.toFixed(1)} }`;return e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Pa,{className:"w-80 sm: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:i}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})}),D2=Ms.memo(function({config:n,onChange:i}){const c=()=>{i({...n,talk_value_rules:[...n.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},u=h=>{i({...n,talk_value_rules:n.talk_value_rules.filter((f,p)=>p!==h)})},m=(h,f,p)=>{const j=[...n.talk_value_rules];j[h]={...j[h],[f]:p},i({...n,talk_value_rules:j})};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 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(ce,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:n.talk_value,onChange:h=>i({...n,talk_value:parseFloat(h.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(Fe,{id:"mentioned_bot_reply",checked:n.mentioned_bot_reply,onCheckedChange:h=>i({...n,mentioned_bot_reply:h})}),e.jsx(k,{htmlFor:"mentioned_bot_reply",className:"cursor-pointer",children:"启用提及必回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(ce,{id:"max_context_size",type:"number",min:"1",value:n.max_context_size,onChange:h=>i({...n,max_context_size:parseInt(h.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ce,{id:"planner_smooth",type:"number",step:"1",min:"0",value:n.planner_smooth,onChange:h=>i({...n,planner_smooth:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-50 为关闭"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"enable_talk_value_rules",checked:n.enable_talk_value_rules,onCheckedChange:h=>i({...n,enable_talk_value_rules:h})}),e.jsx(k,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"include_planner_reasoning",checked:n.include_planner_reasoning,onCheckedChange:h=>i({...n,include_planner_reasoning:h})}),e.jsx(k,{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(C,{onClick:c,size:"sm",children:[e.jsx(ft,{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((h,f)=>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:["规则 #",f+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z2,{rule:h}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm",children:e.jsx(rs,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除规则 #",f+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>u(f),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs($e,{value:h.target===""?"global":"specific",onValueChange:p=>{p==="global"?m(f,"target",""):m(f,"target","qq::group")},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"global",children:"全局配置"}),e.jsx(le,{value:"specific",children:"详细配置"})]})]})]}),h.target!==""&&(()=>{const p=h.target.split(":"),j=p[0]||"qq",v=p[1]||"",N=p[2]||"group";return e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"平台"}),e.jsxs($e,{value:j,onValueChange:b=>{m(f,"target",`${b}:${v}:${N}`)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:v,onChange:b=>{m(f,"target",`${j}:${b.target.value}:${N}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"类型"}),e.jsxs($e,{value:N,onValueChange:b=>{m(f,"target",`${j}:${v}:${b}`)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"group",children:"群组group"}),e.jsx(le,{value:"private",children:"私聊private"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID",h.target||"(未设置)"]})]})})(),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(A2,{value:h.time,onChange:p=>m(f,"time",p)}),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(k,{htmlFor:`rule-value-${f}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(ce,{id:`rule-value-${f}`,type:"number",step:"0.01",min:"0.01",max:"1",value:h.value,onChange:p=>{const j=parseFloat(p.target.value);isNaN(j)||m(f,"value",Math.max(.01,Math.min(1,j)))},className:"w-20 h-8 text-xs"})]}),e.jsx(ya,{value:[h.value],onValueChange:p=>m(f,"value",p[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 (正常)"})]})]})]})]},f))}):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-10 表示完全沉默1 表示正常发言"]})]})]})]})]})}),O2=Ms.memo(function({config:n,onChange:i}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm: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(Fe,{checked:n.enable_asr,onCheckedChange:c=>i({...n,enable_asr:c})}),e.jsx(k,{className:"cursor-pointer",children:"启用语音识别"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后麦麦可以识别语音消息,需要配置语音识别模型"})]})}),R2=Ms.memo(function({config:n,onChange:i}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm: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(Fe,{checked:n.enable,onCheckedChange:c=>i({...n,enable:c})}),e.jsx(k,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),n.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"LPMM 模式"}),e.jsxs($e,{value:n.lpmm_mode,onValueChange:c=>i({...n,lpmm_mode:c}),children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"classic",children:"经典模式"}),e.jsx(le,{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(k,{children:"同义词搜索 TopK"}),e.jsx(ce,{type:"number",min:"1",value:n.rag_synonym_search_top_k,onChange:c=>i({...n,rag_synonym_search_top_k:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"同义词阈值"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:n.rag_synonym_threshold,onChange:c=>i({...n,rag_synonym_threshold:parseFloat(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"实体提取线程数"}),e.jsx(ce,{type:"number",min:"1",value:n.info_extraction_workers,onChange:c=>i({...n,info_extraction_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"嵌入向量维度"}),e.jsx(ce,{type:"number",min:"1",value:n.embedding_dimension,onChange:c=>i({...n,embedding_dimension:parseInt(c.target.value)})})]})]})]})]})]})}),L2=Ms.memo(function({config:n,onChange:i}){const[c,u]=x.useState(""),[m,h]=x.useState("WARNING"),f=()=>{c&&!n.suppress_libraries.includes(c)&&(i({...n,suppress_libraries:[...n.suppress_libraries,c]}),u(""))},p=w=>{i({...n,suppress_libraries:n.suppress_libraries.filter(O=>O!==w)})},j=()=>{c&&!n.library_log_levels[c]&&(i({...n,library_log_levels:{...n.library_log_levels,[c]:m}}),u(""),h("WARNING"))},v=w=>{const O={...n.library_log_levels};delete O[w],i({...n,library_log_levels:O})},N=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],b=["FULL","compact","lite"],S=["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(k,{children:"日期格式"}),e.jsx(ce,{value:n.date_style,onChange:w=>i({...n,date_style:w.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(k,{children:"日志级别样式"}),e.jsxs($e,{value:n.log_level_style,onValueChange:w=>i({...n,log_level_style:w}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:b.map(w=>e.jsx(le,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"日志文本颜色"}),e.jsxs($e,{value:n.color_text,onValueChange:w=>i({...n,color_text:w}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:S.map(w=>e.jsx(le,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"全局日志级别"}),e.jsxs($e,{value:n.log_level,onValueChange:w=>i({...n,log_level:w}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:N.map(w=>e.jsx(le,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"控制台日志级别"}),e.jsxs($e,{value:n.console_log_level,onValueChange:w=>i({...n,console_log_level:w}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:N.map(w=>e.jsx(le,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"文件日志级别"}),e.jsxs($e,{value:n.file_log_level,onValueChange:w=>i({...n,file_log_level:w}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsx(Ue,{children:N.map(w=>e.jsx(le,{value:w,children:w},w))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:w=>u(w.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),f())}}),e.jsx(C,{onClick:f,size:"sm",className:"flex-shrink-0",children:e.jsx(ft,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.suppress_libraries.map(w=>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:w}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>p(w),children:e.jsx(rs,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},w))})]}),e.jsxs("div",{children:[e.jsx(k,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ce,{value:c,onChange:w=>u(w.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs($e,{value:m,onValueChange:h,children:[e.jsx(Le,{className:"w-32",children:e.jsx(He,{})}),e.jsx(Ue,{children:N.map(w=>e.jsx(le,{value:w,children:w},w))})]}),e.jsx(C,{onClick:j,size:"sm",children:e.jsx(ft,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.library_log_levels).map(([w,O])=>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:w}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:O}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>v(w),children:e.jsx(rs,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},w))})]})]})}),U2=Ms.memo(function({config:n,onChange:i}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm: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(k,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(Fe,{checked:n.show_prompt,onCheckedChange:c=>i({...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(k,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(Fe,{checked:n.show_replyer_prompt,onCheckedChange:c=>i({...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(k,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(Fe,{checked:n.show_replyer_reasoning,onCheckedChange:c=>i({...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(k,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(Fe,{checked:n.show_jargon_prompt,onCheckedChange:c=>i({...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(k,{children:"显示记忆检索 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示记忆检索相关的提示词"})]}),e.jsx(Fe,{checked:n.show_memory_prompt,onCheckedChange:c=>i({...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(k,{children:"显示 Planner Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 Planner 的提示词和原始返回结果"})]}),e.jsx(Fe,{checked:n.show_planner_prompt,onCheckedChange:c=>i({...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(k,{children:"显示 LPMM 相关文段"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 LPMM 知识库找到的相关文段日志"})]}),e.jsx(Fe,{checked:n.show_lpmm_paragraph,onCheckedChange:c=>i({...n,show_lpmm_paragraph:c})})]})]})]})}),B2=Ms.memo(function({config:n,onChange:i}){const[c,u]=x.useState(""),m=()=>{c&&!n.auth_token.includes(c)&&(i({...n,auth_token:[...n.auth_token,c]}),u(""))},h=f=>{i({...n,auth_token:n.auth_token.filter((p,j)=>j!==f)})};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:"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(k,{children:"启用自定义服务器"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否使用自定义的 MaimMessage 服务器"})]}),e.jsx(Fe,{checked:n.use_custom,onCheckedChange:f=>i({...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(k,{children:"主机地址"}),e.jsx(ce,{value:n.host,onChange:f=>i({...n,host:f.target.value}),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"端口号"}),e.jsx(ce,{type:"number",value:n.port,onChange:f=>i({...n,port:parseInt(f.target.value)}),placeholder:"8090"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"连接模式"}),e.jsxs($e,{value:n.mode,onValueChange:f=>i({...n,mode:f}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"ws",children:"WebSocket (ws)"}),e.jsx(le,{value:"tcp",children:"TCP"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{checked:n.use_wss,onCheckedChange:f=>i({...n,use_wss:f}),disabled:n.mode!=="ws"}),e.jsx(k,{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(k,{children:"SSL 证书文件路径"}),e.jsx(ce,{value:n.cert_file,onChange:f=>i({...n,cert_file:f.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"SSL 密钥文件路径"}),e.jsx(ce,{value:n.key_file,onChange:f=>i({...n,key_file:f.target.value}),placeholder:"key.pem"})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{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=>u(f.target.value),placeholder:"输入认证令牌",onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),m())}}),e.jsx(C,{onClick:m,size:"sm",children:e.jsx(ft,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:n.auth_token.map((f,p)=>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(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>h(p),children:e.jsx(rs,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},p))})]})]})}),$2=Ms.memo(function({config:n,onChange:i}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm: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(k,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(Fe,{checked:n.enable,onCheckedChange:c=>i({...n,enable:c})})]})]})}),H2=Ms.memo(function({emojiConfig:n,memoryConfig:i,toolConfig:c,onEmojiChange:u,onMemoryChange:m,onToolChange:h}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-4 sm: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(Fe,{id:"enable_tool",checked:c.enable_tool,onCheckedChange:f=>h({...c,enable_tool:f})}),e.jsx(k,{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-4 sm: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(k,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(ce,{id:"max_agent_iterations",type:"number",min:"1",value:i.max_agent_iterations,onChange:f=>m({...i,max_agent_iterations:parseInt(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1不深入思考"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"agent_timeout_seconds",children:"最长回忆时间(秒)"}),e.jsx(ce,{id:"agent_timeout_seconds",type:"number",min:"1",step:"0.1",value:i.agent_timeout_seconds??120,onChange:f=>m({...i,agent_timeout_seconds:parseFloat(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(Fe,{id:"enable_jargon_detection",checked:i.enable_jargon_detection??!0,onCheckedChange:f=>m({...i,enable_jargon_detection:f})}),e.jsx(k,{htmlFor:"enable_jargon_detection",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(Fe,{id:"global_memory",checked:i.global_memory??!1,onCheckedChange:f=>m({...i,global_memory:f})}),e.jsx(k,{htmlFor:"global_memory",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-4 sm: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(k,{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=>u({...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(k,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(ce,{id:"max_reg_num",type:"number",min:"1",value:n.max_reg_num,onChange:f=>u({...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(k,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ce,{id:"check_interval",type:"number",min:"1",value:n.check_interval,onChange:f=>u({...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(Fe,{id:"do_replace",checked:n.do_replace,onCheckedChange:f=>u({...n,do_replace:f})}),e.jsx(k,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:f=>u({...n,steal_emoji:f})}),e.jsx(k,{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(Fe,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:f=>u({...n,content_filtration:f})}),e.jsx(k,{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(k,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ce,{id:"filtration_prompt",value:n.filtration_prompt,onChange:f=>u({...n,filtration_prompt:f.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}),G2=Ms.memo(function({member:n,groupIndex:i,memberIndex:c,availableChatIds:u,onUpdate:m,onRemove:h}){const f=u.includes(n)||n==="*",[p,j]=x.useState(!f);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ce,{value:n,onChange:v=>m(i,c,v.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),u.length>0&&e.jsx(C,{size:"sm",variant:"outline",onClick:()=>j(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($e,{value:n,onValueChange:v=>m(i,c,v),children:[e.jsx(Le,{className:"flex-1",children:e.jsx(He,{placeholder:"选择聊天流"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"*",children:"* (全局共享)"}),u.map((v,N)=>e.jsx(le,{value:v,children:v},N))]})]}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>j(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除组成员 "',n||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>h(i,c),children:"删除"})]})]})]})]})}),P2=Ms.memo(function({config:n,onChange:i}){const c=()=>{i({...n,learning_list:[...n.learning_list,["","enable","enable","1.0"]]})},u=b=>{i({...n,learning_list:n.learning_list.filter((S,w)=>w!==b)})},m=(b,S,w)=>{const O=[...n.learning_list];O[b][S]=w,i({...n,learning_list:O})},h=({rule:b})=>{const S=`["${b[0]}", "${b[1]}", "${b[2]}", "${b[3]}"]`;return e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Pa,{className:"w-80 sm: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:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},f=()=>{i({...n,expression_groups:[...n.expression_groups,[]]})},p=b=>{i({...n,expression_groups:n.expression_groups.filter((S,w)=>w!==b)})},j=b=>{const S=[...n.expression_groups];S[b]=[...S[b],""],i({...n,expression_groups:S})},v=(b,S)=>{const w=[...n.expression_groups];w[b]=w[b].filter((O,M)=>M!==S),i({...n,expression_groups:w})},N=(b,S,w)=>{const O=[...n.expression_groups];O[b][S]=w,i({...n,expression_groups:O})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-4 sm: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(C,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.learning_list.map((b,S)=>{const w=n.learning_list.some((_,T)=>T!==S&&_[0]===""),O=b[0]==="",M=b[0].split(":"),D=M[0]||"qq",$=M[1]||"",E=M[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:["规则 ",S+1," ",O&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{rule:b}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除学习规则 ",S+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>u(S),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs($e,{value:O?"global":"specific",onValueChange:_=>{_==="global"?m(S,0,""):m(S,0,"qq::group")},disabled:w&&!O,children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"global",children:"全局配置"}),e.jsx(le,{value:"specific",disabled:w&&!O,children:"详细配置"})]})]}),w&&!O&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!O&&e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"平台"}),e.jsxs($e,{value:D,onValueChange:_=>{m(S,0,`${_}:${$}:${E}`)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ce,{value:$,onChange:_=>{m(S,0,`${D}:${_.target.value}:${E}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"类型"}),e.jsxs($e,{value:E,onValueChange:_=>{m(S,0,`${D}:${$}:${_}`)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"group",children:"群组group"}),e.jsx(le,{value:"private",children:"私聊private"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID",b[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(k,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(Fe,{checked:b[1]==="enable",onCheckedChange:_=>m(S,1,_?"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(k,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(Fe,{checked:b[2]==="enable",onCheckedChange:_=>m(S,2,_?"enable":"disable")})]})}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{className:"text-xs font-medium",children:"学习强度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"5",value:b[3],onChange:_=>{const T=parseFloat(_.target.value);isNaN(T)||m(S,3,Math.max(0,Math.min(5,T)).toFixed(1))},className:"w-20 h-8 text-xs"})]}),e.jsx(ya,{value:[parseFloat(b[3])||1],onValueChange:_=>m(S,3,_[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/学习强度(秒)"})]})]})]},S)}),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-4 sm: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(Fe,{checked:n.reflect,onCheckedChange:b=>i({...n,reflect:b})})]}),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 S=(n.reflect_operator_id||"").split(":"),w=S[0]||"qq",O=S[1]||"",M=S[2]||"private";return e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"平台"}),e.jsxs($e,{value:w,onValueChange:D=>{i({...n,reflect_operator_id:`${D}:${O}:${M}`})},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"用户/群 ID"}),e.jsx(ce,{value:O,onChange:D=>{i({...n,reflect_operator_id:`${w}:${D.target.value}:${M}`})},placeholder:"输入 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"类型"}),e.jsxs($e,{value:M,onValueChange:D=>{i({...n,reflect_operator_id:`${w}:${O}:${D}`})},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"private",children:"私聊private"}),e.jsx(le,{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(C,{onClick:()=>{i({...n,allow_reflect:[...n.allow_reflect||[],"qq::group"]})},size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加聊天流"]})]}),e.jsxs("div",{className:"space-y-2",children:[(n.allow_reflect||[]).map((b,S)=>{const w=b.split(":"),O=w[0]||"qq",M=w[1]||"",D=w[2]||"group";return e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsxs($e,{value:O,onValueChange:$=>{const E=[...n.allow_reflect];E[S]=`${$}:${M}:${D}`,i({...n,allow_reflect:E})},children:[e.jsx(Le,{className:"w-24",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]}),e.jsx(ce,{value:M,onChange:$=>{const E=[...n.allow_reflect];E[S]=`${O}:${$.target.value}:${D}`,i({...n,allow_reflect:E})},placeholder:"ID",className:"flex-1 font-mono text-sm"}),e.jsxs($e,{value:D,onValueChange:$=>{const E=[...n.allow_reflect];E[S]=`${O}:${M}:${$}`,i({...n,allow_reflect:E})},children:[e.jsx(Le,{className:"w-32",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"group",children:"群组"}),e.jsx(le,{value:"private",children:"私聊"})]})]}),e.jsx(C,{onClick:()=>{i({...n,allow_reflect:n.allow_reflect.filter(($,E)=>E!==S)})},size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})]},S)}),(!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-4 sm: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(C,{onClick:f,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.expression_groups.map((b,S)=>{const w=n.learning_list.map(O=>O[0]).filter(O=>O!=="");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:["共享组 ",S+1,b.length===1&&b[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{onClick:()=>j(S),size:"sm",variant:"outline",children:e.jsx(ft,{className:"h-4 w-4"})}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除共享组 ",S+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>p(S),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:b.map((O,M)=>e.jsx(G2,{member:O,groupIndex:S,memberIndex:M,availableChatIds:w,onUpdate:N,onRemove:v},`${S}-${M}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},S)}),n.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4 sm: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(Fe,{id:"all_global_jargon",checked:n.all_global_jargon??!1,onCheckedChange:b=>i({...n,all_global_jargon:b})}),e.jsx(k,{htmlFor:"all_global_jargon",className:"cursor-pointer",children:"全局黑话模式"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"开启后,新增的黑话将默认设为全局(所有聊天流共享)。关闭后,已记录的全局黑话不会改变,需要手动删除。"})]})})]})});function I2({regex:l,reaction:n,onRegexChange:i,onReactionChange:c}){const[u,m]=x.useState(!1),[h,f]=x.useState(""),[p,j]=x.useState(null),[v,N]=x.useState(""),[b,S]=x.useState({}),[w,O]=x.useState(""),M=x.useRef(null),[D,$]=x.useState("build"),E=A=>A.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),_=(A,ee=0)=>{const H=M.current;if(!H)return;const Z=H.selectionStart||0,re=H.selectionEnd||0,ye=l.substring(0,Z)+A+l.substring(re);i(ye),setTimeout(()=>{const de=Z+A.length+ee;H.setSelectionRange(de,de),H.focus()},0)};x.useEffect(()=>{if(!l||!h){j(null),S({}),O(n),N("");return}try{const A=E(l),ee=new RegExp(A,"g"),H=h.match(ee);j(H),N("");const re=new RegExp(A).exec(h);if(re&&re.groups){S(re.groups);let ye=n;Object.entries(re.groups).forEach(([de,ge])=>{ye=ye.replace(new RegExp(`\\[${de}\\]`,"g"),ge||"")}),O(ye)}else S({}),O(n)}catch(A){N(A.message),j(null),S({}),O(n)}},[l,h,n]);const T=()=>{if(!h||!p||p.length===0)return e.jsx("span",{className:"text-muted-foreground",children:h||"请输入测试文本"});try{const A=E(l),ee=new RegExp(A,"g");let H=0;const Z=[];let re;for(;(re=ee.exec(h))!==null;)re.index>H&&Z.push(e.jsx("span",{children:h.substring(H,re.index)},`text-${H}`)),Z.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:re[0]},`match-${re.index}`)),H=re.index+re[0].length;return H<h.length&&Z.push(e.jsx("span",{children:h.substring(H)},`text-${H}`)),e.jsx(e.Fragment,{children:Z})}catch{return e.jsx("span",{children:h})}},P=[{category:"基础匹配",items:[{label:"任意字符",pattern:".",desc:"匹配除换行符外的任意字符"},{label:"数字",pattern:"\\d",desc:"匹配 0-9"},{label:"非数字",pattern:"\\D",desc:"匹配非数字字符"},{label:"字母数字",pattern:"\\w",desc:"匹配字母、数字、下划线"},{label:"非字母数字",pattern:"\\W",desc:"匹配非字母数字字符"},{label:"空白符",pattern:"\\s",desc:"匹配空格、制表符等"},{label:"非空白符",pattern:"\\S",desc:"匹配非空白字符"}]},{category:"位置锚点",items:[{label:"行首",pattern:"^",desc:"匹配行的开始"},{label:"行尾",pattern:"$",desc:"匹配行的结束"},{label:"单词边界",pattern:"\\b",desc:"匹配单词边界"}]},{category:"重复次数",items:[{label:"0或多次",pattern:"*",desc:"匹配前面的元素0次或多次"},{label:"1或多次",pattern:"+",desc:"匹配前面的元素1次或多次"},{label:"0或1次",pattern:"?",desc:"匹配前面的元素0次或1次"},{label:"指定次数",pattern:"{n}",desc:"匹配n次将n替换为数字"},{label:"次数范围",pattern:"{m,n}",desc:"匹配m到n次"}]},{category:"分组和捕获",items:[{label:"普通分组",pattern:"()",desc:"分组但不捕获",moveCursor:-1},{label:"命名捕获",pattern:"(?P<name>)",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<word>\\S+)",desc:"捕获一个词语"},{label:"捕获句子",pattern:"(?P<sentence>.+)",desc:"捕获整个句子"},{label:"捕获数字",pattern:"(?P<num>\\d+)",desc:"捕获一个或多个数字"},{label:"可选词语",pattern:"(?:词语1|词语2)",desc:"匹配多个可选项之一"}]}];return e.jsxs(Hs,{open:u,onOpenChange:m,children:[e.jsx(Bo,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(Om,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"正则表达式编辑器"}),e.jsx(Ws,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(Xe,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(ma,{value:D,onValueChange:A=>$(A),className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-2",children:[e.jsx(ss,{value:"build",children:"🔧 构建器"}),e.jsx(ss,{value:"test",children:"🧪 测试器"})]}),e.jsxs(Ss,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ce,{ref:M,value:l,onChange:A=>i(A.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(Ys,{value:n,onChange:A=>c(A.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[P.map(A=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:A.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:A.items.map(ee=>e.jsx(C,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>_(ee.pattern,ee.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:ee.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:ee.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:ee.desc})]})},ee.label))})]},A.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(C,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>i("^(?P<n>\\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<n>\\S","{1,20}",")是这样的$"]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「某事物是这样的」并捕获事物名称"})]})}),e.jsx(C,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>i("(?:[^,。.\\s]+\\s*)?我(?:也)?[没沒]要求你\\s*(?P<action>.+?)[.。,]?$"),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<action>.+?)[.。,]?$"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「我没要求你做某事」并捕获具体行为"})]})}),e.jsx(C,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>i("(?P<subject>.+?)(?:是|为什么|怎么)"),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<subject>.+?)(?:是|为什么|怎么)"}),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(Ss,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:l||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(Ys,{id:"test-text",value:h,onChange:A=>f(A.target.value),placeholder:`在此输入要测试的文本...
例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),v&&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:v})]}),!v&&h&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:p&&p.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:["匹配成功 (",p.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(k,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(Xe,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:T()})})]}),Object.keys(b).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(Xe,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(b).map(([A,ee])=>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:["[",A,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:ee})]},A))})})]}),Object.keys(b).length>0&&n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(Xe,{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:w})}),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:"如需修改正则,切换回构建器标签页"})]})]})]})]})})]})]})}const q2=Ms.memo(function({keywordReactionConfig:n,responsePostProcessConfig:i,chineseTypoConfig:c,responseSplitterConfig:u,onKeywordReactionChange:m,onResponsePostProcessChange:h,onChineseTypoChange:f,onResponseSplitterChange:p}){const j=()=>{m({...n,regex_rules:[...n.regex_rules,{regex:[""],reaction:""}]})},v=_=>{m({...n,regex_rules:n.regex_rules.filter((T,P)=>P!==_)})},N=(_,T,P)=>{const A=[...n.regex_rules];T==="regex"&&typeof P=="string"?A[_]={...A[_],regex:[P]}:T==="reaction"&&typeof P=="string"&&(A[_]={...A[_],reaction:P}),m({...n,regex_rules:A})},b=()=>{m({...n,keyword_rules:[...n.keyword_rules,{keywords:[],reaction:""}]})},S=_=>{m({...n,keyword_rules:n.keyword_rules.filter((T,P)=>P!==_)})},w=(_,T,P)=>{const A=[...n.keyword_rules];typeof P=="string"&&(A[_]={...A[_],reaction:P}),m({...n,keyword_rules:A})},O=_=>{const T=[...n.keyword_rules];T[_]={...T[_],keywords:[...T[_].keywords||[],""]},m({...n,keyword_rules:T})},M=(_,T)=>{const P=[...n.keyword_rules];P[_]={...P[_],keywords:(P[_].keywords||[]).filter((A,ee)=>ee!==T)},m({...n,keyword_rules:P})},D=(_,T,P)=>{const A=[...n.keyword_rules],ee=[...A[_].keywords||[]];ee[T]=P,A[_]={...A[_],keywords:ee},m({...n,keyword_rules:A})},$=({rule:_})=>{const T=`{ regex = [${(_.regex||[]).map(P=>`"${P}"`).join(", ")}], reaction = "${_.reaction}" }`;return e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Pa,{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(Xe,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:T})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},E=({rule:_})=>{const T=`[[keyword_reaction.keyword_rules]]
keywords = [${(_.keywords||[]).map(P=>`"${P}"`).join(", ")}]
reaction = "${_.reaction}"`;return e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Pa,{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(Xe,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:T})}),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-4 sm: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(C,{onClick:j,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.regex_rules.map((_,T)=>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]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I2,{regex:_.regex&&_.regex[0]||"",reaction:_.reaction,onRegexChange:P=>N(T,"regex",P),onReactionChange:P=>N(T,"reaction",P)}),e.jsx($,{rule:_}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除正则规则 ",T+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>v(T),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"正则表达式Python 语法)"}),e.jsx(ce,{value:_.regex&&_.regex[0]||"",onChange:P=>N(T,"regex",P.target.value),placeholder:"例如:^(?P<n>\\\\S{1,20})是这样的$ (点击正则编辑器按钮可视化构建)",className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'支持命名捕获组 (?P<name>pattern),可在 reaction 中使用 [name] 引用。点击"正则编辑器"可视化构建和测试!'})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Ys,{value:_.reaction,onChange:P=>N(T,"reaction",P.target.value),placeholder:`触发后麦麦的反应...
可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},T)),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(C,{onClick:b,size:"sm",variant:"outline",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.keyword_rules.map((_,T)=>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]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{rule:_}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除关键词规则 ",T+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>S(T),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(k,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(C,{onClick:()=>O(T),size:"sm",variant:"ghost",children:[e.jsx(ft,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(_.keywords||[]).map((P,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:P,onChange:ee=>D(T,A,ee.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(C,{onClick:()=>M(T,A),size:"sm",variant:"ghost",children:e.jsx(rs,{className:"h-4 w-4"})})]},A)),(!_.keywords||_.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(k,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Ys,{value:_.reaction,onChange:P=>w(T,"reaction",P.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},T)),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-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:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"enable_response_post_process",checked:i.enable_response_post_process,onCheckedChange:_=>h({...i,enable_response_post_process:_})}),e.jsx(k,{htmlFor:"enable_response_post_process",className:"cursor-pointer",children:"启用回复后处理"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"包括错别字生成器和回复分割器"})]}),i.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(Fe,{id:"enable_chinese_typo",checked:c.enable,onCheckedChange:_=>f({...c,enable:_})}),e.jsx(k,{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(k,{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:_=>f({...c,error_rate:parseFloat(_.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(ce,{id:"min_freq",type:"number",min:"0",value:c.min_freq,onChange:_=>f({...c,min_freq:parseInt(_.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{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:_=>f({...c,tone_error_rate:parseFloat(_.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{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:_=>f({...c,word_replace_rate:parseFloat(_.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(Fe,{id:"enable_response_splitter",checked:u.enable,onCheckedChange:_=>p({...u,enable:_})}),e.jsx(k,{htmlFor:"enable_response_splitter",className:"cursor-pointer font-semibold",children:"回复分割器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"控制回复的长度和句子数量"}),u.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(k,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(ce,{id:"max_length",type:"number",min:"1",value:u.max_length,onChange:_=>p({...u,max_length:parseInt(_.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(ce,{id:"max_sentence_num",type:"number",min:"1",value:u.max_sentence_num,onChange:_=>p({...u,max_sentence_num:parseInt(_.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(Fe,{id:"enable_kaomoji_protection",checked:u.enable_kaomoji_protection,onCheckedChange:_=>p({...u,enable_kaomoji_protection:_})}),e.jsx(k,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"enable_overflow_return_all",checked:u.enable_overflow_return_all,onCheckedChange:_=>p({...u,enable_overflow_return_all:_})}),e.jsx(k,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}),an="/api/webui/config";async function ag(){const n=await(await Se(`${an}/bot`)).json();if(!n.success)throw new Error("获取配置数据失败");return n.config}async function Zl(){const n=await(await Se(`${an}/model`)).json();if(!n.success)throw new Error("获取模型配置数据失败");return n.config}async function lg(l){const i=await(await Se(`${an}/bot`,{method:"POST",body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function V2(){const n=await(await Se(`${an}/bot/raw`)).json();if(!n.success)throw new Error("获取配置源代码失败");return n.content}async function F2(l){const i=await(await Se(`${an}/bot/raw`,{method:"POST",body:JSON.stringify({raw_content:l})})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function Ri(l){const i=await(await Se(`${an}/model`,{method:"POST",body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function K2(l,n){const c=await(await Se(`${an}/bot/section/${l}`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${l} 失败`)}async function Em(l,n){const c=await(await Se(`${an}/model/section/${l}`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${l} 失败`)}async function Q2(l,n="openai",i="/models"){const c=new URLSearchParams({provider_name:l,parser:n,endpoint:i}),u=await Se(`/api/webui/models/list?${c}`);if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.detail||`获取模型列表失败 (${u.status})`)}const m=await u.json();if(!m.success)throw new Error("获取模型列表失败");return m.models}async function Y2(l){const n=new URLSearchParams({provider_name:l}),i=await Se(`/api/webui/models/test-connection-by-name?${n}`,{method:"POST"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.detail||`测试连接失败 (${i.status})`)}return await i.json()}const X2=Mr("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"}}),wt=x.forwardRef(({className:l,variant:n,...i},c)=>e.jsx("div",{ref:c,role:"alert",className:L(X2({variant:n}),l),...i}));wt.displayName="Alert";const Sn=x.forwardRef(({className:l,...n},i)=>e.jsx("h5",{ref:i,className:L("mb-1 font-medium leading-none tracking-tight",l),...n}));Sn.displayName="AlertTitle";const _t=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:L("text-sm [&_p]:leading-relaxed",l),...n}));_t.displayName="AlertDescription";const J2={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(l,n){let i;if(!n.inString&&(i=l.match(/^('''|"""|'|")/))&&(n.stringType=i[0],n.inString=!0),l.sol()&&!n.inString&&n.inArray===0&&(n.lhs=!0),n.inString){for(;n.inString;)if(l.match(n.stringType))n.inString=!1;else if(l.peek()==="\\")l.next(),l.next();else{if(l.eol())break;l.match(/^.[^\\\"\']*/)}return n.lhs?"property":"string"}else{if(n.inArray&&l.peek()==="]")return l.next(),n.inArray--,"bracket";if(n.lhs&&l.peek()==="["&&l.skipTo("]"))return l.next(),l.peek()==="]"&&l.next(),"atom";if(l.peek()==="#")return l.skipToEnd(),"comment";if(l.eatSpace())return null;if(n.lhs&&l.eatWhile(function(c){return c!="="&&c!=" "}))return"property";if(n.lhs&&l.peek()==="=")return l.next(),n.lhs=!1,null;if(!n.lhs&&l.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!n.lhs&&(l.match("true")||l.match("false")))return"atom";if(!n.lhs&&l.peek()==="[")return n.inArray++,l.next(),"bracket";if(!n.lhs&&l.match(/^\-?\d+(?:\.\d+)?/))return"number";l.eatSpace()||l.next()}return null},languageData:{commentTokens:{line:"#"}}},Z2={python:[Yw()],json:[Xw(),Jw()],toml:[Qw.define(J2)],text:[]};function W2({value:l,onChange:n,language:i="text",readOnly:c=!1,height:u="400px",minHeight:m,maxHeight:h,placeholder:f,theme:p="dark",className:j=""}){const[v,N]=x.useState(!1);if(x.useEffect(()=>{N(!0)},[]),!v)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${j}`,style:{height:u,minHeight:m,maxHeight:h}});const b=[...Z2[i]||[],Kp.lineWrapping];return c&&b.push(Kp.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border ${j}`,children:e.jsx(Zw,{value:l,height:u,minHeight:m,maxHeight:h,theme:p==="dark"?Ww:void 0,extensions:b,onChange:n,placeholder:f,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 e_({id:l,index:n,itemType:i,itemFields:c,value:u,onChange:m,onRemove:h,disabled:f,canRemove:p,placeholder:j}){const{attributes:v,listeners:N,setNodeRef:b,transform:S,transition:w,isDragging:O}=zj({id:l,disabled:f}),M={transform:Dj.Transform.toString(S),transition:w};return e.jsxs("div",{ref:b,style:M,className:L("flex items-start gap-2 group",O&&"opacity-50 z-50"),children:[e.jsx("button",{type:"button",className:L("flex-shrink-0 p-2 cursor-grab active:cursor-grabbing","text-muted-foreground hover:text-foreground transition-colors","opacity-0 group-hover:opacity-100 focus:opacity-100",f&&"cursor-not-allowed opacity-30"),...v,...N,children:e.jsx(hj,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1 min-w-0",children:i==="object"&&c?e.jsx(s_,{value:u,onChange:m,fields:c,disabled:f}):i==="number"?e.jsx(ce,{type:"number",value:u??"",onChange:D=>m(parseFloat(D.target.value)||0),placeholder:j??`${n+1}`,disabled:f,className:"font-mono"}):e.jsx(ce,{type:"text",value:u??"",onChange:D=>m(D.target.value),placeholder:j??`${n+1}`,disabled:f})}),e.jsx(C,{type:"button",variant:"ghost",size:"icon",onClick:h,disabled:f||!p,className:L("flex-shrink-0 text-muted-foreground hover:text-destructive","opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity"),children:e.jsx(rs,{className:"h-4 w-4"})})]})}function s_({value:l,onChange:n,fields:i,disabled:c}){const u=x.useCallback((h,f)=>{n({...l,[h]:f})},[l,n]),m=(h,f)=>{const p=l?.[h];if(f.type==="boolean"||f.type==="switch")return e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(Fe,{checked:!!(p??f.default),onCheckedChange:j=>u(h,j),disabled:c})]});if(f.type==="slider"||f.type==="number"&&f.min!=null&&f.max!=null){const j=p??f.default??f.min??0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j})]}),e.jsx(ya,{value:[j],onValueChange:v=>u(h,v[0]),min:f.min??0,max:f.max??100,step:f.step??1,disabled:c,className:"py-1"})]})}return f.type==="select"&&f.choices?e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsxs($e,{value:String(p??f.default??""),onValueChange:j=>u(h,j),disabled:c,children:[e.jsx(Le,{className:"h-8 text-sm",children:e.jsx(He,{placeholder:f.placeholder??"请选择"})}),e.jsx(Ue,{children:f.choices.map(j=>e.jsx(le,{value:String(j),children:String(j)},String(j)))})]})]}):f.type==="number"?e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(ce,{type:"number",value:p??f.default??"",onChange:j=>u(h,parseFloat(j.target.value)||0),placeholder:f.placeholder,disabled:c,className:"h-8 text-sm"})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(ce,{type:"text",value:p??f.default??"",onChange:j=>u(h,j.target.value),placeholder:f.placeholder,disabled:c,className:"h-8 text-sm"})]})};return e.jsx(Oe,{className:"p-3 space-y-2 bg-muted/30",children:Object.entries(i).map(([h,f])=>e.jsx("div",{children:m(h,f)},h))})}function t_({value:l,onChange:n,itemType:i="string",itemFields:c,minItems:u,maxItems:m,disabled:h,placeholder:f}){const p=x.useMemo(()=>Array.isArray(l)?l:typeof l=="string"&&l.trim()?l.split(",").map(E=>E.trim()):[],[l]),[j]=x.useState(()=>new Map),v=x.useCallback(E=>(j.has(E)||j.set(E,`item-${Date.now()}-${E}-${Math.random().toString(36).slice(2)}`),j.get(E)),[j]),N=x.useMemo(()=>{const E=[];for(let _=0;_<p.length;_++)E.push(v(_));return E},[p.length,v]),b=_j(Co(kj,{activationConstraint:{distance:8}}),Co(Cj,{coordinateGetter:Sj})),S=x.useCallback(E=>{const{active:_,over:T}=E;if(T&&_.id!==T.id){const P=N.indexOf(_.id),A=N.indexOf(T.id),ee=Tj(p,P,A);n(ee)}},[p,N,n]),w=x.useCallback(()=>{if(m!=null&&p.length>=m)return;let E;i==="object"&&c?E=Object.fromEntries(Object.entries(c).map(([_,T])=>[_,T.default??""])):i==="number"?E=0:E="",n([...p,E])},[p,m,i,c,n]),O=x.useCallback((E,_)=>{const T=[...p];T[E]=_,n(T)},[p,n]),M=x.useCallback(E=>{if(u!=null&&p.length<=u)return;const _=p.filter((T,P)=>P!==E);j.delete(E),n(_)},[p,u,j,n]),D=m==null||p.length<m,$=u==null||p.length>u;return e.jsxs("div",{className:"space-y-2",children:[p.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4 justify-center border border-dashed rounded-md",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx("span",{children:"暂无数据,点击下方按钮添加"})]}):e.jsx(Ej,{sensors:b,collisionDetection:Mj,onDragEnd:S,children:e.jsx(Aj,{items:N,strategy:e1,children:e.jsx("div",{className:"space-y-2",children:p.map((E,_)=>e.jsx(e_,{id:N[_],index:_,itemType:i,itemFields:c,value:E,onChange:T=>O(_,T),onRemove:()=>M(_),disabled:h,canRemove:$,placeholder:f},N[_]))})})}),e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:h||!D,className:"w-full",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加项目",m!==void 0&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",p.length,"/",m,")"]})]}),(u!=null||m!=null)&&(u!==null||m!==null)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:u!=null&&m!=null?`允许 ${u} - ${m}`:u!=null?`至少 ${u}`:`最多 ${m}`})]})}function a_(l,n,i,c={}){const{debounceMs:u=2e3,onSaveSuccess:m,onSaveError:h}=c,f=x.useRef(null),p=x.useCallback(async(b,S)=>{try{n(!0),await K2(b,S),i(!1),m?.()}catch(w){console.error(`自动保存 ${b} 失败:`,w),i(!0),h?.(w instanceof Error?w:new Error(String(w)))}finally{n(!1)}},[n,i,m,h]),j=x.useCallback((b,S)=>{l||(i(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p(b,S)},u))},[l,i,p,u]),v=x.useCallback(async(b,S)=>{f.current&&(clearTimeout(f.current),f.current=null),await p(b,S)},[p]),N=x.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]);return x.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{triggerAutoSave:j,saveNow:v,cancelPendingAutoSave:N}}function It(l,n,i,c){x.useEffect(()=>{l&&!i&&c(n,l)},[l])}const l_=500;function n_(){return e.jsx(On,{children:e.jsx(r_,{})})}function r_(){const[l,n]=x.useState(!0),[i,c]=x.useState(!1),[u,m]=x.useState(!1),[h,f]=x.useState(!1),[p,j]=x.useState("visual"),[v,N]=x.useState(""),[b,S]=x.useState(!1),{toast:w}=et(),{triggerRestart:O,isRestarting:M}=tn(),[D,$]=x.useState(null),[E,_]=x.useState(null),[T,P]=x.useState(null),[A,ee]=x.useState(null),[H,Z]=x.useState(null),[re,ye]=x.useState(null),[de,ge]=x.useState(null),[je,z]=x.useState(null),[Q,J]=x.useState(null),[U,G]=x.useState(null),[Ce,be]=x.useState(null),[ke,I]=x.useState(null),[we,q]=x.useState(null),[oe,Te]=x.useState(null),[X,ne]=x.useState(null),[Ie,Je]=x.useState(null),[pe,as]=x.useState(null),F=x.useRef(!0),ze=x.useRef({}),ue=x.useCallback(_e=>{ze.current=_e,$(_e.bot),_(_e.personality);const gs=_e.chat;gs.talk_value_rules||(gs.talk_value_rules=[]),P(gs),ee(_e.expression),Z(_e.emoji),ye(_e.memory),ge(_e.tool),z(_e.voice),J(_e.lpmm_knowledge),G(_e.keyword_reaction),be(_e.response_post_process),I(_e.chinese_typo),q(_e.response_splitter),Te(_e.log),ne(_e.debug),Je(_e.maim_message),as(_e.telemetry)},[]),ve=x.useCallback(()=>({...ze.current,bot:D,personality:E,chat:T,expression:A,emoji:H,memory:re,tool:de,voice:je,lpmm_knowledge:Q,keyword_reaction:U,response_post_process:Ce,chinese_typo:ke,response_splitter:we,log:oe,debug:X,maim_message:Ie,telemetry:pe}),[D,E,T,A,H,re,de,je,Q,U,Ce,ke,we,oe,X,Ie,pe]),Me=x.useCallback(async()=>{try{const gs=(await V2()).replace(/"([^"]*)"/g,(is,As)=>`"${As.replace(/\\n/g,`
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}"`);N(gs),S(!1)}catch(_e){w({variant:"destructive",title:"加载失败",description:_e instanceof Error?_e.message:"加载源代码失败"})}},[w]),Ke=x.useCallback(async()=>{try{n(!0);const _e=await ag();ue(_e),f(!1),F.current=!1,await Me()}catch(_e){console.error("加载配置失败:",_e),w({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{n(!1)}},[w,Me,ue]);x.useEffect(()=>{Ke()},[Ke]);const{triggerAutoSave:qe,cancelPendingAutoSave:Zt}=a_(F.current,m,f);It(D,"bot",F.current,qe),It(E,"personality",F.current,qe),It(T,"chat",F.current,qe),It(A,"expression",F.current,qe),It(H,"emoji",F.current,qe),It(re,"memory",F.current,qe),It(de,"tool",F.current,qe),It(je,"voice",F.current,qe),It(Q,"lpmm_knowledge",F.current,qe),It(U,"keyword_reaction",F.current,qe),It(Ce,"response_post_process",F.current,qe),It(ke,"chinese_typo",F.current,qe),It(we,"response_splitter",F.current,qe),It(oe,"log",F.current,qe),It(X,"debug",F.current,qe),It(Ie,"maim_message",F.current,qe),It(pe,"telemetry",F.current,qe);const Et=async()=>{try{c(!0);const _e=v.replace(/"([^"]*)"/g,(gs,is)=>`"${is.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}"`);await F2(_e),f(!1),S(!1),w({title:"保存成功",description:"配置已保存"}),await Ke()}catch(_e){S(!0),w({variant:"destructive",title:"保存失败",description:_e instanceof Error?_e.message:"保存配置失败"})}finally{c(!1)}},ot=async _e=>{if(h){w({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(j(_e),_e==="source")await Me();else try{const gs=await ag();ue(gs),f(!1)}catch(gs){console.error("加载配置失败:",gs),w({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},K=async()=>{try{c(!0),Zt(),await lg(ve()),f(!1),w({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(_e){console.error("保存配置失败:",_e),w({title:"保存失败",description:_e.message,variant:"destructive"})}finally{c(!1)}},Pe=async()=>{await O()},Be=async()=>{try{c(!0),Zt(),await lg(ve()),f(!1),w({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(_e=>setTimeout(_e,l_)),await Pe()}catch(_e){console.error("保存失败:",_e),w({title:"保存失败",description:_e.message,variant:"destructive"})}finally{c(!1)}};return l?e.jsx(Xe,{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(Xe,{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 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl md:text-3xl font-bold",children:"麦麦主程序配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs sm:text-sm",children:"管理麦麦的核心功能和行为设置"})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs(C,{onClick:p==="visual"?K:Et,disabled:i||u||!h||M,size:"sm",variant:"outline",className:"w-20 sm:w-24",children:[e.jsx(Fi,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:i?"保存中":u?"自动":h?"保存":"已保存"})]}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{disabled:i||u||M,size:"sm",className:"w-20 sm:w-28",children:[e.jsx(Vi,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:M?"重启中":h?"保存重启":"重启"})]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重启麦麦?"}),e.jsx(hs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:h?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:h?Be:Pe,children:h?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsx("div",{className:"flex",children:e.jsx(ma,{value:p,onValueChange:_e=>ot(_e),className:"w-full",children:e.jsxs(Xt,{className:"h-8 sm:h-9 w-full grid grid-cols-2",children:[e.jsxs(ss,{value:"visual",className:"text-xs sm:text-sm",children:[e.jsx(kw,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"可视化编辑"]}),e.jsxs(ss,{value:"source",className:"text-xs sm:text-sm",children:[e.jsx(Tw,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码编辑"]})]})})})]}),e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsxs(_t,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),p==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsxs(_t,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在后端验证格式,只有格式完全正确才能保存。",b&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(W2,{value:v,onChange:_e=>{N(_e),f(!0),b&&S(!1)},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),p==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(ma,{defaultValue:"bot",className:"w-full",children:[e.jsxs(Xt,{className:"flex flex-wrap h-auto gap-1 p-1 sm:grid sm:grid-cols-5 lg:grid-cols-9",children:[e.jsx(ss,{value:"bot",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"基本信息"}),e.jsx(ss,{value:"personality",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"人格"}),e.jsx(ss,{value:"chat",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"聊天"}),e.jsx(ss,{value:"expression",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"表达"}),e.jsx(ss,{value:"features",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"功能"}),e.jsx(ss,{value:"processing",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"处理"}),e.jsx(ss,{value:"voice",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"语音"}),e.jsx(ss,{value:"lpmm",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"知识库"}),e.jsx(ss,{value:"other",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"其他"})]}),e.jsx(Ss,{value:"bot",className:"space-y-4",children:D&&e.jsx(k2,{config:D,onChange:$})}),e.jsx(Ss,{value:"personality",className:"space-y-4",children:E&&e.jsx(T2,{config:E,onChange:_})}),e.jsx(Ss,{value:"chat",className:"space-y-4",children:T&&e.jsx(D2,{config:T,onChange:P})}),e.jsx(Ss,{value:"expression",className:"space-y-4",children:A&&e.jsx(P2,{config:A,onChange:ee})}),e.jsx(Ss,{value:"features",className:"space-y-4",children:H&&re&&de&&e.jsx(H2,{emojiConfig:H,memoryConfig:re,toolConfig:de,onEmojiChange:Z,onMemoryChange:ye,onToolChange:ge})}),e.jsx(Ss,{value:"processing",className:"space-y-4",children:U&&Ce&&ke&&we&&e.jsx(q2,{keywordReactionConfig:U,responsePostProcessConfig:Ce,chineseTypoConfig:ke,responseSplitterConfig:we,onKeywordReactionChange:G,onResponsePostProcessChange:be,onChineseTypoChange:I,onResponseSplitterChange:q})}),e.jsx(Ss,{value:"voice",className:"space-y-4",children:je&&e.jsx(O2,{config:je,onChange:z})}),e.jsx(Ss,{value:"lpmm",className:"space-y-4",children:Q&&e.jsx(R2,{config:Q,onChange:J})}),e.jsxs(Ss,{value:"other",className:"space-y-4",children:[oe&&e.jsx(L2,{config:oe,onChange:Te}),X&&e.jsx(U2,{config:X,onChange:ne}),Ie&&e.jsx(B2,{config:Ie,onChange:Je}),pe&&e.jsx($2,{config:pe,onChange:as})]})]})}),e.jsx(Rn,{})]})})}const _l=x.forwardRef(({className:l,...n},i)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:i,className:L("w-full caption-bottom text-sm",l),...n})}));_l.displayName="Table";const Sl=x.forwardRef(({className:l,...n},i)=>e.jsx("thead",{ref:i,className:L("[&_tr]:border-b",l),...n}));Sl.displayName="TableHeader";const Cl=x.forwardRef(({className:l,...n},i)=>e.jsx("tbody",{ref:i,className:L("[&_tr:last-child]:border-0",l),...n}));Cl.displayName="TableBody";const i_=x.forwardRef(({className:l,...n},i)=>e.jsx("tfoot",{ref:i,className:L("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",l),...n}));i_.displayName="TableFooter";const lt=x.forwardRef(({className:l,...n},i)=>e.jsx("tr",{ref:i,className:L("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",l),...n}));lt.displayName="TableRow";const Ye=x.forwardRef(({className:l,...n},i)=>e.jsx("th",{ref:i,className:L("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",l),...n}));Ye.displayName="TableHead";const Ge=x.forwardRef(({className:l,...n},i)=>e.jsx("td",{ref:i,className:L("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",l),...n}));Ge.displayName="TableCell";const c_=x.forwardRef(({className:l,...n},i)=>e.jsx("caption",{ref:i,className:L("mt-4 text-sm text-muted-foreground",l),...n}));c_.displayName="TableCaption";const $o=x.forwardRef(({className:l,...n},i)=>e.jsx(ha,{ref:i,className:L("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",l),...n}));$o.displayName=ha.displayName;const Ho=x.forwardRef(({className:l,...n},i)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Vt,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ha.Input,{ref:i,className:L("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",l),...n})]}));Ho.displayName=ha.Input.displayName;const Go=x.forwardRef(({className:l,...n},i)=>e.jsx(ha.List,{ref:i,className:L("max-h-[300px] overflow-y-auto overflow-x-hidden",l),...n}));Go.displayName=ha.List.displayName;const Po=x.forwardRef((l,n)=>e.jsx(ha.Empty,{ref:n,className:"py-6 text-center text-sm",...l}));Po.displayName=ha.Empty.displayName;const Hi=x.forwardRef(({className:l,...n},i)=>e.jsx(ha.Group,{ref:i,className:L("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",l),...n}));Hi.displayName=ha.Group.displayName;const o_=x.forwardRef(({className:l,...n},i)=>e.jsx(ha.Separator,{ref:i,className:L("-mx-1 h-px bg-border",l),...n}));o_.displayName=ha.Separator.displayName;const Gi=x.forwardRef(({className:l,...n},i)=>e.jsx(ha.Item,{ref:i,className:L("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",l),...n}));Gi.displayName=ha.Item.displayName;const Js=x.forwardRef(({className:l,...n},i)=>e.jsx(sj,{ref:i,className:L("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",l),...n,children:e.jsx(lw,{className:L("grid place-content-center text-current"),children:e.jsx(yt,{className:"h-4 w-4"})})}));Js.displayName=sj.displayName;const Yj=x.createContext(null),Xj="maibot-completed-tours";function d_(){try{const l=localStorage.getItem(Xj);return l?new Set(JSON.parse(l)):new Set}catch{return new Set}}function ng(l){localStorage.setItem(Xj,JSON.stringify([...l]))}function u_({children:l}){const[n,i]=x.useState({activeTourId:null,stepIndex:0,isRunning:!1}),c=x.useRef(new Map),[,u]=x.useState(0),[m,h]=x.useState(d_),f=x.useCallback((E,_)=>{c.current.set(E,_),u(T=>T+1)},[]),p=x.useCallback(E=>{c.current.delete(E),i(_=>_.activeTourId===E?{..._,activeTourId:null,isRunning:!1,stepIndex:0}:_)},[]),j=x.useCallback((E,_=0)=>{c.current.has(E)&&i({activeTourId:E,stepIndex:_,isRunning:!0})},[]),v=x.useCallback(()=>{i(E=>({...E,isRunning:!1}))},[]),N=x.useCallback(E=>{i(_=>({..._,stepIndex:E}))},[]),b=x.useCallback(()=>{i(E=>({...E,stepIndex:E.stepIndex+1}))},[]),S=x.useCallback(()=>{i(E=>({...E,stepIndex:Math.max(0,E.stepIndex-1)}))},[]),w=x.useCallback(()=>n.activeTourId?c.current.get(n.activeTourId)||[]:[],[n.activeTourId]),O=x.useCallback(E=>{h(_=>{const T=new Set(_);return T.add(E),ng(T),T})},[]),M=x.useCallback(E=>{const{action:_,index:T,status:P,type:A}=E,ee=["finished","skipped"];if(_==="close"){i(H=>({...H,isRunning:!1,stepIndex:0}));return}ee.includes(P)?i(H=>(P==="finished"&&H.activeTourId&&setTimeout(()=>O(H.activeTourId),0),{...H,isRunning:!1,stepIndex:0})):A==="step:after"&&(_==="next"?i(H=>({...H,stepIndex:T+1})):_==="prev"&&i(H=>({...H,stepIndex:T-1})))},[O]),D=x.useCallback(E=>m.has(E),[m]),$=x.useCallback(E=>{h(_=>{const T=new Set(_);return T.delete(E),ng(T),T})},[]);return e.jsx(Yj.Provider,{value:{state:n,tours:c.current,registerTour:f,unregisterTour:p,startTour:j,stopTour:v,goToStep:N,nextStep:b,prevStep:S,getCurrentSteps:w,handleJoyrideCallback:M,isTourCompleted:D,markTourCompleted:O,resetTourCompleted:$},children:l})}function $m(){const l=x.useContext(Yj);if(!l)throw new Error("useTour must be used within a TourProvider");return l}const m_={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)"}},x_={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function h_(){const{state:l,getCurrentSteps:n,handleJoyrideCallback:i}=$m(),c=n(),[u,m]=x.useState(!1),h=x.useRef(l.stepIndex),f=x.useRef(null);x.useEffect(()=>{h.current!==l.stepIndex&&(m(!1),h.current=l.stepIndex)},[l.stepIndex]),x.useEffect(()=>{if(!l.isRunning||c.length===0){m(!1);return}const v=c[l.stepIndex];if(!v){m(!1);return}const N=v.target;if(N==="body"){m(!0);return}m(!1);const b=setTimeout(()=>{const S=()=>{const D=document.querySelector(N);if(D){const $=D.getBoundingClientRect();if($.width>0&&$.height>0)return!0}return!1};if(S()){setTimeout(()=>m(!0),100);return}const w=setInterval(()=>{S()&&(clearInterval(w),setTimeout(()=>m(!0),100))},100),O=setTimeout(()=>{clearInterval(w),m(!0)},5e3),M=()=>{clearInterval(w),clearTimeout(O)};f.current=M},150);return()=>{clearTimeout(b),f.current&&(f.current(),f.current=null)}},[l.isRunning,l.stepIndex,c]);const p=x.useRef(null);if(x.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,()=>{}},[]),!l.isRunning||c.length===0||!u)return null;const j=e.jsx(t1,{steps:c,stepIndex:l.stepIndex,run:l.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:i,styles:m_,locale:x_,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${l.stepIndex}`);return p.current?Iy.createPortal(j,p.current):j}const Ya="model-assignment-tour",Jj=[{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}],Zj={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"},Mi=[{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 rg(l){return l?l.replace(/\/+$/,"").toLowerCase():""}function f_(l){if(!l)return null;const n=rg(l);return Mi.find(i=>i.id!=="custom"&&rg(i.base_url)===n)||null}const ho=l=>({...l,max_retry:l.max_retry??2,timeout:l.timeout??30,retry_interval:l.retry_interval??10}),p_=l=>{const n={};return l?(l.name?.trim()||(n.name="请输入提供商名称"),l.base_url?.trim()||(n.base_url="请输入基础 URL"),l.api_key?.trim()||(n.api_key="请输入 API Key"),{isValid:Object.keys(n).length===0,errors:n}):{isValid:!1,errors:{name:"提供商数据为空"}}};function g_(){return e.jsx(On,{children:e.jsx(j_,{})})}function j_(){const[l,n]=x.useState([]),[i,c]=x.useState(!0),[u,m]=x.useState(!1),[h,f]=x.useState(!1),[p,j]=x.useState(!1),[v,N]=x.useState(!1),[b,S]=x.useState(null),[w,O]=x.useState(null),[M,D]=x.useState("custom"),[$,E]=x.useState(!1),[_,T]=x.useState(!1),[P,A]=x.useState(null),[ee,H]=x.useState(!1),[Z,re]=x.useState(""),[ye,de]=x.useState(new Set),[ge,je]=x.useState(!1),[z,Q]=x.useState(1),[J,U]=x.useState(20),[G,Ce]=x.useState(""),[be,ke]=x.useState({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),[I,we]=x.useState({}),[q,oe]=x.useState(new Set),[Te,X]=x.useState(new Map),{toast:ne}=et(),Ie=xa(),{state:Je,goToStep:pe,registerTour:as}=$m(),{triggerRestart:F,isRestarting:ze}=tn(),ue=x.useRef(null),ve=x.useRef(!0);x.useEffect(()=>{as(Ya,Jj)},[as]),x.useEffect(()=>{if(Je.activeTourId===Ya&&Je.isRunning){const Y=Zj[Je.stepIndex];Y&&!window.location.pathname.endsWith(Y.replace("/config/",""))&&Ie({to:Y})}},[Je.stepIndex,Je.activeTourId,Je.isRunning,Ie]);const Me=x.useRef(Je.stepIndex);x.useEffect(()=>{if(Je.activeTourId===Ya&&Je.isRunning){const Y=Me.current,Ne=Je.stepIndex;Y>=3&&Y<=9&&Ne<3&&N(!1),Y>=10&&Ne>=3&&Ne<=9&&(we({}),D("custom"),S({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),O(null),H(!1),N(!0)),Me.current=Ne}},[Je.stepIndex,Je.activeTourId,Je.isRunning]),x.useEffect(()=>{if(Je.activeTourId!==Ya||!Je.isRunning)return;const Y=Ne=>{const Ee=Ne.target,Ps=Je.stepIndex;Ps===2&&Ee.closest('[data-tour="add-provider-button"]')?setTimeout(()=>pe(3),300):Ps===9&&Ee.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>pe(10),300)};return document.addEventListener("click",Y,!0),()=>document.removeEventListener("click",Y,!0)},[Je,pe]),x.useEffect(()=>{Ke()},[]);const Ke=async()=>{try{c(!0);const Y=await Zl();n(Y.api_providers||[]),j(!1),ve.current=!1}catch(Y){console.error("加载配置失败:",Y)}finally{c(!1)}},qe=async()=>{await F()},Zt=async()=>{try{m(!0),ue.current&&clearTimeout(ue.current);const Y=l.map(dt=>({...dt,max_retry:dt.max_retry??2,timeout:dt.timeout??30,retry_interval:dt.retry_interval??10})),{shouldProceed:Ne}=await Et(Y,"restart");if(!Ne){m(!1);return}const Ee=await Zl(),Ps=new Set(Y.map(dt=>dt.name)),Wt=(Ee.models||[]).filter(dt=>Ps.has(dt.api_provider));Ee.api_providers=Y,Ee.models=Wt,await Ri(Ee),j(!1),ne({title:"保存成功",description:"正在重启麦麦..."}),await qe()}catch(Y){console.error("保存配置失败:",Y),ne({title:"保存失败",description:Y.message,variant:"destructive"}),m(!1)}},Et=x.useCallback(async(Y,Ne="auto")=>{try{const Ee=await Zl(),Ps=new Set(l.map(vt=>vt.name)),qa=new Set(Y.map(vt=>vt.name)),Wt=Array.from(Ps).filter(vt=>!qa.has(vt));if(Wt.length===0)return{shouldProceed:!0,providers:Y};const ea=(Ee.models||[]).filter(vt=>Wt.includes(vt.api_provider));return ea.length===0?{shouldProceed:!0,providers:Y}:(ke({isOpen:!0,providersToDelete:Wt,affectedModels:ea,pendingProviders:Y,context:Ne,oldProviders:[...l]}),{shouldProceed:!1,providers:Y})}catch(Ee){return console.error("检查删除影响失败:",Ee),{shouldProceed:!0,providers:Y}}},[l]),ot=async()=>{try{(be.context==="auto"?f:m)(!0),ke(vt=>({...vt,isOpen:!1}));const Ne=await Zl(),Ee=be.pendingProviders.map(ho),Ps=new Set(Ee.map(vt=>vt.name)),Wt=(Ne.models||[]).filter(vt=>Ps.has(vt.api_provider)),dt=new Set(be.affectedModels.map(vt=>vt.name)),ea=Ne.model_task_config;ea&&Object.keys(ea).forEach(vt=>{const nn=ea[vt];nn&&Array.isArray(nn.model_list)&&(nn.model_list=nn.model_list.filter(Xi=>!dt.has(Xi)))}),Ne.api_providers=Ee,Ne.models=Wt,Ne.model_task_config=ea,await Ri(Ne),n(be.pendingProviders),j(!1),ne({title:"删除成功",description:`已删除 ${be.providersToDelete.length} 个提供商和 ${be.affectedModels.length} 个关联模型`}),ke({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),de(new Set),be.context==="restart"&&await qe()}catch(Y){console.error("删除失败:",Y),ne({title:"删除失败",description:Y.message,variant:"destructive"})}finally{be.context==="auto"?f(!1):m(!1)}},K=()=>{be.oldProviders.length>0&&n(be.oldProviders),ke({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),j(!1)},Pe=x.useCallback(async Y=>{if(ve.current)return;const{shouldProceed:Ne}=await Et(Y,"auto");if(!Ne){j(!0);return}try{f(!0);const Ee=Y.map(ho);await Em("api_providers",Ee),j(!1)}catch(Ee){console.error("自动保存失败:",Ee),ne({title:"自动保存失败",description:Ee.message,variant:"destructive"}),j(!0)}finally{f(!1)}},[l,Et]);x.useEffect(()=>{if(!ve.current)return j(!0),ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{Pe(l)},2e3),()=>{ue.current&&clearTimeout(ue.current)}},[l,Pe]);const Be=async()=>{try{m(!0),ue.current&&clearTimeout(ue.current);const Y=l.map(ho),{shouldProceed:Ne}=await Et(Y,"manual");if(!Ne){m(!1);return}const Ee=await Zl(),Ps=new Set(Y.map(dt=>dt.name)),qa=Ee.models||[],Wt=qa.filter(dt=>{const ea=Ps.has(dt.api_provider);return ea||console.warn(`模型 "${dt.name}" 引用了已删除的提供商 "${dt.api_provider}",将被移除`),ea});if(qa.length!==Wt.length){const dt=qa.length-Wt.length;ne({title:"注意",description:`已自动移除 ${dt} 个引用已删除提供商的模型`,variant:"default"})}console.log("发送的 providers 数据:",Y),Ee.api_providers=Y,Ee.models=Wt,console.log("完整配置数据:",Ee),await Ri(Ee),j(!1),ne({title:"保存成功",description:"模型提供商配置已保存"})}catch(Y){console.error("保存配置失败:",Y),ne({title:"保存失败",description:Y.message,variant:"destructive"})}finally{m(!1)}},_e=(Y,Ne)=>{if(we({}),Y){const Ee=Mi.find(Ps=>Ps.base_url===Y.base_url&&Ps.client_type===Y.client_type);D(Ee?.id||"custom"),S(Y)}else D("custom"),S({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});O(Ne),H(!1),N(!0)},gs=x.useCallback(Y=>{D(Y),E(!1);const Ne=Mi.find(Ee=>Ee.id===Y);Ne&&Ne.id!=="custom"?S(Ee=>({...Ee,name:Ne.name,base_url:Ne.base_url,client_type:Ne.client_type})):Ne?.id==="custom"&&S(Ee=>({...Ee,name:"",base_url:"",client_type:"openai"}))},[]),is=x.useMemo(()=>M!=="custom",[M]),As=x.useCallback(async()=>{if(b?.api_key)try{await navigator.clipboard.writeText(b.api_key),ne({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{ne({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},[b?.api_key,ne]),Ds=()=>{if(!b)return;const{isValid:Y,errors:Ne}=p_(b);if(!Y){we(Ne);return}we({});const Ee=ho(b);if(w!==null){const Ps=[...l];Ps[w]=Ee,n(Ps)}else n([...l,Ee]);N(!1),S(null),O(null)},Gs=Y=>{if(!Y&&b){const Ne={...b,max_retry:b.max_retry??2,timeout:b.timeout??30,retry_interval:b.retry_interval??10};S(Ne)}N(Y)},ls=Y=>{A(Y),T(!0)},es=async()=>{if(P!==null){const Y=l.filter((Ee,Ps)=>Ps!==P),{shouldProceed:Ne}=await Et(Y,"manual");Ne&&(n(Y),ne({title:"删除成功",description:"提供商已从列表中移除"}))}T(!1),A(null)},Ze=Y=>{const Ne=new Set(ye);Ne.has(Y)?Ne.delete(Y):Ne.add(Y),de(Ne)},Us=()=>{if(ye.size===Cs.length)de(new Set);else{const Y=Cs.map((Ne,Ee)=>l.findIndex(Ps=>Ps===Cs[Ee]));de(new Set(Y))}},zt=()=>{if(ye.size===0){ne({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}je(!0)},st=async()=>{const Y=l.filter((Ee,Ps)=>!ye.has(Ps)),{shouldProceed:Ne}=await Et(Y,"manual");Ne&&(n(Y),de(new Set),ne({title:"批量删除成功",description:`已删除 ${ye.size} 个提供商`})),je(!1)},Cs=x.useMemo(()=>{if(!Z)return l;const Y=Z.toLowerCase();return l.filter(Ne=>Ne.name.toLowerCase().includes(Y)||Ne.base_url.toLowerCase().includes(Y)||Ne.client_type.toLowerCase().includes(Y))},[l,Z]),{totalPages:jt,paginatedProviders:ae}=x.useMemo(()=>{const Y=Math.ceil(Cs.length/J),Ne=Cs.slice((z-1)*J,z*J);return{totalPages:Y,paginatedProviders:Ne}},[Cs,z,J]),xe=x.useCallback(()=>{const Y=parseInt(G);Y>=1&&Y<=jt&&(Q(Y),Ce(""))},[G,jt]),ys=async Y=>{oe(Ne=>new Set(Ne).add(Y));try{const Ne=await Y2(Y);X(Ee=>new Map(Ee).set(Y,Ne)),Ne.network_ok?Ne.api_key_valid===!0?ne({title:"连接正常",description:`${Y} 网络连接正常API Key 有效 (${Ne.latency_ms}ms)`}):Ne.api_key_valid===!1?ne({title:"连接正常但 Key 无效",description:`${Y} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):ne({title:"网络连接正常",description:`${Y} 可以访问 (${Ne.latency_ms}ms)`}):ne({title:"连接失败",description:Ne.error||"无法连接到提供商",variant:"destructive"})}catch(Ne){ne({title:"测试失败",description:Ne.message,variant:"destructive"})}finally{oe(Ne=>{const Ee=new Set(Ne);return Ee.delete(Y),Ee})}},Dt=async()=>{for(const Y of l)await ys(Y.name)},Ot=Y=>{const Ne=q.has(Y),Ee=Te.get(Y);return Ne?e.jsxs(Ae,{variant:"secondary",className:"gap-1",children:[e.jsx(Xs,{className:"h-3 w-3 animate-spin"}),"测试中"]}):Ee?Ee.network_ok?Ee.api_key_valid===!0?e.jsxs(Ae,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(ua,{className:"h-3 w-3"}),"正常"]}):Ee.api_key_valid===!1?e.jsxs(Ae,{variant:"destructive",className:"gap-1",children:[e.jsx(Ut,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(Ae,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(ua,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(Ae,{variant:"destructive",className:"gap-1",children:[e.jsx(dj,{className:"h-3 w-3"}),"离线"]}):null};return i?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:[ye.size>0&&e.jsxs(C,{onClick:zt,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(rs,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",ye.size,")"]}),e.jsxs(C,{onClick:Dt,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:l.length===0||q.size>0,children:[e.jsx(Cn,{className:"mr-2 h-4 w-4"}),q.size>0?`测试中 (${q.size})`:"测试全部"]}),e.jsxs(C,{onClick:()=>_e(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(ft,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(C,{onClick:Be,disabled:u||h||!p||ze,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(Fi,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),u?"保存中...":h?"自动保存中...":p?"保存配置":"已保存"]}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{disabled:u||h||ze,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(Vi,{className:"mr-2 h-4 w-4"}),ze?"重启中...":p?"保存并重启":"重启麦麦"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重启麦麦?"}),e.jsx(hs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:p?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:p?Zt:qe,children:p?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsxs(_t,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Xe,{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(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索提供商名称、URL 或类型...",value:Z,onChange:Y=>re(Y.target.value),className:"pl-9"})]}),Z&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Cs.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Cs.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:Z?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):ae.map((Y,Ne)=>{const Ee=l.findIndex(Ps=>Ps===Y);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:Y.name}),Ot(Y.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:Y.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>ys(Y.name),disabled:q.has(Y.name),title:"测试连接",children:q.has(Y.name)?e.jsx(Xs,{className:"h-4 w-4 animate-spin"}):e.jsx(Cn,{className:"h-4 w-4"})}),e.jsx(C,{variant:"default",size:"sm",onClick:()=>_e(Y,Ee),children:e.jsx(kn,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(C,{size:"sm",onClick:()=>ls(Ee),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(rs,{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:Y.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:Y.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:Y.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:Y.retry_interval})]})]})]},Ne)})}),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(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{className:"w-12",children:e.jsx(Js,{checked:ye.size===Cs.length&&Cs.length>0,onCheckedChange:Us})}),e.jsx(Ye,{children:"状态"}),e.jsx(Ye,{children:"名称"}),e.jsx(Ye,{children:"基础URL"}),e.jsx(Ye,{children:"客户端类型"}),e.jsx(Ye,{className:"text-right",children:"最大重试"}),e.jsx(Ye,{className:"text-right",children:"超时(秒)"}),e.jsx(Ye,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:ae.length===0?e.jsx(lt,{children:e.jsx(Ge,{colSpan:9,className:"text-center text-muted-foreground py-8",children:Z?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):ae.map((Y,Ne)=>{const Ee=l.findIndex(Ps=>Ps===Y);return e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Js,{checked:ye.has(Ee),onCheckedChange:()=>Ze(Ee)})}),e.jsx(Ge,{children:Ot(Y.name)||e.jsx(Ae,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Ge,{className:"font-medium",children:Y.name}),e.jsx(Ge,{className:"max-w-xs truncate",title:Y.base_url,children:Y.base_url}),e.jsx(Ge,{children:Y.client_type}),e.jsx(Ge,{className:"text-right",children:Y.max_retry}),e.jsx(Ge,{className:"text-right",children:Y.timeout}),e.jsx(Ge,{className:"text-right",children:Y.retry_interval}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>ys(Y.name),disabled:q.has(Y.name),title:"测试连接",children:q.has(Y.name)?e.jsx(Xs,{className:"h-4 w-4 animate-spin"}):e.jsx(Cn,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"default",size:"sm",onClick:()=>_e(Y,Ee),children:[e.jsx(kn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(C,{size:"sm",onClick:()=>ls(Ee),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},Ne)})})]})})}),Cs.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(k,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs($e,{value:J.toString(),onValueChange:Y=>{U(parseInt(Y)),Q(1),de(new Set)},children:[e.jsx(Le,{id:"page-size-provider",className:"w-20",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(z-1)*J+1," 到"," ",Math.min(z*J,Cs.length)," 条,共 ",Cs.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>Q(1),disabled:z===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Q(Y=>Math.max(1,Y-1)),disabled:z===1,children:[e.jsx(el,{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:G,onChange:Y=>Ce(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&xe(),placeholder:z.toString(),className:"w-16 h-8 text-center",min:1,max:jt}),e.jsx(C,{variant:"outline",size:"sm",onClick:xe,disabled:!G,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Q(Y=>Y+1),disabled:z>=jt,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>Q(jt),disabled:z>=jt,className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})]}),e.jsx(Hs,{open:v,onOpenChange:Gs,children:e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:Je.isRunning,children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:w!==null?"编辑提供商":"添加提供商"}),e.jsx(Ws,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:Y=>{Y.preventDefault(),Ds()},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(k,{htmlFor:"template",children:"提供商模板"}),e.jsxs(Za,{open:$,onOpenChange:E,children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":$,className:"w-full justify-between",children:[M?Mi.find(Y=>Y.id===M)?.display_name:"选择提供商模板...",e.jsx(Rm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs($o,{children:[e.jsx(Ho,{placeholder:"搜索提供商模板..."}),e.jsx(Xe,{className:"h-[300px]",children:e.jsxs(Go,{className:"max-h-none overflow-visible",children:[e.jsx(Po,{children:"未找到匹配的模板"}),e.jsx(Hi,{children:Mi.map(Y=>e.jsxs(Gi,{value:Y.display_name,onSelect:()=>gs(Y.id),children:[e.jsx(yt,{className:`mr-2 h-4 w-4 ${M===Y.id?"opacity-100":"opacity-0"}`}),Y.display_name]},Y.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(k,{htmlFor:"name",className:I.name?"text-destructive":"",children:"名称 *"}),e.jsx(ce,{id:"name",value:b?.name||"",onChange:Y=>{S(Ne=>Ne?{...Ne,name:Y.target.value}:null),I.name&&we(Ne=>({...Ne,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:I.name?"border-destructive focus-visible:ring-destructive":""}),I.name&&e.jsx("p",{className:"text-xs text-destructive",children:I.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsx(k,{htmlFor:"base_url",className:I.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(ce,{id:"base_url",value:b?.base_url||"",onChange:Y=>{S(Ne=>Ne?{...Ne,base_url:Y.target.value}:null),I.base_url&&we(Ne=>({...Ne,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:is,className:`${is?"bg-muted cursor-not-allowed":""} ${I.base_url?"border-destructive focus-visible:ring-destructive":""}`}),I.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:I.base_url}),is&&!I.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(k,{htmlFor:"api_key",className:I.api_key?"text-destructive":"",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{id:"api_key",type:ee?"text":"password",value:b?.api_key||"",onChange:Y=>{S(Ne=>Ne?{...Ne,api_key:Y.target.value}:null),I.api_key&&we(Ne=>({...Ne,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${I.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(C,{type:"button",variant:"outline",size:"icon",onClick:()=>H(!ee),title:ee?"隐藏密钥":"显示密钥",children:ee?e.jsx(Ui,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})}),e.jsx(C,{type:"button",variant:"outline",size:"icon",onClick:As,title:"复制密钥",children:e.jsx(_o,{className:"h-4 w-4"})})]}),I.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:I.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs($e,{value:b?.client_type||"openai",onValueChange:Y=>S(Ne=>Ne?{...Ne,client_type:Y}:null),disabled:is,children:[e.jsx(Le,{id:"client_type",className:is?"bg-muted cursor-not-allowed":"",children:e.jsx(He,{placeholder:"选择客户端类型"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"openai",children:"OpenAI"}),e.jsx(le,{value:"gemini",children:"Gemini"})]})]}),is&&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(k,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(ce,{id:"max_retry",type:"number",min:"0",value:b?.max_retry??"",onChange:Y=>{const Ne=Y.target.value===""?null:parseInt(Y.target.value);S(Ee=>Ee?{...Ee,max_retry:Ne}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(ce,{id:"timeout",type:"number",min:"1",value:b?.timeout??"",onChange:Y=>{const Ne=Y.target.value===""?null:parseInt(Y.target.value);S(Ee=>Ee?{...Ee,timeout:Ne}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(ce,{id:"retry_interval",type:"number",min:"1",value:b?.retry_interval??"",onChange:Y=>{const Ne=Y.target.value===""?null:parseInt(Y.target.value);S(Ee=>Ee?{...Ee,retry_interval:Ne}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(nt,{children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>N(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(C,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(js,{open:_,onOpenChange:T,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除提供商 "',P!==null?l[P]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:es,children:"删除"})]})]})}),e.jsx(js,{open:ge,onOpenChange:je,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["确定要删除选中的 ",ye.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:st,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(js,{open:be.isOpen,onOpenChange:Y=>ke(Ne=>({...Ne,isOpen:Y})),children:e.jsxs(ds,{className:"max-w-2xl",children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除提供商"}),e.jsx(hs,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["您即将删除以下提供商:",e.jsx("strong",{className:"text-foreground ml-1",children:be.providersToDelete.join(", ")})]}),e.jsxs("p",{className:"text-yellow-600 dark:text-yellow-500 font-medium",children:["⚠️ 此操作将同时删除 ",be.affectedModels.length," 个关联的模型:"]}),e.jsx(Xe,{className:"h-32 w-full rounded border p-3",children:e.jsx("div",{className:"space-y-1",children:be.affectedModels.map((Y,Ne)=>e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-mono text-muted-foreground",children:"•"}),e.jsx("span",{className:"ml-2 font-medium",children:Y.name}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",Y.model_identifier,")"]})]},Ne))})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"这些模型将从模型列表和所有任务分配中移除。此操作无法撤销。"})]})})]}),e.jsxs(ms,{children:[e.jsx(ps,{onClick:K,children:"取消"}),e.jsx(fs,{onClick:ot,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})}),e.jsx(Rn,{})]})}function Wj(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,11)}`}function ev(l){return typeof l=="boolean"?"boolean":typeof l=="number"?"number":"string"}function v_(l,n){switch(n){case"boolean":return l==="true";case"number":{const i=parseFloat(l);return isNaN(i)?0:i}default:return l}}function hm(l){return Object.entries(l).map(([n,i])=>({id:Wj(),key:n,value:i,type:ev(i)}))}function fm(l){const n={};for(const i of l)i.key.trim()&&(n[i.key.trim()]=i.value);return n}function pm(l){if(!l.trim())return{valid:!0,parsed:{}};try{const n=JSON.parse(l);if(typeof n!="object"||n===null||Array.isArray(n))return{valid:!1,error:"必须是一个 JSON 对象 {}"};for(const[i,c]of Object.entries(n))if(c!==null&&!["string","number","boolean"].includes(typeof c))return{valid:!1,error:`键 "${i}" 的值类型不支持(仅支持 string/number/boolean`};return{valid:!0,parsed:n}}catch{return{valid:!1,error:"JSON 格式错误"}}}function N_(l){switch(l){case"boolean":return"布尔";case"number":return"数字";default:return"字符串"}}function b_(l){switch(l){case"boolean":return"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";case"number":return"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400";default:return"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"}}function y_({value:l,onChange:n,className:i,placeholder:c="添加额外参数..."}){const[u,m]=x.useState("list"),[h,f]=x.useState(()=>hm(l||{})),[p,j]=x.useState(()=>Object.keys(l||{}).length>0?JSON.stringify(l,null,2):""),[v,N]=x.useState(null);x.useEffect(()=>{const $=hm(l||{});f($),j(Object.keys(l||{}).length>0?JSON.stringify(l,null,2):"")},[l]);const b=x.useMemo(()=>{const $=pm(p);return $.valid&&$.parsed?{success:!0,data:$.parsed}:{success:!1,data:{}}},[p]),S=x.useCallback($=>{const E=$;if(E==="json"&&u==="list"){const _=fm(h);j(Object.keys(_).length>0?JSON.stringify(_,null,2):""),N(null)}else if(E==="list"&&u==="json"){const _=pm(p);_.valid&&_.parsed&&(f(hm(_.parsed)),N(null))}m(E)},[u,h,p]),w=x.useCallback(()=>{const $={id:Wj(),key:"",value:"",type:"string"},E=[...h,$];f(E)},[h]),O=x.useCallback($=>{const E=h.filter(_=>_.id!==$);f(E),n(fm(E))},[h,n]),M=x.useCallback(($,E,_)=>{const T=h.map(P=>{if(P.id!==$)return P;if(E==="type"){const A=_;let ee;return A==="boolean"?ee=P.value==="true"||P.value===!0:A==="number"?ee=typeof P.value=="number"?P.value:parseFloat(String(P.value))||0:ee=String(P.value),{...P,type:A,value:ee}}else return E==="value"?{...P,value:v_(_,P.type)}:{...P,[E]:_}});f(T),n(fm(T))},[h,n]),D=x.useCallback($=>{j($);const E=pm($);E.valid&&E.parsed?(N(null),n(E.parsed)):N(E.error||"JSON 格式错误")},[n]);return e.jsxs("div",{className:L("space-y-3",i),children:[e.jsx(k,{className:"text-sm font-medium",children:"额外参数"}),e.jsxs(ma,{value:u,onValueChange:S,className:"w-full",children:[e.jsxs(Xt,{className:"h-8 p-0.5 bg-muted/60",children:[e.jsx(ss,{value:"list",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"键值对"}),e.jsx(ss,{value:"json",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"JSON"})]}),e.jsxs(Ss,{value:"list",className:"mt-3 space-y-2",children:[h.length===0?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded-md",children:c}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_90px_32px] gap-2 text-xs text-muted-foreground px-1",children:[e.jsx("span",{children:"键名"}),e.jsx("span",{children:"值"}),e.jsx("span",{children:"类型"}),e.jsx("span",{})]}),h.map($=>e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_90px_32px] gap-2 items-center",children:[e.jsx(ce,{value:$.key,onChange:E=>M($.id,"key",E.target.value),placeholder:"key",className:"h-8 text-sm"}),$.type==="boolean"?e.jsxs("div",{className:"flex items-center h-8 px-3 border rounded-md bg-background",children:[e.jsx(Fe,{checked:$.value===!0,onCheckedChange:E=>M($.id,"value",String(E))}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:$.value?"true":"false"})]}):e.jsx(ce,{type:$.type==="number"?"number":"text",value:$.value,onChange:E=>M($.id,"value",E.target.value),placeholder:"value",className:"h-8 text-sm",step:$.type==="number"?"any":void 0}),e.jsxs($e,{value:$.type,onValueChange:E=>M($.id,"type",E),children:[e.jsx(Le,{className:"h-8 text-xs",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"string",children:"字符串"}),e.jsx(le,{value:"number",children:"数字"}),e.jsx(le,{value:"boolean",children:"布尔"})]})]}),e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>O($.id),children:e.jsx(rs,{className:"h-4 w-4"})})]},$.id))]}),e.jsxs(C,{type:"button",variant:"outline",size:"sm",className:"w-full h-8",onClick:w,children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"添加参数"]})]}),e.jsx(Ss,{value:"json",className:"mt-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"编辑"}),v?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[e.jsx(Ut,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[150px]",children:v})]}):p.trim()&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[e.jsx(yt,{className:"h-3 w-3"}),e.jsx("span",{children:"有效"})]})]}),e.jsx(Ys,{value:p,onChange:$=>D($.target.value),placeholder:`{
"key": "value"
}`,className:L("font-mono text-sm min-h-[140px] h-[140px] resize-y flex-1",v&&"border-destructive focus-visible:ring-destructive")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持 string、number、boolean 类型"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"预览"}),e.jsx("div",{className:"min-h-[140px] h-[140px] flex-1 rounded-md border bg-muted/30 p-3 overflow-auto",children:b.success&&Object.keys(b.data).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(b.data).map(([$,E])=>{const _=ev(E);return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("code",{className:"px-1.5 py-0.5 bg-background rounded text-xs font-medium",children:$}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:L("font-mono",_==="boolean"&&(E?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),_==="number"&&"text-blue-600 dark:text-blue-400",_==="string"&&"text-amber-600 dark:text-amber-400"),children:_==="string"?`"${E}"`:String(E)}),e.jsx(Ae,{variant:"secondary",className:L("h-5 text-[10px] px-1.5",b_(_)),children:N_(_)})]},$)})}):b.success?e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"暂无参数"}):e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive",children:"JSON 格式错误"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"实时预览解析结果"})]})]})})]})]})}const Or="https://maibot-plugin-stats.maibot-webui.workers.dev";async function w_(l){const n=new URLSearchParams;l?.status&&n.set("status",l.status),l?.page&&n.set("page",l.page.toString()),l?.page_size&&n.set("page_size",l.page_size.toString()),l?.search&&n.set("search",l.search),l?.sort_by&&n.set("sort_by",l.sort_by),l?.sort_order&&n.set("sort_order",l.sort_order);const i=await fetch(`${Or}/pack?${n.toString()}`);if(!i.ok)throw new Error(`获取 Pack 列表失败: ${i.status}`);return i.json()}async function __(l){const n=await fetch(`${Or}/pack/${l}`);if(!n.ok)throw new Error(`获取 Pack 失败: ${n.status}`);const i=await n.json();if(!i.success)throw new Error(i.error||"获取 Pack 失败");return i.pack}async function S_(l){const i=await(await fetch(`${Or}/pack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.error||"创建 Pack 失败");return i}async function C_(l,n){await fetch(`${Or}/pack/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:l,user_id:n})})}async function sv(l,n){const c=await(await fetch(`${Or}/pack/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:l,user_id:n})})).json();if(!c.success)throw new Error(c.error||"点赞失败");return{likes:c.likes,liked:c.liked}}async function tv(l,n){return(await(await fetch(`${Or}/pack/like/check?pack_id=${l}&user_id=${n}`)).json()).liked||!1}async function k_(l){const n=await Se("/api/webui/config/model");if(!n.ok)throw new Error("获取当前模型配置失败");const i=await n.json(),c=i.config||i;console.log("=== Pack Conflict Detection ==="),console.log("Pack providers:",l.providers),console.log("Local providers:",c.api_providers);const u={existing_providers:[],new_providers:[],conflicting_models:[]},m=c.api_providers||[];for(const f of l.providers){console.log(`
Checking pack provider: ${f.name}`),console.log(` Pack URL: ${f.base_url}`),console.log(` Normalized: ${gm(f.base_url)}`);const p=m.filter(j=>{const v=gm(j.base_url),N=gm(f.base_url);return console.log(` Comparing with local "${j.name}": ${j.base_url}`),console.log(` Local normalized: ${v}`),console.log(` Match: ${v===N}`),v===N});p.length>0?(console.log(` ✓ Matched with ${p.length} local provider(s):`,p.map(j=>j.name).join(", ")),u.existing_providers.push({pack_provider:f,local_providers:p.map(j=>({name:j.name,base_url:j.base_url}))})):(console.log(" ✗ No match found - will need API key"),u.new_providers.push(f))}const h=c.models||[];console.log(`
=== Model Conflict Detection ===`);for(const f of l.models){const p=h.find(j=>j.name===f.name);p&&(console.log(`Model conflict: ${f.name}`),u.conflicting_models.push({pack_model:f.name,local_model:p.name}))}return console.log(`
=== Detection Summary ===`),console.log(`Existing providers: ${u.existing_providers.length}`),console.log(`New providers: ${u.new_providers.length}`),console.log(`Conflicting models: ${u.conflicting_models.length}`),console.log(`===========================
`),u}async function T_(l,n,i,c){const u=await Se("/api/webui/config/model");if(!u.ok)throw new Error("获取当前模型配置失败");const m=await u.json(),h=m.config||m;if(n.apply_providers){const p=n.selected_providers?l.providers.filter(j=>n.selected_providers.includes(j.name)):l.providers;for(const j of p){if(i[j.name])continue;const v=c[j.name];if(!v)throw new Error(`提供商 "${j.name}" 缺少 API Key`);const N={...j,api_key:v},b=h.api_providers.findIndex(S=>S.name===j.name);b>=0?h.api_providers[b]=N:h.api_providers.push(N)}}if(n.apply_models){const p=n.selected_models?l.models.filter(j=>n.selected_models.includes(j.name)):l.models;for(const j of p){const v=i[j.api_provider]||j.api_provider,N={...j,api_provider:v},b=h.models.findIndex(S=>S.name===j.name);b>=0?h.models[b]=N:h.models.push(N)}}if(n.apply_task_config){const p=n.selected_tasks||Object.keys(l.task_config);for(const j of p){const v=l.task_config[j];if(!v)continue;const N=new Set(n.selected_models||l.models.map(w=>w.name)),b=v.model_list.filter(w=>N.has(w));if(b.length===0)continue;const S={...v,model_list:b};if(n.task_mode==="replace")h.model_task_config[j]=S;else{const w=h.model_task_config[j];if(w){const O=[...new Set([...w.model_list,...b])];h.model_task_config[j]={...w,model_list:O}}else h.model_task_config[j]=S}}}if(!(await Se("/api/webui/config/model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).ok)throw new Error("保存配置失败")}async function E_(l){const n=await Se("/api/webui/config/model");if(!n.ok)throw new Error("获取当前模型配置失败");const i=await n.json();if(!i.success||!i.config)throw new Error("获取配置失败");const c=i.config;let u=(c.api_providers||[]).map(j=>({name:j.name,base_url:j.base_url,client_type:j.client_type,max_retry:j.max_retry,timeout:j.timeout,retry_interval:j.retry_interval}));l.selectedProviders&&(u=u.filter(j=>l.selectedProviders.includes(j.name)));let m=c.models||[];l.selectedModels&&(m=m.filter(j=>l.selectedModels.includes(j.name)));const h={},f=c.model_task_config||{},p=l.selectedTasks||Object.keys(f);for(const j of p)f[j]&&(h[j]=f[j]);return{providers:u,models:m,task_config:h}}function gm(l){try{const n=new URL(l);return`${n.protocol}//${n.host}${n.pathname}`.replace(/\/$/,"").toLowerCase()}catch{return l.toLowerCase().replace(/\/$/,"")}}function av(){const l="maibot_pack_user_id";let n=localStorage.getItem(l);return n||(n="pack_user_"+Math.random().toString(36).substring(2,15),localStorage.setItem(l,n)),n}const M_={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"},A_=["官方推荐","性价比","高性能","免费模型","国内可用","海外模型","OpenAI","Claude","Gemini","国产模型","多模态","轻量级"];function z_({trigger:l}){const[n,i]=x.useState(!1),[c,u]=x.useState(1),[m,h]=x.useState(!1),[f,p]=x.useState(!1),[j,v]=x.useState([]),[N,b]=x.useState([]),[S,w]=x.useState({}),[O,M]=x.useState(new Set),[D,$]=x.useState(new Set),[E,_]=x.useState(new Set),[T,P]=x.useState(""),[A,ee]=x.useState(""),[H,Z]=x.useState(""),[re,ye]=x.useState([]);x.useEffect(()=>{n&&c===1&&de()},[n,c]);const de=async()=>{h(!0);try{const I=await E_({name:"",description:"",author:""});v(I.providers),b(I.models),w(I.task_config),M(new Set(I.providers.map(we=>we.name))),$(new Set(I.models.map(we=>we.name))),_(new Set(Object.keys(I.task_config)))}catch(I){console.error("加载配置失败:",I),qt({title:"加载当前配置失败",variant:"destructive"})}finally{h(!1)}},ge=I=>{const we=new Set(O),q=new Set(D),oe=new Set(E);we.has(I)?(we.delete(I),N.filter(X=>X.api_provider===I).forEach(X=>q.delete(X.name)),Object.entries(S).forEach(([X,ne])=>{ne.model_list&&(ne.model_list.some(Je=>q.has(Je))||oe.delete(X))})):(we.add(I),N.filter(X=>X.api_provider===I).forEach(X=>q.add(X.name)),Object.entries(S).forEach(([X,ne])=>{ne.model_list&&ne.model_list.some(Je=>{const pe=N.find(as=>as.name===Je);return pe&&pe.api_provider===I})&&oe.add(X)})),M(we),$(q),_(oe)},je=I=>{const we=new Set(D),q=new Set(E);we.has(I)?(we.delete(I),Object.entries(S).forEach(([oe,Te])=>{Te.model_list&&(Te.model_list.some(ne=>we.has(ne))||q.delete(oe))})):(we.add(I),Object.entries(S).forEach(([oe,Te])=>{Te.model_list&&Te.model_list.includes(I)&&q.add(oe)})),$(we),_(q)},z=I=>{const we=new Set(E);we.has(I)?we.delete(I):we.add(I),_(we)},Q=I=>{re.includes(I)?ye(re.filter(we=>we!==I)):re.length<5?ye([...re,I]):qt({title:"最多选择 5 个标签",variant:"destructive"})},J=()=>{O.size===j.length?M(new Set):M(new Set(j.map(I=>I.name)))},U=()=>{D.size===N.length?$(new Set):$(new Set(N.map(I=>I.name)))},G=()=>{const I=Object.keys(S);E.size===I.length?_(new Set):_(new Set(I))},Ce=async()=>{if(!T.trim()){qt({title:"请输入模板名称",variant:"destructive"});return}if(!A.trim()){qt({title:"请输入模板描述",variant:"destructive"});return}if(!H.trim()){qt({title:"请输入作者名称",variant:"destructive"});return}if(O.size===0&&D.size===0&&E.size===0){qt({title:"请至少选择一项配置",variant:"destructive"});return}p(!0);try{const I=j.filter(oe=>O.has(oe.name)),we=N.filter(oe=>D.has(oe.name)),q={};for(const[oe,Te]of Object.entries(S))E.has(oe)&&(q[oe]=Te);await S_({name:T.trim(),description:A.trim(),author:H.trim(),tags:re,providers:I,models:we,task_config:q}),qt({title:"模板已提交审核,审核通过后将显示在市场中"}),i(!1),be()}catch(I){console.error("提交失败:",I),qt({title:I instanceof Error?I.message:"提交失败",variant:"destructive"})}finally{p(!1)}},be=()=>{u(1),P(""),ee(""),Z(""),ye([]),M(new Set),$(new Set),_(new Set)},ke=2;return e.jsxs(Hs,{open:n,onOpenChange:i,children:[e.jsx(Bo,{asChild:!0,children:l||e.jsxs(C,{variant:"outline",children:[e.jsx(fj,{className:"w-4 h-4 mr-2"}),"分享配置"]})}),e.jsxs(Os,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(da,{className:"w-5 h-5"}),"分享配置模板"]}),e.jsxs(Ws,{children:["步骤 ",c," / ",ke,"",c===1&&"选择要分享的配置",c===2&&"填写模板信息"]})]}),e.jsx(Xe,{className:"h-[calc(85vh-220px)] pr-4",children:m?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Xs,{className:"w-8 h-8 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"正在加载当前配置..."})]}):e.jsxs(e.Fragment,{children:[c===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(Sn,{children:"安全提示"}),e.jsxs(_t,{children:["分享的配置将",e.jsx("strong",{children:"不包含"})," API Key其他用户需要自行配置。"]})]}),e.jsxs(ma,{defaultValue:"providers",className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-3",children:[e.jsxs(ss,{value:"providers",children:[e.jsx(wl,{className:"w-4 h-4 mr-2"}),"API 提供商",e.jsxs(Ae,{variant:"secondary",className:"ml-2",children:[O.size,"/",j.length]})]}),e.jsxs(ss,{value:"models",children:[e.jsx(Tn,{className:"w-4 h-4 mr-2"}),"模型配置",e.jsxs(Ae,{variant:"secondary",className:"ml-2",children:[D.size,"/",N.length]})]}),e.jsxs(ss,{value:"tasks",children:[e.jsx(En,{className:"w-4 h-4 mr-2"}),"任务配置",e.jsxs(Ae,{variant:"secondary",className:"ml-2",children:[E.size,"/",Object.keys(S).length]})]})]}),e.jsx(Ss,{value:"providers",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(C,{variant:"ghost",size:"sm",onClick:J,children:O.size===j.length?"取消全选":"全选"})}),j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无提供商配置"}):j.map(I=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(Js,{id:`provider-${I.name}`,checked:O.has(I.name),onCheckedChange:()=>ge(I.name)}),e.jsxs(k,{htmlFor:`provider-${I.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:I.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:I.base_url})]}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:I.client_type})]},I.name))]})}),e.jsx(Ss,{value:"models",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(C,{variant:"ghost",size:"sm",onClick:U,children:D.size===N.length?"取消全选":"全选"})}),N.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无模型配置"}):N.map(I=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(Js,{id:`model-${I.name}`,checked:D.has(I.name),onCheckedChange:()=>je(I.name)}),e.jsxs(k,{htmlFor:`model-${I.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:I.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:I.model_identifier})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:I.api_provider})]},I.name))]})}),e.jsx(Ss,{value:"tasks",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(C,{variant:"ghost",size:"sm",onClick:G,children:E.size===Object.keys(S).length?"取消全选":"全选"})}),Object.keys(S).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无任务配置"}):Object.entries(S).map(([I,we])=>e.jsxs("div",{className:"space-y-2 p-2 rounded hover:bg-muted",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:`task-${I}`,checked:E.has(I),onCheckedChange:()=>z(I)}),e.jsx(k,{htmlFor:`task-${I}`,className:"flex-1 cursor-pointer",children:e.jsx("span",{className:"font-medium",children:M_[I]||I})}),e.jsxs(Ae,{variant:"outline",className:"text-xs",children:[we.model_list.length," 个模型"]})]}),we.model_list&&we.model_list.length>0&&e.jsx("div",{className:"ml-6 flex flex-wrap gap-1",children:we.model_list.map(q=>{const oe=N.find(X=>X.name===q),Te=D.has(q);return e.jsxs(Ae,{variant:Te?"default":"outline",className:"text-xs cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>je(q),children:[q,oe&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",oe.api_provider,")"]})]},q)})})]},I))]})})]})]}),c===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 text-sm p-3 bg-muted rounded-lg",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wl,{className:"w-4 h-4"}),O.size," 个提供商"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"w-4 h-4"}),D.size," 个模型"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(En,{className:"w-4 h-4"}),E.size," 个任务"]})]}),e.jsx(Dr,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"pack-name",children:"模板名称 *"}),e.jsx(ce,{id:"pack-name",placeholder:"例如:高性价比国产模型配置",value:T,onChange:I=>P(I.target.value),maxLength:50}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.length,"/50"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"pack-description",children:"模板描述 *"}),e.jsx(Ys,{id:"pack-description",placeholder:"详细描述这个配置模板的特点、适用场景等...",value:A,onChange:I=>ee(I.target.value),rows:4,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.length,"/500"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"pack-author",children:"作者名称 *"}),e.jsx(ce,{id:"pack-author",placeholder:"你的昵称或 ID",value:H,onChange:I=>Z(I.target.value),maxLength:30})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"标签(可选,最多 5 个)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A_.map(I=>e.jsxs(Ae,{variant:re.includes(I)?"default":"outline",className:"cursor-pointer transition-colors",onClick:()=>Q(I),children:[re.includes(I)&&e.jsx(yt,{className:"w-3 h-3 mr-1"}),e.jsx(Lm,{className:"w-3 h-3 mr-1"}),I]},I))})]})]}),e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(Sn,{children:"审核说明"}),e.jsx(_t,{children:"提交后需要经过审核才能在市场中展示。审核通常在 1-3 个工作日内完成。"})]})]})]})}),e.jsxs(nt,{className:"flex justify-between pt-4 border-t",children:[e.jsx("div",{children:c>1&&e.jsx(C,{variant:"outline",onClick:()=>u(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:()=>{i(!1),be()},disabled:f,children:"取消"}),c<ke?e.jsx(C,{onClick:()=>u(c+1),disabled:m||O.size===0&&D.size===0&&E.size===0,children:"下一步"}):e.jsxs(C,{onClick:Ce,disabled:f,children:[f&&e.jsx(Xs,{className:"w-4 h-4 mr-2 animate-spin"}),"提交审核"]})]})]})]})]})}function D_({value:l,label:n,onRemove:i}){const{attributes:c,listeners:u,setNodeRef:m,transform:h,transition:f,isDragging:p}=zj({id:l}),j={transform:Dj.Transform.toString(h),transition:f,opacity:p?.5:1},v=b=>{b.preventDefault(),b.stopPropagation(),i(l)},N=b=>{b.stopPropagation()};return e.jsx("div",{ref:m,style:j,className:L("inline-flex items-center gap-1",p&&"shadow-lg"),children:e.jsxs(Ae,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...c,...u,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(hj,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:n}),e.jsx("button",{type:"button",className:"ml-1 rounded-sm hover:bg-destructive/20 focus:outline-none focus:ring-1 focus:ring-destructive",onClick:v,onPointerDown:N,onMouseDown:b=>b.stopPropagation(),children:e.jsx(Ja,{className:"h-3 w-3 cursor-pointer hover:text-destructive",strokeWidth:2,fill:"none"})})]})})}function O_({options:l,selected:n,onChange:i,placeholder:c="选择选项...",emptyText:u="未找到选项",className:m}){const[h,f]=x.useState(!1),p=_j(Co(kj,{activationConstraint:{distance:8}}),Co(Cj,{coordinateGetter:Sj})),j=b=>{n.includes(b)?i(n.filter(S=>S!==b)):i([...n,b])},v=b=>{i(n.filter(S=>S!==b))},N=b=>{const{active:S,over:w}=b;if(w&&S.id!==w.id){const O=n.indexOf(S.id),M=n.indexOf(w.id);i(Tj(n,O,M))}};return e.jsxs(Za,{open:h,onOpenChange:f,children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":h,className:L("w-full justify-between min-h-10 h-auto",m),children:[e.jsx(Ej,{sensors:p,collisionDetection:Mj,onDragEnd:N,children:e.jsx(Aj,{items:n,strategy:s1,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:n.length===0?e.jsx("span",{className:"text-muted-foreground",children:c}):n.map(b=>{const S=l.find(w=>w.value===b);return e.jsx(D_,{value:b,label:S?.label||b,onRemove:v},b)})})})}),e.jsx(Rm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(Pa,{className:"w-full p-0",align:"start",children:e.jsxs($o,{children:[e.jsx(Ho,{placeholder:"搜索...",className:"h-9"}),e.jsxs(Go,{children:[e.jsx(Po,{children:u}),e.jsx(Hi,{children:l.map(b=>{const S=n.includes(b.value);return e.jsxs(Gi,{value:b.value,onSelect:()=>j(b.value),children:[e.jsx("div",{className:L("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",S?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(yt,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:b.label})]},b.value)})})]})]})})]})}const Ha=Ms.memo(function({title:n,description:i,taskConfig:c,modelNames:u,onChange:m,hideTemperature:h=!1,hideMaxTokens:f=!1,dataTour:p}){const j=v=>{m("model_list",v)};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:i})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":p,children:[e.jsx(k,{children:"模型列表"}),e.jsx(O_,{options:u.map(v=>({label:v,value:v})),selected:c.model_list||[],onChange:j,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!h&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{children:"温度"}),e.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",value:c.temperature??.3,onChange:v=>{const N=parseFloat(v.target.value);!isNaN(N)&&N>=0&&N<=1&&m("temperature",N)},className:"w-20 h-8 text-sm"})]}),e.jsx(ya,{value:[c.temperature??.3],onValueChange:v=>m("temperature",v[0]),min:0,max:1,step:.1,className:"w-full"})]}),!f&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{children:"最大 Token"}),e.jsx(ce,{type:"number",step:"1",min:"1",value:c.max_tokens??1024,onChange:v=>m("max_tokens",parseInt(v.target.value))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{children:"慢请求阈值 (秒)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"超时警告"})]}),e.jsx(ce,{type:"number",step:"1",min:"1",value:c.slow_threshold??15,onChange:v=>{const N=parseInt(v.target.value);!isNaN(N)&&N>=1&&m("slow_threshold",N)},placeholder:"15"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"模型响应时间超过此阈值将输出警告日志"})]})]})]})}),R_=Ms.memo(function({paginatedModels:n,allModels:i,onEdit:c,onDelete:u,isModelUsed:m,searchQuery:h}){return n.length===0?e.jsx("div",{className:"md:hidden text-center text-muted-foreground py-8 rounded-lg border bg-card",children:h?"未找到匹配的模型":"暂无模型配置"}):e.jsx("div",{className:"md:hidden space-y-3",children:n.map((f,p)=>{const j=i.findIndex(N=>N===f),v=m(f.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:f.name}),e.jsx(Ae,{variant:v?"default":"secondary",className:v?"bg-green-600 hover:bg-green-700":"",children:v?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:f.model_identifier,children:f.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(C,{variant:"default",size:"sm",onClick:()=>c(f,j),children:[e.jsx(kn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(C,{size:"sm",onClick:()=>u(j),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{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:f.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"模型温度"}),e.jsx("p",{className:"font-medium",children:f.temperature!=null?f.temperature:e.jsx("span",{className:"text-muted-foreground",children:"默认"})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输入价格"}),e.jsxs("p",{className:"font-medium",children:["¥",f.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",f.price_out,"/M"]})]})]})]},p)})})}),L_=Ms.memo(function({paginatedModels:n,allModels:i,filteredModels:c,selectedModels:u,onEdit:m,onDelete:h,onToggleSelection:f,onToggleSelectAll:p,isModelUsed:j,searchQuery:v}){return 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(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{className:"w-12",children:e.jsx(Js,{checked:u.size===c.length&&c.length>0,onCheckedChange:p})}),e.jsx(Ye,{className:"w-24",children:"使用状态"}),e.jsx(Ye,{children:"模型名称"}),e.jsx(Ye,{children:"模型标识符"}),e.jsx(Ye,{children:"提供商"}),e.jsx(Ye,{className:"text-center",children:"温度"}),e.jsx(Ye,{className:"text-right",children:"输入价格"}),e.jsx(Ye,{className:"text-right",children:"输出价格"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:n.length===0?e.jsx(lt,{children:e.jsx(Ge,{colSpan:9,className:"text-center text-muted-foreground py-8",children:v?"未找到匹配的模型":"暂无模型配置"})}):n.map((N,b)=>{const S=i.findIndex(O=>O===N),w=j(N.name);return e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Js,{checked:u.has(S),onCheckedChange:()=>f(S)})}),e.jsx(Ge,{children:e.jsx(Ae,{variant:w?"default":"secondary",className:w?"bg-green-600 hover:bg-green-700":"",children:w?"已使用":"未使用"})}),e.jsx(Ge,{className:"font-medium",children:N.name}),e.jsx(Ge,{className:"max-w-xs truncate",title:N.model_identifier,children:N.model_identifier}),e.jsx(Ge,{children:N.api_provider}),e.jsx(Ge,{className:"text-center",children:N.temperature!=null?N.temperature:e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(Ge,{className:"text-right",children:["¥",N.price_in,"/M"]}),e.jsxs(Ge,{className:"text-right",children:["¥",N.price_out,"/M"]}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(C,{variant:"default",size:"sm",onClick:()=>m(N,S),children:[e.jsx(kn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(C,{size:"sm",onClick:()=>h(S),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},b)})})]})})})}),U_=300*1e3,ig=new Map,B_=[10,20,50,100],$_=Ms.memo(function({page:n,pageSize:i,totalItems:c,jumpToPage:u,onPageChange:m,onPageSizeChange:h,onJumpToPageChange:f,onJumpToPage:p,onSelectionClear:j}){const v=Math.ceil(c/i),N=S=>{h(parseInt(S)),m(1),j?.()},b=S=>{S.key==="Enter"&&p()};return c===0?null: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(k,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs($e,{value:i.toString(),onValueChange:N,children:[e.jsx(Le,{id:"page-size-model",className:"w-20",children:e.jsx(He,{})}),e.jsx(Ue,{children:B_.map(S=>e.jsx(le,{value:S.toString(),children:S},S))})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(n-1)*i+1," 到"," ",Math.min(n*i,c)," 条,共 ",c," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>m(1),disabled:n===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>m(Math.max(1,n-1)),disabled:n===1,children:[e.jsx(el,{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:u,onChange:S=>f(S.target.value),onKeyDown:b,placeholder:n.toString(),className:"w-16 h-8 text-center",min:1,max:v}),e.jsx(C,{variant:"outline",size:"sm",onClick:p,disabled:!u,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>m(n+1),disabled:n>=v,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>m(v),disabled:n>=v,className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})});function H_(l){const{models:n,taskConfig:i,debounceMs:c=2e3,onSavingChange:u,onUnsavedChange:m}=l,h=x.useRef(null),f=x.useRef(null),p=x.useRef(!0),j=x.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null)},[]),v=x.useCallback(S=>{const w={model_identifier:S.model_identifier,name:S.name,api_provider:S.api_provider,price_in:S.price_in??0,price_out:S.price_out??0,force_stream_mode:S.force_stream_mode??!1,extra_params:S.extra_params??{}};return S.temperature!=null&&(w.temperature=S.temperature),S.max_tokens!=null&&(w.max_tokens=S.max_tokens),w},[]),N=x.useCallback(async S=>{try{u?.(!0);const w=S.map(v);await Em("models",w),m?.(!1)}catch(w){console.error("自动保存模型列表失败:",w),m?.(!0)}finally{u?.(!1)}},[u,m,v]),b=x.useCallback(async S=>{try{u?.(!0),await Em("model_task_config",S),m?.(!1)}catch(w){console.error("自动保存任务配置失败:",w),m?.(!0)}finally{u?.(!1)}},[u,m]);return x.useEffect(()=>{if(!p.current)return m?.(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{N(n)},c),()=>{h.current&&clearTimeout(h.current)}},[n,N,c,m]),x.useEffect(()=>{if(!(p.current||!i))return m?.(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{b(i)},c),()=>{f.current&&clearTimeout(f.current)}},[i,b,c,m]),x.useEffect(()=>()=>{j()},[j]),{clearTimers:j,initialLoadRef:p}}function G_(l={}){const{onCloseEditDialog:n}=l,i=xa(),{registerTour:c,startTour:u,state:m,goToStep:h}=$m(),f=x.useRef(m.stepIndex);return x.useEffect(()=>{c(Ya,Jj)},[c]),x.useEffect(()=>{if(m.activeTourId===Ya&&m.isRunning){const j=Zj[m.stepIndex];j&&!window.location.pathname.endsWith(j.replace("/config/",""))&&i({to:j})}},[m.stepIndex,m.activeTourId,m.isRunning,i]),x.useEffect(()=>{if(m.activeTourId===Ya&&m.isRunning){const j=f.current,v=m.stepIndex;j>=12&&j<=17&&v<12&&n?.(),f.current=v}},[m.stepIndex,m.activeTourId,m.isRunning,n]),x.useEffect(()=>{if(m.activeTourId!==Ya||!m.isRunning)return;const j=v=>{const N=v.target,b=m.stepIndex;b===2&&N.closest('[data-tour="add-provider-button"]')?setTimeout(()=>h(3),300):b===9&&N.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>h(10),300):b===11&&N.closest('[data-tour="add-model-button"]')?setTimeout(()=>h(12),300):b===17&&N.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>h(18),300):b===18&&N.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>h(19),300)};return document.addEventListener("click",j,!0),()=>document.removeEventListener("click",j,!0)},[m,h]),{startTour:x.useCallback(()=>{u(Ya)},[u]),isRunning:m.isRunning&&m.activeTourId===Ya,stepIndex:m.stepIndex}}function P_(l){const{getProviderConfig:n}=l,[i,c]=x.useState([]),[u,m]=x.useState(!1),[h,f]=x.useState(null),[p,j]=x.useState(null),v=x.useCallback(()=>{c([]),f(null),j(null)},[]),N=x.useCallback(async(b,S=!1)=>{const w=n(b);if(!w?.base_url){c([]),j(null),f('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!w.api_key){c([]),j(null),f('该提供商未配置 API Key请先在"模型提供商配置"中填写');return}const O=f_(w.base_url);if(j(O),!O?.modelFetcher){c([]),f(null);return}const M=`${b}:${w.base_url}`,D=ig.get(M);if(!S&&D&&Date.now()-D.timestamp<U_){c(D.models),f(null);return}m(!0),f(null);try{const $=await Q2(b,O.modelFetcher.parser,O.modelFetcher.endpoint);c($),ig.set(M,{models:$,timestamp:Date.now()})}catch($){console.error("获取模型列表失败:",$);const E=$.message||"获取模型列表失败";E.includes("无效")||E.includes("过期")||E.includes("API Key")?f('API Key 无效或已过期,请检查"模型提供商配置"中的密钥'):E.includes("权限")?f("没有权限获取模型列表,请检查 API Key 权限"):E.includes("timeout")||E.includes("超时")?f("请求超时,请检查网络连接后重试"):E.includes("不支持")?f("该提供商不支持自动获取模型列表,请手动输入"):f(E),c([])}finally{m(!1)}},[n]);return{availableModels:i,fetchingModels:u,modelFetchError:h,matchedTemplate:p,fetchModelsForProvider:N,clearModels:v}}function I_(){return e.jsx(On,{children:e.jsx(q_,{})})}function q_(){const[l,n]=x.useState([]),[i,c]=x.useState([]),[u,m]=x.useState([]),[h,f]=x.useState([]),[p,j]=x.useState(null),[v,N]=x.useState(!0),[b,S]=x.useState(!1),[w,O]=x.useState(!1),[M,D]=x.useState(!1),[$,E]=x.useState(!1),[_,T]=x.useState(null),[P,A]=x.useState(null),[ee,H]=x.useState(!1),[Z,re]=x.useState(null),[ye,de]=x.useState(""),[ge,je]=x.useState(new Set),[z,Q]=x.useState(!1),[J,U]=x.useState(1),[G,Ce]=x.useState(20),[be,ke]=x.useState(""),[I,we]=x.useState(!1),[q,oe]=x.useState({}),{toast:Te}=et(),{triggerRestart:X,isRestarting:ne}=tn(),{startTour:Ie,isRunning:Je}=G_({onCloseEditDialog:()=>E(!1)}),{clearTimers:pe,initialLoadRef:as}=H_({models:l,taskConfig:p,onSavingChange:O,onUnsavedChange:D}),F=x.useCallback(async()=>{try{N(!0);const ae=await Zl(),xe=ae.models||[];n(xe),f(xe.map(Dt=>Dt.name));const ys=ae.api_providers||[];c(ys.map(Dt=>Dt.name)),m(ys),j(ae.model_task_config||null),D(!1),as.current=!1}catch(ae){console.error("加载配置失败:",ae)}finally{N(!1)}},[as]);x.useEffect(()=>{F()},[F]);const ze=x.useCallback(ae=>u.find(xe=>xe.name===ae),[u]),{availableModels:ue,fetchingModels:ve,modelFetchError:Me,matchedTemplate:Ke,fetchModelsForProvider:qe,clearModels:Zt}=P_({getProviderConfig:ze});x.useEffect(()=>{$&&_?.api_provider&&qe(_.api_provider)},[$,_?.api_provider,qe]);const Et=async()=>{await X()},ot=ae=>{const xe={model_identifier:ae.model_identifier,name:ae.name,api_provider:ae.api_provider,price_in:ae.price_in??0,price_out:ae.price_out??0,force_stream_mode:ae.force_stream_mode??!1,extra_params:ae.extra_params??{}};return ae.temperature!=null&&(xe.temperature=ae.temperature),ae.max_tokens!=null&&(xe.max_tokens=ae.max_tokens),xe},K=async()=>{try{S(!0),pe();const ae=await Zl();ae.models=l.map(ot),ae.model_task_config=p,await Ri(ae),D(!1),Te({title:"保存成功",description:"正在重启麦麦..."}),await Et()}catch(ae){console.error("保存配置失败:",ae),Te({title:"保存失败",description:ae.message,variant:"destructive"}),S(!1)}},Pe=async()=>{try{S(!0),pe();const ae=await Zl();ae.models=l.map(ot),ae.model_task_config=p,await Ri(ae),D(!1),Te({title:"保存成功",description:"模型配置已保存"}),await F()}catch(ae){console.error("保存配置失败:",ae),Te({title:"保存失败",description:ae.message,variant:"destructive"})}finally{S(!1)}},Be=(ae,xe)=>{oe({}),T(ae||{model_identifier:"",name:"",api_provider:i[0]||"",price_in:0,price_out:0,temperature:null,max_tokens:null,force_stream_mode:!1,extra_params:{}}),A(xe),E(!0)},_e=()=>{if(!_)return;const ae={};if(_.name?.trim()||(ae.name="请输入模型名称"),_.api_provider?.trim()||(ae.api_provider="请选择 API 提供商"),_.model_identifier?.trim()||(ae.model_identifier="请输入模型标识符"),Object.keys(ae).length>0){oe(ae);return}oe({});const xe={model_identifier:_.model_identifier,name:_.name,api_provider:_.api_provider,price_in:_.price_in??0,price_out:_.price_out??0,force_stream_mode:_.force_stream_mode??!1,extra_params:_.extra_params??{}};_.temperature!=null&&(xe.temperature=_.temperature),_.max_tokens!=null&&(xe.max_tokens=_.max_tokens);let ys,Dt=null;if(P!==null?(Dt=l[P].name,ys=[...l],ys[P]=xe):ys=[...l,xe],n(ys),f(ys.map(Ot=>Ot.name)),Dt&&Dt!==xe.name&&p){const Ot=Y=>Y.map(Ne=>Ne===Dt?xe.name:Ne);j({...p,utils:{...p.utils,model_list:Ot(p.utils?.model_list||[])},utils_small:{...p.utils_small,model_list:Ot(p.utils_small?.model_list||[])},tool_use:{...p.tool_use,model_list:Ot(p.tool_use?.model_list||[])},replyer:{...p.replyer,model_list:Ot(p.replyer?.model_list||[])},planner:{...p.planner,model_list:Ot(p.planner?.model_list||[])},vlm:{...p.vlm,model_list:Ot(p.vlm?.model_list||[])},voice:{...p.voice,model_list:Ot(p.voice?.model_list||[])},embedding:{...p.embedding,model_list:Ot(p.embedding?.model_list||[])},lpmm_entity_extract:{...p.lpmm_entity_extract,model_list:Ot(p.lpmm_entity_extract?.model_list||[])},lpmm_rdf_build:{...p.lpmm_rdf_build,model_list:Ot(p.lpmm_rdf_build?.model_list||[])},lpmm_qa:{...p.lpmm_qa,model_list:Ot(p.lpmm_qa?.model_list||[])}})}E(!1),T(null),A(null)},gs=ae=>{if(!ae&&_){const xe={..._,price_in:_.price_in??0,price_out:_.price_out??0};T(xe)}E(ae)},is=ae=>{re(ae),H(!0)},As=()=>{if(Z!==null){const ae=l.filter((xe,ys)=>ys!==Z);n(ae),f(ae.map(xe=>xe.name)),Te({title:"删除成功",description:"模型已从列表中移除"})}H(!1),re(null)},Ds=ae=>{const xe=new Set(ge);xe.has(ae)?xe.delete(ae):xe.add(ae),je(xe)},Gs=()=>{if(ge.size===Us.length)je(new Set);else{const ae=Us.map((xe,ys)=>l.findIndex(Dt=>Dt===Us[ys]));je(new Set(ae))}},ls=()=>{if(ge.size===0){Te({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}Q(!0)},es=()=>{const ae=l.filter((xe,ys)=>!ge.has(ys));n(ae),f(ae.map(xe=>xe.name)),je(new Set),Q(!1),Te({title:"批量删除成功",description:`已删除 ${ge.size} 个模型`})},Ze=(ae,xe,ys)=>{p&&j({...p,[ae]:{...p[ae],[xe]:ys}})},Us=l.filter(ae=>{if(!ye)return!0;const xe=ye.toLowerCase();return ae.name.toLowerCase().includes(xe)||ae.model_identifier.toLowerCase().includes(xe)||ae.api_provider.toLowerCase().includes(xe)}),zt=Math.ceil(Us.length/G),st=Us.slice((J-1)*G,J*G),Cs=()=>{const ae=parseInt(be);ae>=1&&ae<=zt&&(U(ae),ke(""))},jt=ae=>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(ys=>ys.includes(ae)):!1;return v?e.jsx(Xe,{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(Xe,{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.jsx(z_,{trigger:e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(fj,{className:"mr-2 h-4 w-4"}),"分享配置"]})}),e.jsxs(C,{onClick:Pe,disabled:b||w||!M||ne,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(Fi,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),b?"保存中...":w?"自动保存中...":M?"保存配置":"已保存"]}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsxs(C,{disabled:b||w||ne,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(Vi,{className:"mr-2 h-4 w-4"}),ne?"重启中...":M?"保存并重启":"重启麦麦"]})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认重启麦麦?"}),e.jsx(hs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:M?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:M?K:Et,children:M?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsxs(_t,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(wt,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:Ie,children:[e.jsx(Ew,{className:"h-4 w-4 text-primary"}),e.jsxs(_t,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:"新手引导:"}),"不知道如何配置模型?点击这里开始学习如何为麦麦的组件分配模型。"]}),e.jsx(C,{variant:"outline",size:"sm",className:"ml-4 shrink-0",children:"开始引导"})]})]}),e.jsxs(ma,{defaultValue:"models",className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx(ss,{value:"models",children:"添加模型"}),e.jsx(ss,{value:"tasks","data-tour":"tasks-tab-trigger",children:"为模型分配功能"})]}),e.jsxs(Ss,{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:[ge.size>0&&e.jsxs(C,{onClick:ls,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(rs,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",ge.size,")"]}),e.jsxs(C,{onClick:()=>Be(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(ft,{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(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索模型名称、标识符或提供商...",value:ye,onChange:ae=>de(ae.target.value),className:"pl-9"})]}),ye&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Us.length," 个结果"]})]}),e.jsx(R_,{paginatedModels:st,allModels:l,onEdit:Be,onDelete:is,isModelUsed:jt,searchQuery:ye}),e.jsx(L_,{paginatedModels:st,allModels:l,filteredModels:Us,selectedModels:ge,onEdit:Be,onDelete:is,onToggleSelection:Ds,onToggleSelectAll:Gs,isModelUsed:jt,searchQuery:ye}),e.jsx($_,{page:J,pageSize:G,totalItems:Us.length,jumpToPage:be,onPageChange:U,onPageSizeChange:Ce,onJumpToPageChange:ke,onJumpToPage:Cs,onSelectionClear:()=>je(new Set)})]}),e.jsxs(Ss,{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(Ha,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:p.utils,modelNames:h,onChange:(ae,xe)=>Ze("utils",ae,xe),dataTour:"task-model-select"}),e.jsx(Ha,{title:"组件小模型 (utils_small)",description:"消耗量较大的组件,建议使用速度较快的小模型",taskConfig:p.utils_small,modelNames:h,onChange:(ae,xe)=>Ze("utils_small",ae,xe)}),e.jsx(Ha,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:p.tool_use,modelNames:h,onChange:(ae,xe)=>Ze("tool_use",ae,xe)}),e.jsx(Ha,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:p.replyer,modelNames:h,onChange:(ae,xe)=>Ze("replyer",ae,xe)}),e.jsx(Ha,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:p.planner,modelNames:h,onChange:(ae,xe)=>Ze("planner",ae,xe)}),e.jsx(Ha,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:p.vlm,modelNames:h,onChange:(ae,xe)=>Ze("vlm",ae,xe),hideTemperature:!0}),e.jsx(Ha,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:p.voice,modelNames:h,onChange:(ae,xe)=>Ze("voice",ae,xe),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(Ha,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:p.embedding,modelNames:h,onChange:(ae,xe)=>Ze("embedding",ae,xe),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(Ha,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:p.lpmm_entity_extract,modelNames:h,onChange:(ae,xe)=>Ze("lpmm_entity_extract",ae,xe)}),e.jsx(Ha,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:p.lpmm_rdf_build,modelNames:h,onChange:(ae,xe)=>Ze("lpmm_rdf_build",ae,xe)}),e.jsx(Ha,{title:"问答模型 (lpmm_qa)",description:"知识库问答",taskConfig:p.lpmm_qa,modelNames:h,onChange:(ae,xe)=>Ze("lpmm_qa",ae,xe)})]})]})]})]}),e.jsx(Hs,{open:$,onOpenChange:gs,children:e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Je,children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:P!==null?"编辑模型":"添加模型"}),e.jsx(Ws,{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(k,{htmlFor:"model_name",className:q.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ce,{id:"model_name",value:_?.name||"",onChange:ae=>{T(xe=>xe?{...xe,name:ae.target.value}:null),q.name&&oe(xe=>({...xe,name:void 0}))},placeholder:"例如: qwen3-30b",className:q.name?"border-destructive focus-visible:ring-destructive":""}),q.name?e.jsx("p",{className:"text-xs text-destructive",children:q.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(k,{htmlFor:"api_provider",className:q.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs($e,{value:_?.api_provider||"",onValueChange:ae=>{T(xe=>xe?{...xe,api_provider:ae}:null),Zt(),q.api_provider&&oe(xe=>({...xe,api_provider:void 0}))},children:[e.jsx(Le,{id:"api_provider",className:q.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx(He,{placeholder:"选择提供商"})}),e.jsx(Ue,{children:i.map(ae=>e.jsx(le,{value:ae,children:ae},ae))})]}),q.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:q.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(k,{htmlFor:"model_identifier",className:q.model_identifier?"text-destructive":"",children:"模型标识符 *"}),Ke?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{variant:"secondary",className:"text-xs",children:Ke.display_name}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>_?.api_provider&&qe(_.api_provider,!0),disabled:ve,children:ve?e.jsx(Xs,{className:"h-3 w-3 animate-spin"}):e.jsx(At,{className:"h-3 w-3"})})]})]}),Ke?.modelFetcher?e.jsxs(Za,{open:I,onOpenChange:we,children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":I,className:"w-full justify-between font-normal",disabled:ve||!!Me,children:[ve?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Xs,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):Me?e.jsx("span",{className:"text-muted-foreground text-sm",children:"点击下方输入框手动填写"}):_?.model_identifier?e.jsx("span",{className:"truncate",children:_.model_identifier}):e.jsx("span",{className:"text-muted-foreground",children:"搜索或选择模型..."}),e.jsx(Rm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs($o,{children:[e.jsx(Ho,{placeholder:"搜索模型..."}),e.jsx(Xe,{className:"h-[300px]",children:e.jsxs(Go,{className:"max-h-none overflow-visible",children:[e.jsx(Po,{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(C,{variant:"link",size:"sm",onClick:()=>_?.api_provider&&qe(_.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(Hi,{heading:"可用模型",children:ue.map(ae=>e.jsxs(Gi,{value:ae.id,onSelect:()=>{T(xe=>xe?{...xe,model_identifier:ae.id}:null),we(!1)},children:[e.jsx(yt,{className:`mr-2 h-4 w-4 ${_?.model_identifier===ae.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:ae.id}),ae.name!==ae.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ae.name})]})]},ae.id))}),e.jsx(Hi,{heading:"手动输入",children:e.jsxs(Gi,{value:"__manual_input__",onSelect:()=>{we(!1)},children:[e.jsx(kn,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ce,{id:"model_identifier",value:_?.model_identifier||"",onChange:ae=>{T(xe=>xe?{...xe,model_identifier:ae.target.value}:null),q.model_identifier&&oe(xe=>({...xe,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:q.model_identifier?"border-destructive focus-visible:ring-destructive":""}),q.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:q.model_identifier}),Me&&Ke?.modelFetcher&&!q.model_identifier&&e.jsxs(wt,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(_t,{className:"text-xs",children:Me})]}),Ke?.modelFetcher&&e.jsx(ce,{value:_?.model_identifier||"",onChange:ae=>{T(xe=>xe?{...xe,model_identifier:ae.target.value}:null),q.model_identifier&&oe(xe=>({...xe,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${q.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!q.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:Me?'请手动输入模型标识符,或前往"模型提供商配置"检查 API Key':Ke?.modelFetcher?`已识别为 ${Ke.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(k,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(ce,{id:"price_in",type:"number",step:"0.1",min:"0",value:_?.price_in??"",onChange:ae=>{const xe=ae.target.value===""?null:parseFloat(ae.target.value);T(ys=>ys?{...ys,price_in:xe}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ce,{id:"price_out",type:"number",step:"0.1",min:"0",value:_?.price_out??"",onChange:ae=>{const xe=ae.target.value===""?null:parseFloat(ae.target.value);T(ys=>ys?{...ys,price_out:xe}:null)},placeholder:"默认: 0"})]})]}),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("div",{className:"space-y-0.5",children:[e.jsx(k,{htmlFor:"enable_model_temperature",className:"cursor-pointer",children:"自定义模型温度"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务温度配置"})]}),e.jsx(Fe,{id:"enable_model_temperature",checked:_?.temperature!=null,onCheckedChange:ae=>{T(ae?xe=>xe?{...xe,temperature:.5}:null:xe=>xe?{...xe,temperature:null}:null)}})]}),_?.temperature!=null&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{className:"text-sm",children:"温度值"}),e.jsx("span",{className:"text-sm font-medium tabular-nums",children:_.temperature.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"0"}),e.jsx(ya,{value:[_.temperature],onValueChange:ae=>T(xe=>xe?{...xe,temperature:ae[0]}:null),min:0,max:1,step:.1,className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"较低的温度0.1-0.3产生更确定的输出较高的温度0.7-1.0)产生更多样化的输出"})]})]}),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("div",{className:"space-y-0.5",children:[e.jsx(k,{htmlFor:"enable_model_max_tokens",className:"cursor-pointer",children:"自定义最大 Token"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务最大 Token 配置"})]}),e.jsx(Fe,{id:"enable_model_max_tokens",checked:_?.max_tokens!=null,onCheckedChange:ae=>{T(ae?xe=>xe?{...xe,max_tokens:2048}:null:xe=>xe?{...xe,max_tokens:null}:null)}})]}),_?.max_tokens!=null&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{className:"text-sm",children:"最大 Token 数"}),e.jsx(ce,{type:"number",min:"1",max:"128000",value:_.max_tokens,onChange:ae=>{const xe=parseInt(ae.target.value);!isNaN(xe)&&xe>=1&&T(ys=>ys?{...ys,max_tokens:xe}:null)},className:"w-28 h-8 text-sm"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"限制模型单次输出的最大 token 数量,不同模型支持的上限不同"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"force_stream_mode",checked:_?.force_stream_mode||!1,onCheckedChange:ae=>T(xe=>xe?{...xe,force_stream_mode:ae}:null)}),e.jsx(k,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]}),e.jsx(y_,{value:_?.extra_params||{},onChange:ae=>T(xe=>xe?{...xe,extra_params:ae}:null),placeholder:"添加额外参数(如 enable_thinking、top_p 等)..."})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>E(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(C,{onClick:_e,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(js,{open:ee,onOpenChange:H,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除模型 "',Z!==null?l[Z]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:As,children:"删除"})]})]})}),e.jsx(js,{open:z,onOpenChange:Q,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["确定要删除选中的 ",ge.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:es,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(Rn,{})]})})}const Pi=Lg,Ii=g0,qi=j0,Io="/api/webui/config";async function V_(){const n=await(await Se(`${Io}/adapter-config/path`)).json();return!n.success||!n.path?null:{path:n.path,lastModified:n.lastModified}}async function cg(l){const i=await(await Se(`${Io}/adapter-config/path`,{method:"POST",headers:Zs(),body:JSON.stringify({path:l})})).json();if(!i.success)throw new Error(i.message||"保存路径失败")}async function og(l){const i=await(await Se(`${Io}/adapter-config?path=${encodeURIComponent(l)}`)).json();if(!i.success)throw new Error("读取配置文件失败");return i.content}async function dg(l,n){const c=await(await Se(`${Io}/adapter-config`,{method:"POST",headers:Zs(),body:JSON.stringify({path:l,content:n})})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}const xt={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"}},jm={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:da},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:Mw}};function F_(l,n){let i=l.slice(0,n).split(/\r\n|\n|\r/g);return[i.length,i.pop().length+1]}function K_(l,n,i){let c=l.split(/\r\n|\n|\r/g),u="",m=(Math.log10(n+1)|0)+1;for(let h=n-1;h<=n+1;h++){let f=c[h-1];f&&(u+=h.toString().padEnd(m," "),u+=": ",u+=f,u+=`
`,h===n&&(u+=" ".repeat(m+i+2),u+=`^
`))}return u}class bs extends Error{line;column;codeblock;constructor(n,i){const[c,u]=F_(i.toml,i.ptr),m=K_(i.toml,c,u);super(`Invalid TOML document: ${n}
${m}`,i),this.line=c,this.column=u,this.codeblock=m}}function Q_(l,n){let i=0;for(;l[n-++i]==="\\";);return--i&&i%2}function Eo(l,n=0,i=l.length){let c=l.indexOf(`
`,n);return l[c-1]==="\r"&&c--,c<=i?c:-1}function Hm(l,n){for(let i=n;i<l.length;i++){let c=l[i];if(c===`
`)return i;if(c==="\r"&&l[i+1]===`
`)return i+1;if(c<" "&&c!==" "||c==="")throw new bs("control characters are not allowed in comments",{toml:l,ptr:n})}return l.length}function yl(l,n,i,c){let u;for(;(u=l[n])===" "||u===" "||!i&&(u===`
`||u==="\r"&&l[n+1]===`
`);)n++;return c||u!=="#"?n:yl(l,Hm(l,n),i)}function ug(l,n,i,c,u=!1){if(!c)return n=Eo(l,n),n<0?l.length:n;for(let m=n;m<l.length;m++){let h=l[m];if(h==="#")m=Eo(l,m);else{if(h===i)return m+1;if(h===c||u&&(h===`
`||h==="\r"&&l[m+1]===`
`))return m}}throw new bs("cannot find end of structure",{toml:l,ptr:n})}function lv(l,n){let i=l[n],c=i===l[n+1]&&l[n+1]===l[n+2]?l.slice(n,n+3):i;n+=c.length-1;do n=l.indexOf(c,++n);while(n>-1&&i!=="'"&&Q_(l,n));return n>-1&&(n+=c.length,c.length>1&&(l[n]===i&&n++,l[n]===i&&n++)),n}let Y_=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;class Sr extends Date{#s=!1;#t=!1;#e=null;constructor(n){let i=!0,c=!0,u="Z";if(typeof n=="string"){let m=n.match(Y_);m?(m[1]||(i=!1,n=`0000-01-01T${n}`),c=!!m[2],c&&n[10]===" "&&(n=n.replace(" ","T")),m[2]&&+m[2]>23?n="":(u=m[3]||null,n=n.toUpperCase(),!u&&c&&(n+="Z"))):n=""}super(n),isNaN(this.getTime())||(this.#s=i,this.#t=c,this.#e=u)}isDateTime(){return this.#s&&this.#t}isLocal(){return!this.#s||!this.#t||!this.#e}isDate(){return this.#s&&!this.#t}isTime(){return this.#t&&!this.#s}isValid(){return this.#s||this.#t}toISOString(){let n=super.toISOString();if(this.isDate())return n.slice(0,10);if(this.isTime())return n.slice(11,23);if(this.#e===null)return n.slice(0,-1);if(this.#e==="Z")return n;let i=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return i=this.#e[0]==="-"?i:-i,new Date(this.getTime()-i*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(n,i="Z"){let c=new Sr(n);return c.#e=i,c}static wrapAsLocalDateTime(n){let i=new Sr(n);return i.#e=null,i}static wrapAsLocalDate(n){let i=new Sr(n);return i.#t=!1,i.#e=null,i}static wrapAsLocalTime(n){let i=new Sr(n);return i.#s=!1,i.#e=null,i}}let X_=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,J_=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Z_=/^[+-]?0[0-9_]/,W_=/^[0-9a-f]{4,8}$/i,mg={b:"\b",t:" ",n:`
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};function nv(l,n=0,i=l.length){let c=l[n]==="'",u=l[n++]===l[n]&&l[n]===l[n+1];u&&(i-=2,l[n+=2]==="\r"&&n++,l[n]===`
`&&n++);let m=0,h,f="",p=n;for(;n<i-1;){let j=l[n++];if(j===`
`||j==="\r"&&l[n]===`
`){if(!u)throw new bs("newlines are not allowed in strings",{toml:l,ptr:n-1})}else if(j<" "&&j!==" "||j==="")throw new bs("control characters are not allowed in strings",{toml:l,ptr:n-1});if(h){if(h=!1,j==="u"||j==="U"){let v=l.slice(n,n+=j==="u"?4:8);if(!W_.test(v))throw new bs("invalid unicode escape",{toml:l,ptr:m});try{f+=String.fromCodePoint(parseInt(v,16))}catch{throw new bs("invalid unicode escape",{toml:l,ptr:m})}}else if(u&&(j===`
`||j===" "||j===" "||j==="\r")){if(n=yl(l,n-1,!0),l[n]!==`
`&&l[n]!=="\r")throw new bs("invalid escape: only line-ending whitespace may be escaped",{toml:l,ptr:m});n=yl(l,n)}else if(j in mg)f+=mg[j];else throw new bs("unrecognized escape sequence",{toml:l,ptr:m});p=n}else!c&&j==="\\"&&(m=n-1,h=!0,f+=l.slice(p,m))}return f+l.slice(p,i-1)}function eS(l,n,i,c){if(l==="true")return!0;if(l==="false")return!1;if(l==="-inf")return-1/0;if(l==="inf"||l==="+inf")return 1/0;if(l==="nan"||l==="+nan"||l==="-nan")return NaN;if(l==="-0")return c?0n:0;let u=X_.test(l);if(u||J_.test(l)){if(Z_.test(l))throw new bs("leading zeroes are not allowed",{toml:n,ptr:i});l=l.replace(/_/g,"");let h=+l;if(isNaN(h))throw new bs("invalid number",{toml:n,ptr:i});if(u){if((u=!Number.isSafeInteger(h))&&!c)throw new bs("integer value cannot be represented losslessly",{toml:n,ptr:i});(u||c===!0)&&(h=BigInt(l))}return h}const m=new Sr(l);if(!m.isValid())throw new bs("invalid value",{toml:n,ptr:i});return m}function sS(l,n,i,c){let u=l.slice(n,i),m=u.indexOf("#");m>-1&&(Hm(l,m),u=u.slice(0,m));let h=u.trimEnd();if(!c){let f=u.indexOf(`
`,h.length);if(f>-1)throw new bs("newlines are not allowed in inline tables",{toml:l,ptr:n+f})}return[h,m]}function Gm(l,n,i,c,u){if(c===0)throw new bs("document contains excessively nested structures. aborting.",{toml:l,ptr:n});let m=l[n];if(m==="["||m==="{"){let[p,j]=m==="["?lS(l,n,c,u):aS(l,n,c,u),v=i?ug(l,j,",",i):j;if(j-v&&i==="}"){let N=Eo(l,j,v);if(N>-1)throw new bs("newlines are not allowed in inline tables",{toml:l,ptr:N})}return[p,v]}let h;if(m==='"'||m==="'"){h=lv(l,n);let p=nv(l,n,h);if(i){if(h=yl(l,h,i!=="]"),l[h]&&l[h]!==","&&l[h]!==i&&l[h]!==`
`&&l[h]!=="\r")throw new bs("unexpected character encountered",{toml:l,ptr:h});h+=+(l[h]===",")}return[p,h]}h=ug(l,n,",",i);let f=sS(l,n,h-+(l[h-1]===","),i==="]");if(!f[0])throw new bs("incomplete key-value declaration: no value specified",{toml:l,ptr:n});return i&&f[1]>-1&&(h=yl(l,n+f[1]),h+=+(l[h]===",")),[eS(f[0],l,n,u),h]}let tS=/^[a-zA-Z0-9-_]+[ \t]*$/;function Mm(l,n,i="="){let c=n-1,u=[],m=l.indexOf(i,n);if(m<0)throw new bs("incomplete key-value: cannot find end of key",{toml:l,ptr:n});do{let h=l[n=++c];if(h!==" "&&h!==" ")if(h==='"'||h==="'"){if(h===l[n+1]&&h===l[n+2])throw new bs("multiline strings are not allowed in keys",{toml:l,ptr:n});let f=lv(l,n);if(f<0)throw new bs("unfinished string encountered",{toml:l,ptr:n});c=l.indexOf(".",f);let p=l.slice(f,c<0||c>m?m:c),j=Eo(p);if(j>-1)throw new bs("newlines are not allowed in keys",{toml:l,ptr:n+c+j});if(p.trimStart())throw new bs("found extra tokens after the string part",{toml:l,ptr:f});if(m<f&&(m=l.indexOf(i,f),m<0))throw new bs("incomplete key-value: cannot find end of key",{toml:l,ptr:n});u.push(nv(l,n,f))}else{c=l.indexOf(".",n);let f=l.slice(n,c<0||c>m?m:c);if(!tS.test(f))throw new bs("only letter, numbers, dashes and underscores are allowed in keys",{toml:l,ptr:n});u.push(f.trimEnd())}}while(c+1&&c<m);return[u,yl(l,m+1,!0,!0)]}function aS(l,n,i,c){let u={},m=new Set,h,f=0;for(n++;(h=l[n++])!=="}"&&h;){let p={toml:l,ptr:n-1};if(h===`
`)throw new bs("newlines are not allowed in inline tables",p);if(h==="#")throw new bs("inline tables cannot contain comments",p);if(h===",")throw new bs("expected key-value, found comma",p);if(h!==" "&&h!==" "){let j,v=u,N=!1,[b,S]=Mm(l,n-1);for(let M=0;M<b.length;M++){if(M&&(v=N?v[j]:v[j]={}),j=b[M],(N=Object.hasOwn(v,j))&&(typeof v[j]!="object"||m.has(v[j])))throw new bs("trying to redefine an already defined value",{toml:l,ptr:n});!N&&j==="__proto__"&&Object.defineProperty(v,j,{enumerable:!0,configurable:!0,writable:!0})}if(N)throw new bs("trying to redefine an already defined value",{toml:l,ptr:n});let[w,O]=Gm(l,S,"}",i-1,c);m.add(w),v[j]=w,n=O,f=l[n-1]===","?n-1:0}}if(f)throw new bs("trailing commas are not allowed in inline tables",{toml:l,ptr:f});if(!h)throw new bs("unfinished table encountered",{toml:l,ptr:n});return[u,n]}function lS(l,n,i,c){let u=[],m;for(n++;(m=l[n++])!=="]"&&m;){if(m===",")throw new bs("expected value, found comma",{toml:l,ptr:n-1});if(m==="#")n=Hm(l,n);else if(m!==" "&&m!==" "&&m!==`
`&&m!=="\r"){let h=Gm(l,n-1,"]",i-1,c);u.push(h[0]),n=h[1]}}if(!m)throw new bs("unfinished array encountered",{toml:l,ptr:n});return[u,n]}function xg(l,n,i,c){let u=n,m=i,h,f=!1,p;for(let j=0;j<l.length;j++){if(j){if(u=f?u[h]:u[h]={},m=(p=m[h]).c,c===0&&(p.t===1||p.t===2))return null;if(p.t===2){let v=u.length-1;u=u[v],m=m[v].c}}if(h=l[j],(f=Object.hasOwn(u,h))&&m[h]?.t===0&&m[h]?.d)return null;f||(h==="__proto__"&&(Object.defineProperty(u,h,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(m,h,{enumerable:!0,configurable:!0,writable:!0})),m[h]={t:j<l.length-1&&c===2?3:c,d:!1,i:0,c:{}})}if(p=m[h],p.t!==c&&!(c===1&&p.t===3)||(c===2&&(p.d||(p.d=!0,u[h]=[]),u[h].push(u={}),p.c[p.i++]=p={t:1,d:!1,i:0,c:{}}),p.d))return null;if(p.d=!0,c===1)u=f?u[h]:u[h]={};else if(c===0&&f)return null;return[h,u,p.c]}function nS(l,{maxDepth:n=1e3,integersAsBigInt:i}={}){let c={},u={},m=c,h=u;for(let f=yl(l,0);f<l.length;){if(l[f]==="["){let p=l[++f]==="[",j=Mm(l,f+=+p,"]");if(p){if(l[j[1]-1]!=="]")throw new bs("expected end of table declaration",{toml:l,ptr:j[1]-1});j[1]++}let v=xg(j[0],c,u,p?2:1);if(!v)throw new bs("trying to redefine an already defined table or value",{toml:l,ptr:f});h=v[2],m=v[1],f=j[1]}else{let p=Mm(l,f),j=xg(p[0],m,h,0);if(!j)throw new bs("trying to redefine an already defined table or value",{toml:l,ptr:f});let v=Gm(l,p[1],void 0,n,i);j[1][j[0]]=v[0],f=v[1]}if(f=yl(l,f,!0),l[f]&&l[f]!==`
`&&l[f]!=="\r")throw new bs("each key-value declaration must be followed by an end-of-line",{toml:l,ptr:f});f=yl(l,f)}return c}let rv=/^[a-z0-9-_]+$/i;function Ki(l){let n=typeof l;if(n==="object"){if(Array.isArray(l))return"array";if(l instanceof Date)return"date"}return n}function rS(l){for(let n=0;n<l.length;n++)if(Ki(l[n])!=="object")return!1;return l.length!=0}function Pm(l){return JSON.stringify(l).replace(/\x7f/g,"\\u007f")}function Im(l,n,i,c){if(i===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(n==="number")return isNaN(l)?"nan":l===1/0?"inf":l===-1/0?"-inf":c&&Number.isInteger(l)?l.toFixed(1):l.toString();if(n==="bigint"||n==="boolean")return l.toString();if(n==="string")return Pm(l);if(n==="date"){if(isNaN(l.getTime()))throw new TypeError("cannot serialize invalid date");return l.toISOString()}if(n==="object")return iS(l,i,c);if(n==="array")return cS(l,i,c)}function iS(l,n,i){let c=Object.keys(l);if(c.length===0)return"{}";let u="{ ";for(let m=0;m<c.length;m++){let h=c[m];m&&(u+=", "),u+=rv.test(h)?h:Pm(h),u+=" = ",u+=Im(l[h],Ki(l[h]),n-1,i)}return u+" }"}function cS(l,n,i){if(l.length===0)return"[]";let c="[ ";for(let u=0;u<l.length;u++){if(u&&(c+=", "),l[u]===null||l[u]===void 0)throw new TypeError("arrays cannot contain null or undefined values");c+=Im(l[u],Ki(l[u]),n-1,i)}return c+" ]"}function oS(l,n,i,c){if(i===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let u="";for(let m=0;m<l.length;m++)u+=`${u&&`
`}[[${n}]]
`,u+=qm(0,l[m],n,i,c);return u}function qm(l,n,i,c,u){if(c===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let m="",h="",f=Object.keys(n);for(let p=0;p<f.length;p++){let j=f[p];if(n[j]!==null&&n[j]!==void 0){let v=Ki(n[j]);if(v==="symbol"||v==="function")throw new TypeError(`cannot serialize values of type '${v}'`);let N=rv.test(j)?j:Pm(j);if(v==="array"&&rS(n[j]))h+=(h&&`
`)+oS(n[j],i?`${i}.${N}`:N,c-1,u);else if(v==="object"){let b=i?`${i}.${N}`:N;h+=(h&&`
`)+qm(b,n[j],b,c-1,u)}else m+=N,m+=" = ",m+=Im(n[j],v,c,u),m+=`
`}}return l&&(m||!h)&&(m=m?`[${l}]
${m}`:`[${l}]`),m&&h?`${m}
${h}`:m||h}function dS(l,{maxDepth:n=1e3,numbersAsFloat:i=!1}={}){if(Ki(l)!=="object")throw new TypeError("stringify can only be called with an object");let c=qm(0,l,"",n,i);return c[c.length-1]!==`
`?c+`
`:c}function vm(l){try{const n=nS(l);return{inner:{...xt.inner,...n.inner},nickname:{...xt.nickname,...n.nickname},napcat_server:{...xt.napcat_server,...n.napcat_server},maibot_server:{...xt.maibot_server,...n.maibot_server},chat:{...xt.chat,...n.chat},voice:{...xt.voice,...n.voice},debug:{...xt.debug,...n.debug}}}catch(n){throw console.error("TOML 解析失败:",n),new Error(`无法解析 TOML 文件: ${n instanceof Error?n.message:"未知错误"}`)}}function Nm(l){try{const n=(u,m)=>u===""||u===null||u===void 0?m:u,i={inner:{version:n(l.inner.version,xt.inner.version)},nickname:{nickname:n(l.nickname.nickname,xt.nickname.nickname)},napcat_server:{host:n(l.napcat_server.host,xt.napcat_server.host),port:n(l.napcat_server.port||0,xt.napcat_server.port),token:n(l.napcat_server.token,xt.napcat_server.token),heartbeat_interval:n(l.napcat_server.heartbeat_interval||0,xt.napcat_server.heartbeat_interval)},maibot_server:{host:n(l.maibot_server.host,xt.maibot_server.host),port:n(l.maibot_server.port||0,xt.maibot_server.port)},chat:{group_list_type:n(l.chat.group_list_type,xt.chat.group_list_type),group_list:l.chat.group_list||[],private_list_type:n(l.chat.private_list_type,xt.chat.private_list_type),private_list:l.chat.private_list||[],ban_user_id:l.chat.ban_user_id||[],ban_qq_bot:l.chat.ban_qq_bot??xt.chat.ban_qq_bot,enable_poke:l.chat.enable_poke??xt.chat.enable_poke},voice:{use_tts:l.voice.use_tts??xt.voice.use_tts},debug:{level:n(l.debug.level,xt.debug.level)}};let c=dS(i);return c=uS(c),c}catch(n){throw console.error("TOML 生成失败:",n),new Error(`无法生成 TOML 文件: ${n instanceof Error?n.message:"未知错误"}`)}}function uS(l){const n=l.split(`
`),i=[];for(let c=0;c<n.length;c++){const u=n[c];if(u==="[inner]"){i.push(u);continue}if(u.startsWith("version = ")){i.push(`${u} # 版本号`),i.push("# 请勿修改版本号,除非你知道自己在做什么");continue}if(u==="[nickname]"){i.push("[nickname] # 现在没用");continue}if(u==="[napcat_server]"){i.push("[napcat_server] # Napcat连接的ws服务设置");continue}if(u.startsWith("host = ")&&i[i.length-1]?.includes("[napcat_server]")){i.push(`${u} # Napcat设定的主机地址`);continue}if(u.startsWith("port = ")&&n[c-1]?.includes("host")){i.push(`${u} # Napcat设定的端口`);continue}if(u.startsWith("token = ")){i.push(`${u} # Napcat设定的访问令牌若无则留空`);continue}if(u.startsWith("heartbeat_interval = ")){i.push(`${u} # 与Napcat设置的心跳相同按秒计`);continue}if(u==="[maibot_server]"){i.push("[maibot_server] # 连接麦麦的ws服务设置");continue}if(u.startsWith("host = ")&&i[i.length-1]?.includes("[maibot_server]")){i.push(`${u} # 麦麦在.env文件中设置的主机地址即HOST字段`);continue}if(u.startsWith("port = ")&&i[i.length-1]?.includes("麦麦在.env")){i.push(`${u} # 麦麦在.env文件中设置的端口即PORT字段`);continue}if(u==="[chat]"){i.push("[chat] # 黑白名单功能");continue}if(u.startsWith("group_list_type = ")){i.push(`${u} # 群组名单类型可选为whitelist, blacklist`);continue}if(u.startsWith("group_list = ")){i.push(`${u} # 群组名单`),i.push("# 当group_list_type为whitelist时只有群组名单中的群组可以聊天"),i.push("# 当group_list_type为blacklist时群组名单中的任何群组无法聊天");continue}if(u.startsWith("private_list_type = ")){i.push(`${u} # 私聊名单类型可选为whitelist, blacklist`);continue}if(u.startsWith("private_list = ")){i.push(`${u} # 私聊名单`),i.push("# 当private_list_type为whitelist时只有私聊名单中的用户可以聊天"),i.push("# 当private_list_type为blacklist时私聊名单中的任何用户无法聊天");continue}if(u.startsWith("ban_user_id = ")){i.push(`${u} # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`);continue}if(u.startsWith("ban_qq_bot = ")){i.push(`${u} # 是否屏蔽QQ官方机器人`);continue}if(u.startsWith("enable_poke = ")){i.push(`${u} # 是否启用戳一戳功能`);continue}if(u==="[voice]"){i.push("[voice] # 发送语音设置");continue}if(u.startsWith("use_tts = ")){i.push(`${u} # 是否使用tts语音请确保你配置了tts并有对应的adapter`);continue}if(u.startsWith("level = ")&&i[i.length-1]==="[debug]"){i.push(`${u} # 日志等级DEBUG, INFO, WARNING, ERROR, CRITICAL`);continue}i.push(u)}return i.join(`
`)}function bm(l){if(!l.trim())return{valid:!1,error:"路径不能为空"};if(!l.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const n=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,i=/^(\/|~\/).+\.toml$/i,c=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,u=n.test(l),m=i.test(l),h=c.test(l);return!u&&!m&&!h?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(l)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}}function mS(){const[l,n]=x.useState("upload"),[i,c]=x.useState(null),[u,m]=x.useState(""),[h,f]=x.useState(""),[p,j]=x.useState("oneclick"),[v,N]=x.useState(""),[b,S]=x.useState(!1),[w,O]=x.useState(!1),[M,D]=x.useState(!1),[$,E]=x.useState(!1),[_,T]=x.useState(null),[P,A]=x.useState(!1),ee=x.useRef(null),{toast:H}=et(),Z=x.useRef(null),re=q=>{if(f(q),q.trim()){const oe=bm(q);N(oe.error)}else N("")},ye=x.useCallback(async q=>{const oe=jm[q];O(!0);try{const Te=await og(oe.path),X=vm(Te);c(X),j(q),f(oe.path),await cg(oe.path),H({title:"加载成功",description:`已从${oe.name}预设加载配置`})}catch(Te){console.error("加载预设配置失败:",Te),H({title:"加载失败",description:Te instanceof Error?Te.message:"无法读取预设配置文件",variant:"destructive"})}finally{O(!1)}},[H]),de=x.useCallback(async q=>{const oe=bm(q);if(!oe.valid){N(oe.error),H({title:"路径无效",description:oe.error,variant:"destructive"});return}N(""),O(!0);try{const Te=await og(q),X=vm(Te);c(X),f(q),await cg(q),H({title:"加载成功",description:"已从配置文件加载"})}catch(Te){console.error("加载配置失败:",Te),H({title:"加载失败",description:Te instanceof Error?Te.message:"无法读取配置文件",variant:"destructive"})}finally{O(!1)}},[H]);x.useEffect(()=>{(async()=>{try{const oe=await V_();if(oe&&oe.path){f(oe.path);const Te=Object.entries(jm).find(([,X])=>X.path===oe.path);Te?(n("preset"),j(Te[0]),await ye(Te[0])):(n("path"),await de(oe.path))}}catch(oe){console.error("加载保存的路径失败:",oe)}})()},[de,ye]);const ge=x.useCallback(q=>{l!=="path"&&l!=="preset"||!h||(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(async()=>{S(!0);try{const oe=Nm(q);await dg(h,oe),H({title:"自动保存成功",description:"配置已保存到文件"})}catch(oe){console.error("自动保存失败:",oe),H({title:"自动保存失败",description:oe instanceof Error?oe.message:"保存配置失败",variant:"destructive"})}finally{S(!1)}},1e3))},[l,h,H]),je=async()=>{if(!i||!h)return;const q=bm(h);if(!q.valid){H({title:"保存失败",description:q.error,variant:"destructive"});return}S(!0);try{const oe=Nm(i);await dg(h,oe),H({title:"保存成功",description:"配置已保存到文件"})}catch(oe){console.error("保存失败:",oe),H({title:"保存失败",description:oe instanceof Error?oe.message:"保存配置失败",variant:"destructive"})}finally{S(!1)}},z=async()=>{h&&await de(h)},Q=q=>{if(q!==l){if(i){T(q),D(!0);return}J(q)}},J=q=>{c(null),m(""),N(""),n(q),q==="preset"&&ye("oneclick"),H({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[q]})},U=()=>{_&&(J(_),T(null)),D(!1)},G=()=>{if(i){E(!0);return}Ce()},Ce=()=>{f(""),c(null),N(""),H({title:"已清空",description:"路径和配置已清空"})},be=()=>{Ce(),E(!1)},ke=q=>{const oe=q.target.files?.[0];if(!oe)return;const Te=new FileReader;Te.onload=X=>{try{const ne=X.target?.result,Ie=vm(ne);c(Ie),m(oe.name),H({title:"上传成功",description:`已加载配置文件:${oe.name}`})}catch(ne){console.error("解析配置文件失败:",ne),H({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},Te.readAsText(oe)},I=()=>{if(!i)return;const q=Nm(i),oe=new Blob([q],{type:"text/plain;charset=utf-8"}),Te=URL.createObjectURL(oe),X=document.createElement("a");X.href=Te,X.download=u||"config.toml",document.body.appendChild(X),X.click(),document.body.removeChild(X),URL.revokeObjectURL(Te),H({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},we=()=>{c(JSON.parse(JSON.stringify(xt))),m("config.toml"),H({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(Xe,{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(Ut,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsx(Pi,{open:P,onOpenChange:A,children:e.jsxs(Oe,{children:[e.jsx(ts,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ns,{children:"工作模式"}),e.jsx(Qs,{children:"选择配置文件的管理方式"})]}),e.jsx(Ii,{asChild:!0,children:e.jsxs(C,{variant:"ghost",size:"sm",className:"w-9 p-0",children:[e.jsx(Ra,{className:`h-4 w-4 transition-transform duration-200 ${P?"transform rotate-180":""}`}),e.jsx("span",{className:"sr-only",children:"切换"})]})})]})}),e.jsx(qi,{children:e.jsxs(We,{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 ${l==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(da,{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 ${l==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(Bi,{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 ${l==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(Aw,{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:"指定配置文件路径,自动加载和保存"})]})]})})]}),l==="preset"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsx(k,{className:"text-sm md:text-base",children:"选择部署方式"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(jm).map(([q,oe])=>{const Te=oe.icon,X=p===q;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${X?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{j(q),ye(q)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Te,{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:oe.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:oe.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:oe.path})]})]})},q)})})]}),l==="path"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{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:h,onChange:q=>re(q.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(C,{onClick:()=>de(h),disabled:w||!h||!!v,className:"w-full sm:w-auto",children:w?e.jsxs(e.Fragment,{children:[e.jsx(At,{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(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(_t,{children:l==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]}):l==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]})})]}),l==="upload"&&!i&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:ee,type:"file",accept:".toml",className:"hidden",onChange:ke}),e.jsxs(C,{onClick:()=>ee.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Bi,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(C,{onClick:we,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Ga,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),l==="upload"&&i&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(C,{onClick:I,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(l==="preset"||l==="path")&&i&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(C,{onClick:je,size:"sm",disabled:b||!!v,className:"w-full sm:w-auto",children:[e.jsx(Fi,{className:"mr-2 h-4 w-4"}),b?"保存中...":"立即保存"]}),e.jsxs(C,{onClick:z,size:"sm",variant:"outline",disabled:w,className:"w-full sm:w-auto",children:[e.jsx(At,{className:`mr-2 h-4 w-4 ${w?"animate-spin":""}`}),"刷新"]}),l==="path"&&e.jsxs(C,{onClick:G,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(rs,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),i?e.jsxs(ma,{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(Xt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5",children:[e.jsxs(ss,{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(ss,{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(ss,{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(ss,{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(ss,{value:"debug",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:"调试"})]})}),e.jsx(Ss,{value:"napcat",className:"space-y-4",children:e.jsx(xS,{config:i,onChange:q=>{c(q),ge(q)}})}),e.jsx(Ss,{value:"maibot",className:"space-y-4",children:e.jsx(hS,{config:i,onChange:q=>{c(q),ge(q)}})}),e.jsx(Ss,{value:"chat",className:"space-y-4",children:e.jsx(fS,{config:i,onChange:q=>{c(q),ge(q)}})}),e.jsx(Ss,{value:"voice",className:"space-y-4",children:e.jsx(pS,{config:i,onChange:q=>{c(q),ge(q)}})}),e.jsx(Ss,{value:"debug",className:"space-y-4",children:e.jsx(gS,{config:i,onChange:q=>{c(q),ge(q)}})})]}):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(Ga,{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:l==="preset"?"请选择预设的部署方式":l==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(js,{open:M,onOpenChange:D,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认切换模式"}),e.jsxs(hs,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(ms,{children:[e.jsx(ps,{onClick:()=>{D(!1),T(null)},children:"取消"}),e.jsx(fs,{onClick:U,children:"确认切换"})]})]})}),e.jsx(js,{open:$,onOpenChange:E,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认清空路径"}),e.jsxs(hs,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(ms,{children:[e.jsx(ps,{onClick:()=>E(!1),children:"取消"}),e.jsx(fs,{onClick:be,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function xS({config:l,onChange:n}){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(k,{htmlFor:"napcat-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"napcat-host",value:l.napcat_server.host,onChange:i=>n({...l,napcat_server:{...l.napcat_server,host:i.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(k,{htmlFor:"napcat-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"napcat-port",type:"number",value:l.napcat_server.port||"",onChange:i=>n({...l,napcat_server:{...l.napcat_server,port:i.target.value?parseInt(i.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(k,{htmlFor:"napcat-token",className:"text-sm md:text-base",children:"访问令牌Token"}),e.jsx(ce,{id:"napcat-token",type:"password",value:l.napcat_server.token,onChange:i=>n({...l,napcat_server:{...l.napcat_server,token:i.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(k,{htmlFor:"napcat-heartbeat",className:"text-sm md:text-base",children:"心跳间隔(秒)"}),e.jsx(ce,{id:"napcat-heartbeat",type:"number",value:l.napcat_server.heartbeat_interval||"",onChange:i=>n({...l,napcat_server:{...l.napcat_server,heartbeat_interval:i.target.value?parseInt(i.target.value):0}}),placeholder:"30",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"与 Napcat 设置的心跳间隔保持一致(留空使用默认值 30"})]})]})]})})}function hS({config:l,onChange:n}){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(k,{htmlFor:"maibot-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ce,{id:"maibot-host",value:l.maibot_server.host,onChange:i=>n({...l,maibot_server:{...l.maibot_server,host:i.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(k,{htmlFor:"maibot-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ce,{id:"maibot-port",type:"number",value:l.maibot_server.port||"",onChange:i=>n({...l,maibot_server:{...l.maibot_server,port:i.target.value?parseInt(i.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 fS({config:l,onChange:n}){const i=m=>{const h={...l};m==="group"?h.chat.group_list=[...h.chat.group_list,0]:m==="private"?h.chat.private_list=[...h.chat.private_list,0]:h.chat.ban_user_id=[...h.chat.ban_user_id,0],n(h)},c=(m,h)=>{const f={...l};m==="group"?f.chat.group_list=f.chat.group_list.filter((p,j)=>j!==h):m==="private"?f.chat.private_list=f.chat.private_list.filter((p,j)=>j!==h):f.chat.ban_user_id=f.chat.ban_user_id.filter((p,j)=>j!==h),n(f)},u=(m,h,f)=>{const p={...l};m==="group"?p.chat.group_list[h]=f:m==="private"?p.chat.private_list[h]=f:p.chat.ban_user_id[h]=f,n(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(k,{className:"text-sm md:text-base",children:"群组名单类型"}),e.jsxs($e,{value:l.chat.group_list_type,onValueChange:m=>n({...l,chat:{...l.chat,group_list_type:m}}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(le,{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(k,{className:"text-sm md:text-base",children:"群组列表"}),e.jsxs(C,{onClick:()=>i("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ga,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),l.chat.group_list.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:m,onChange:f=>u("group",h,parseInt(f.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除群号 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>c("group",h),children:"删除"})]})]})]})]},h)),l.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(k,{className:"text-sm md:text-base",children:"私聊名单类型"}),e.jsxs($e,{value:l.chat.private_list_type,onValueChange:m=>n({...l,chat:{...l.chat,private_list_type:m}}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(le,{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(k,{className:"text-sm md:text-base",children:"私聊列表"}),e.jsxs(C,{onClick:()=>i("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ga,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),l.chat.private_list.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:m,onChange:f=>u("private",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要删除用户 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>c("private",h),children:"删除"})]})]})]})]},h)),l.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(k,{className:"text-sm md:text-base",children:"全局禁止名单"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"名单中的用户无法进行任何聊天"})]}),e.jsxs(C,{onClick:()=>i("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ga,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),l.chat.ban_user_id.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{type:"number",value:m,onChange:f=>u("ban",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(js,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(C,{size:"icon",variant:"outline",children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:["确定要从全局禁止名单中删除用户 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>c("ban",h),children:"删除"})]})]})]})]},h)),l.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(k,{className:"text-sm md:text-base",children:"屏蔽QQ官方机器人"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否屏蔽来自QQ官方机器人的消息"})]}),e.jsx(Fe,{checked:l.chat.ban_qq_bot,onCheckedChange:m=>n({...l,chat:{...l.chat,ban_qq_bot:m}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-sm md:text-base",children:"启用戳一戳功能"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否响应戳一戳消息"})]}),e.jsx(Fe,{checked:l.chat.enable_poke,onCheckedChange:m=>n({...l,chat:{...l.chat,enable_poke:m}})})]})]})]})})}function pS({config:l,onChange:n}){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(k,{className:"text-sm md:text-base",children:"使用 TTS 语音"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"请确保已配置 TTS 并有对应的适配器"})]}),e.jsx(Fe,{checked:l.voice.use_tts,onCheckedChange:i=>n({...l,voice:{use_tts:i}})})]})]})})}function gS({config:l,onChange:n}){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(k,{className:"text-sm md:text-base",children:"日志等级"}),e.jsxs($e,{value:l.debug.level,onValueChange:i=>n({...l,debug:{level:i}}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"DEBUG",children:"DEBUG调试"}),e.jsx(le,{value:"INFO",children:"INFO信息"}),e.jsx(le,{value:"WARNING",children:"WARNING警告"}),e.jsx(le,{value:"ERROR",children:"ERROR错误"}),e.jsx(le,{value:"CRITICAL",children:"CRITICAL严重"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const jS=["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"],vS=/^(aria-|data-)/,iv=l=>Object.fromEntries(Object.entries(l).filter(([n])=>vS.test(n)||jS.includes(n)));function NS(l,n){const i=iv(l);return Object.keys(l).some(c=>!Object.hasOwn(i,c)&&l[c]!==n[c])}class bS extends x.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(n){if(n.uppy!==this.props.uppy)this.uninstallPlugin(n),this.installPlugin();else if(NS(this.props,n)){const{uppy:i,...c}={...this.props,target:this.container};this.plugin.setOptions(c)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:n,...i}={id:"Dashboard",...this.props,inline:!0,target:this.container};n.use(l1,i),this.plugin=n.getPlugin(i.id)}uninstallPlugin(n=this.props){const{uppy:i}=n;i.removePlugin(this.plugin)}render(){return x.createElement("div",{className:"uppy-Container",ref:n=>{this.container=n},...iv(this.props)})}}function yS({src:l,alt:n="表情包",className:i,maxRetries:c=5,retryInterval:u=1500}){const[m,h]=x.useState("loading"),[f,p]=x.useState(0),[j,v]=x.useState(null),N=x.useCallback(async()=>{try{const b=await fetch(l,{credentials:"include"});if(b.status===202){h("generating"),f<c?setTimeout(()=>{p(O=>O+1)},u):h("error");return}if(!b.ok){h("error");return}const S=await b.blob(),w=URL.createObjectURL(S);v(w),h("loaded")}catch(b){console.error("加载缩略图失败:",b),h("error")}},[l,f,c,u]);return x.useEffect(()=>{h("loading"),p(0),v(null)},[l]),x.useEffect(()=>{N()},[N]),x.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]),m==="loading"||m==="generating"?e.jsx(Ks,{className:L("w-full h-full",i)}):m==="error"||!j?e.jsx("div",{className:L("w-full h-full flex items-center justify-center bg-muted",i),children:e.jsx(pj,{className:"h-8 w-8 text-muted-foreground"})}):e.jsx("img",{src:j,alt:n,className:L("w-full h-full object-contain",i)})}function cv({content:l,className:n=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${n}`,children:e.jsx(r1,{remarkPlugins:[c1,o1],rehypePlugins:[i1],components:{code({inline:i,className:c,children:u,...m}){return i?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...m,children:u}):e.jsx("code",{className:`${c} block bg-muted p-4 rounded-lg overflow-x-auto`,...m,children:u})},table({children:i,...c}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...c,children:i})})},th({children:i,...c}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...c,children:i})},td({children:i,...c}){return e.jsx("td",{className:"border border-border px-4 py-2",...c,children:i})},a({children:i,...c}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...c,children:i})},blockquote({children:i,...c}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...c,children:i})},h1({children:i,...c}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...c,children:i})},h2({children:i,...c}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...c,children:i})},h3({children:i,...c}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...c,children:i})},h4({children:i,...c}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...c,children:i})},ul({children:i,...c}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...c,children:i})},ol({children:i,...c}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...c,children:i})},p({children:i,...c}){return e.jsx("p",{className:"my-2 leading-relaxed",...c,children:i})},hr({...i}){return e.jsx("hr",{className:"my-4 border-border",...i})}},children:l})})}function wS({children:l,className:n}){return e.jsx(cv,{content:l,className:n})}const La="/api/webui/emoji";async function _S(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.is_registered!==void 0&&n.append("is_registered",l.is_registered.toString()),l.is_banned!==void 0&&n.append("is_banned",l.is_banned.toString()),l.format&&n.append("format",l.format),l.sort_by&&n.append("sort_by",l.sort_by),l.sort_order&&n.append("sort_order",l.sort_order);const i=await Se(`${La}/list?${n}`,{});if(!i.ok)throw new Error(`获取表情包列表失败: ${i.statusText}`);return i.json()}async function SS(l){const n=await Se(`${La}/${l}`,{});if(!n.ok)throw new Error(`获取表情包详情失败: ${n.statusText}`);return n.json()}async function CS(l,n){const i=await Se(`${La}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok)throw new Error(`更新表情包失败: ${i.statusText}`);return i.json()}async function kS(l){const n=await Se(`${La}/${l}`,{method:"DELETE"});if(!n.ok)throw new Error(`删除表情包失败: ${n.statusText}`);return n.json()}async function TS(){const l=await Se(`${La}/stats/summary`,{});if(!l.ok)throw new Error(`获取统计数据失败: ${l.statusText}`);return l.json()}async function ES(l){const n=await Se(`${La}/${l}/register`,{method:"POST"});if(!n.ok)throw new Error(`注册表情包失败: ${n.statusText}`);return n.json()}async function MS(l){const n=await Se(`${La}/${l}/ban`,{method:"POST"});if(!n.ok)throw new Error(`封禁表情包失败: ${n.statusText}`);return n.json()}function AS(l,n=!1){return n?`${La}/${l}/thumbnail?original=true`:`${La}/${l}/thumbnail`}function zS(l){return`${La}/${l}/thumbnail?original=true`}async function DS(l){const n=await Se(`${La}/batch/delete`,{method:"POST",body:JSON.stringify({emoji_ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除失败")}return n.json()}function OS(){return`${La}/upload`}function RS(){const[l,n]=x.useState([]),[i,c]=x.useState(null),[u,m]=x.useState(!1),[h,f]=x.useState(1),[p,j]=x.useState(0),[v,N]=x.useState(20),[b,S]=x.useState("all"),[w,O]=x.useState("all"),[M,D]=x.useState("all"),[$,E]=x.useState("usage_count"),[_,T]=x.useState("desc"),[P,A]=x.useState(null),[ee,H]=x.useState(!1),[Z,re]=x.useState(!1),[ye,de]=x.useState(!1),[ge,je]=x.useState(new Set),[z,Q]=x.useState(!1),[J,U]=x.useState(""),[G,Ce]=x.useState("medium"),[be,ke]=x.useState(!1),{toast:I}=et(),we=x.useCallback(async()=>{try{m(!0);const ue=await _S({page:h,page_size:v,is_registered:b==="all"?void 0:b==="registered",is_banned:w==="all"?void 0:w==="banned",format:M==="all"?void 0:M,sort_by:$,sort_order:_});n(ue.data),j(ue.total)}catch(ue){const ve=ue instanceof Error?ue.message:"加载表情包列表失败";I({title:"错误",description:ve,variant:"destructive"})}finally{m(!1)}},[h,v,b,w,M,$,_,I]),q=async()=>{try{const ue=await TS();c(ue.data)}catch(ue){console.error("加载统计数据失败:",ue)}};x.useEffect(()=>{we()},[we]),x.useEffect(()=>{q()},[]);const oe=async ue=>{try{const ve=await SS(ue.id);A(ve.data),H(!0)}catch(ve){const Me=ve instanceof Error?ve.message:"加载详情失败";I({title:"错误",description:Me,variant:"destructive"})}},Te=ue=>{A(ue),re(!0)},X=ue=>{A(ue),de(!0)},ne=async()=>{if(P)try{await kS(P.id),I({title:"成功",description:"表情包已删除"}),de(!1),A(null),we(),q()}catch(ue){const ve=ue instanceof Error?ue.message:"删除失败";I({title:"错误",description:ve,variant:"destructive"})}},Ie=async ue=>{try{await ES(ue.id),I({title:"成功",description:"表情包已注册"}),we(),q()}catch(ve){const Me=ve instanceof Error?ve.message:"注册失败";I({title:"错误",description:Me,variant:"destructive"})}},Je=async ue=>{try{await MS(ue.id),I({title:"成功",description:"表情包已封禁"}),we(),q()}catch(ve){const Me=ve instanceof Error?ve.message:"封禁失败";I({title:"错误",description:Me,variant:"destructive"})}},pe=ue=>{const ve=new Set(ge);ve.has(ue)?ve.delete(ue):ve.add(ue),je(ve)},as=async()=>{try{const ue=await DS(Array.from(ge));I({title:"批量删除完成",description:ue.message}),je(new Set),Q(!1),we(),q()}catch(ue){I({title:"批量删除失败",description:ue instanceof Error?ue.message:"批量删除失败",variant:"destructive"})}},F=()=>{const ue=parseInt(J),ve=Math.ceil(p/v);ue>=1&&ue<=ve?(f(ue),U("")):I({title:"无效的页码",description:`请输入1-${ve}之间的页码`,variant:"destructive"})},ze=i?.formats?Object.keys(i.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(C,{onClick:()=>ke(!0),className:"gap-2",children:[e.jsx(Bi,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(Xe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[i&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Oe,{children:e.jsxs(ts,{className:"pb-2",children:[e.jsx(Qs,{children:"总数"}),e.jsx(ns,{className:"text-2xl",children:i.total})]})}),e.jsx(Oe,{children:e.jsxs(ts,{className:"pb-2",children:[e.jsx(Qs,{children:"已注册"}),e.jsx(ns,{className:"text-2xl text-green-600",children:i.registered})]})}),e.jsx(Oe,{children:e.jsxs(ts,{className:"pb-2",children:[e.jsx(Qs,{children:"已封禁"}),e.jsx(ns,{className:"text-2xl text-red-600",children:i.banned})]})}),e.jsx(Oe,{children:e.jsxs(ts,{className:"pb-2",children:[e.jsx(Qs,{children:"未注册"}),e.jsx(ns,{className:"text-2xl text-gray-600",children:i.unregistered})]})})]}),e.jsxs(Oe,{children:[e.jsx(ts,{children:e.jsxs(ns,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(We,{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(k,{children:"排序方式"}),e.jsxs($e,{value:`${$}-${_}`,onValueChange:ue=>{const[ve,Me]=ue.split("-");E(ve),T(Me),f(1)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(le,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(le,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(le,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(le,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(le,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(le,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(le,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"注册状态"}),e.jsxs($e,{value:b,onValueChange:ue=>{S(ue),f(1)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"registered",children:"已注册"}),e.jsx(le,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"封禁状态"}),e.jsxs($e,{value:w,onValueChange:ue=>{O(ue),f(1)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"banned",children:"已封禁"}),e.jsx(le,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"格式"}),e.jsxs($e,{value:M,onValueChange:ue=>{D(ue),f(1)},children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部"}),ze.map(ue=>e.jsxs(le,{value:ue,children:[ue.toUpperCase()," (",i?.formats[ue],")"]},ue))]})]})]})]}),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:[ge.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",ge.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs($e,{value:G,onValueChange:ue=>Ce(ue),children:[e.jsx(Le,{className:"w-24",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"small",children:"小"}),e.jsx(le,{value:"medium",children:"中"}),e.jsx(le,{value:"large",children:"大"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs($e,{value:v.toString(),onValueChange:ue=>{N(parseInt(ue)),f(1),je(new Set)},children:[e.jsx(Le,{id:"emoji-page-size",className:"w-20",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"40",children:"40"}),e.jsx(le,{value:"60",children:"60"}),e.jsx(le,{value:"100",children:"100"})]})]}),ge.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>je(new Set),children:"取消选择"}),e.jsxs(C,{variant:"destructive",size:"sm",onClick:()=>Q(!0),children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:we,disabled:u,children:[e.jsx(At,{className:`h-4 w-4 mr-2 ${u?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"表情包列表"}),e.jsxs(Qs,{children:["共 ",p," 个表情包,当前第 ",h," 页"]})]}),e.jsxs(We,{children:[l.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${G==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":G==="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:l.map(ue=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${ge.has(ue.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>pe(ue.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${ge.has(ue.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 ${ge.has(ue.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:ge.has(ue.id)&&e.jsx(ua,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[ue.is_registered&&e.jsx(Ae,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),ue.is_banned&&e.jsx(Ae,{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 ${G==="small"?"p-1":G==="medium"?"p-2":"p-3"}`,children:e.jsx(yS,{src:AS(ue.id),alt:"表情包"})}),e.jsxs("div",{className:`border-t bg-card ${G==="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(Ae,{variant:"outline",className:"text-[10px] px-1 py-0",children:ue.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[ue.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${G==="small"?"flex-wrap":""}`,children:[e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ve=>{ve.stopPropagation(),Te(ue)},title:"编辑",children:e.jsx(Mn,{className:"h-3 w-3"})}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ve=>{ve.stopPropagation(),oe(ue)},title:"详情",children:e.jsx(Qt,{className:"h-3 w-3"})}),!ue.is_registered&&e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:ve=>{ve.stopPropagation(),Ie(ue)},title:"注册",children:e.jsx(ua,{className:"h-3 w-3"})}),!ue.is_banned&&e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:ve=>{ve.stopPropagation(),Je(ue)},title:"封禁",children:e.jsx(zw,{className:"h-3 w-3"})}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:ve=>{ve.stopPropagation(),X(ue)},title:"删除",children:e.jsx(rs,{className:"h-3 w-3"})})]})]})]},ue.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:["显示 ",(h-1)*v+1," 到"," ",Math.min(h*v,p)," 条,共 ",p," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(ue=>Math.max(1,ue-1)),disabled:h===1,children:[e.jsx(el,{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:J,onChange:ue=>U(ue.target.value),onKeyDown:ue=>ue.key==="Enter"&&F(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(p/v)}),e.jsx(C,{variant:"outline",size:"sm",onClick:F,disabled:!J,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(ue=>ue+1),disabled:h>=Math.ceil(p/v),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(p/v)),disabled:h>=Math.ceil(p/v),className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(LS,{emoji:P,open:ee,onOpenChange:H}),e.jsx(US,{emoji:P,open:Z,onOpenChange:re,onSuccess:()=>{we(),q()}}),e.jsx(BS,{open:be,onOpenChange:ke,onSuccess:()=>{we(),q()}})]})}),e.jsx(js,{open:z,onOpenChange:Q,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["你确定要删除选中的 ",ge.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:as,children:"确认删除"})]})]})}),e.jsx(Hs,{open:ye,onOpenChange:de,children:e.jsxs(Os,{children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"确认删除"}),e.jsx(Ws,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>de(!1),children:"取消"}),e.jsx(C,{variant:"destructive",onClick:ne,children:"删除"})]})]})})]})}function LS({emoji:l,open:n,onOpenChange:i}){if(!l)return null;const c=u=>u?new Date(u*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(Rs,{children:e.jsx(Ls,{children:"表情包详情"})}),e.jsx(Xe,{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:zS(l.id),alt:l.description||"表情包",className:"w-full h-full object-cover",onError:u=>{const m=u.target;m.style.display="none";const h=m.parentElement;h&&(h.innerHTML='<svg class="h-16 w-16 text-muted-foreground" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>')}})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:l.id})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ae,{variant:"outline",children:l.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:l.full_path})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:l.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"描述"}),l.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(wS,{className:"prose-sm",children:l.description})}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"-"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"情绪"}),e.jsx("div",{className:"mt-1",children:l.emotion?e.jsx("span",{className:"text-sm",children:l.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(k,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[l.is_registered&&e.jsx(Ae,{variant:"default",className:"bg-green-600",children:"已注册"}),l.is_banned&&e.jsx(Ae,{variant:"destructive",children:"已封禁"}),!l.is_registered&&!l.is_banned&&e.jsx(Ae,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:l.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:c(l.record_time)})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:c(l.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:c(l.last_used_time)})]})]})})]})})}function US({emoji:l,open:n,onOpenChange:i,onSuccess:c}){const[u,m]=x.useState(""),[h,f]=x.useState(!1),[p,j]=x.useState(!1),[v,N]=x.useState(!1),{toast:b}=et();x.useEffect(()=>{l&&(m(l.emotion||""),f(l.is_registered),j(l.is_banned))},[l]);const S=async()=>{if(l)try{N(!0);const w=u.split(/[,,]/).map(O=>O.trim()).filter(Boolean).join(",");await CS(l.id,{emotion:w||void 0,is_registered:h,is_banned:p}),b({title:"成功",description:"表情包信息已更新"}),i(!1),c()}catch(w){const O=w instanceof Error?w.message:"保存失败";b({title:"错误",description:O,variant:"destructive"})}finally{N(!1)}};return l?e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"编辑表情包"}),e.jsx(Ws,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(k,{children:"情绪"}),e.jsx(Ys,{value:u,onChange:w=>m(w.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(Js,{id:"is_registered",checked:h,onCheckedChange:w=>{w===!0?(f(!0),j(!1)):f(!1)}}),e.jsx(k,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"is_banned",checked:p,onCheckedChange:w=>{w===!0?(j(!0),f(!1)):j(!1)}}),e.jsx(k,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(C,{onClick:S,disabled:v,children:v?"保存中...":"保存"})]})]})}):null}function BS({open:l,onOpenChange:n,onSuccess:i}){const[c,u]=x.useState("select"),[m,h]=x.useState([]),[f,p]=x.useState(null),[j,v]=x.useState(!1),{toast:N}=et(),b=x.useMemo(()=>new n1({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}"}}}),[]);x.useEffect(()=>{const P=()=>{const A=b.getFiles();if(A.length===0)return;const ee=A.map(H=>({id:H.id,name:H.name,previewUrl:H.preview||URL.createObjectURL(H.data),emotion:"",description:"",isRegistered:!0,file:H.data}));h(ee),A.length===1?(p(ee[0].id),u("edit-single")):u("edit-multiple")};return b.on("upload",P),()=>{b.off("upload",P)}},[b]),x.useEffect(()=>{l||(b.cancelAll(),u("select"),h([]),p(null),v(!1))},[l,b]);const S=x.useCallback((P,A)=>{h(ee=>ee.map(H=>H.id===P?{...H,...A}:H))},[]),w=x.useCallback(P=>P.emotion.trim().length>0,[]),O=x.useMemo(()=>m.length>0&&m.every(w),[m,w]),M=x.useMemo(()=>m.find(P=>P.id===f)||null,[m,f]),D=x.useCallback(()=>{(c==="edit-single"||c==="edit-multiple")&&(u("select"),h([]),p(null))},[c]),$=x.useCallback(async()=>{if(!O){N({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}v(!0);let P=0,A=0;try{for(const ee of m){const H=new FormData;H.append("file",ee.file),H.append("emotion",ee.emotion),H.append("description",ee.description),H.append("is_registered",ee.isRegistered.toString());try{(await Se(OS(),{method:"POST",body:H})).ok?P++:A++}catch{A++}}A===0?(N({title:"上传成功",description:`成功上传 ${P} 个表情包`}),n(!1),i()):(N({title:"部分上传失败",description:`成功 ${P} 个,失败 ${A}`,variant:"destructive"}),i())}finally{v(!1)}},[O,m,N,n,i]),E=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(bS,{uppy:b,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),_=()=>{const P=m[0];return P?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:D,children:[e.jsx(sn,{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:P.previewUrl,alt:P.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:P.name})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"single-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"single-emotion",value:P.emotion,onChange:A=>S(P.id,{emotion:A.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:P.emotion.trim()?"":"border-destructive"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于情感匹配,多个标签用逗号分隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"single-description",children:"描述"}),e.jsx(ce,{id:"single-description",value:P.description,onChange:A=>S(P.id,{description:A.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"single-is-registered",checked:P.isRegistered,onCheckedChange:A=>S(P.id,{isRegistered:A===!0})}),e.jsx(k,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(nt,{children:e.jsx(C,{onClick:$,disabled:!O||j,children:j?"上传中...":"上传"})})]}):null},T=()=>{const P=m.filter(w).length,A=m.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(C,{variant:"ghost",size:"sm",onClick:D,children:[e.jsx(sn,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",P,"/",A," 已完成)"]})]}),e.jsx(Ae,{variant:O?"default":"secondary",children:O?e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ja,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Xe,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:m.map(ee=>{const H=w(ee),Z=f===ee.id;return e.jsxs("div",{onClick:()=>p(ee.id),className:`
flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all
${Z?"ring-2 ring-primary":""}
${H?"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:ee.previewUrl,alt:ee.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:ee.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ee.emotion||"未填写情感标签"})]}),H?e.jsx(ua,{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"})]},ee.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:M?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:M.previewUrl,alt:M.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:M.name}),w(M)&&e.jsxs(Ae,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(yt,{className:"h-3 w-3 mr-1"}),"已完成"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"multi-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"multi-emotion",value:M.emotion,onChange:ee=>S(M.id,{emotion:ee.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:M.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"multi-description",children:"描述"}),e.jsx(ce,{id:"multi-description",value:M.description,onChange:ee=>S(M.id,{description:ee.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"multi-is-registered",checked:M.isRegistered,onCheckedChange:ee=>S(M.id,{isRegistered:ee===!0})}),e.jsx(k,{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(pj,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(nt,{children:e.jsx(C,{onClick:$,disabled:!O||j,children:j?"上传中...":`上传全部 (${A})`})})]})};return e.jsx(Hs,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(Bi,{className:"h-5 w-5"}),c==="select"&&"上传表情包 - 选择文件",c==="edit-single"&&"上传表情包 - 填写信息",c==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs(Ws,{children:[c==="select"&&"支持 JPG、PNG、GIF、WebP 格式,单个文件最大 10MB可同时上传多个文件",c==="edit-single"&&"请填写表情包的情感标签(必填)和描述",c==="edit-multiple"&&"点击左侧卡片编辑每个表情包的信息,情感标签为必填项"]})]}),e.jsxs("div",{className:"overflow-y-auto pr-1",children:[c==="select"&&E(),c==="edit-single"&&_(),c==="edit-multiple"&&T()]})]})})}const ln="/api/webui/expression";async function $S(){const l=await Se(`${ln}/chats`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取聊天列表失败")}return l.json()}async function HS(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.chat_id&&n.append("chat_id",l.chat_id);const i=await Se(`${ln}/list?${n}`,{});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取表达方式列表失败")}return i.json()}async function GS(l){const n=await Se(`${ln}/${l}`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取表达方式详情失败")}return n.json()}async function PS(l){const n=await Se(`${ln}/`,{method:"POST",body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"创建表达方式失败")}return n.json()}async function IS(l,n){const i=await Se(`${ln}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新表达方式失败")}return i.json()}async function qS(l){const n=await Se(`${ln}/${l}`,{method:"DELETE"});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除表达方式失败")}return n.json()}async function VS(l){const n=await Se(`${ln}/batch/delete`,{method:"POST",body:JSON.stringify({ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除表达方式失败")}return n.json()}async function FS(){const l=await Se(`${ln}/stats/summary`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取统计数据失败")}return l.json()}function KS(){const[l,n]=x.useState([]),[i,c]=x.useState(!0),[u,m]=x.useState(0),[h,f]=x.useState(1),[p,j]=x.useState(20),[v,N]=x.useState(""),[b,S]=x.useState(null),[w,O]=x.useState(!1),[M,D]=x.useState(!1),[$,E]=x.useState(!1),[_,T]=x.useState(null),[P,A]=x.useState(new Set),[ee,H]=x.useState(!1),[Z,re]=x.useState(""),[ye,de]=x.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[ge,je]=x.useState([]),[z,Q]=x.useState(new Map),{toast:J}=et(),U=async()=>{try{c(!0);const ne=await HS({page:h,page_size:p,search:v||void 0});n(ne.data),m(ne.total)}catch(ne){J({title:"加载失败",description:ne instanceof Error?ne.message:"无法加载表达方式",variant:"destructive"})}finally{c(!1)}},G=async()=>{try{const ne=await FS();ne?.data&&de(ne.data)}catch(ne){console.error("加载统计数据失败:",ne)}},Ce=async()=>{try{const ne=await $S();if(ne?.data){je(ne.data);const Ie=new Map;ne.data.forEach(Je=>{Ie.set(Je.chat_id,Je.chat_name)}),Q(Ie)}}catch(ne){console.error("加载聊天列表失败:",ne)}},be=ne=>z.get(ne)||ne;x.useEffect(()=>{U(),G(),Ce()},[h,p,v]);const ke=async ne=>{try{const Ie=await GS(ne.id);S(Ie.data),O(!0)}catch(Ie){J({title:"加载详情失败",description:Ie instanceof Error?Ie.message:"无法加载表达方式详情",variant:"destructive"})}},I=ne=>{S(ne),D(!0)},we=async ne=>{try{await qS(ne.id),J({title:"删除成功",description:`已删除表达方式: ${ne.situation}`}),T(null),U(),G()}catch(Ie){J({title:"删除失败",description:Ie instanceof Error?Ie.message:"无法删除表达方式",variant:"destructive"})}},q=ne=>{const Ie=new Set(P);Ie.has(ne)?Ie.delete(ne):Ie.add(ne),A(Ie)},oe=()=>{P.size===l.length&&l.length>0?A(new Set):A(new Set(l.map(ne=>ne.id)))},Te=async()=>{try{await VS(Array.from(P)),J({title:"批量删除成功",description:`已删除 ${P.size} 个表达方式`}),A(new Set),H(!1),U(),G()}catch(ne){J({title:"批量删除失败",description:ne instanceof Error?ne.message:"无法批量删除表达方式",variant:"destructive"})}},X=()=>{const ne=parseInt(Z),Ie=Math.ceil(u/p);ne>=1&&ne<=Ie?(f(ne),re("")):J({title:"无效的页码",description:`请输入1-${Ie}之间的页码`,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(en,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs(C,{onClick:()=>E(!0),className:"gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),"新增表达方式"]})]})}),e.jsx(Xe,{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(k,{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(Vt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索情境、风格或上下文...",value:v,onChange:ne=>N(ne.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:P.size>0&&e.jsxs("span",{children:["已选择 ",P.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs($e,{value:p.toString(),onValueChange:ne=>{j(parseInt(ne)),f(1),A(new Set)},children:[e.jsx(Le,{id:"page-size",className:"w-20",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),P.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>A(new Set),children:"取消选择"}),e.jsxs(C,{variant:"destructive",size:"sm",onClick:()=>H(!0),children:[e.jsx(rs,{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(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{className:"w-12",children:e.jsx(Js,{checked:P.size===l.length&&l.length>0,onCheckedChange:oe})}),e.jsx(Ye,{children:"情境"}),e.jsx(Ye,{children:"风格"}),e.jsx(Ye,{children:"聊天"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:i?e.jsx(lt,{children:e.jsx(Ge,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(lt,{children:e.jsx(Ge,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(ne=>e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Js,{checked:P.has(ne.id),onCheckedChange:()=>q(ne.id)})}),e.jsx(Ge,{className:"font-medium max-w-xs truncate",children:ne.situation}),e.jsx(Ge,{className:"max-w-xs truncate",children:ne.style}),e.jsx(Ge,{className:"max-w-[200px] truncate",title:be(ne.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:be(ne.chat_id)})}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(C,{variant:"default",size:"sm",onClick:()=>I(ne),children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ke(ne),title:"查看详情",children:e.jsx(Yt,{className:"h-4 w-4"})}),e.jsxs(C,{size:"sm",onClick:()=>T(ne),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},ne.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(ne=>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(Js,{checked:P.has(ne.id),onCheckedChange:()=>q(ne.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:ne.situation,children:ne.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:ne.style,children:ne.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:be(ne.chat_id),style:{wordBreak:"keep-all"},children:be(ne.chat_id)})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>I(ne),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>ke(ne),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(Yt,{className:"h-3 w-3"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>T(ne),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},ne.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(el,{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:Z,onChange:ne=>re(ne.target.value),onKeyDown:ne=>ne.key==="Enter"&&X(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(C,{variant:"outline",size:"sm",onClick:X,disabled:!Z,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(QS,{expression:b,open:w,onOpenChange:O,chatNameMap:z}),e.jsx(YS,{open:$,onOpenChange:E,chatList:ge,onSuccess:()=>{U(),G(),E(!1)}}),e.jsx(XS,{expression:b,open:M,onOpenChange:D,chatList:ge,onSuccess:()=>{U(),G(),D(!1)}}),e.jsx(js,{open:!!_,onOpenChange:()=>T(null),children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除表达方式 "',_?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>_&&we(_),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(JS,{open:ee,onOpenChange:H,onConfirm:Te,count:P.size})]})}function QS({expression:l,open:n,onOpenChange:i,chatNameMap:c}){if(!l)return null;const u=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-",m=h=>c.get(h)||h;return e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"表达方式详情"}),e.jsx(Ws,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ti,{label:"情境",value:l.situation}),e.jsx(Ti,{label:"风格",value:l.style}),e.jsx(Ti,{label:"聊天",value:m(l.chat_id)}),e.jsx(Ti,{icon:Tr,label:"记录ID",value:l.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(Ti,{icon:bl,label:"创建时间",value:u(l.create_date)})})]}),e.jsx(nt,{children:e.jsx(C,{onClick:()=>i(!1),children:"关闭"})})]})})}function Ti({icon:l,label:n,value:i,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:L("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function YS({open:l,onOpenChange:n,chatList:i,onSuccess:c}){const[u,m]=x.useState({situation:"",style:"",chat_id:""}),[h,f]=x.useState(!1),{toast:p}=et(),j=async()=>{if(!u.situation||!u.style||!u.chat_id){p({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{f(!0),await PS(u),p({title:"创建成功",description:"表达方式已创建"}),m({situation:"",style:"",chat_id:""}),c()}catch(v){p({title:"创建失败",description:v instanceof Error?v.message:"无法创建表达方式",variant:"destructive"})}finally{f(!1)}};return e.jsx(Hs,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"新增表达方式"}),e.jsx(Ws,{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(k,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"situation",value:u.situation,onChange:v=>m({...u,situation:v.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"style",value:u.style,onChange:v=>m({...u,style:v.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs($e,{value:u.chat_id,onValueChange:v=>m({...u,chat_id:v}),children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择关联的聊天"})}),e.jsx(Ue,{children:i.map(v=>e.jsx(le,{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(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsx(C,{onClick:j,disabled:h,children:h?"创建中...":"创建"})]})]})})}function XS({expression:l,open:n,onOpenChange:i,chatList:c,onSuccess:u}){const[m,h]=x.useState({}),[f,p]=x.useState(!1),{toast:j}=et();x.useEffect(()=>{l&&h({situation:l.situation,style:l.style,chat_id:l.chat_id})},[l]);const v=async()=>{if(l)try{p(!0),await IS(l.id,m),j({title:"保存成功",description:"表达方式已更新"}),u()}catch(N){j({title:"保存失败",description:N instanceof Error?N.message:"无法更新表达方式",variant:"destructive"})}finally{p(!1)}};return l?e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"编辑表达方式"}),e.jsx(Ws,{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(k,{htmlFor:"edit_situation",children:"情境"}),e.jsx(ce,{id:"edit_situation",value:m.situation||"",onChange:N=>h({...m,situation:N.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit_style",children:"风格"}),e.jsx(ce,{id:"edit_style",value:m.style||"",onChange:N=>h({...m,style:N.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs($e,{value:m.chat_id||"",onValueChange:N=>h({...m,chat_id:N}),children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择关联的聊天"})}),e.jsx(Ue,{children:c.map(N=>e.jsx(le,{value:N.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[N.chat_name,N.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},N.chat_id))})]})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(C,{onClick:v,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}function JS({open:l,onOpenChange:n,onConfirm:i,count:c}){return e.jsx(js,{open:l,onOpenChange:n,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["您即将删除 ",c," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:i,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const kl="/api/webui/jargon";async function ZS(){const l=await Se(`${kl}/chats`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取聊天列表失败")}return l.json()}async function WS(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.chat_id&&n.append("chat_id",l.chat_id),l.is_jargon!==void 0&&l.is_jargon!==null&&n.append("is_jargon",l.is_jargon.toString()),l.is_global!==void 0&&n.append("is_global",l.is_global.toString());const i=await Se(`${kl}/list?${n}`,{});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取黑话列表失败")}return i.json()}async function e4(l){const n=await Se(`${kl}/${l}`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取黑话详情失败")}return n.json()}async function s4(l){const n=await Se(`${kl}/`,{method:"POST",body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"创建黑话失败")}return n.json()}async function t4(l,n){const i=await Se(`${kl}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新黑话失败")}return i.json()}async function a4(l){const n=await Se(`${kl}/${l}`,{method:"DELETE"});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除黑话失败")}return n.json()}async function l4(l){const n=await Se(`${kl}/batch/delete`,{method:"POST",body:JSON.stringify({ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除黑话失败")}return n.json()}async function n4(){const l=await Se(`${kl}/stats/summary`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取黑话统计失败")}return l.json()}async function r4(l,n){const i=new URLSearchParams;l.forEach(u=>i.append("ids",u.toString())),i.append("is_jargon",n.toString());const c=await Se(`${kl}/batch/set-jargon?${i}`,{method:"POST"});if(!c.ok){const u=await c.json();throw new Error(u.detail||"批量设置黑话状态失败")}return c.json()}function i4(){const[l,n]=x.useState([]),[i,c]=x.useState(!0),[u,m]=x.useState(0),[h,f]=x.useState(1),[p,j]=x.useState(20),[v,N]=x.useState(""),[b,S]=x.useState("all"),[w,O]=x.useState("all"),[M,D]=x.useState(null),[$,E]=x.useState(!1),[_,T]=x.useState(!1),[P,A]=x.useState(!1),[ee,H]=x.useState(null),[Z,re]=x.useState(new Set),[ye,de]=x.useState(!1),[ge,je]=x.useState(""),[z,Q]=x.useState({total:0,confirmed_jargon:0,confirmed_not_jargon:0,pending:0,global_count:0,complete_count:0,chat_count:0,top_chats:{}}),[J,U]=x.useState([]),{toast:G}=et(),Ce=async()=>{try{c(!0);const pe=await WS({page:h,page_size:p,search:v||void 0,chat_id:b==="all"?void 0:b,is_jargon:w==="all"?void 0:w==="true"?!0:w==="false"?!1:void 0});n(pe.data),m(pe.total)}catch(pe){G({title:"加载失败",description:pe instanceof Error?pe.message:"无法加载黑话列表",variant:"destructive"})}finally{c(!1)}},be=async()=>{try{const pe=await n4();pe?.data&&Q(pe.data)}catch(pe){console.error("加载统计数据失败:",pe)}},ke=async()=>{try{const pe=await ZS();pe?.data&&U(pe.data)}catch(pe){console.error("加载聊天列表失败:",pe)}};x.useEffect(()=>{Ce(),be(),ke()},[h,p,v,b,w]);const I=async pe=>{try{const as=await e4(pe.id);D(as.data),E(!0)}catch(as){G({title:"加载详情失败",description:as instanceof Error?as.message:"无法加载黑话详情",variant:"destructive"})}},we=pe=>{D(pe),T(!0)},q=async pe=>{try{await a4(pe.id),G({title:"删除成功",description:`已删除黑话: ${pe.content}`}),H(null),Ce(),be()}catch(as){G({title:"删除失败",description:as instanceof Error?as.message:"无法删除黑话",variant:"destructive"})}},oe=pe=>{const as=new Set(Z);as.has(pe)?as.delete(pe):as.add(pe),re(as)},Te=()=>{Z.size===l.length&&l.length>0?re(new Set):re(new Set(l.map(pe=>pe.id)))},X=async()=>{try{await l4(Array.from(Z)),G({title:"批量删除成功",description:`已删除 ${Z.size} 个黑话`}),re(new Set),de(!1),Ce(),be()}catch(pe){G({title:"批量删除失败",description:pe instanceof Error?pe.message:"无法批量删除黑话",variant:"destructive"})}},ne=async pe=>{try{await r4(Array.from(Z),pe),G({title:"操作成功",description:`已将 ${Z.size} 个词条设为${pe?"黑话":"非黑话"}`}),re(new Set),Ce(),be()}catch(as){G({title:"操作失败",description:as instanceof Error?as.message:"批量设置失败",variant:"destructive"})}},Ie=()=>{const pe=parseInt(ge),as=Math.ceil(u/p);pe>=1&&pe<=as?(f(pe),je("")):G({title:"无效的页码",description:`请输入1-${as}之间的页码`,variant:"destructive"})},Je=pe=>pe===!0?e.jsxs(Ae,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(yt,{className:"h-3 w-3 mr-1"}),"是黑话"]}):pe===!1?e.jsxs(Ae,{variant:"secondary",children:[e.jsx(Ja,{className:"h-3 w-3 mr-1"}),"非黑话"]}):e.jsxs(Ae,{variant:"outline",children:[e.jsx(xj,{className:"h-3 w-3 mr-1"}),"未判定"]});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(Dw,{className:"h-8 w-8",strokeWidth:2}),"黑话管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦学习到的黑话和俚语"})]}),e.jsxs(C,{onClick:()=>A(!0),className:"gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),"新增黑话"]})]})}),e.jsx(Xe,{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-2 sm:grid-cols-4 lg:grid-cols-7 gap-3",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:z.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"已确认黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-green-600",children:z.confirmed_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"确认非黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-gray-500",children:z.confirmed_not_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"待判定"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-yellow-600",children:z.pending})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"全局黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-blue-600",children:z.global_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"推断完成"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-purple-600",children:z.complete_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:z.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{id:"search",placeholder:"搜索内容、含义...",value:v,onChange:pe=>N(pe.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{children:"聊天筛选"}),e.jsxs($e,{value:b,onValueChange:S,children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"全部聊天"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部聊天"}),J.map(pe=>e.jsx(le,{value:pe.chat_id,children:pe.chat_name},pe.chat_id))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{children:"状态筛选"}),e.jsxs($e,{value:w,onValueChange:O,children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"全部状态"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部状态"}),e.jsx(le,{value:"true",children:"是黑话"}),e.jsx(le,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{htmlFor:"page-size",children:"每页显示"}),e.jsxs($e,{value:p.toString(),onValueChange:pe=>{j(parseInt(pe)),f(1),re(new Set)},children:[e.jsx(Le,{id:"page-size",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]})]})]}),Z.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4 pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",Z.size," 个"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>ne(!0),children:[e.jsx(yt,{className:"h-4 w-4 mr-1"}),"标记为黑话"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>ne(!1),children:[e.jsx(Ja,{className:"h-4 w-4 mr-1"}),"标记为非黑话"]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>re(new Set),children:"取消选择"}),e.jsxs(C,{variant:"destructive",size:"sm",onClick:()=>de(!0),children:[e.jsx(rs,{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(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{className:"w-12",children:e.jsx(Js,{checked:Z.size===l.length&&l.length>0,onCheckedChange:Te})}),e.jsx(Ye,{children:"内容"}),e.jsx(Ye,{children:"含义"}),e.jsx(Ye,{children:"聊天"}),e.jsx(Ye,{children:"状态"}),e.jsx(Ye,{className:"text-center",children:"次数"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:i?e.jsx(lt,{children:e.jsx(Ge,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(lt,{children:e.jsx(Ge,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(pe=>e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Js,{checked:Z.has(pe.id),onCheckedChange:()=>oe(pe.id)})}),e.jsx(Ge,{className:"font-medium max-w-[200px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[pe.is_global&&e.jsx("span",{title:"全局黑话",children:e.jsx(Sm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})}),e.jsx("span",{className:"truncate",title:pe.content,children:pe.content})]})}),e.jsx(Ge,{className:"max-w-[200px] truncate",title:pe.meaning||"",children:pe.meaning||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ge,{className:"max-w-[150px] truncate",title:pe.chat_name||pe.chat_id,children:pe.chat_name||pe.chat_id}),e.jsx(Ge,{children:Je(pe.is_jargon)}),e.jsx(Ge,{className:"text-center",children:pe.count}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(C,{variant:"default",size:"sm",onClick:()=>we(pe),children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>I(pe),title:"查看详情",children:e.jsx(Yt,{className:"h-4 w-4"})}),e.jsxs(C,{size:"sm",onClick:()=>H(pe),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},pe.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(pe=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Js,{checked:Z.has(pe.id),onCheckedChange:()=>oe(pe.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[pe.is_global&&e.jsx(Sm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm break-all",children:pe.content})]}),pe.meaning&&e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:pe.meaning}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[Je(pe.is_jargon),e.jsxs("span",{className:"text-muted-foreground",children:["次数: ",pe.count]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["聊天: ",pe.chat_name||pe.chat_id]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>we(pe),className:"text-xs px-2 py-1 h-auto",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>I(pe),className:"text-xs px-2 py-1 h-auto",children:e.jsx(Yt,{className:"h-3 w-3"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>H(pe),className:"text-xs px-2 py-1 h-auto text-destructive hover:text-destructive",children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},pe.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(el,{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:ge,onChange:pe=>je(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&Ie(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(C,{variant:"outline",size:"sm",onClick:Ie,disabled:!ge,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(c4,{jargon:M,open:$,onOpenChange:E}),e.jsx(o4,{open:P,onOpenChange:A,chatList:J,onSuccess:()=>{Ce(),be(),A(!1)}}),e.jsx(d4,{jargon:M,open:_,onOpenChange:T,chatList:J,onSuccess:()=>{Ce(),be(),T(!1)}}),e.jsx(js,{open:!!ee,onOpenChange:()=>H(null),children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除黑话 "',ee?.content,'" 吗?此操作不可撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>ee&&q(ee),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(js,{open:ye,onOpenChange:de,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["您即将删除 ",Z.size," 个黑话,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})]})}function c4({jargon:l,open:n,onOpenChange:i}){return l?e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"黑话详情"}),e.jsx(Ws,{children:"查看黑话的完整信息"})]}),e.jsx(Xe,{className:"h-full pr-4",children:e.jsxs("div",{className:"space-y-4 pb-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ym,{icon:Tr,label:"记录ID",value:l.id.toString(),mono:!0}),e.jsx(ym,{label:"使用次数",value:l.count.toString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all whitespace-pre-wrap",children:l.content})]}),l.raw_content&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"原始内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:(()=>{try{const c=JSON.parse(l.raw_content);return Array.isArray(c)?c.map((u,m)=>e.jsxs("div",{children:[m>0&&e.jsx("hr",{className:"my-3 border-border"}),e.jsx("div",{className:"whitespace-pre-wrap",children:u})]},m)):e.jsx("div",{className:"whitespace-pre-wrap",children:l.raw_content})}catch{return e.jsx("div",{className:"whitespace-pre-wrap",children:l.raw_content})}})()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"含义"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:l.meaning?e.jsx(cv,{content:l.meaning}):"-"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ym,{label:"聊天",value:l.chat_name||l.chat_id}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"flex items-center gap-2",children:[l.is_jargon===!0&&e.jsx(Ae,{variant:"default",className:"bg-green-600",children:"是黑话"}),l.is_jargon===!1&&e.jsx(Ae,{variant:"secondary",children:"非黑话"}),l.is_jargon===null&&e.jsx(Ae,{variant:"outline",children:"未判定"}),l.is_global&&e.jsx(Ae,{variant:"outline",className:"border-blue-500 text-blue-500",children:"全局"}),l.is_complete&&e.jsx(Ae,{variant:"outline",className:"border-purple-500 text-purple-500",children:"推断完成"})]})]})]}),l.inference_with_context&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"上下文推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:l.inference_with_context})]}),l.inference_content_only&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"纯词条推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:l.inference_content_only})]})]})}),e.jsx(nt,{className:"flex-shrink-0",children:e.jsx(C,{onClick:()=>i(!1),children:"关闭"})})]})}):null}function ym({icon:l,label:n,value:i,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:L("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function o4({open:l,onOpenChange:n,chatList:i,onSuccess:c}){const[u,m]=x.useState({content:"",meaning:"",chat_id:"",is_global:!1}),[h,f]=x.useState(!1),{toast:p}=et(),j=async()=>{if(!u.content||!u.chat_id){p({title:"验证失败",description:"请填写必填字段:内容和聊天",variant:"destructive"});return}try{f(!0),await s4(u),p({title:"创建成功",description:"黑话已创建"}),m({content:"",meaning:"",chat_id:"",is_global:!1}),c()}catch(v){p({title:"创建失败",description:v instanceof Error?v.message:"无法创建黑话",variant:"destructive"})}finally{f(!1)}};return e.jsx(Hs,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"新增黑话"}),e.jsx(Ws,{children:"创建新的黑话记录"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"content",children:["内容 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ce,{id:"content",value:u.content,onChange:v=>m({...u,content:v.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"meaning",children:"含义"}),e.jsx(Ys,{id:"meaning",value:u.meaning||"",onChange:v=>m({...u,meaning:v.target.value}),placeholder:"输入黑话含义(可选)",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs($e,{value:u.chat_id,onValueChange:v=>m({...u,chat_id:v}),children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择关联的聊天"})}),e.jsx(Ue,{children:i.map(v=>e.jsx(le,{value:v.chat_id,children:v.chat_name},v.chat_id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"is_global",checked:u.is_global,onCheckedChange:v=>m({...u,is_global:v})}),e.jsx(k,{htmlFor:"is_global",children:"设为全局黑话"})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsx(C,{onClick:j,disabled:h,children:h?"创建中...":"创建"})]})]})})}function d4({jargon:l,open:n,onOpenChange:i,chatList:c,onSuccess:u}){const[m,h]=x.useState({}),[f,p]=x.useState(!1),{toast:j}=et();x.useEffect(()=>{l&&h({content:l.content,meaning:l.meaning||"",chat_id:l.stream_id||l.chat_id,is_global:l.is_global,is_jargon:l.is_jargon})},[l]);const v=async()=>{if(l)try{p(!0),await t4(l.id,m),j({title:"保存成功",description:"黑话已更新"}),u()}catch(N){j({title:"保存失败",description:N instanceof Error?N.message:"无法更新黑话",variant:"destructive"})}finally{p(!1)}};return l?e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"编辑黑话"}),e.jsx(Ws,{children:"修改黑话的信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit_content",children:"内容"}),e.jsx(ce,{id:"edit_content",value:m.content||"",onChange:N=>h({...m,content:N.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit_meaning",children:"含义"}),e.jsx(Ys,{id:"edit_meaning",value:m.meaning||"",onChange:N=>h({...m,meaning:N.target.value}),placeholder:"输入黑话含义",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs($e,{value:m.chat_id||"",onValueChange:N=>h({...m,chat_id:N}),children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择关联的聊天"})}),e.jsx(Ue,{children:c.map(N=>e.jsx(le,{value:N.chat_id,children:N.chat_name},N.chat_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"黑话状态"}),e.jsxs($e,{value:m.is_jargon===null?"null":m.is_jargon?.toString()||"null",onValueChange:N=>h({...m,is_jargon:N==="null"?null:N==="true"}),children:[e.jsx(Le,{children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"null",children:"未判定"}),e.jsx(le,{value:"true",children:"是黑话"}),e.jsx(le,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fe,{id:"edit_is_global",checked:m.is_global,onCheckedChange:N=>h({...m,is_global:N})}),e.jsx(k,{htmlFor:"edit_is_global",children:"全局黑话"})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(C,{onClick:v,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}const Rr="/api/webui/person";async function u4(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.is_known!==void 0&&n.append("is_known",l.is_known.toString()),l.platform&&n.append("platform",l.platform);const i=await Se(`${Rr}/list?${n}`,{headers:Zs()});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取人物列表失败")}return i.json()}async function m4(l){const n=await Se(`${Rr}/${l}`,{headers:Zs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取人物详情失败")}return n.json()}async function x4(l,n){const i=await Se(`${Rr}/${l}`,{method:"PATCH",headers:Zs(),body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新人物信息失败")}return i.json()}async function h4(l){const n=await Se(`${Rr}/${l}`,{method:"DELETE",headers:Zs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除人物信息失败")}return n.json()}async function f4(){const l=await Se(`${Rr}/stats/summary`,{headers:Zs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取统计数据失败")}return l.json()}async function p4(l){const n=await Se(`${Rr}/batch/delete`,{method:"POST",headers:Zs(),body:JSON.stringify({person_ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除失败")}return n.json()}function g4(){const[l,n]=x.useState([]),[i,c]=x.useState(!0),[u,m]=x.useState(0),[h,f]=x.useState(1),[p,j]=x.useState(20),[v,N]=x.useState(""),[b,S]=x.useState(void 0),[w,O]=x.useState(void 0),[M,D]=x.useState(null),[$,E]=x.useState(!1),[_,T]=x.useState(!1),[P,A]=x.useState(null),[ee,H]=x.useState({total:0,known:0,unknown:0,platforms:{}}),[Z,re]=x.useState(new Set),[ye,de]=x.useState(!1),[ge,je]=x.useState(""),{toast:z}=et(),Q=async()=>{try{c(!0);const X=await u4({page:h,page_size:p,search:v||void 0,is_known:b,platform:w});n(X.data),m(X.total)}catch(X){z({title:"加载失败",description:X instanceof Error?X.message:"无法加载人物信息",variant:"destructive"})}finally{c(!1)}},J=async()=>{try{const X=await f4();X?.data&&H(X.data)}catch(X){console.error("加载统计数据失败:",X)}};x.useEffect(()=>{Q(),J()},[h,p,v,b,w]);const U=async X=>{try{const ne=await m4(X.person_id);D(ne.data),E(!0)}catch(ne){z({title:"加载详情失败",description:ne instanceof Error?ne.message:"无法加载人物详情",variant:"destructive"})}},G=X=>{D(X),T(!0)},Ce=async X=>{try{await h4(X.person_id),z({title:"删除成功",description:`已删除人物信息: ${X.person_name||X.nickname||X.user_id}`}),A(null),Q(),J()}catch(ne){z({title:"删除失败",description:ne instanceof Error?ne.message:"无法删除人物信息",variant:"destructive"})}},be=x.useMemo(()=>Object.keys(ee.platforms),[ee.platforms]),ke=X=>{const ne=new Set(Z);ne.has(X)?ne.delete(X):ne.add(X),re(ne)},I=()=>{Z.size===l.length&&l.length>0?re(new Set):re(new Set(l.map(X=>X.person_id)))},we=()=>{if(Z.size===0){z({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}de(!0)},q=async()=>{try{const X=await p4(Array.from(Z));z({title:"批量删除完成",description:X.message}),re(new Set),de(!1),Q(),J()}catch(X){z({title:"批量删除失败",description:X instanceof Error?X.message:"批量删除失败",variant:"destructive"})}},oe=()=>{const X=parseInt(ge),ne=Math.ceil(u/p);X>=1&&X<=ne?(f(X),je("")):z({title:"无效的页码",description:`请输入1-${ne}之间的页码`,variant:"destructive"})},Te=X=>X?new Date(X*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(Cm,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(Xe,{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:ee.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:ee.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:ee.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(k,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(Vt,{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:X=>N(X.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs($e,{value:b===void 0?"all":b.toString(),onValueChange:X=>{S(X==="all"?void 0:X==="true"),f(1)},children:[e.jsx(Le,{id:"filter-known",className:"mt-1.5",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"true",children:"已认识"}),e.jsx(le,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"filter-platform",children:"平台"}),e.jsxs($e,{value:w||"all",onValueChange:X=>{O(X==="all"?void 0:X),f(1)},children:[e.jsx(Le,{id:"filter-platform",className:"mt-1.5",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部平台"}),be.map(X=>e.jsxs(le,{value:X,children:[X," (",ee.platforms[X],")"]},X))]})]})]})]}),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:Z.size>0&&e.jsxs("span",{children:["已选择 ",Z.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs($e,{value:p.toString(),onValueChange:X=>{j(parseInt(X)),f(1),re(new Set)},children:[e.jsx(Le,{id:"page-size",className:"w-20",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),Z.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>re(new Set),children:"取消选择"}),e.jsxs(C,{variant:"destructive",size:"sm",onClick:we,children:[e.jsx(rs,{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(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{className:"w-12",children:e.jsx(Js,{checked:l.length>0&&Z.size===l.length,onCheckedChange:I,"aria-label":"全选"})}),e.jsx(Ye,{children:"状态"}),e.jsx(Ye,{children:"名称"}),e.jsx(Ye,{children:"昵称"}),e.jsx(Ye,{children:"平台"}),e.jsx(Ye,{children:"用户ID"}),e.jsx(Ye,{children:"最后更新"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:i?e.jsx(lt,{children:e.jsx(Ge,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(lt,{children:e.jsx(Ge,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(X=>e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Js,{checked:Z.has(X.person_id),onCheckedChange:()=>ke(X.person_id),"aria-label":`选择 ${X.person_name||X.nickname||X.user_id}`})}),e.jsx(Ge,{children:e.jsx("div",{className:L("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",X.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:X.is_known?"已认识":"未认识"})}),e.jsx(Ge,{className:"font-medium",children:X.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ge,{children:X.nickname||"-"}),e.jsx(Ge,{children:X.platform}),e.jsx(Ge,{className:"font-mono text-sm",children:X.user_id}),e.jsx(Ge,{className:"text-sm text-muted-foreground",children:Te(X.last_know)}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(C,{variant:"default",size:"sm",onClick:()=>U(X),children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(C,{variant:"default",size:"sm",onClick:()=>G(X),children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(C,{size:"sm",onClick:()=>A(X),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},X.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(X=>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(Js,{checked:Z.has(X.person_id),onCheckedChange:()=>ke(X.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:L("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",X.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:X.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:X.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),X.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",X.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:X.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:X.user_id,children:X.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:Te(X.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>U(X),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Yt,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>G(X),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>A(X),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},X.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(el,{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:ge,onChange:X=>je(X.target.value),onKeyDown:X=>X.key==="Enter"&&oe(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(C,{variant:"outline",size:"sm",onClick:oe,disabled:!ge,className:"h-8",children:"跳转"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(wa,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(zr,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(j4,{person:M,open:$,onOpenChange:E}),e.jsx(v4,{person:M,open:_,onOpenChange:T,onSuccess:()=>{Q(),J(),T(!1)}}),e.jsx(js,{open:!!P,onOpenChange:()=>A(null),children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认删除"}),e.jsxs(hs,{children:['确定要删除人物信息 "',P?.person_name||P?.nickname||P?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:()=>P&&Ce(P),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(js,{open:ye,onOpenChange:de,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"确认批量删除"}),e.jsxs(hs,{children:["确定要删除选中的 ",Z.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{children:"取消"}),e.jsx(fs,{onClick:q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function j4({person:l,open:n,onOpenChange:i}){if(!l)return null;const c=u=>u?new Date(u*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"人物详情"}),e.jsxs(Ws,{children:["查看 ",l.person_name||l.nickname||l.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(vl,{icon:Cr,label:"人物名称",value:l.person_name}),e.jsx(vl,{icon:en,label:"昵称",value:l.nickname}),e.jsx(vl,{icon:Tr,label:"用户ID",value:l.user_id,mono:!0}),e.jsx(vl,{icon:Tr,label:"人物ID",value:l.person_id,mono:!0}),e.jsx(vl,{label:"平台",value:l.platform}),e.jsx(vl,{label:"状态",value:l.is_known?"已认识":"未认识"})]}),l.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:l.name_reason})]}),l.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:l.memory_points})]}),l.group_nick_name&&l.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(k,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:l.group_nick_name.map((u,m)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:u.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:u.group_nick_name})]},m))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(vl,{icon:bl,label:"认识时间",value:c(l.know_times)}),e.jsx(vl,{icon:bl,label:"首次记录",value:c(l.know_since)}),e.jsx(vl,{icon:bl,label:"最后更新",value:c(l.last_know)})]})]}),e.jsx(nt,{children:e.jsx(C,{onClick:()=>i(!1),children:"关闭"})})]})})}function vl({icon:l,label:n,value:i,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:L("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function v4({person:l,open:n,onOpenChange:i,onSuccess:c}){const[u,m]=x.useState({}),[h,f]=x.useState(!1),{toast:p}=et();x.useEffect(()=>{l&&m({person_name:l.person_name||"",name_reason:l.name_reason||"",nickname:l.nickname||"",memory_points:l.memory_points||"",is_known:l.is_known})},[l]);const j=async()=>{if(l)try{f(!0),await x4(l.person_id,u),p({title:"保存成功",description:"人物信息已更新"}),c()}catch(v){p({title:"保存失败",description:v instanceof Error?v.message:"无法更新人物信息",variant:"destructive"})}finally{f(!1)}};return l?e.jsx(Hs,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"编辑人物信息"}),e.jsxs(Ws,{children:["修改 ",l.person_name||l.nickname||l.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(k,{htmlFor:"person_name",children:"人物名称"}),e.jsx(ce,{id:"person_name",value:u.person_name||"",onChange:v=>m({...u,person_name:v.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"nickname",children:"昵称"}),e.jsx(ce,{id:"nickname",value:u.nickname||"",onChange:v=>m({...u,nickname:v.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(Ys,{id:"name_reason",value:u.name_reason||"",onChange:v=>m({...u,name_reason:v.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"memory_points",children:"个人印象"}),e.jsx(Ys,{id:"memory_points",value:u.memory_points||"",onChange:v=>m({...u,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(k,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(Fe,{id:"is_known",checked:u.is_known,onCheckedChange:v=>m({...u,is_known:v})})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(C,{onClick:j,disabled:h,children:h?"保存中...":"保存"})]})]})}):null}var N4=d1();const hg=Zy(N4),Vm="/api/webui";async function b4(l=100,n="all"){const i=`${Vm}/knowledge/graph?limit=${l}&node_type=${n}`,c=await fetch(i);if(!c.ok)throw new Error(`获取知识图谱失败: ${c.status}`);return c.json()}async function y4(){const l=await fetch(`${Vm}/knowledge/stats`);if(!l.ok)throw new Error("获取知识图谱统计信息失败");return l.json()}async function w4(l){const n=await fetch(`${Vm}/knowledge/search?query=${encodeURIComponent(l)}`);if(!n.ok)throw new Error("搜索知识节点失败");return n.json()}const ov=x.memo(({data:l})=>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(ko,{type:"target",position:To.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:l.content,children:l.label}),e.jsx(ko,{type:"source",position:To.Bottom})]}));ov.displayName="EntityNode";const dv=x.memo(({data:l})=>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(ko,{type:"target",position:To.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:l.content,children:l.label}),e.jsx(ko,{type:"source",position:To.Bottom})]}));dv.displayName="ParagraphNode";const _4={entity:ov,paragraph:dv};function S4(l,n){const i=new hg.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const c=[],u=[];return l.forEach(m=>{i.setNode(m.id,{width:150,height:50})}),n.forEach(m=>{i.setEdge(m.source,m.target)}),hg.layout(i),l.forEach(m=>{const h=i.node(m.id);c.push({id:m.id,type:m.type,position:{x:h.x-75,y:h.y-25},data:{label:m.content.slice(0,20)+(m.content.length>20?"...":""),content:m.content}})}),n.forEach((m,h)=>{const f={id:`edge-${h}`,source:m.source,target:m.target,animated:l.length<=200&&m.weight>5,style:{strokeWidth:Math.min(m.weight/2,5),opacity:.6}};m.weight>10&&l.length<100&&(f.label=`${m.weight.toFixed(0)}`),u.push(f)}),{nodes:c,edges:u}}function C4(){const l=xa(),[n,i]=x.useState(!1),[c,u]=x.useState(null),[m,h]=x.useState(""),[f,p]=x.useState("all"),[j,v]=x.useState(50),[N,b]=x.useState("50"),[S,w]=x.useState(!1),[O,M]=x.useState(!0),[D,$]=x.useState(!1),[E,_]=x.useState(!1),[T,P,A]=u1([]),[ee,H,Z]=m1([]),[re,ye]=x.useState(0),[de,ge]=x.useState(null),[je,z]=x.useState(null),{toast:Q}=et(),J=x.useCallback(q=>q.type==="entity"?"#6366f1":q.type==="paragraph"?"#10b981":"#6b7280",[]),U=x.useCallback(async(q=!1)=>{try{if(!q&&j>200){_(!0);return}i(!0);const[oe,Te]=await Promise.all([b4(j,f),y4()]);if(u(Te),oe.nodes.length===0){Q({title:"提示",description:"知识库为空,请先导入知识数据"}),P([]),H([]);return}const{nodes:X,edges:ne}=S4(oe.nodes,oe.edges);P(X),H(ne),ye(X.length),Te&&Te.total_nodes>j&&Q({title:"提示",description:`知识图谱包含 ${Te.total_nodes} 个节点,当前显示 ${X.length}`}),Q({title:"加载成功",description:`已加载 ${X.length} 个节点,${ne.length} 条边`})}catch(oe){console.error("加载知识图谱失败:",oe),Q({title:"加载失败",description:oe instanceof Error?oe.message:"未知错误",variant:"destructive"})}finally{i(!1)}},[j,f,Q]),G=x.useCallback(async()=>{if(!m.trim()){Q({title:"提示",description:"请输入搜索关键词"});return}try{const q=await w4(m);if(q.length===0){Q({title:"未找到",description:"没有找到匹配的节点"});return}const oe=new Set(q.map(Te=>Te.id));P(Te=>Te.map(X=>({...X,style:{...X.style,opacity:oe.has(X.id)?1:.3,filter:oe.has(X.id)?"brightness(1.2)":"brightness(0.8)"}}))),Q({title:"搜索完成",description:`找到 ${q.length} 个匹配节点`})}catch(q){console.error("搜索失败:",q),Q({title:"搜索失败",description:q instanceof Error?q.message:"未知错误",variant:"destructive"})}},[m,Q]),Ce=x.useCallback(()=>{P(q=>q.map(oe=>({...oe,style:{...oe.style,opacity:1,filter:"brightness(1)"}})))},[]),be=x.useCallback(()=>{M(!1),$(!0),U()},[U]),ke=x.useCallback(()=>{_(!1),setTimeout(()=>{U(!0)},0)},[U]),I=x.useCallback((q,oe)=>{T.find(X=>X.id===oe.id)&&ge({id:oe.id,type:oe.type,content:oe.data.content})},[T]);x.useEffect(()=>{O||D&&U()},[j,f,O,D]);const we=x.useCallback((q,oe)=>{const Te=T.find(Ie=>Ie.id===oe.source),X=T.find(Ie=>Ie.id===oe.target),ne=ee.find(Ie=>Ie.id===oe.id);Te&&X&&ne&&z({source:{id:Te.id,type:Te.type,content:Te.data.content},target:{id:X.id,type:X.type,content:X.data.content},edge:{source:oe.source,target:oe.target,weight:parseFloat(oe.label||"0")}})},[T,ee]);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:"可视化知识实体与关系网络"})]}),c&&e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Ae,{variant:"outline",className:"gap-1",children:[e.jsx(wo,{className:"h-3 w-3"}),"节点: ",c.total_nodes]}),e.jsxs(Ae,{variant:"outline",className:"gap-1",children:[e.jsx(gj,{className:"h-3 w-3"}),"边: ",c.total_edges]}),e.jsxs(Ae,{variant:"outline",className:"gap-1",children:[e.jsx(Qt,{className:"h-3 w-3"}),"实体: ",c.entity_nodes]}),e.jsxs(Ae,{variant:"outline",className:"gap-1",children:[e.jsx(Ga,{className:"h-3 w-3"}),"段落: ",c.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:m,onChange:q=>h(q.target.value),onKeyDown:q=>q.key==="Enter"&&G(),className:"flex-1"}),e.jsx(C,{onClick:G,size:"sm",children:e.jsx(Vt,{className:"h-4 w-4"})}),e.jsx(C,{onClick:Ce,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($e,{value:f,onValueChange:q=>p(q),children:[e.jsx(Le,{className:"w-[120px]",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部节点"}),e.jsx(le,{value:"entity",children:"仅实体"}),e.jsx(le,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs($e,{value:j===1e4?"all":S?"custom":j.toString(),onValueChange:q=>{q==="custom"?(w(!0),b(j.toString())):q==="all"?(w(!1),v(1e4)):(w(!1),v(Number(q)))},children:[e.jsx(Le,{className:"w-[120px]",children:e.jsx(He,{})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"50",children:"50 节点"}),e.jsx(le,{value:"100",children:"100 节点"}),e.jsx(le,{value:"200",children:"200 节点"}),e.jsx(le,{value:"500",children:"500 节点"}),e.jsx(le,{value:"1000",children:"1000 节点"}),e.jsx(le,{value:"all",children:"全部 (最多10000)"}),e.jsx(le,{value:"custom",children:"自定义..."})]})]}),S&&e.jsx(ce,{type:"number",min:"50",value:N,onChange:q=>b(q.target.value),onBlur:()=>{const q=parseInt(N);!isNaN(q)&&q>=50?v(q):(b("50"),v(50))},onKeyDown:q=>{if(q.key==="Enter"){const oe=parseInt(N);!isNaN(oe)&&oe>=50?v(oe):(b("50"),v(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(C,{onClick:()=>U(),variant:"outline",size:"sm",disabled:n,children:e.jsx(At,{className:L("h-4 w-4",n&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:n?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(At,{className:"h-8 w-8 animate-spin mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"加载知识图谱中..."})]})}):T.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(wo,{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(x1,{nodes:T,edges:ee,onNodesChange:A,onEdgesChange:Z,onNodeClick:I,onEdgeClick:we,nodeTypes:_4,fitView:!0,minZoom:.05,maxZoom:1.5,defaultViewport:{x:0,y:0,zoom:.5},elevateNodesOnSelect:re<=500,nodesDraggable:re<=1e3,attributionPosition:"bottom-left",children:[e.jsx(h1,{variant:f1.Dots,gap:12,size:1}),e.jsx(p1,{}),re<=500&&e.jsx(g1,{nodeColor:J,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(j1,{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:"段落节点"})]}),re>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:"已禁用动画"}),re>500&&e.jsx("div",{children:"已禁用缩略图"})]})]})]})]})}),e.jsx(Hs,{open:!!de,onOpenChange:q=>!q&&ge(null),children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(Rs,{children:e.jsx(Ls,{children:"节点详情"})}),de&&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(Ae,{variant:de.type==="entity"?"default":"secondary",children:de.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:de.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(Xe,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:de.content})})]})]})]})}),e.jsx(Hs,{open:!!je,onOpenChange:q=>!q&&z(null),children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Rs,{children:e.jsx(Ls,{children:"边详情"})}),je&&e.jsx(Xe,{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:je.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[je.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:je.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[je.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(Ae,{variant:"outline",className:"text-base font-mono",children:je.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(js,{open:O,onOpenChange:M,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"加载知识图谱"}),e.jsxs(hs,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(ms,{children:[e.jsx(ps,{onClick:()=>l({to:"/"}),children:"取消 (返回首页)"}),e.jsx(fs,{onClick:be,children:"确认加载"})]})]})}),e.jsx(js,{open:E,onOpenChange:_,children:e.jsxs(ds,{children:[e.jsxs(us,{children:[e.jsx(xs,{children:"⚠️ 节点数量较多"}),e.jsx(hs,{asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["您正在尝试加载 ",e.jsx("strong",{className:"text-orange-600",children:j>=1e4?"全部 (最多10000个)":j})," 个节点。"]}),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(ms,{children:[e.jsx(ps,{onClick:()=>{_(!1),j>200&&(v(50),w(!1))},children:"取消"}),e.jsx(fs,{onClick:ke,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function fg({className:l,classNames:n,showOutsideDays:i=!0,captionLayout:c="label",buttonVariant:u="ghost",formatters:m,components:h,...f}){const p=Oj();return e.jsx(a1,{showOutsideDays:i,className:L("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`,l),captionLayout:c,formatters:{formatMonthDropdown:j=>j.toLocaleString("default",{month:"short"}),...m},classNames:{root:L("w-fit",p.root),months:L("relative flex flex-col gap-4 md:flex-row",p.months),month:L("flex w-full flex-col gap-4",p.month),nav:L("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",p.nav),button_previous:L(Er({variant:u}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_previous),button_next:L(Er({variant:u}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_next),month_caption:L("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",p.month_caption),dropdowns:L("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",p.dropdowns),dropdown_root:L("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:L("bg-popover absolute inset-0 opacity-0",p.dropdown),caption_label:L("select-none font-medium",c==="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:L("flex",p.weekdays),weekday:L("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",p.weekday),week:L("mt-2 flex w-full",p.week),week_number_header:L("w-[--cell-size] select-none",p.week_number_header),week_number:L("text-muted-foreground select-none text-[0.8rem]",p.week_number),day:L("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:L("bg-accent rounded-l-md",p.range_start),range_middle:L("rounded-none",p.range_middle),range_end:L("bg-accent rounded-r-md",p.range_end),today:L("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",p.today),outside:L("text-muted-foreground aria-selected:text-muted-foreground",p.outside),disabled:L("text-muted-foreground opacity-50",p.disabled),hidden:L("invisible",p.hidden),...n},components:{Root:({className:j,rootRef:v,...N})=>e.jsx("div",{"data-slot":"calendar",ref:v,className:L(j),...N}),Chevron:({className:j,orientation:v,...N})=>v==="left"?e.jsx(el,{className:L("size-4",j),...N}):v==="right"?e.jsx(wa,{className:L("size-4",j),...N}):e.jsx(Ra,{className:L("size-4",j),...N}),DayButton:k4,WeekNumber:({children:j,...v})=>e.jsx("td",{...v,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:j})}),...h},...f})}function k4({className:l,day:n,modifiers:i,...c}){const u=Oj(),m=x.useRef(null);return x.useEffect(()=>{i.focused&&m.current?.focus()},[i.focused]),e.jsx(C,{ref:m,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":i.selected&&!i.range_start&&!i.range_end&&!i.range_middle,"data-range-start":i.range_start,"data-range-end":i.range_end,"data-range-middle":i.range_middle,className:L("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",u.day,l),...c})}const fo={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 T4(){const[l,n]=x.useState([]),[i,c]=x.useState(""),[u,m]=x.useState("all"),[h,f]=x.useState("all"),[p,j]=x.useState(void 0),[v,N]=x.useState(void 0),[b,S]=x.useState(!0),[w,O]=x.useState(!1),[M,D]=x.useState("xs"),[$,E]=x.useState(4),[_,T]=x.useState(!1),P=x.useRef(null);x.useEffect(()=>{const G=_n.getAllLogs();n(G);const Ce=_n.onLog(()=>{n(_n.getAllLogs())}),be=_n.onConnectionChange(ke=>{O(ke)});return()=>{Ce(),be()}},[]);const A=x.useMemo(()=>{const G=new Set(l.map(Ce=>Ce.module).filter(Ce=>Ce&&Ce.trim()!==""));return Array.from(G).sort()},[l]),ee=G=>{switch(G){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"}},H=G=>{switch(G){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"}},Z=()=>{window.location.reload()},re=()=>{_n.clearLogs(),n([])},ye=()=>{const G=je.map(I=>`${I.timestamp} [${I.level.padEnd(8)}] [${I.module}] ${I.message}`).join(`
`),Ce=new Blob([G],{type:"text/plain;charset=utf-8"}),be=URL.createObjectURL(Ce),ke=document.createElement("a");ke.href=be,ke.download=`logs-${lm(new Date,"yyyy-MM-dd-HHmmss")}.txt`,ke.click(),URL.revokeObjectURL(be)},de=()=>{S(!b)},ge=()=>{j(void 0),N(void 0)},je=x.useMemo(()=>l.filter(G=>{const Ce=i===""||G.message.toLowerCase().includes(i.toLowerCase())||G.module.toLowerCase().includes(i.toLowerCase()),be=u==="all"||G.level===u,ke=h==="all"||G.module===h;let I=!0;if(p||v){const we=new Date(G.timestamp);if(p){const q=new Date(p);q.setHours(0,0,0,0),I=I&&we>=q}if(v){const q=new Date(v);q.setHours(23,59,59,999),I=I&&we<=q}}return Ce&&be&&ke&&I}),[l,i,u,h,p,v]),z=fo[M].rowHeight+$,Q=qy({count:je.length,getScrollElement:()=>P.current,estimateSize:()=>z,overscan:50}),J=x.useRef(!1),U=x.useRef(je.length);return x.useEffect(()=>{const G=P.current;if(!G)return;const Ce=()=>{if(J.current)return;const{scrollTop:be,scrollHeight:ke,clientHeight:I}=G,we=ke-be-I;we>100&&b?S(!1):we<50&&!b&&S(!0)};return G.addEventListener("scroll",Ce,{passive:!0}),()=>G.removeEventListener("scroll",Ce)},[b]),x.useEffect(()=>{const G=je.length>U.current;U.current=je.length,b&&je.length>0&&G&&(J.current=!0,Q.scrollToIndex(je.length-1,{align:"end",behavior:"auto"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{J.current=!1})}))},[je.length,b,Q]),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 space-y-2 sm:space-y-3 p-2 sm:p-3 lg:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg sm:text-xl lg:text-2xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 hidden sm:block",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:L("h-2 w-2 sm:h-2.5 sm:w-2.5 rounded-full",w?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w?"已连接":"未连接"})]})]}),e.jsx(Oe,{className:"p-2 sm:p-3",children:e.jsx(Pi,{open:_,onOpenChange:T,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative min-w-0",children:[e.jsx(Vt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索日志...",value:i,onChange:G=>c(G.target.value),className:"pl-8 h-8 text-xs sm:text-sm"})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(C,{variant:b?"default":"outline",size:"sm",onClick:de,className:"h-8 px-2",title:b?"自动滚动":"已暂停",children:[b?e.jsx(Ow,{className:"h-3.5 w-3.5"}):e.jsx(Rw,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden sm:inline",children:b?"滚动":"暂停"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:re,className:"h-8 px-2",title:"清空日志",children:[e.jsx(rs,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden md:inline",children:"清空"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:ye,className:"h-8 px-2 hidden sm:flex",title:"导出日志",children:[e.jsx(Kt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden lg:inline",children:"导出"})]}),e.jsx(Ii,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:"h-8 px-2",title:_?"收起筛选":"展开筛选",children:[e.jsx(vo,{className:"h-3.5 w-3.5"}),_?e.jsx(kr,{className:"h-3.5 w-3.5 ml-1"}):e.jsx(Ra,{className:"h-3.5 w-3.5 ml-1"})]})})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center sm:text-right -mt-1",children:[e.jsxs("span",{className:"font-mono",children:[je.length," / ",l.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]}),e.jsxs(qi,{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs($e,{value:u,onValueChange:m,children:[e.jsxs(Le,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(vo,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(He,{placeholder:"级别"})]}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部级别"}),e.jsx(le,{value:"DEBUG",children:"DEBUG"}),e.jsx(le,{value:"INFO",children:"INFO"}),e.jsx(le,{value:"WARNING",children:"WARNING"}),e.jsx(le,{value:"ERROR",children:"ERROR"}),e.jsx(le,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs($e,{value:h,onValueChange:f,children:[e.jsxs(Le,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(vo,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(He,{placeholder:"模块"})]}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部模块"}),A.map(G=>e.jsx(le,{value:G,children:G},G))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:L("w-full sm:flex-1 justify-start text-left font-normal h-8",!p&&"text-muted-foreground"),children:[e.jsx(qp,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:p?lm(p,"PP",{locale:xo}):"开始日期"})]})}),e.jsx(Pa,{className:"w-auto p-0",align:"start",children:e.jsx(fg,{mode:"single",selected:p,onSelect:j,initialFocus:!0,locale:xo})})]}),e.jsxs(Za,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:L("w-full sm:flex-1 justify-start text-left font-normal h-8",!v&&"text-muted-foreground"),children:[e.jsx(qp,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:v?lm(v,"PP",{locale:xo}):"结束日期"})]})}),e.jsx(Pa,{className:"w-auto p-0",align:"start",children:e.jsx(fg,{mode:"single",selected:v,onSelect:N,initialFocus:!0,locale:xo})})]}),(p||v)&&e.jsxs(C,{variant:"outline",size:"sm",onClick:ge,className:"w-full sm:w-auto h-8",children:[e.jsx(Ja,{className:"h-3.5 w-3.5 sm:mr-1"}),e.jsx("span",{className:"text-xs",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Lw,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys(fo).map(G=>e.jsx(C,{variant:M===G?"default":"outline",size:"sm",onClick:()=>D(G),className:"h-6 px-2 text-xs",children:fo[G].label},G))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-[200px]",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"行距"}),e.jsx(ya,{value:[$],onValueChange:([G])=>E(G),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-7",children:[$,"px"]})]}),e.jsxs("div",{className:"flex gap-2 sm:hidden",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:Z,className:"flex-1 h-8",children:[e.jsx(At,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"刷新"})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:ye,className:"flex-1 h-8",children:[e.jsx(Kt,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"导出"})]})]})]})]})]})})})]}),e.jsx("div",{className:"flex-1 min-h-0 px-2 sm:px-3 lg:px-4 pb-2 sm:pb-3 lg:pb-4",children:e.jsx(Oe,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900 h-full overflow-hidden",children:e.jsx("div",{ref:P,className:L("h-full overflow-auto","[&::-webkit-scrollbar]:w-2.5","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb:hover]:bg-border/80"),children:e.jsx("div",{className:L("p-2 sm:p-3 font-mono relative",fo[M].class),style:{height:`${Q.getTotalSize()}px`},children:je.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-xs sm:text-sm",children:"暂无日志数据"}):Q.getVirtualItems().map(G=>{const Ce=je[G.index];return e.jsxs("div",{"data-index":G.index,ref:Q.measureElement,className:L("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors",H(Ce.level)),style:{transform:`translateY(${G.start}px)`,paddingTop:`${$/2}px`,paddingBottom:`${$/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 text-[10px]",children:Ce.timestamp}),e.jsxs("span",{className:L("font-semibold text-[10px]",ee(Ce.level)),children:["[",Ce.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate text-[10px]",children:Ce.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words text-[10px]",children:Ce.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:Ce.timestamp}),e.jsxs("span",{className:L("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",ee(Ce.level)),children:["[",Ce.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:Ce.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:Ce.message})]})]},G.key)})})})})})]})}const E4="Mai-with-u",M4="plugin-repo",A4="main",z4="plugin_details.json";async function D4(){try{const l=await Se("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:E4,repo:M4,branch:A4,file_path:z4})});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const n=await l.json();if(!n.success||!n.data)throw new Error(n.error||"获取插件列表失败");return JSON.parse(n.data).filter(u=>!u?.id||!u?.manifest?(console.warn("跳过无效插件数据:",u),!1):!u.manifest.name||!u.manifest.version?(console.warn("跳过缺少必需字段的插件:",u.id),!1):!0).map(u=>({id:u.id,manifest:{manifest_version:u.manifest.manifest_version||1,name:u.manifest.name,version:u.manifest.version,description:u.manifest.description||"",author:u.manifest.author||{name:"Unknown"},license:u.manifest.license||"Unknown",host_application:u.manifest.host_application||{min_version:"0.0.0"},homepage_url:u.manifest.homepage_url,repository_url:u.manifest.repository_url,keywords:u.manifest.keywords||[],categories:u.manifest.categories||[],default_locale:u.manifest.default_locale||"zh-CN",locales_path:u.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(l){throw console.error("Failed to fetch plugin list:",l),l}}async function O4(){try{const l=await Se("/api/webui/plugins/git-status");if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return await l.json()}catch(l){return console.error("Failed to check Git status:",l),{installed:!1,error:"无法检测 Git 安装状态"}}}async function R4(){try{const l=await Se("/api/webui/plugins/version");if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return await l.json()}catch(l){return console.error("Failed to get Maimai version:",l),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function L4(l,n,i){const c=l.split(".").map(f=>parseInt(f)||0),u=c[0]||0,m=c[1]||0,h=c[2]||0;if(i.version_major<u||i.version_major===u&&i.version_minor<m||i.version_major===u&&i.version_minor===m&&i.version_patch<h)return!1;if(n){const f=n.split(".").map(N=>parseInt(N)||0),p=f[0]||0,j=f[1]||0,v=f[2]||0;if(i.version_major>p||i.version_major===p&&i.version_minor>j||i.version_major===p&&i.version_minor===j&&i.version_patch>v)return!1}return!0}async function U4(){try{const l=await Se("/api/webui/ws-token");if(!l.ok)return console.error("获取 WebSocket token 失败:",l.status),null;const n=await l.json();return n.success&&n.token?n.token:null}catch(l){return console.error("获取 WebSocket token 失败:",l),null}}async function B4(l,n){const i=await U4();if(!i)return console.warn("无法获取 WebSocket token可能未登录"),null;const c=window.location.protocol==="https:"?"wss:":"ws:",u=window.location.host,m=`${c}//${u}/api/webui/ws/plugin-progress?token=${encodeURIComponent(i)}`;try{const h=new WebSocket(m);return h.onopen=()=>{console.log("Plugin progress WebSocket connected");const f=setInterval(()=>{h.readyState===WebSocket.OPEN?h.send("ping"):clearInterval(f)},3e4)},h.onmessage=f=>{try{if(f.data==="pong")return;const p=JSON.parse(f.data);l(p)}catch(p){console.error("Failed to parse progress data:",p)}},h.onerror=f=>{console.error("Plugin progress WebSocket error:",f),n?.(f)},h.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},h}catch(h){return console.error("创建 WebSocket 连接失败:",h),null}}async function Ai(){try{const l=await Se("/api/webui/plugins/installed",{headers:Zs()});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const n=await l.json();if(!n.success)throw new Error(n.message||"获取已安装插件列表失败");return n.plugins||[]}catch(l){return console.error("Failed to get installed plugins:",l),[]}}function po(l,n){return n.some(i=>i.id===l)}function go(l,n){const i=n.find(c=>c.id===l);if(i)return i.manifest?.version||i.version}async function $4(l,n,i="main"){const c=await Se("/api/webui/plugins/install",{method:"POST",body:JSON.stringify({plugin_id:l,repository_url:n,branch:i})});if(!c.ok){const u=await c.json();throw new Error(u.detail||"安装失败")}return await c.json()}async function H4(l){const n=await Se("/api/webui/plugins/uninstall",{method:"POST",body:JSON.stringify({plugin_id:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"卸载失败")}return await n.json()}async function G4(l,n,i="main"){const c=await Se("/api/webui/plugins/update",{method:"POST",body:JSON.stringify({plugin_id:l,repository_url:n,branch:i})});if(!c.ok){const u=await c.json();throw new Error(u.detail||"更新失败")}return await c.json()}async function P4(l){const n=await Se(`/api/webui/plugins/config/${l}/schema`,{headers:Zs()});if(!n.ok){const c=await n.json();throw new Error(c.detail||"获取配置 Schema 失败")}const i=await n.json();if(!i.success)throw new Error(i.message||"获取配置 Schema 失败");return i.schema}async function I4(l){const n=await Se(`/api/webui/plugins/config/${l}`,{headers:Zs()});if(!n.ok){const c=await n.json();throw new Error(c.detail||"获取配置失败")}const i=await n.json();if(!i.success)throw new Error(i.message||"获取配置失败");return i.config}async function q4(l,n){const i=await Se(`/api/webui/plugins/config/${l}`,{method:"PUT",body:JSON.stringify({config:n})});if(!i.ok){const c=await i.json();throw new Error(c.detail||"保存配置失败")}return await i.json()}async function V4(l){const n=await Se(`/api/webui/plugins/config/${l}/reset`,{method:"POST",headers:Zs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"重置配置失败")}return await n.json()}async function F4(l){const n=await Se(`/api/webui/plugins/config/${l}/toggle`,{method:"POST",headers:Zs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"切换状态失败")}return await n.json()}const Qi="https://maibot-plugin-stats.maibot-webui.workers.dev";async function uv(l){try{const n=await fetch(`${Qi}/stats/${l}`);return n.ok?await n.json():(console.error("Failed to fetch plugin stats:",n.statusText),null)}catch(n){return console.error("Error fetching plugin stats:",n),null}}async function K4(l,n){try{const i=n||Fm(),c=await fetch(`${Qi}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,user_id:i})}),u=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...u}:{success:!1,error:u.error||"点赞失败"}}catch(i){return console.error("Error liking plugin:",i),{success:!1,error:"网络错误"}}}async function Q4(l,n){try{const i=n||Fm(),c=await fetch(`${Qi}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,user_id:i})}),u=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...u}:{success:!1,error:u.error||"点踩失败"}}catch(i){return console.error("Error disliking plugin:",i),{success:!1,error:"网络错误"}}}async function Y4(l,n,i,c){if(n<1||n>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const u=c||Fm(),m=await fetch(`${Qi}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,rating:n,comment:i,user_id:u})}),h=await m.json();return m.status===429?{success:!1,error:"每天最多评分 3 次"}:m.ok?{success:!0,...h}:{success:!1,error:h.error||"评分失败"}}catch(u){return console.error("Error rating plugin:",u),{success:!1,error:"网络错误"}}}async function X4(l){try{const n=await fetch(`${Qi}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l})}),i=await n.json();return n.status===429?(console.warn("Download recording rate limited"),{success:!0}):n.ok?{success:!0,...i}:(console.error("Failed to record download:",i.error),{success:!1,error:i.error})}catch(n){return console.error("Error recording download:",n),{success:!1,error:"网络错误"}}}function J4(){const l=navigator,n=[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,l.deviceMemory||0].join("|");let i=0;for(let c=0;c<n.length;c++){const u=n.charCodeAt(c);i=(i<<5)-i+u,i=i&i}return`fp_${Math.abs(i).toString(36)}`}function Fm(){const l="maibot_user_id";let n=localStorage.getItem(l);if(!n){const i=J4(),c=Date.now().toString(36),u=Math.random().toString(36).substring(2,15);n=`${i}_${c}_${u}`,localStorage.setItem(l,n)}return n}function Z4({pluginId:l,compact:n=!1}){const[i,c]=x.useState(null),[u,m]=x.useState(!0),[h,f]=x.useState(0),[p,j]=x.useState(""),[v,N]=x.useState(!1),{toast:b}=et(),S=async()=>{m(!0);const D=await uv(l);D&&c(D),m(!1)};x.useEffect(()=>{S()},[l]);const w=async()=>{const D=await K4(l);D.success?(b({title:"已点赞",description:"感谢你的支持!"}),S()):b({title:"点赞失败",description:D.error||"未知错误",variant:"destructive"})},O=async()=>{const D=await Q4(l);D.success?(b({title:"已反馈",description:"感谢你的反馈!"}),S()):b({title:"操作失败",description:D.error||"未知错误",variant:"destructive"})},M=async()=>{if(h===0){b({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const D=await Y4(l,h,p||void 0);D.success?(b({title:"评分成功",description:"感谢你的评价!"}),N(!1),f(0),j(""),S()):b({title:"评分失败",description:D.error||"未知错误",variant:"destructive"})};return u?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(Kt,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Nl,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):i?n?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:`下载量: ${i.downloads.toLocaleString()}`,children:[e.jsx(Kt,{className:"h-4 w-4"}),e.jsx("span",{children:i.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`评分: ${i.rating.toFixed(1)} (${i.rating_count} 条评价)`,children:[e.jsx(Nl,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:i.rating.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`点赞数: ${i.likes}`,children:[e.jsx(rm,{className:"h-4 w-4"}),e.jsx("span",{children:i.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(Kt,{className:"h-5 w-5 text-muted-foreground mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.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(Nl,{className:"h-5 w-5 text-yellow-400 mb-1 fill-yellow-400"}),e.jsx("span",{className:"text-2xl font-bold",children:i.rating.toFixed(1)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.rating_count," 条评价"]})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(rm,{className:"h-5 w-5 text-green-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.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(Vp,{className:"h-5 w-5 text-red-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.dislikes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点踩"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:w,children:[e.jsx(rm,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(Vp,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Hs,{open:v,onOpenChange:N,children:[e.jsx(Bo,{asChild:!0,children:e.jsxs(C,{variant:"default",size:"sm",children:[e.jsx(Nl,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(Os,{children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"为插件评分"}),e.jsx(Ws,{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(D=>e.jsx("button",{onClick:()=>f(D),className:"focus:outline-none",children:e.jsx(Nl,{className:`h-8 w-8 transition-colors ${D<=h?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-300"}`})},D))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h===0&&"点击星星进行评分",h===1&&"很差",h===2&&"一般",h===3&&"还行",h===4&&"不错",h===5&&"非常好"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"评论(可选)"}),e.jsx(Ys,{value:p,onChange:D=>j(D.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(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>N(!1),children:"取消"}),e.jsx(C,{onClick:M,disabled:h===0,children:"提交评分"})]})]})]})]}),i.recent_ratings&&i.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:i.recent_ratings.map((D,$)=>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(E=>e.jsx(Nl,{className:`h-3 w-3 ${E<=D.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},E))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(D.created_at).toLocaleDateString()})]}),D.comment&&e.jsx("p",{className:"text-sm text-muted-foreground",children:D.comment})]},$))})]})]}):null}const pg={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function W4(){return e.jsx(On,{children:e.jsx(eC,{})})}function eC(){const l=xa(),{triggerRestart:n,isRestarting:i}=tn(),[c,u]=x.useState(null),[m,h]=x.useState(""),[f,p]=x.useState("all"),[j,v]=x.useState("all"),[N,b]=x.useState(!0),[S,w]=x.useState([]),[O,M]=x.useState(!0),[D,$]=x.useState(null),[E,_]=x.useState(null),[T,P]=x.useState(null),[A,ee]=x.useState(null),[,H]=x.useState([]),[Z,re]=x.useState({}),[ye,de]=x.useState(!1),[ge,je]=x.useState(null),[z,Q]=x.useState("main"),[J,U]=x.useState(""),[G,Ce]=x.useState("preset"),[be,ke]=x.useState(!1),{toast:I}=et(),we=async F=>{const ze=F.map(async Me=>{try{const Ke=await uv(Me.id);return{id:Me.id,stats:Ke}}catch(Ke){return console.warn(`Failed to load stats for ${Me.id}:`,Ke),{id:Me.id,stats:null}}}),ue=await Promise.all(ze),ve={};ue.forEach(({id:Me,stats:Ke})=>{Ke&&(ve[Me]=Ke)}),re(ve)};x.useEffect(()=>{let F=null,ze=!1;return(async()=>{if(F=await B4(ve=>{ze||(P(ve),ve.stage==="success"?setTimeout(()=>{ze||P(null)},2e3):ve.stage==="error"&&(M(!1),$(ve.error||"加载失败")))},ve=>{console.error("WebSocket error:",ve),ze||I({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(ve=>{if(!F){ve();return}const Me=()=>{F&&F.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),ve()):F&&F.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),ve()):setTimeout(Me,100)};Me()}),!ze){const ve=await O4();_(ve),ve.installed||I({title:"Git 未安装",description:ve.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!ze){const ve=await R4();ee(ve)}if(!ze)try{M(!0),$(null);const ve=await D4();if(!ze){const Me=await Ai();H(Me);const Ke=ve.map(qe=>{const Zt=po(qe.id,Me),Et=go(qe.id,Me);return{...qe,installed:Zt,installed_version:Et}});for(const qe of Me)!Ke.some(Et=>Et.id===qe.id)&&qe.manifest&&Ke.push({id:qe.id,manifest:{manifest_version:qe.manifest.manifest_version||1,name:qe.manifest.name,version:qe.manifest.version,description:qe.manifest.description||"",author:qe.manifest.author,license:qe.manifest.license||"Unknown",host_application:qe.manifest.host_application,homepage_url:qe.manifest.homepage_url,repository_url:qe.manifest.repository_url,keywords:qe.manifest.keywords||[],categories:qe.manifest.categories||[],default_locale:qe.manifest.default_locale||"zh-CN",locales_path:qe.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:qe.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});w(Ke),we(Ke)}}catch(ve){if(!ze){const Me=ve instanceof Error?ve.message:"加载插件列表失败";$(Me),I({title:"加载失败",description:Me,variant:"destructive"})}}finally{ze||M(!1)}})(),()=>{ze=!0,F&&F.close()}},[I]);const q=F=>{if(!F.installed&&A&&!oe(F))return e.jsxs(Ae,{variant:"destructive",className:"gap-1",children:[e.jsx(Ut,{className:"h-3 w-3"}),"不兼容"]});if(F.installed){const ze=F.installed_version?.trim(),ue=F.manifest.version?.trim();if(ze!==ue){const ve=ze?.split(".").map(Number)||[0,0,0],Me=ue?.split(".").map(Number)||[0,0,0];for(let Ke=0;Ke<3;Ke++){if((Me[Ke]||0)>(ve[Ke]||0))return e.jsxs(Ae,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Ut,{className:"h-3 w-3"}),"可更新"]});if((Me[Ke]||0)<(ve[Ke]||0))break}}return e.jsxs(Ae,{variant:"default",className:"gap-1",children:[e.jsx(ua,{className:"h-3 w-3"}),"已安装"]})}return null},oe=F=>!A||!F.manifest?.host_application?!0:L4(F.manifest.host_application.min_version,F.manifest.host_application.max_version,A),Te=F=>{if(!F.installed||!F.installed_version||!F.manifest?.version)return!1;const ze=F.installed_version.trim(),ue=F.manifest.version.trim();if(ze===ue)return!1;const ve=ze.split(".").map(Number),Me=ue.split(".").map(Number);for(let Ke=0;Ke<3;Ke++){if((Me[Ke]||0)>(ve[Ke]||0))return!0;if((Me[Ke]||0)<(ve[Ke]||0))return!1}return!1},X=S.filter(F=>{if(!F.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",F.id),!1;const ze=m===""||F.manifest.name?.toLowerCase().includes(m.toLowerCase())||F.manifest.description?.toLowerCase().includes(m.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Ke=>Ke.toLowerCase().includes(m.toLowerCase())),ue=f==="all"||F.manifest.categories&&F.manifest.categories.includes(f);let ve=!0;j==="installed"?ve=F.installed===!0:j==="updates"&&(ve=F.installed===!0&&Te(F));const Me=!N||!A||oe(F);return ze&&ue&&ve&&Me}),ne=()=>{u(null)},Ie=F=>{if(!E?.installed){I({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(A&&!oe(F)){I({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}je(F),Q("main"),U(""),Ce("preset"),ke(!1),de(!0)},Je=async()=>{if(!ge)return;const F=G==="custom"?J:z;if(!F||F.trim()===""){I({title:"分支名称不能为空",variant:"destructive"});return}try{de(!1),await $4(ge.id,ge.manifest.repository_url||"",F),X4(ge.id).catch(ue=>{console.warn("Failed to record download:",ue)}),I({title:"安装成功",description:`${ge.manifest.name} 已成功安装`});const ze=await Ai();H(ze),w(ue=>ue.map(ve=>{if(ve.id===ge.id){const Me=po(ve.id,ze),Ke=go(ve.id,ze);return{...ve,installed:Me,installed_version:Ke}}return ve}))}catch(ze){I({title:"安装失败",description:ze instanceof Error?ze.message:"未知错误",variant:"destructive"})}finally{je(null)}},pe=async F=>{try{await H4(F.id),I({title:"卸载成功",description:`${F.manifest.name} 已成功卸载`});const ze=await Ai();H(ze),w(ue=>ue.map(ve=>{if(ve.id===F.id){const Me=po(ve.id,ze),Ke=go(ve.id,ze);return{...ve,installed:Me,installed_version:Ke}}return ve}))}catch(ze){I({title:"卸载失败",description:ze instanceof Error?ze.message:"未知错误",variant:"destructive"})}},as=async F=>{if(!E?.installed){I({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const ze=await G4(F.id,F.manifest.repository_url||"","main");I({title:"更新成功",description:`${F.manifest.name} 已从 ${ze.old_version} 更新到 ${ze.new_version}`});const ue=await Ai();H(ue),w(ve=>ve.map(Me=>{if(Me.id===F.id){const Ke=po(Me.id,ue),qe=go(Me.id,ue);return{...Me,installed:Ke,installed_version:qe}}return Me}))}catch(ze){I({title:"更新失败",description:ze instanceof Error?ze.message:"未知错误",variant:"destructive"})}};return e.jsx(Xe,{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("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>n(),disabled:i,children:[e.jsx(jj,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(C,{onClick:()=>l({to:"/plugin-mirrors"}),children:[e.jsx(Uw,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]})]}),e.jsx(Oe,{className:"border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-900",children:e.jsx(We,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qt,{className:"h-4 w-4 text-blue-600 flex-shrink-0"}),e.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:["安装、卸载或更新插件后,需要",e.jsx("span",{className:"font-semibold",children:"重启麦麦"}),"才能使更改生效"]})]})})}),E&&!E.installed&&e.jsxs(Oe,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(ts,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oa,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(ns,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(Qs,{className:"text-orange-800 dark:text-orange-200",children:E.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(We,{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(Oe,{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(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:m,onChange:F=>h(F.target.value),className:"pl-9"})]}),e.jsxs($e,{value:f,onValueChange:p,children:[e.jsx(Le,{className:"w-full sm:w-[200px]",children:e.jsx(He,{placeholder:"选择分类"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"all",children:"全部分类"}),e.jsx(le,{value:"Group Management",children:"群组管理"}),e.jsx(le,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(le,{value:"Utility Tools",children:"实用工具"}),e.jsx(le,{value:"Content Generation",children:"内容生成"}),e.jsx(le,{value:"Multimedia",children:"多媒体"}),e.jsx(le,{value:"External Integration",children:"外部集成"}),e.jsx(le,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(le,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"compatible-only",checked:N,onCheckedChange:F=>b(F===!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(ma,{value:j,onValueChange:v,className:"w-full",children:e.jsxs(Xt,{className:"grid w-full grid-cols-3",children:[e.jsxs(ss,{value:"all",children:["全部插件 (",S.filter(F=>{if(!F.manifest)return!1;const ze=m===""||F.manifest.name?.toLowerCase().includes(m.toLowerCase())||F.manifest.description?.toLowerCase().includes(m.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Me=>Me.toLowerCase().includes(m.toLowerCase())),ue=f==="all"||F.manifest.categories&&F.manifest.categories.includes(f),ve=!N||!A||oe(F);return ze&&ue&&ve}).length,")"]}),e.jsxs(ss,{value:"installed",children:["已安装 (",S.filter(F=>{if(!F.manifest)return!1;const ze=m===""||F.manifest.name?.toLowerCase().includes(m.toLowerCase())||F.manifest.description?.toLowerCase().includes(m.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Me=>Me.toLowerCase().includes(m.toLowerCase())),ue=f==="all"||F.manifest.categories&&F.manifest.categories.includes(f),ve=!N||!A||oe(F);return F.installed&&ze&&ue&&ve}).length,")"]}),e.jsxs(ss,{value:"updates",children:["可更新 (",S.filter(F=>{if(!F.manifest)return!1;const ze=m===""||F.manifest.name?.toLowerCase().includes(m.toLowerCase())||F.manifest.description?.toLowerCase().includes(m.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Me=>Me.toLowerCase().includes(m.toLowerCase())),ue=f==="all"||F.manifest.categories&&F.manifest.categories.includes(f),ve=!N||!A||oe(F);return F.installed&&Te(F)&&ze&&ue&&ve}).length,")"]})]})}),T&&T.stage==="loading"&&T.operation==="fetch"&&e.jsx(Oe,{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(Xs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm font-medium",children:"加载插件列表"})]}),e.jsxs("span",{className:"text-sm font-medium",children:[T.progress,"%"]})]}),e.jsx(An,{value:T.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:T.message}),T.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",T.loaded_plugins," / ",T.total_plugins," 个插件"]})]})}),T&&T.stage==="error"&&T.error&&e.jsx(Oe,{className:"border-destructive bg-destructive/10",children:e.jsx(ts,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oa,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(ns,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(Qs,{className:"text-destructive/80",children:T.error})]})]})})}),O?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Xs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):D?e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(oa,{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:D}),e.jsx(C,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):X.length===0?e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Vt,{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:m||f!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:X.map(F=>e.jsxs(Oe,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(ts,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(ns,{className:"text-xl",children:F.manifest?.name||F.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[F.manifest?.categories&&F.manifest.categories[0]&&e.jsx(Ae,{variant:"secondary",className:"text-xs whitespace-nowrap",children:pg[F.manifest.categories[0]]||F.manifest.categories[0]}),q(F)]})]}),e.jsx(Qs,{className:"line-clamp-2",children:F.manifest?.description||"无描述"})]}),e.jsx(We,{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(Kt,{className:"h-4 w-4"}),e.jsx("span",{children:(Z[F.id]?.downloads??F.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Nl,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(Z[F.id]?.rating??F.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[F.manifest?.keywords&&F.manifest.keywords.slice(0,3).map(ze=>e.jsx(Ae,{variant:"outline",className:"text-xs",children:ze},ze)),F.manifest?.keywords&&F.manifest.keywords.length>3&&e.jsxs(Ae,{variant:"outline",className:"text-xs",children:["+",F.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",F.manifest?.version||"unknown"," · ",F.manifest?.author?.name||"Unknown"]}),F.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[F.manifest.host_application.min_version,F.manifest.host_application.max_version?` - ${F.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(Lo,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>u(F),children:"查看详情"}),F.installed?Te(F)?e.jsxs(C,{size:"sm",disabled:!E?.installed,title:E?.installed?void 0:"Git 未安装",onClick:()=>as(F),children:[e.jsx(At,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(C,{variant:"destructive",size:"sm",disabled:!E?.installed,title:E?.installed?void 0:"Git 未安装",onClick:()=>pe(F),children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(C,{size:"sm",disabled:!E?.installed||T?.operation==="install"||A!==null&&!oe(F),title:E?.installed?A!==null&&!oe(F)?`不兼容当前版本 (需要 ${F.manifest?.host_application?.min_version||"未知"}${F.manifest?.host_application?.max_version?` - ${F.manifest.host_application.max_version}`:"+"},当前 ${A?.version})`:void 0:"Git 未安装",onClick:()=>Ie(F),children:[e.jsx(Kt,{className:"h-4 w-4 mr-1"}),T?.operation==="install"&&T?.plugin_id===F.id?"安装中...":"安装"]})]})}),T&&(T.stage==="loading"||T.stage==="success"||T.stage==="error")&&T.operation!=="fetch"&&T.plugin_id===F.id&&e.jsx("div",{className:"px-6 pb-4 -mt-2",children:e.jsxs("div",{className:`space-y-2 p-3 rounded-lg border ${T.stage==="success"?"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900":T.stage==="error"?"bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[T.stage==="loading"?e.jsx(Xs,{className:"h-3 w-3 animate-spin"}):T.stage==="success"?e.jsx(ua,{className:"h-3 w-3 text-green-600"}):e.jsx(Ut,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:`text-xs font-medium ${T.stage==="success"?"text-green-700 dark:text-green-300":T.stage==="error"?"text-red-700 dark:text-red-300":""}`,children:T.stage==="loading"?e.jsxs(e.Fragment,{children:[T.operation==="install"&&"正在安装",T.operation==="uninstall"&&"正在卸载",T.operation==="update"&&"正在更新"]}):T.stage==="success"?e.jsxs(e.Fragment,{children:[T.operation==="install"&&"安装完成",T.operation==="uninstall"&&"卸载完成",T.operation==="update"&&"更新完成"]}):e.jsxs(e.Fragment,{children:[T.operation==="install"&&"安装失败",T.operation==="uninstall"&&"卸载失败",T.operation==="update"&&"更新失败"]})})]}),T.stage!=="error"&&e.jsxs("span",{className:`text-xs font-medium ${T.stage==="success"?"text-green-700 dark:text-green-300":""}`,children:[T.progress,"%"]})]}),T.stage!=="error"&&e.jsx(An,{value:T.progress,className:`h-1.5 ${T.stage==="success"?"[&>div]:bg-green-500":""}`}),e.jsx("div",{className:`text-xs ${T.stage==="success"?"text-green-600 dark:text-green-400 truncate":T.stage==="error"?"text-red-600 dark:text-red-400":"text-muted-foreground truncate"}`,children:T.stage==="error"?T.error||T.message||"操作失败":T.message})]})})]},F.id))}),e.jsx(Hs,{open:c!==null,onOpenChange:ne,children:c&&c.manifest&&e.jsx(Os,{className:"max-w-2xl max-h-[80vh] p-0 flex flex-col",children:e.jsx(Xe,{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsx(Rs,{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(Ls,{className:"text-2xl",children:c.manifest.name}),e.jsxs(Ws,{children:["作者: ",c.manifest.author?.name||"Unknown",c.manifest.author?.url&&e.jsx("a",{href:c.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-primary hover:underline",children:e.jsx(jo,{className:"h-3 w-3 inline"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[c.manifest.categories&&c.manifest.categories[0]&&e.jsx(Ae,{variant:"secondary",children:pg[c.manifest.categories[0]]||c.manifest.categories[0]}),q(c)]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Z4,{pluginId:c.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",c.manifest?.version||"unknown"]}),c.installed&&c.installed_version&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["已安装: v",c.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:(Z[c.id]?.downloads??c.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(Nl,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(Z[c.id]?.rating??c.rating??0).toFixed(1)," (",Z[c.id]?.rating_count??c.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:c.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:[c.manifest.host_application?.min_version||"未知",c.manifest.host_application?.max_version?` - ${c.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:c.manifest.keywords&&c.manifest.keywords.map(F=>e.jsx(Ae,{variant:"outline",children:F},F))})]}),c.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:c.detailed_description})]}),!c.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:c.manifest.description||"无描述"})]}),e.jsxs("div",{className:"space-y-2",children:[c.manifest.homepage_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"主页: "}),e.jsx("a",{href:c.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:c.manifest.homepage_url})]}),c.manifest.repository_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"仓库: "}),e.jsx("a",{href:c.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:c.manifest.repository_url})]})]})]}),e.jsxs(nt,{children:[c.manifest.homepage_url&&e.jsxs(C,{onClick:()=>window.open(c.manifest.homepage_url,"_blank"),children:[e.jsx(jo,{className:"h-4 w-4 mr-2"}),"访问主页"]}),c.manifest.repository_url&&e.jsxs(C,{variant:"outline",onClick:()=>window.open(c.manifest.repository_url,"_blank"),children:[e.jsx(jo,{className:"h-4 w-4 mr-2"}),"查看仓库"]})]})]})})})}),e.jsx(Hs,{open:ye,onOpenChange:de,children:e.jsxs(Os,{children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"安装插件"}),e.jsxs(Ws,{children:["安装 ",ge?.manifest.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["版本: ",ge?.manifest.version]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["作者: ",typeof ge?.manifest.author=="string"?ge.manifest.author:ge?.manifest.author?.name]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"advanced-options",checked:be,onCheckedChange:F=>ke(F)}),e.jsx("label",{htmlFor:"advanced-options",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"高级选项"})]}),be&&e.jsx("div",{className:"space-y-4 p-4 border rounded-lg",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"分支选择"}),e.jsxs(ma,{value:G,onValueChange:F=>Ce(F),children:[e.jsxs(Xt,{className:"grid w-full grid-cols-2",children:[e.jsx(ss,{value:"preset",className:"text-xs",children:"预设分支"}),e.jsx(ss,{value:"custom",className:"text-xs",children:"自定义分支"})]}),G==="preset"&&e.jsx("div",{className:"mt-3",children:e.jsxs($e,{value:z,onValueChange:Q,children:[e.jsx(Le,{children:e.jsx(He,{placeholder:"选择分支"})}),e.jsxs(Ue,{children:[e.jsx(le,{value:"main",children:"main (默认)"}),e.jsx(le,{value:"master",children:"master"}),e.jsx(le,{value:"dev",children:"dev (开发版)"}),e.jsx(le,{value:"develop",children:"develop"}),e.jsx(le,{value:"beta",children:"beta (测试版)"}),e.jsx(le,{value:"stable",children:"stable (稳定版)"})]})]})}),G==="custom"&&e.jsxs("div",{className:"space-y-2 mt-3",children:[e.jsx("input",{type:"text",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:"输入分支名称,例如: feature/new-feature",value:J,onChange:F=>U(F.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"输入 Git 分支名称、标签或提交哈希"})]})]})]})}),!be&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"将从默认分支 (main) 安装插件"})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>de(!1),children:"取消"}),e.jsxs(C,{onClick:Je,children:[e.jsx(Kt,{className:"h-4 w-4 mr-2"}),"安装"]})]})]})}),e.jsx(Rn,{})]})})}function sC(){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(vj,{className:"h-8 w-8",strokeWidth:2}),"模型分配预设市场"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"浏览和下载社区共享的模型分配预设配置"})]})})}),e.jsx(Xe,{className:"flex-1",children:e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-12rem)]",children:e.jsxs(Oe,{className:"max-w-2xl w-full border-dashed",children:[e.jsxs(ts,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(da,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(ns,{className:"text-2xl",children:"功能开发中"}),e.jsx(Qs,{className:"text-base",children:"模型分配预设市场功能正在开发中,敬请期待!"})]}),e.jsx(We,{children:e.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:"📦 即将推出的功能:"}),e.jsxs("ul",{className:"space-y-2 ml-6",children:[e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"浏览社区共享的模型分配预设配置"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"一键下载和应用预设配置"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"分享自己的模型分配方案"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"预设配置评分和评论系统"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"根据使用场景智能推荐配置"})]})]})]})})]})})})]})}function tC({field:l,value:n,onChange:i}){const[c,u]=x.useState(!1);switch(l.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(k,{children:l.label}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]}),e.jsx(Fe,{checked:!!n,onCheckedChange:i,disabled:l.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsx(ce,{type:"number",value:n??l.default,onChange:m=>i(parseFloat(m.target.value)||0),min:l.min,max:l.max,step:l.step??1,placeholder:l.placeholder,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"slider":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{children:l.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:n??l.default})]}),e.jsx(ya,{value:[n??l.default],onValueChange:m=>i(m[0]),min:l.min??0,max:l.max??100,step:l.step??1,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsxs($e,{value:String(n??l.default),onValueChange:i,disabled:l.disabled,children:[e.jsx(Le,{children:e.jsx(He,{placeholder:l.placeholder??"请选择"})}),e.jsx(Ue,{children:l.choices?.map(m=>e.jsx(le,{value:String(m),children:String(m)},String(m)))})]}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsx(Ys,{value:n??l.default,onChange:m=>i(m.target.value),placeholder:l.placeholder,rows:l.rows??3,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{type:c?"text":"password",value:n??"",onChange:m=>i(m.target.value),placeholder:l.placeholder,disabled:l.disabled,className:"pr-10"}),e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>u(!c),children:c?e.jsx(Ui,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})})]}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"list":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsx(t_,{value:Array.isArray(n)?n:[],onChange:m=>i(m),itemType:l.item_type??"string",itemFields:l.item_fields,minItems:l.min_items,maxItems:l.max_items,disabled:l.disabled,placeholder:l.placeholder}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:l.label}),e.jsx(ce,{type:"text",value:n??l.default??"",onChange:m=>i(m.target.value),placeholder:l.placeholder,maxLength:l.max_length,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]})}}function gg({section:l,config:n,onChange:i}){const[c,u]=x.useState(!l.collapsed),m=Object.entries(l.fields).filter(([,h])=>!h.hidden).sort(([,h],[,f])=>h.order-f.order);return e.jsx(Pi,{open:c,onOpenChange:u,children:e.jsxs(Oe,{children:[e.jsx(Ii,{asChild:!0,children:e.jsxs(ts,{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:[c?e.jsx(Ra,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(wa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ns,{className:"text-lg",children:l.title})]}),e.jsxs(Ae,{variant:"secondary",className:"text-xs",children:[m.length," 项"]})]}),l.description&&e.jsx(Qs,{className:"ml-6",children:l.description})]})}),e.jsx(qi,{children:e.jsx(We,{className:"space-y-4 pt-0",children:m.map(([h,f])=>e.jsx(tC,{field:f,value:n[l.name]?.[h],onChange:p=>i(l.name,h,p),sectionName:l.name},h))})})]})})}function aC({plugin:l,onBack:n}){const{toast:i}=et(),{triggerRestart:c,isRestarting:u}=tn(),[m,h]=x.useState(null),[f,p]=x.useState({}),[j,v]=x.useState({}),[N,b]=x.useState(!0),[S,w]=x.useState(!1),[O,M]=x.useState(!1),[D,$]=x.useState(!1),E=x.useCallback(async()=>{b(!0);try{const[Z,re]=await Promise.all([P4(l.id),I4(l.id)]);h(Z),p(re),v(JSON.parse(JSON.stringify(re)))}catch(Z){i({title:"加载配置失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}finally{b(!1)}},[l.id,i]);x.useEffect(()=>{E()},[E]),x.useEffect(()=>{M(JSON.stringify(f)!==JSON.stringify(j))},[f,j]);const _=(Z,re,ye)=>{p(de=>({...de,[Z]:{...de[Z]||{},[re]:ye}}))},T=async()=>{w(!0);try{await q4(l.id,f),v(JSON.parse(JSON.stringify(f))),i({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(Z){i({title:"保存失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}finally{w(!1)}},P=async()=>{try{await V4(l.id),i({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),$(!1),E()}catch(Z){i({title:"重置失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}},A=async()=>{try{const Z=await F4(l.id);i({title:Z.message,description:Z.note}),E()}catch(Z){i({title:"切换状态失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}};if(N)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(Xs,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!m)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 space-y-4",children:[e.jsx(Ut,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(C,{onClick:n,variant:"outline",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"返回"]})]});const ee=Object.values(m.sections).sort((Z,re)=>Z.order-re.order),H=f.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(C,{variant:"ghost",size:"icon",onClick:n,children:e.jsx(sn,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:m.plugin_info.name||l.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ae,{variant:H?"default":"secondary",children:H?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",m.plugin_info.version||l.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>c(),disabled:u,children:[e.jsx(jj,{className:`h-4 w-4 mr-2 ${u?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:A,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),H?"禁用":"启用"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>$(!0),children:[e.jsx(Li,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(C,{size:"sm",onClick:T,disabled:!O||S,children:[S?e.jsx(Xs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),O&&e.jsx(Oe,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(We,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qt,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),m.layout.type==="tabs"&&m.layout.tabs.length>0?e.jsxs(ma,{defaultValue:m.layout.tabs[0]?.id,children:[e.jsx(Xt,{children:m.layout.tabs.map(Z=>e.jsxs(ss,{value:Z.id,children:[Z.title,Z.badge&&e.jsx(Ae,{variant:"secondary",className:"ml-2 text-xs",children:Z.badge})]},Z.id))}),m.layout.tabs.map(Z=>e.jsx(Ss,{value:Z.id,className:"space-y-4 mt-4",children:Z.sections.map(re=>{const ye=m.sections[re];return ye?e.jsx(gg,{section:ye,config:f,onChange:_},re):null})},Z.id))]}):e.jsx("div",{className:"space-y-4",children:ee.map(Z=>e.jsx(gg,{section:Z,config:f,onChange:_},Z.name))}),e.jsx(Hs,{open:D,onOpenChange:$,children:e.jsxs(Os,{children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"确认重置配置"}),e.jsx(Ws,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>$(!1),children:"取消"}),e.jsx(C,{variant:"destructive",onClick:P,children:"确认重置"})]})]})})]})}function lC(){return e.jsx(On,{children:e.jsx(nC,{})})}function nC(){const{toast:l}=et(),[n,i]=x.useState([]),[c,u]=x.useState(!0),[m,h]=x.useState(""),[f,p]=x.useState(null),j=async()=>{u(!0);try{const S=await Ai();i(S)}catch(S){l({title:"加载插件列表失败",description:S instanceof Error?S.message:"未知错误",variant:"destructive"})}finally{u(!1)}};x.useEffect(()=>{j()},[]);const v=n.filter(S=>{const w=m.toLowerCase();return S.id.toLowerCase().includes(w)||S.manifest.name.toLowerCase().includes(w)||S.manifest.description?.toLowerCase().includes(w)}),N=n.length,b=0;return f?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(aC,{plugin:f,onBack:()=>p(null)})})}),e.jsx(Rn,{})]}):e.jsx(Xe,{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(C,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(At,{className:`h-4 w-4 mr-2 ${c?"animate-spin":""}`}),"刷新"]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(We,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c?"正在加载...":"个插件"})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"已启用"}),e.jsx(ua,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(We,{children:[e.jsx("div",{className:"text-2xl font-bold",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ns,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Ut,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(We,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索插件...",value:m,onChange:S=>h(S.target.value),className:"pl-9"})]}),e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"已安装的插件"}),e.jsx(Qs,{children:"点击插件查看和编辑配置"})]}),e.jsx(We,{children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Xs,{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(da,{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:m?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:v.map(S=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>p(S),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(da,{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:S.manifest.name}),e.jsxs(Ae,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",S.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:S.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(C,{variant:"ghost",size:"sm",children:e.jsx(Dn,{className:"h-4 w-4"})}),e.jsx(wa,{className:"h-4 w-4 text-muted-foreground"})]})]},S.id))})})]})]})})}function rC(){const l=xa(),{toast:n}=et(),[i,c]=x.useState([]),[u,m]=x.useState(!0),[h,f]=x.useState(null),[p,j]=x.useState(null),[v,N]=x.useState(!1),[b,S]=x.useState(!1),[w,O]=x.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),M=x.useCallback(async()=>{try{m(!0),f(null);const A=await Se("/api/webui/plugins/mirrors");if(!A.ok)throw new Error("获取镜像源列表失败");const ee=await A.json();c(ee.mirrors||[])}catch(A){const ee=A instanceof Error?A.message:"加载镜像源失败";f(ee),n({title:"加载失败",description:ee,variant:"destructive"})}finally{m(!1)}},[n]);x.useEffect(()=>{M()},[M]);const D=async()=>{try{const A=await Se("/api/webui/plugins/mirrors",{method:"POST",body:JSON.stringify(w)});if(!A.ok){const ee=await A.json();throw new Error(ee.detail||"添加镜像源失败")}n({title:"添加成功",description:"镜像源已添加"}),N(!1),O({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),M()}catch(A){n({title:"添加失败",description:A instanceof Error?A.message:"未知错误",variant:"destructive"})}},$=async()=>{if(p)try{if(!(await Se(`/api/webui/plugins/mirrors/${p.id}`,{method:"PUT",body:JSON.stringify({name:w.name,raw_prefix:w.raw_prefix,clone_prefix:w.clone_prefix,enabled:w.enabled,priority:w.priority})})).ok)throw new Error("更新镜像源失败");n({title:"更新成功",description:"镜像源已更新"}),S(!1),j(null),M()}catch(A){n({title:"更新失败",description:A instanceof Error?A.message:"未知错误",variant:"destructive"})}},E=async A=>{if(confirm("确定要删除这个镜像源吗?"))try{if(!(await Se(`/api/webui/plugins/mirrors/${A}`,{method:"DELETE"})).ok)throw new Error("删除镜像源失败");n({title:"删除成功",description:"镜像源已删除"}),M()}catch(ee){n({title:"删除失败",description:ee instanceof Error?ee.message:"未知错误",variant:"destructive"})}},_=async A=>{try{if(!(await Se(`/api/webui/plugins/mirrors/${A.id}`,{method:"PUT",body:JSON.stringify({enabled:!A.enabled})})).ok)throw new Error("更新状态失败");M()}catch(ee){n({title:"更新失败",description:ee instanceof Error?ee.message:"未知错误",variant:"destructive"})}},T=A=>{j(A),O({id:A.id,name:A.name,raw_prefix:A.raw_prefix,clone_prefix:A.clone_prefix,enabled:A.enabled,priority:A.priority}),S(!0)},P=async(A,ee)=>{const H=ee==="up"?A.priority-1:A.priority+1;if(!(H<1))try{if(!(await Se(`/api/webui/plugins/mirrors/${A.id}`,{method:"PUT",body:JSON.stringify({priority:H})})).ok)throw new Error("更新优先级失败");M()}catch(Z){n({title:"更新失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}};return e.jsx(Xe,{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(C,{variant:"ghost",size:"icon",onClick:()=>l({to:"/plugins"}),children:e.jsx(sn,{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(C,{onClick:()=>N(!0),children:[e.jsx(ft,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),u?e.jsx(Oe,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xs,{className:"h-8 w-8 animate-spin text-primary"})})}):h?e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(oa,{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:h}),e.jsx(C,{onClick:M,children:"重新加载"})]})}):e.jsxs(Oe,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{children:"状态"}),e.jsx(Ye,{children:"名称"}),e.jsx(Ye,{children:"ID"}),e.jsx(Ye,{children:"优先级"}),e.jsx(Ye,{className:"text-right",children:"操作"})]})}),e.jsx(Cl,{children:i.map(A=>e.jsxs(lt,{children:[e.jsx(Ge,{children:e.jsx(Fe,{checked:A.enabled,onCheckedChange:()=>_(A)})}),e.jsx(Ge,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:A.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",A.raw_prefix]})]})}),e.jsx(Ge,{children:e.jsx(Ae,{variant:"outline",children:A.id})}),e.jsx(Ge,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:A.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(C,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>P(A,"up"),disabled:A.priority===1,children:e.jsx(kr,{className:"h-3 w-3"})}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>P(A,"down"),children:e.jsx(Ra,{className:"h-3 w-3"})})]})]})}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>T(A),children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>E(A.id),children:e.jsx(rs,{className:"h-4 w-4 text-destructive"})})]})})]},A.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:i.map(A=>e.jsx(Oe,{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:A.name}),A.enabled&&e.jsx(Ae,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(Ae,{variant:"outline",className:"mt-1 text-xs",children:A.id})]}),e.jsx(Fe,{checked:A.enabled,onCheckedChange:()=>_(A)})]}),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:A.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:A.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>T(A),children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>P(A,"up"),disabled:A.priority===1,children:e.jsx(kr,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>P(A,"down"),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(C,{variant:"destructive",size:"sm",onClick:()=>E(A.id),children:e.jsx(rs,{className:"h-4 w-4"})})]})]})},A.id))})]}),e.jsx(Hs,{open:v,onOpenChange:N,children:e.jsxs(Os,{className:"max-w-lg",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"添加镜像源"}),e.jsx(Ws,{children:"添加新的 Git 镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(ce,{id:"add-id",placeholder:"例如: my-mirror",value:w.id,onChange:A=>O({...w,id:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ce,{id:"add-name",placeholder:"例如: 我的镜像源",value:w.name,onChange:A=>O({...w,name:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"add-raw",placeholder:"https://example.com/raw",value:w.raw_prefix,onChange:A=>O({...w,raw_prefix:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"add-clone",placeholder:"https://example.com/clone",value:w.clone_prefix,onChange:A=>O({...w,clone_prefix:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ce,{id:"add-priority",type:"number",min:"1",value:w.priority,onChange:A=>O({...w,priority:parseInt(A.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(Fe,{id:"add-enabled",checked:w.enabled,onCheckedChange:A=>O({...w,enabled:A})}),e.jsx(k,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>N(!1),children:"取消"}),e.jsx(C,{onClick:D,children:"添加"})]})]})}),e.jsx(Hs,{open:b,onOpenChange:S,children:e.jsxs(Os,{className:"max-w-lg",children:[e.jsxs(Rs,{children:[e.jsx(Ls,{children:"编辑镜像源"}),e.jsx(Ws,{children:"修改镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"镜像源 ID"}),e.jsx(ce,{value:w.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ce,{id:"edit-name",value:w.name,onChange:A=>O({...w,name:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ce,{id:"edit-raw",value:w.raw_prefix,onChange:A=>O({...w,raw_prefix:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ce,{id:"edit-clone",value:w.clone_prefix,onChange:A=>O({...w,clone_prefix:A.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ce,{id:"edit-priority",type:"number",min:"1",value:w.priority,onChange:A=>O({...w,priority:parseInt(A.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(Fe,{id:"edit-enabled",checked:w.enabled,onCheckedChange:A=>O({...w,enabled:A})}),e.jsx(k,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(nt,{children:[e.jsx(C,{variant:"outline",onClick:()=>S(!1),children:"取消"}),e.jsx(C,{onClick:$,children:"保存"})]})]})})]})})}const zi=x.forwardRef(({className:l,...n},i)=>e.jsx(Ug,{ref:i,className:L("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",l),...n}));zi.displayName=Ug.displayName;const iC=x.forwardRef(({className:l,...n},i)=>e.jsx(Bg,{ref:i,className:L("aspect-square h-full w-full",l),...n}));iC.displayName=Bg.displayName;const Di=x.forwardRef(({className:l,...n},i)=>e.jsx($g,{ref:i,className:L("flex h-full w-full items-center justify-center rounded-full bg-muted",l),...n}));Di.displayName=$g.displayName;function cC(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function oC(){const l="maibot_webui_user_id";let n=localStorage.getItem(l);return n||(n=cC(),localStorage.setItem(l,n)),n}function dC(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function uC(l){localStorage.setItem("maibot_webui_user_name",l)}const mv="maibot_webui_virtual_tabs";function mC(){try{const l=localStorage.getItem(mv);if(l)return JSON.parse(l)}catch(l){console.error("[Chat] 加载虚拟标签页失败:",l)}return[]}function jg(l){try{localStorage.setItem(mv,JSON.stringify(l))}catch(n){console.error("[Chat] 保存虚拟标签页失败:",n)}}function xC({segment:l}){switch(l.type){case"text":return e.jsx("span",{className:"whitespace-pre-wrap",children:String(l.data)});case"image":case"emoji":return e.jsx("img",{src:String(l.data),alt:l.type==="emoji"?"表情包":"图片",className:L("rounded-lg max-w-full",l.type==="emoji"?"max-h-32":"max-h-64"),loading:"lazy",onError:n=>{const i=n.target;i.style.display="none",i.parentElement?.insertAdjacentHTML("beforeend",`<span class="text-muted-foreground text-xs">[${l.type==="emoji"?"表情包":"图片"}加载失败]</span>`)}});case"voice":return e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("audio",{controls:!0,src:String(l.data),className:"max-w-[200px] h-8",children:"您的浏览器不支持音频播放"})});case"video":return e.jsx("video",{controls:!0,src:String(l.data),className:"rounded-lg max-w-full max-h-64",children:"您的浏览器不支持视频播放"});case"face":return e.jsxs("span",{className:"text-muted-foreground",children:["[表情:",String(l.data),"]"]});case"music":return e.jsx("span",{className:"text-muted-foreground",children:"[音乐分享]"});case"file":return e.jsxs("span",{className:"text-muted-foreground",children:["[文件: ",String(l.data),"]"]});case"reply":return e.jsx("span",{className:"text-muted-foreground text-xs",children:"[回复消息]"});case"forward":return e.jsx("span",{className:"text-muted-foreground",children:"[转发消息]"});case"unknown":default:return e.jsxs("span",{className:"text-muted-foreground",children:["[",l.original_type||"未知消息","]"]})}}function hC({message:l,isBot:n}){return l.message_type==="rich"&&l.segments&&l.segments.length>0?e.jsx("div",{className:"flex flex-col gap-2",children:l.segments.map((i,c)=>e.jsx(xC,{segment:i},c))}):e.jsx("span",{className:"whitespace-pre-wrap",children:l.content})}function fC(){const l={id:"webui-default",type:"webui",label:"WebUI",messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}},n=()=>{const Pe=mC().map(Be=>{const _e=Be.virtualConfig;return!_e.groupId&&_e.platform&&_e.userId&&(_e.groupId=`webui_virtual_group_${_e.platform}_${_e.userId}`),{id:Be.id,type:"virtual",label:Be.label,virtualConfig:_e,messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}}});return[l,...Pe]},[i,c]=x.useState(n),[u,m]=x.useState("webui-default"),h=i.find(K=>K.id===u)||i[0],[f,p]=x.useState(""),[j,v]=x.useState(!1),[N,b]=x.useState(!0),[S,w]=x.useState(dC()),[O,M]=x.useState(!1),[D,$]=x.useState(""),[E,_]=x.useState(!1),[T,P]=x.useState([]),[A,ee]=x.useState([]),[H,Z]=x.useState(!1),[re,ye]=x.useState(!1),[de,ge]=x.useState(""),[je,z]=x.useState({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),Q=x.useRef(oC()),J=x.useRef(new Map),U=x.useRef(null),G=x.useRef(new Map),Ce=x.useRef(0),be=x.useRef(new Map),{toast:ke}=et(),I=K=>(Ce.current+=1,`${K}-${Date.now()}-${Ce.current}-${Math.random().toString(36).substr(2,9)}`),we=x.useCallback((K,Pe)=>{c(Be=>Be.map(_e=>_e.id===K?{..._e,...Pe}:_e))},[]),q=x.useCallback((K,Pe)=>{c(Be=>Be.map(_e=>_e.id===K?{..._e,messages:[..._e.messages,Pe]}:_e))},[]),oe=x.useCallback(()=>{U.current?.scrollIntoView({behavior:"smooth"})},[]);x.useEffect(()=>{oe()},[h?.messages,oe]);const Te=x.useCallback(async()=>{Z(!0);try{const K=await Se("/api/chat/platforms");if(console.log("[Chat] 平台列表响应:",K.status,K.headers.get("content-type")),K.ok){const Pe=K.headers.get("content-type");if(Pe&&Pe.includes("application/json")){const Be=await K.json();console.log("[Chat] 平台列表数据:",Be),P(Be.platforms||[])}else{const Be=await K.text();console.error("[Chat] 获取平台列表失败: 非 JSON 响应:",Be.substring(0,200)),ke({title:"连接失败",description:"无法连接到后端服务,请确保 MaiBot 已启动",variant:"destructive"})}}else console.error("[Chat] 获取平台列表失败: HTTP",K.status),ke({title:"获取平台失败",description:`服务器返回错误: ${K.status}`,variant:"destructive"})}catch(K){console.error("[Chat] 获取平台列表失败:",K),ke({title:"网络错误",description:"无法连接到后端服务",variant:"destructive"})}finally{Z(!1)}},[ke]),X=x.useCallback(async(K,Pe)=>{ye(!0);try{const Be=new URLSearchParams;K&&Be.append("platform",K),Pe&&Be.append("search",Pe),Be.append("limit","50");const _e=await Se(`/api/chat/persons?${Be.toString()}`);if(_e.ok){const gs=_e.headers.get("content-type");if(gs&&gs.includes("application/json")){const is=await _e.json();ee(is.persons||[])}else console.error("[Chat] 获取用户列表失败: 后端返回非 JSON 响应")}}catch(Be){console.error("[Chat] 获取用户列表失败:",Be)}finally{ye(!1)}},[]);x.useEffect(()=>{je.platform&&X(je.platform,de)},[je.platform,de,X]);const ne=x.useCallback(async(K,Pe)=>{b(!0);try{const Be=new URLSearchParams;Be.append("user_id",Q.current),Be.append("limit","50"),Pe&&Be.append("group_id",Pe);const _e=`/api/chat/history?${Be.toString()}`;console.log("[Chat] 正在加载历史消息:",_e);const gs=await Se(_e);if(gs.ok){const is=await gs.text();try{const As=JSON.parse(is);if(As.messages&&As.messages.length>0){const Ds=As.messages.map(ls=>({id:ls.id,type:ls.type,content:ls.content,timestamp:ls.timestamp,sender:{name:ls.sender_name||(ls.is_bot?"麦麦":"WebUI用户"),user_id:ls.user_id,is_bot:ls.is_bot}}));we(K,{messages:Ds});const Gs=be.current.get(K)||new Set;Ds.forEach(ls=>{if(ls.type==="bot"){const es=`bot-${ls.content}-${Math.floor(ls.timestamp*1e3)}`;Gs.add(es)}}),be.current.set(K,Gs)}}catch(As){console.error("[Chat] JSON 解析失败:",As)}}}catch(Be){console.error("[Chat] 加载历史消息失败:",Be)}finally{b(!1)}},[we]),Ie=x.useCallback(async(K,Pe,Be)=>{const _e=J.current.get(K);if(_e?.readyState===WebSocket.OPEN||_e?.readyState===WebSocket.CONNECTING){console.log(`[Tab ${K}] WebSocket 已存在,跳过连接`);return}v(!0);let gs=null;try{const Gs=await Se("/api/webui/ws-token");if(Gs.ok){const ls=await Gs.json();if(ls.success&&ls.token)gs=ls.token;else{console.warn(`[Tab ${K}] 获取 WebSocket token 失败: ${ls.message||"未登录"}`),v(!1);return}}}catch(Gs){console.error(`[Tab ${K}] 获取 WebSocket token 失败:`,Gs),v(!1);return}if(!gs){v(!1);return}const is=window.location.protocol==="https:"?"wss:":"ws:",As=new URLSearchParams;As.append("token",gs),Pe==="virtual"&&Be?(As.append("user_id",Be.userId),As.append("user_name",Be.userName),As.append("platform",Be.platform),As.append("person_id",Be.personId),As.append("group_name",Be.groupName||"WebUI虚拟群聊"),Be.groupId&&As.append("group_id",Be.groupId)):(As.append("user_id",Q.current),As.append("user_name",S));const Ds=`${is}//${window.location.host}/api/chat/ws?${As.toString()}`;console.log(`[Tab ${K}] 正在连接 WebSocket:`,Ds);try{const Gs=new WebSocket(Ds);J.current.set(K,Gs),Gs.onopen=()=>{we(K,{isConnected:!0}),v(!1),console.log(`[Tab ${K}] WebSocket 已连接`)},Gs.onmessage=ls=>{try{const es=JSON.parse(ls.data);switch(es.type){case"session_info":we(K,{sessionInfo:{session_id:es.session_id,user_id:es.user_id,user_name:es.user_name,bot_name:es.bot_name}});break;case"system":q(K,{id:I("sys"),type:"system",content:es.content||"",timestamp:es.timestamp||Date.now()/1e3});break;case"user_message":{const Ze=es.sender?.user_id,Us=Pe==="virtual"&&Be?Be.userId:Q.current;console.log(`[Tab ${K}] 收到 user_message, sender: ${Ze}, current: ${Us}`);const zt=Ze?Ze.replace(/^webui_user_/,""):"",st=Us?Us.replace(/^webui_user_/,""):"";if(zt&&st&&zt===st){console.log(`[Tab ${K}] 跳过自己的消息user_id 匹配)`);break}const Cs=be.current.get(K)||new Set,jt=`user-${es.content}-${Math.floor((es.timestamp||0)*1e3)}`;if(Cs.has(jt)){console.log(`[Tab ${K}] 跳过自己的消息(内容去重)`);break}if(Cs.add(jt),be.current.set(K,Cs),Cs.size>100){const ae=Cs.values().next().value;ae&&Cs.delete(ae)}q(K,{id:es.message_id||I("user"),type:"user",content:es.content||"",timestamp:es.timestamp||Date.now()/1e3,sender:es.sender});break}case"bot_message":{we(K,{isTyping:!1});const Ze=be.current.get(K)||new Set,Us=`bot-${es.content}-${Math.floor((es.timestamp||0)*1e3)}`;if(Ze.has(Us))break;if(Ze.add(Us),be.current.set(K,Ze),Ze.size>100){const zt=Ze.values().next().value;zt&&Ze.delete(zt)}c(zt=>zt.map(st=>{if(st.id!==K)return st;const Cs=st.messages.filter(ae=>ae.type!=="thinking"),jt={id:I("bot"),type:"bot",content:es.content||"",message_type:es.message_type==="rich"?"rich":"text",segments:es.segments,timestamp:es.timestamp||Date.now()/1e3,sender:es.sender};return{...st,messages:[...Cs,jt]}}));break}case"typing":we(K,{isTyping:es.is_typing||!1});break;case"error":c(Ze=>Ze.map(Us=>{if(Us.id!==K)return Us;const zt=Us.messages.filter(st=>st.type!=="thinking");return{...Us,messages:[...zt,{id:I("error"),type:"error",content:es.content||"发生错误",timestamp:es.timestamp||Date.now()/1e3}]}})),ke({title:"错误",description:es.content,variant:"destructive"});break;case"pong":break;case"history":{const Ze=es.messages||[];if(Ze.length>0){const Us=be.current.get(K)||new Set,zt=Ze.map(st=>{const Cs=st.is_bot||!1,jt=st.id||I(Cs?"bot":"user"),ae=`${Cs?"bot":"user"}-${st.content}-${Math.floor(st.timestamp*1e3)}`;return Us.add(ae),{id:jt,type:Cs?"bot":"user",content:st.content,timestamp:st.timestamp,sender:{name:st.sender_name||(Cs?"麦麦":"用户"),user_id:st.sender_id,is_bot:Cs}}});be.current.set(K,Us),we(K,{messages:zt}),console.log(`[Tab ${K}] 已加载 ${zt.length} 条历史消息`)}break}default:console.log("未知消息类型:",es.type)}}catch(es){console.error("解析消息失败:",es)}},Gs.onclose=()=>{we(K,{isConnected:!1}),v(!1),J.current.delete(K),console.log(`[Tab ${K}] WebSocket 已断开`);const ls=G.current.get(K);ls&&clearTimeout(ls);const es=window.setTimeout(()=>{if(!Je.current){const Ze=i.find(Us=>Us.id===K);Ze&&Ie(K,Ze.type,Ze.virtualConfig)}},5e3);G.current.set(K,es)},Gs.onerror=ls=>{console.error(`[Tab ${K}] WebSocket 错误:`,ls),v(!1)}}catch(Gs){console.error(`[Tab ${K}] 创建 WebSocket 失败:`,Gs),v(!1)}},[S,we,q,ke,i]),Je=x.useRef(!1);x.useEffect(()=>{Je.current=!1;const K=J.current,Pe=G.current,Be=be.current;ne("webui-default");const _e=setTimeout(()=>{Je.current||(Ie("webui-default","webui"),i.forEach(is=>{is.type==="virtual"&&is.virtualConfig&&(Be.set(is.id,new Set),setTimeout(()=>{Je.current||Ie(is.id,"virtual",is.virtualConfig)},200))}))},100),gs=setInterval(()=>{K.forEach(is=>{is.readyState===WebSocket.OPEN&&is.send(JSON.stringify({type:"ping"}))})},3e4);return()=>{Je.current=!0,clearTimeout(_e),clearInterval(gs),Pe.forEach(is=>{clearTimeout(is)}),Pe.clear(),K.forEach(is=>{is.close()}),K.clear()}},[]);const pe=x.useCallback(()=>{const K=J.current.get(u);if(!f.trim()||!K||K.readyState!==WebSocket.OPEN)return;const Pe=h?.type==="virtual"&&h.virtualConfig?.userName||S,Be=f.trim(),_e=Date.now()/1e3;K.send(JSON.stringify({type:"message",content:Be,user_name:Pe}));const gs=be.current.get(u)||new Set,is=`user-${Be}-${Math.floor(_e*1e3)}`;if(gs.add(is),be.current.set(u,gs),gs.size>100){const Gs=gs.values().next().value;Gs&&gs.delete(Gs)}const As={id:I("user"),type:"user",content:Be,timestamp:_e,sender:{name:Pe,is_bot:!1}};q(u,As);const Ds={id:I("thinking"),type:"thinking",content:"",timestamp:_e+.001,sender:{name:h?.sessionInfo.bot_name||"麦麦",is_bot:!0}};q(u,Ds),p("")},[f,S,u,h,q]),as=K=>{K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),pe())},F=()=>{$(S),M(!0)},ze=()=>{const K=D.trim()||"WebUI用户";w(K),uC(K),M(!1);const Pe=J.current.get(u);Pe?.readyState===WebSocket.OPEN&&Pe.send(JSON.stringify({type:"update_nickname",user_name:K}))},ue=()=>{$(""),M(!1)},ve=K=>new Date(K*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),Me=()=>{const K=J.current.get(u);K&&(K.close(),J.current.delete(u)),Ie(u,h?.type||"webui",h?.virtualConfig)},Ke=()=>{z({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),ge(""),Te(),_(!0)},qe=()=>{if(!je.platform||!je.personId){ke({title:"配置不完整",description:"请选择平台和用户",variant:"destructive"});return}const K=`webui_virtual_group_${je.platform}_${je.userId}`,Pe=`virtual-${je.platform}-${je.userId}-${Date.now()}`,Be=je.userName||je.userId,_e={id:Pe,type:"virtual",label:Be,virtualConfig:{...je,groupId:K},messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}};c(gs=>{const is=[...gs,_e],As=is.filter(Ds=>Ds.type==="virtual"&&Ds.virtualConfig).map(Ds=>({id:Ds.id,label:Ds.label,virtualConfig:Ds.virtualConfig,createdAt:Date.now()}));return jg(As),is}),m(Pe),_(!1),be.current.set(Pe,new Set),setTimeout(()=>{Ie(Pe,"virtual",je)},100),ke({title:"虚拟身份标签页",description:`已创建 ${Be} 的对话`})},Zt=(K,Pe)=>{if(Pe?.stopPropagation(),K==="webui-default")return;const Be=J.current.get(K);Be&&(Be.close(),J.current.delete(K));const _e=G.current.get(K);_e&&(clearTimeout(_e),G.current.delete(K)),be.current.delete(K),c(gs=>{const is=gs.filter(Ds=>Ds.id!==K),As=is.filter(Ds=>Ds.type==="virtual"&&Ds.virtualConfig).map(Ds=>({id:Ds.id,label:Ds.label,virtualConfig:Ds.virtualConfig,createdAt:Date.now()}));return jg(As),is}),u===K&&m("webui-default")},Et=K=>{m(K)},ot=K=>{z(Pe=>({...Pe,personId:K.person_id,userId:K.user_id,userName:K.nickname||K.person_name}))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Hs,{open:E,onOpenChange:_,children:e.jsxs(Os,{className:"sm:max-w-[500px] max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(im,{className:"h-5 w-5"}),"新建虚拟身份对话"]}),e.jsx(Ws,{children:"选择一个麦麦已认识的用户,以该用户的身份与麦麦对话。麦麦将使用她对该用户的记忆和认知来回应。"})]}),e.jsxs("div",{className:"space-y-4 flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-4 w-4"}),"选择平台"]}),e.jsxs($e,{value:je.platform,onValueChange:K=>{z(Pe=>({...Pe,platform:K,personId:"",userId:"",userName:""})),ee([])},children:[e.jsx(Le,{disabled:H,children:e.jsx(He,{placeholder:H?"加载中...":"选择平台"})}),e.jsx(Ue,{children:T.map(K=>e.jsxs(le,{value:K.platform,children:[K.platform," (",K.count," 人)"]},K.platform))})]})]}),je.platform&&e.jsxs("div",{className:"space-y-2 flex-1 overflow-hidden flex flex-col",children:[e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(Cm,{className:"h-4 w-4"}),"选择用户"]}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索用户名...",value:de,onChange:K=>ge(K.target.value),className:"pl-9"})]}),e.jsx(Xe,{className:"h-[250px] border rounded-md",children:e.jsx("div",{className:"p-2",children:re?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[e.jsx(Cm,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"没有找到用户"})]}):e.jsx("div",{className:"space-y-1",children:A.map(K=>e.jsxs("button",{onClick:()=>ot(K),className:L("w-full flex items-center gap-3 p-2 rounded-md text-left transition-colors",je.personId===K.person_id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[e.jsx(zi,{className:"h-8 w-8 shrink-0",children:e.jsx(Di,{className:L("text-xs",je.personId===K.person_id?"bg-primary-foreground/20":"bg-muted"),children:(K.nickname||K.person_name||"?").charAt(0)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium truncate",children:K.nickname||K.person_name}),e.jsxs("div",{className:L("text-xs truncate",je.personId===K.person_id?"text-primary-foreground/70":"text-muted-foreground"),children:["ID: ",K.user_id,K.is_known&&" · 已认识"]})]})]},K.person_id))})})})]}),je.personId&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"虚拟群名(可选)"}),e.jsx(ce,{placeholder:"WebUI虚拟群聊",value:je.groupName,onChange:K=>z(Pe=>({...Pe,groupName:K.target.value}))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会认为这是一个名为此名称的群聊"})]})]}),e.jsxs(nt,{className:"gap-2 sm:gap-0",children:[e.jsx(C,{variant:"outline",onClick:()=>_(!1),children:"取消"}),e.jsx(C,{onClick:qe,disabled:!je.platform||!je.personId,children:"创建对话"})]})]})}),e.jsx("div",{className:"shrink-0 border-b bg-muted/30",children:e.jsx("div",{className:"max-w-4xl mx-auto px-2 sm:px-4",children:e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto py-1.5 scrollbar-thin",children:[i.map(K=>e.jsxs("div",{className:L("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm whitespace-nowrap transition-colors cursor-pointer","hover:bg-muted",u===K.id?"bg-background shadow-sm border":"text-muted-foreground"),onClick:()=>Et(K.id),children:[K.type==="webui"?e.jsx(en,{className:"h-3.5 w-3.5"}):e.jsx(im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"max-w-[100px] truncate",children:K.label}),e.jsx("span",{className:L("w-1.5 h-1.5 rounded-full",K.isConnected?"bg-green-500":"bg-muted-foreground/50")}),K.id!=="webui-default"&&e.jsx("span",{onClick:Pe=>Zt(K.id,Pe),className:"ml-0.5 p-0.5 rounded hover:bg-muted-foreground/20 cursor-pointer",role:"button",tabIndex:0,onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),Zt(K.id,Pe))},children:e.jsx(Ja,{className:"h-3 w-3"})})]},K.id)),e.jsx("button",{onClick:Ke,className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-sm text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",title:"新建虚拟身份对话",children:e.jsx(ft,{className:"h-3.5 w-3.5"})})]})})}),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(zi,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(Di,{className:"bg-primary/10 text-primary",children:e.jsx(Ei,{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:h?.sessionInfo.bot_name||"麦麦"}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:h?.isConnected?e.jsxs(e.Fragment,{children:[e.jsx(Bw,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"已连接"})]}):j?e.jsxs(e.Fragment,{children:[e.jsx(Xs,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx($w,{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:[N&&e.jsx(Xs,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Me,disabled:j,title:"重新连接",children:e.jsx(At,{className:L("h-4 w-4",j&&"animate-spin")})})]})]}),e.jsx("div",{className:"hidden sm:flex items-center gap-2 mt-2 text-sm text-muted-foreground",children:h?.type==="virtual"&&h.virtualConfig?e.jsxs(e.Fragment,{children:[e.jsx(im,{className:"h-3 w-3 text-primary"}),e.jsx("span",{children:"虚拟身份:"}),e.jsx("span",{className:"font-medium text-primary",children:h.virtualConfig.userName}),e.jsxs("span",{className:"text-xs",children:["(",h.virtualConfig.platform,")"]}),h.virtualConfig.groupName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1",children:"·"}),e.jsxs("span",{className:"text-xs",children:["群:",h.virtualConfig.groupName]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cr,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),O?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{value:D,onChange:K=>$(K.target.value),onKeyDown:K=>{K.key==="Enter"&&ze(),K.key==="Escape"&&ue()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(C,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:ze,children:"保存"}),e.jsx(C,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:ue,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:S}),e.jsx(C,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:F,title:"修改昵称",children:e.jsx(Hw,{className:"h-3 w-3"})})]})]})})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Xe,{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:[h?.messages.length===0&&!N&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(Ei,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",h?.sessionInfo.bot_name||"麦麦"," 对话吧!"]})]}),h?.messages.map(K=>e.jsxs("div",{className:L("flex gap-2 sm:gap-3",K.type==="user"&&"flex-row-reverse",K.type==="system"&&"justify-center",K.type==="error"&&"justify-center"),children:[K.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:K.content}),K.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:K.content}),K.type==="thinking"&&e.jsxs(e.Fragment,{children:[e.jsx(zi,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Di,{className:"bg-primary/10 text-primary",children:e.jsx(Ei,{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%]",children:[e.jsx("div",{className:"flex items-center gap-2 text-[10px] sm:text-xs text-muted-foreground",children:e.jsx("span",{className:"hidden sm:inline",children:K.sender?.name||h?.sessionInfo.bot_name})}),e.jsx("div",{className:"bg-muted rounded-2xl rounded-tl-sm px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"思考中..."})]})})]})]}),(K.type==="user"||K.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(zi,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Di,{className:L("text-xs",K.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:K.type==="bot"?e.jsx(Ei,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(Cr,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:L("flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",K.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:K.sender?.name||(K.type==="bot"?h?.sessionInfo.bot_name:S)}),e.jsx("span",{children:ve(K.timestamp)})]}),e.jsx("div",{className:L("rounded-2xl px-3 py-2 text-sm break-words",K.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:e.jsx(hC,{message:K,isBot:K.type==="bot"})})]})]})]},K.id)),e.jsx("div",{ref:U})]})})}),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:f,onChange:K=>p(K.target.value),onKeyDown:as,placeholder:h?.isConnected?"输入消息...":"等待连接...",disabled:!h?.isConnected,className:"flex-1 h-10 sm:h-10"}),e.jsx(C,{onClick:pe,disabled:!h?.isConnected||!f.trim(),size:"icon",className:"h-10 w-10 shrink-0",children:e.jsx(Gw,{className:"h-4 w-4"})})]})})})]})}var Km="Radio",[pC,xv]=Do(Km),[gC,jC]=pC(Km),hv=x.forwardRef((l,n)=>{const{__scopeRadio:i,name:c,checked:u=!1,required:m,disabled:h,value:f="on",onCheck:p,form:j,...v}=l,[N,b]=x.useState(null),S=Oo(n,M=>b(M)),w=x.useRef(!1),O=N?j||!!N.closest("form"):!0;return e.jsxs(gC,{scope:i,checked:u,disabled:h,children:[e.jsx(zn.button,{type:"button",role:"radio","aria-checked":u,"data-state":jv(u),"data-disabled":h?"":void 0,disabled:h,value:f,...v,ref:S,onClick:Wl(l.onClick,M=>{u||p?.(),O&&(w.current=M.isPropagationStopped(),w.current||M.stopPropagation())})}),O&&e.jsx(gv,{control:N,bubbles:!w.current,name:c,value:f,checked:u,required:m,disabled:h,form:j,style:{transform:"translateX(-100%)"}})]})});hv.displayName=Km;var fv="RadioIndicator",pv=x.forwardRef((l,n)=>{const{__scopeRadio:i,forceMount:c,...u}=l,m=jC(fv,i);return e.jsx(nw,{present:c||m.checked,children:e.jsx(zn.span,{"data-state":jv(m.checked),"data-disabled":m.disabled?"":void 0,...u,ref:n})})});pv.displayName=fv;var vC="RadioBubbleInput",gv=x.forwardRef(({__scopeRadio:l,control:n,checked:i,bubbles:c=!0,...u},m)=>{const h=x.useRef(null),f=Oo(h,m),p=rw(i),j=iw(n);return x.useEffect(()=>{const v=h.current;if(!v)return;const N=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(N,"checked").set;if(p!==i&&S){const w=new Event("click",{bubbles:c});S.call(v,i),v.dispatchEvent(w)}},[p,i,c]),e.jsx(zn.input,{type:"radio","aria-hidden":!0,defaultChecked:i,...u,tabIndex:-1,ref:f,style:{...u.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});gv.displayName=vC;function jv(l){return l?"checked":"unchecked"}var NC=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],qo="RadioGroup",[bC]=Do(qo,[Hg,xv]),vv=Hg(),Nv=xv(),[yC,wC]=bC(qo),bv=x.forwardRef((l,n)=>{const{__scopeRadioGroup:i,name:c,defaultValue:u,value:m,required:h=!1,disabled:f=!1,orientation:p,dir:j,loop:v=!0,onValueChange:N,...b}=l,S=vv(i),w=tj(j),[O,M]=zo({prop:m,defaultProp:u??null,onChange:N,caller:qo});return e.jsx(yC,{scope:i,name:c,required:h,disabled:f,value:O,onValueChange:M,children:e.jsx(v0,{asChild:!0,...S,orientation:p,dir:w,loop:v,children:e.jsx(zn.div,{role:"radiogroup","aria-required":h,"aria-orientation":p,"data-disabled":f?"":void 0,dir:w,...b,ref:n})})})});bv.displayName=qo;var yv="RadioGroupItem",wv=x.forwardRef((l,n)=>{const{__scopeRadioGroup:i,disabled:c,...u}=l,m=wC(yv,i),h=m.disabled||c,f=vv(i),p=Nv(i),j=x.useRef(null),v=Oo(n,j),N=m.value===u.value,b=x.useRef(!1);return x.useEffect(()=>{const S=O=>{NC.includes(O.key)&&(b.current=!0)},w=()=>b.current=!1;return document.addEventListener("keydown",S),document.addEventListener("keyup",w),()=>{document.removeEventListener("keydown",S),document.removeEventListener("keyup",w)}},[]),e.jsx(N0,{asChild:!0,...f,focusable:!h,active:N,children:e.jsx(hv,{disabled:h,required:m.required,checked:N,...p,...u,name:m.name,ref:v,onCheck:()=>m.onValueChange(u.value),onKeyDown:Wl(S=>{S.key==="Enter"&&S.preventDefault()}),onFocus:Wl(u.onFocus,()=>{b.current&&j.current?.click()})})})});wv.displayName=yv;var _C="RadioGroupIndicator",_v=x.forwardRef((l,n)=>{const{__scopeRadioGroup:i,...c}=l,u=Nv(i);return e.jsx(pv,{...u,...c,ref:n})});_v.displayName=_C;var Sv=bv,Cv=wv,SC=_v;const Qm=x.forwardRef(({className:l,...n},i)=>e.jsx(Sv,{className:L("grid gap-2",l),...n,ref:i}));Qm.displayName=Sv.displayName;const Mo=x.forwardRef(({className:l,...n},i)=>e.jsx(Cv,{ref:i,className:L("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",l),...n,children:e.jsx(SC,{className:"flex items-center justify-center",children:e.jsx(Nj,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Mo.displayName=Cv.displayName;function CC({question:l,value:n,onChange:i,error:c,disabled:u=!1}){const[m,h]=x.useState(null),f=u||l.readOnly,p=()=>{switch(l.type){case"single":return e.jsx(Qm,{value:n||"",onValueChange:i,disabled:f,className:"space-y-2",children:l.options?.map(j=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Mo,{value:j.value,id:`${l.id}-${j.id}`}),e.jsx(k,{htmlFor:`${l.id}-${j.id}`,className:"cursor-pointer font-normal",children:j.label})]},j.id))});case"multiple":{const j=n||[];return e.jsxs("div",{className:"space-y-2",children:[l.options?.map(v=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:`${l.id}-${v.id}`,checked:j.includes(v.value),disabled:f||l.maxSelections!==void 0&&j.length>=l.maxSelections&&!j.includes(v.value),onCheckedChange:N=>{i(N?[...j,v.value]:j.filter(b=>b!==v.value))}}),e.jsx(k,{htmlFor:`${l.id}-${v.id}`,className:"cursor-pointer font-normal",children:v.label})]},v.id)),l.maxSelections&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["最多选择 ",l.maxSelections," 项"]})]})}case"text":return e.jsx(ce,{value:n||"",onChange:j=>i(j.target.value),placeholder:l.placeholder||"请输入...",disabled:f,readOnly:l.readOnly,maxLength:l.maxLength,className:L(l.readOnly&&"bg-muted cursor-not-allowed")});case"textarea":return e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ys,{value:n||"",onChange:j=>i(j.target.value),placeholder:l.placeholder||"请输入...",disabled:f,readOnly:l.readOnly,maxLength:l.maxLength,rows:4,className:L(l.readOnly&&"bg-muted cursor-not-allowed")}),l.maxLength&&e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[(n||"").length," / ",l.maxLength]})]});case"rating":{const j=n||0,v=m!==null?m:j;return e.jsxs("div",{className:"flex items-center gap-1",children:[[1,2,3,4,5].map(N=>e.jsx("button",{type:"button",disabled:f,className:L("p-1 transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded",f&&"cursor-not-allowed opacity-50"),onMouseEnter:()=>!f&&h(N),onMouseLeave:()=>h(null),onClick:()=>!f&&i(N),children:e.jsx(Nl,{className:L("h-6 w-6 transition-colors",N<=v?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},N)),j>0&&e.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[j," / 5"]})]})}case"scale":{const j=l.min??1,v=l.max??10,N=l.step??1,b=n??j;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ya,{value:[b],onValueChange:([S])=>i(S),min:j,max:v,step:N,disabled:f}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:l.minLabel||j}),e.jsx("span",{className:"font-medium text-foreground",children:b}),e.jsx("span",{children:l.maxLabel||v})]})]})}case"dropdown":return e.jsxs($e,{value:n||"",onValueChange:i,disabled:f,children:[e.jsx(Le,{children:e.jsx(He,{placeholder:l.placeholder||"请选择..."})}),e.jsx(Ue,{children:l.options?.map(j=>e.jsx(le,{value:j.value,children:j.label},j.id))})]});default:return e.jsx("div",{className:"text-muted-foreground",children:"不支持的问题类型"})}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-base font-medium",children:[l.title,l.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),p(),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]})}const kv="https://maibot-plugin-stats.maibot-webui.workers.dev";function Tv(){const l="maibot_user_id";let n=localStorage.getItem(l);if(!n){const i=Math.random().toString(36).substring(2,10),c=Date.now().toString(36),u=Math.random().toString(36).substring(2,10);n=`fp_${i}_${c}_${u}`,localStorage.setItem(l,n)}return n}async function kC(l,n,i,c){try{const u=c?.userId||Tv(),m={surveyId:l,surveyVersion:n,userId:u,answers:i,submittedAt:new Date().toISOString(),allowMultiple:c?.allowMultiple,metadata:{userAgent:navigator.userAgent,language:navigator.language}},h=await fetch(`${kv}/survey/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),f=await h.json();return h.status===429?{success:!1,error:"提交过于频繁,请稍后再试"}:h.status===409?{success:!1,error:f.error||"你已经提交过这份问卷了"}:h.ok?{success:!0,submissionId:f.submissionId,message:f.message}:{success:!1,error:f.error||"提交失败"}}catch(u){return console.error("Error submitting survey:",u),{success:!1,error:"网络错误"}}}async function TC(l,n){try{const i=n||Tv(),c=new URLSearchParams({user_id:i,survey_id:l}),u=await fetch(`${kv}/survey/check?${c}`);return u.ok?{success:!0,hasSubmitted:(await u.json()).hasSubmitted}:{success:!1,error:(await u.json()).error||"检查失败"}}catch(i){return console.error("Error checking submission:",i),{success:!1,error:"网络错误"}}}function Ev({config:l,initialAnswers:n,onSubmitSuccess:i,onSubmitError:c,showProgress:u=!0,paginateQuestions:m=!1,className:h}){const f=x.useCallback(()=>!n||n.length===0?{}:n.reduce((J,U)=>(J[U.questionId]=U.value,J),{}),[n]),[p,j]=x.useState(()=>f()),[v,N]=x.useState({}),[b,S]=x.useState(0),[w,O]=x.useState(!1),[M,D]=x.useState(!1),[$,E]=x.useState(null),[_,T]=x.useState(null),[P,A]=x.useState(!1),[ee,H]=x.useState(!0);x.useEffect(()=>{n&&n.length>0&&j(J=>({...J,...f()}))},[n,f]),x.useEffect(()=>{(async()=>{if(!l.settings?.allowMultiple){const U=await TC(l.id);U.success&&U.hasSubmitted&&A(!0)}H(!1)})()},[l.id,l.settings?.allowMultiple]);const Z=x.useCallback(()=>{const J=new Date;return!(l.settings?.startTime&&new Date(l.settings.startTime)>J||l.settings?.endTime&&new Date(l.settings.endTime)<J)},[l.settings?.startTime,l.settings?.endTime]),re=l.questions.filter(J=>{const U=p[J.id];return U==null?!1:Array.isArray(U)?U.length>0:typeof U=="string"?U.trim()!=="":!0}).length,ye=re/l.questions.length*100,de=x.useCallback((J,U)=>{j(G=>({...G,[J]:U})),N(G=>{const Ce={...G};return delete Ce[J],Ce})},[]),ge=x.useCallback(()=>{const J={};for(const U of l.questions){if(U.required){const G=p[U.id];if(G==null){J[U.id]="此题为必填项";continue}if(Array.isArray(G)&&G.length===0){J[U.id]="请至少选择一项";continue}if(typeof G=="string"&&G.trim()===""){J[U.id]="此题为必填项";continue}}U.minLength&&typeof p[U.id]=="string"&&p[U.id].length<U.minLength&&(J[U.id]=`至少需要 ${U.minLength} 个字符`)}return N(J),Object.keys(J).length===0},[l.questions,p]),je=x.useCallback(async()=>{if(!ge()){if(m){const J=l.questions.findIndex(U=>v[U.id]);J>=0&&S(J)}return}O(!0),E(null);try{const J=l.questions.filter(G=>p[G.id]!==void 0).map(G=>({questionId:G.id,value:p[G.id]})),U=await kC(l.id,l.version,J,{allowMultiple:l.settings?.allowMultiple});if(U.success&&U.submissionId)D(!0),T(U.submissionId),i?.(U.submissionId);else{const G=U.error||"提交失败";E(G),c?.(G)}}catch(J){const U=J instanceof Error?J.message:"提交失败";E(U),c?.(U)}finally{O(!1)}},[ge,m,l,p,v,i,c]),z=x.useCallback(J=>{J>=0&&J<l.questions.length&&S(J)},[l.questions.length]);if(ee)return e.jsx(Oe,{className:L("w-full max-w-2xl mx-auto",h),children:e.jsx(We,{className:"py-12 flex items-center justify-center",children:e.jsx(Xs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if(P&&!l.settings?.allowMultiple)return e.jsxs(Oe,{className:L("w-full max-w-2xl mx-auto",h),children:[e.jsx(ts,{children:e.jsx(ns,{children:l.title})}),e.jsx(We,{className:"py-8",children:e.jsxs(wt,{children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(_t,{children:"你已经提交过这份问卷了,感谢参与!"})]})})]});if(!Z())return e.jsxs(Oe,{className:L("w-full max-w-2xl mx-auto",h),children:[e.jsx(ts,{children:e.jsx(ns,{children:l.title})}),e.jsx(We,{className:"py-8",children:e.jsxs(wt,{variant:"destructive",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(_t,{children:"问卷不在有效期内"})]})})]});if(M)return e.jsxs(Oe,{className:L("w-full max-w-2xl mx-auto",h),children:[e.jsx(ts,{children:e.jsxs(ns,{className:"flex items-center gap-2 text-green-600",children:[e.jsx(ua,{className:"h-6 w-6"}),"提交成功"]})}),e.jsxs(We,{className:"py-8",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:l.settings?.thankYouMessage||"感谢你的参与!"}),_&&e.jsxs("p",{className:"text-center text-xs text-muted-foreground mt-4",children:["提交编号:",_]})]})]});const Q=m?[l.questions[b]]:l.questions;return e.jsxs("div",{className:L("h-full flex flex-col",h),children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 mb-4 shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold",children:l.title}),l.description&&e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:l.description}),u&&e.jsxs("div",{className:"space-y-1 pt-3",children:[e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"进度"}),e.jsxs("span",{children:[re," / ",l.questions.length]})]}),e.jsx(An,{value:ye,className:"h-2"})]})]}),e.jsx(Xe,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[Q.map((J,U)=>e.jsxs("div",{className:L("p-4 rounded-lg border bg-card",v[J.id]?"border-destructive bg-destructive/5":"border-border"),children:[m&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:["问题 ",b+1," / ",l.questions.length]}),!m&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:[U+1,"."]}),e.jsx(CC,{question:J,value:p[J.id],onChange:G=>de(J.id,G),error:v[J.id],disabled:w})]},J.id)),$&&e.jsxs(wt,{variant:"destructive",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(_t,{children:$})]}),e.jsx("div",{className:"flex justify-between items-center py-4",children:m?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"outline",onClick:()=>z(b-1),disabled:b===0||w,children:[e.jsx(el,{className:"h-4 w-4 mr-1"}),"上一题"]}),b===l.questions.length-1?e.jsxs(C,{onClick:je,disabled:w,children:[w&&e.jsx(Xs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]}):e.jsxs(C,{onClick:()=>z(b+1),disabled:w,children:["下一题",e.jsx(wa,{className:"h-4 w-4 ml-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:Object.keys(v).length>0&&e.jsxs("span",{className:"text-destructive",children:["还有 ",Object.keys(v).length," 个必填项未完成"]})}),e.jsxs(C,{onClick:je,disabled:w,size:"lg",children:[w&&e.jsx(Xs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]})]})})]})})]})}const EC={id:"webui-feedback-v1",version:"1.0.0",title:"麦麦 WebUI 使用反馈问卷",description:"感谢您使用麦麦 WebUI您的反馈将帮助我们不断改进产品体验。",questions:[{id:"webui_version",type:"text",title:"你正在使用的 WebUI 版本",description:"此项由系统自动填写",required:!0,readOnly:!0,placeholder:"自动检测中..."},{id:"ui_design_satisfaction",type:"single",title:"你觉得当前的 WebUI 界面设计如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"problems_encountered",type:"multiple",title:"你在使用 WebUI 时遇到过哪些问题?",description:"可多选",required:!0,options:[{id:"lag",label:"界面卡顿",value:"lag"},{id:"incomplete",label:"功能不完整",value:"incomplete"},{id:"complex",label:"操作复杂",value:"complex"},{id:"bugs",label:"存在 Bug",value:"bugs"},{id:"none",label:"没有遇到问题",value:"none"},{id:"other",label:"其他",value:"other"}]},{id:"problems_other",type:"text",title:'如选择"其他",请说明遇到的问题',required:!1,placeholder:"请描述你遇到的其他问题...",maxLength:500},{id:"useful_features",type:"textarea",title:"你觉得哪些功能是最有用的?",required:!0,placeholder:"请分享你认为最有价值的功能...",maxLength:1e3},{id:"feature_requests",type:"textarea",title:"你希望在未来的版本中增加哪些功能?",required:!0,placeholder:"请告诉我们你期望的新功能...",maxLength:1e3},{id:"overall_satisfaction",type:"single",title:"你对麦麦 WebUI 的整体满意度如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"would_recommend",type:"single",title:"你愿意推荐麦麦 WebUI 给其他人使用吗?",required:!0,options:[{id:"yes",label:"是",value:"yes"},{id:"no",label:"否",value:"no"}]},{id:"other_suggestions",type:"textarea",title:"其他建议或意见",description:"此项为选填",required:!1,placeholder:"如果你有任何其他想法或建议,请在此分享...",maxLength:2e3}],settings:{allowMultiple:!1,thankYouMessage:"感谢你的反馈!你的意见对我们非常重要,我们会认真考虑每一条建议。"}},MC={id:"maibot-feedback-v1",version:"1.0.0",title:"麦麦使用体验反馈问卷",description:"感谢您使用麦麦!您的反馈将帮助我们打造更好的 AI 伙伴。",questions:[{id:"maibot_version",type:"text",title:"你正在使用的麦麦版本",description:"此项由系统自动填写",required:!0,readOnly:!0,placeholder:"自动检测中..."},{id:"improvement_areas",type:"textarea",title:"你认为麦麦还有哪些部分可以改进?",required:!0,placeholder:"请分享你认为可以改进的方面...",maxLength:1e3},{id:"problems_encountered",type:"multiple",title:"你在使用麦麦时遇到过哪些问题?",description:"可多选",required:!0,options:[{id:"incomplete",label:"功能不完整",value:"incomplete"},{id:"slow_response",label:"响应速度慢",value:"slow_response"},{id:"complex",label:"操作复杂",value:"complex"},{id:"unstable",label:"运行不稳定",value:"unstable"},{id:"config_difficult",label:"配置困难",value:"config_difficult"},{id:"none",label:"没有遇到问题",value:"none"},{id:"other",label:"其他",value:"other"}]},{id:"problems_other",type:"text",title:'如选择"其他",请说明遇到的问题',required:!1,placeholder:"请描述你遇到的其他问题...",maxLength:500},{id:"helpful_features",type:"textarea",title:"你觉得麦麦的哪些功能对你最有帮助?",required:!0,placeholder:"请分享对你最有帮助的功能...",maxLength:1e3},{id:"feature_requests",type:"textarea",title:"你希望在未来的版本中增加哪些功能?",required:!0,placeholder:"请告诉我们你期望的新功能...",maxLength:1e3},{id:"overall_satisfaction",type:"single",title:"你对麦麦的整体满意度如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"would_recommend",type:"single",title:"你愿意推荐麦麦给其他人使用吗?",required:!0,options:[{id:"yes",label:"是",value:"yes"},{id:"no",label:"否",value:"no"}]},{id:"other_suggestions",type:"textarea",title:"其他建议或意见",description:"此项为选填",required:!1,placeholder:"如果你有任何其他想法或建议,请在此分享...",maxLength:2e3}],settings:{allowMultiple:!1,thankYouMessage:"感谢你的反馈!你的意见对麦麦的成长非常重要,我们会认真考虑每一条建议。"}};function AC(){const[l,n]=x.useState(null),[i,c]=x.useState(!0);x.useEffect(()=>{const f=JSON.parse(JSON.stringify(EC));n(f),c(!1)},[]);const u=x.useMemo(()=>[{questionId:"webui_version",value:`v${Uo}`}],[]),m=x.useCallback(f=>{console.log("WebUI Survey submitted:",f)},[]),h=x.useCallback(f=>{console.error("WebUI Survey submission error:",f)},[]);return i?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Xs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?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 shrink-0",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(bj,{className:"h-8 w-8",strokeWidth:2}),"WebUI 使用反馈问卷"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"感谢您的反馈,帮助我们持续改进产品体验"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ev,{config:l,initialAnswers:u,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:m,onSubmitError:h})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(wt,{variant:"destructive",className:"max-w-md",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(_t,{children:"无法加载问卷配置"})]}),e.jsx(C,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}function zC(){const[l,n]=x.useState(null),[i,c]=x.useState(!0),[u,m]=x.useState("未知版本");x.useEffect(()=>{(async()=>{try{const N=await M1();m(N.version||"未知版本")}catch(N){console.error("Failed to get MaiBot version:",N),m("获取失败")}const v=JSON.parse(JSON.stringify(MC));n(v),c(!1)})()},[]);const h=x.useMemo(()=>[{questionId:"maibot_version",value:u}],[u]),f=x.useCallback(j=>{console.log("MaiBot Survey submitted:",j)},[]),p=x.useCallback(j=>{console.error("MaiBot Survey submission error:",j)},[]);return i?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Xs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?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 shrink-0",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(bj,{className:"h-8 w-8",strokeWidth:2}),"麦麦使用体验反馈问卷"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"感谢您的反馈,帮助我们打造更好的 AI 伙伴"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ev,{config:l,initialAnswers:h,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:f,onSubmitError:p})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(wt,{variant:"destructive",className:"max-w-md",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(_t,{children:"无法加载问卷配置"})]}),e.jsx(C,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}var Vo="DropdownMenu",[DC]=Do(Vo,[Gg]),Jt=Gg(),[OC,Mv]=DC(Vo),Av=l=>{const{__scopeDropdownMenu:n,children:i,dir:c,open:u,defaultOpen:m,onOpenChange:h,modal:f=!0}=l,p=Jt(n),j=x.useRef(null),[v,N]=zo({prop:u,defaultProp:m??!1,onChange:h,caller:Vo});return e.jsx(OC,{scope:n,triggerId:_m(),triggerRef:j,contentId:_m(),open:v,onOpenChange:N,onOpenToggle:x.useCallback(()=>N(b=>!b),[N]),modal:f,children:e.jsx(A0,{...p,open:v,onOpenChange:N,dir:c,modal:f,children:i})})};Av.displayName=Vo;var zv="DropdownMenuTrigger",Dv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,disabled:c=!1,...u}=l,m=Mv(zv,i),h=Jt(i);return e.jsx(z0,{asChild:!0,...h,children:e.jsx(zn.button,{type:"button",id:m.triggerId,"aria-haspopup":"menu","aria-expanded":m.open,"aria-controls":m.open?m.contentId:void 0,"data-state":m.open?"open":"closed","data-disabled":c?"":void 0,disabled:c,...u,ref:cw(n,m.triggerRef),onPointerDown:Wl(l.onPointerDown,f=>{!c&&f.button===0&&f.ctrlKey===!1&&(m.onOpenToggle(),m.open||f.preventDefault())}),onKeyDown:Wl(l.onKeyDown,f=>{c||(["Enter"," "].includes(f.key)&&m.onOpenToggle(),f.key==="ArrowDown"&&m.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});Dv.displayName=zv;var RC="DropdownMenuPortal",Ov=l=>{const{__scopeDropdownMenu:n,...i}=l,c=Jt(n);return e.jsx(w0,{...c,...i})};Ov.displayName=RC;var Rv="DropdownMenuContent",Lv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Mv(Rv,i),m=Jt(i),h=x.useRef(!1);return e.jsx(_0,{id:u.contentId,"aria-labelledby":u.triggerId,...m,...c,ref:n,onCloseAutoFocus:Wl(l.onCloseAutoFocus,f=>{h.current||u.triggerRef.current?.focus(),h.current=!1,f.preventDefault()}),onInteractOutside:Wl(l.onInteractOutside,f=>{const p=f.detail.originalEvent,j=p.button===0&&p.ctrlKey===!0,v=p.button===2||j;(!u.modal||v)&&(h.current=!0)}),style:{...l.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lv.displayName=Rv;var LC="DropdownMenuGroup",UC=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(D0,{...u,...c,ref:n})});UC.displayName=LC;var BC="DropdownMenuLabel",Uv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(E0,{...u,...c,ref:n})});Uv.displayName=BC;var $C="DropdownMenuItem",Bv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(S0,{...u,...c,ref:n})});Bv.displayName=$C;var HC="DropdownMenuCheckboxItem",$v=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(C0,{...u,...c,ref:n})});$v.displayName=HC;var GC="DropdownMenuRadioGroup",PC=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(O0,{...u,...c,ref:n})});PC.displayName=GC;var IC="DropdownMenuRadioItem",Hv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(T0,{...u,...c,ref:n})});Hv.displayName=IC;var qC="DropdownMenuItemIndicator",Gv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(k0,{...u,...c,ref:n})});Gv.displayName=qC;var VC="DropdownMenuSeparator",Pv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(M0,{...u,...c,ref:n})});Pv.displayName=VC;var FC="DropdownMenuArrow",KC=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(R0,{...u,...c,ref:n})});KC.displayName=FC;var QC="DropdownMenuSubTrigger",Iv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(b0,{...u,...c,ref:n})});Iv.displayName=QC;var YC="DropdownMenuSubContent",qv=x.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=Jt(i);return e.jsx(y0,{...u,...c,ref:n,style:{...l.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qv.displayName=YC;var XC=Av,JC=Dv,ZC=Ov,Vv=Lv,Fv=Uv,Kv=Bv,Qv=$v,Yv=Hv,Xv=Gv,Jv=Pv,Zv=Iv,Wv=qv;const WC=XC,ek=JC,sk=x.forwardRef(({className:l,inset:n,children:i,...c},u)=>e.jsxs(Zv,{ref:u,className:L("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",l),...c,children:[i,e.jsx(wa,{className:"ml-auto h-4 w-4"})]}));sk.displayName=Zv.displayName;const tk=x.forwardRef(({className:l,...n},i)=>e.jsx(Wv,{ref:i,className:L("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",l),...n}));tk.displayName=Wv.displayName;const eN=x.forwardRef(({className:l,sideOffset:n=4,...i},c)=>e.jsx(ZC,{children:e.jsx(Vv,{ref:c,sideOffset:n,className:L("z-50 min-w-[8rem] overflow-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",l),...i})}));eN.displayName=Vv.displayName;const sN=x.forwardRef(({className:l,inset:n,...i},c)=>e.jsx(Kv,{ref:c,className:L("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",l),...i}));sN.displayName=Kv.displayName;const ak=x.forwardRef(({className:l,children:n,checked:i,...c},u)=>e.jsxs(Qv,{ref:u,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l),checked:i,...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xv,{children:e.jsx(yt,{className:"h-4 w-4"})})}),n]}));ak.displayName=Qv.displayName;const lk=x.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(Yv,{ref:c,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l),...i,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xv,{children:e.jsx(Nj,{className:"h-2 w-2 fill-current"})})}),n]}));lk.displayName=Yv.displayName;const nk=x.forwardRef(({className:l,inset:n,...i},c)=>e.jsx(Fv,{ref:c,className:L("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",l),...i}));nk.displayName=Fv.displayName;const rk=x.forwardRef(({className:l,...n},i)=>e.jsx(Jv,{ref:i,className:L("-mx-1 my-1 h-px bg-muted",l),...n}));rk.displayName=Jv.displayName;const tN=({className:l,...n})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:L("mx-auto flex w-full justify-center",l),...n});tN.displayName="Pagination";const aN=x.forwardRef(({className:l,...n},i)=>e.jsx("ul",{ref:i,className:L("flex flex-row items-center gap-1",l),...n}));aN.displayName="PaginationContent";const yo=x.forwardRef(({className:l,...n},i)=>e.jsx("li",{ref:i,className:L("",l),...n}));yo.displayName="PaginationItem";const Fo=({className:l,isActive:n,size:i="icon",...c})=>e.jsx("a",{"aria-current":n?"page":void 0,className:L(Er({variant:n?"outline":"ghost",size:i}),l),...c});Fo.displayName="PaginationLink";const lN=({className:l,...n})=>e.jsxs(Fo,{"aria-label":"Go to previous page",size:"default",className:L("gap-1 pl-2.5",l),...n,children:[e.jsx(el,{className:"h-4 w-4"}),e.jsx("span",{children:"上一页"})]});lN.displayName="PaginationPrevious";const nN=({className:l,...n})=>e.jsxs(Fo,{"aria-label":"Go to next page",size:"default",className:L("gap-1 pr-2.5",l),...n,children:[e.jsx("span",{children:"下一页"}),e.jsx(wa,{className:"h-4 w-4"})]});nN.displayName="PaginationNext";const wm=[{value:"created_at",label:"最新发布",icon:bl},{value:"downloads",label:"下载最多",icon:Kt},{value:"likes",label:"最受欢迎",icon:So}];function ik(){const l=xa(),[n,i]=x.useState([]),[c,u]=x.useState(!0),[m,h]=x.useState(""),[f,p]=x.useState("downloads"),[j,v]=x.useState(1),[N,b]=x.useState(1),[S,w]=x.useState(0),[O,M]=x.useState(new Set),[D,$]=x.useState(new Set),E=av(),_=x.useCallback(async()=>{u(!0);try{const H=await w_({status:"approved",page:j,page_size:12,search:m||void 0,sort_by:f,sort_order:"desc"});i(H.packs),b(H.total_pages),w(H.total);const Z=new Set;for(const re of H.packs)await tv(re.id,E)&&Z.add(re.id);M(Z)}catch(H){console.error("加载 Pack 列表失败:",H),qt({title:"加载 Pack 列表失败",variant:"destructive"})}finally{u(!1)}},[j,m,f,E]);x.useEffect(()=>{_()},[_]);const T=H=>{H.preventDefault(),v(1),_()},P=async H=>{if(!D.has(H)){$(Z=>new Set(Z).add(H));try{const Z=await sv(H,E);M(re=>{const ye=new Set(re);return Z.liked?ye.add(H):ye.delete(H),ye}),i(re=>re.map(ye=>ye.id===H?{...ye,likes:Z.likes}:ye))}catch(Z){console.error("点赞失败:",Z),qt({title:"点赞失败",variant:"destructive"})}finally{$(Z=>{const re=new Set(Z);return re.delete(H),re})}}},A=H=>{l({to:"/config/pack-market/$packId",params:{packId:H}})},ee=wm.find(H=>H.value===f)||wm[0];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(da,{className:"h-8 w-8",strokeWidth:2}),"配置模板市场"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"浏览和应用社区分享的模型配置模板,快速配置你的 MaiBot"})]}),e.jsxs(C,{variant:"outline",onClick:_,disabled:c,className:"gap-2",children:[e.jsx(At,{className:`h-4 w-4 ${c?"animate-spin":""}`}),"刷新"]})]})}),e.jsx(Xe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 flex-wrap",children:[e.jsx("form",{onSubmit:T,className:"flex-1 min-w-[200px] max-w-md",children:e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"搜索模板名称、描述...",value:m,onChange:H=>h(H.target.value),className:"pl-10"})]})}),e.jsxs(WC,{children:[e.jsx(ek,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"min-w-[140px] gap-2",children:[e.jsx(Pw,{className:"w-4 h-4"}),ee.label,e.jsx(Ra,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(eN,{align:"end",children:wm.map(H=>e.jsxs(sN,{onClick:()=>{p(H.value),v(1)},children:[e.jsx(H.icon,{className:"w-4 h-4 mr-2"}),H.label]},H.value))})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共找到 ",e.jsx("span",{className:"font-medium text-foreground",children:S})," 个模板"]}),c?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((H,Z)=>e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(Ks,{className:"h-6 w-3/4"}),e.jsx(Ks,{className:"h-4 w-full mt-2"})]}),e.jsx(We,{children:e.jsx(Ks,{className:"h-20 w-full"})}),e.jsx(Lo,{children:e.jsx(Ks,{className:"h-9 w-full"})})]},Z))}):n.length===0?e.jsx(Oe,{className:"py-12",children:e.jsxs(We,{className:"text-center text-muted-foreground",children:[e.jsx(da,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无模板"}),e.jsx("p",{className:"mt-1",children:"还没有人分享配置模板,快来分享第一个吧!"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(H=>e.jsx(ck,{pack:H,liked:O.has(H.id),liking:D.has(H.id),onLike:()=>P(H.id),onView:()=>A(H.id)},H.id))}),N>1&&e.jsx(tN,{children:e.jsxs(aN,{children:[e.jsx(yo,{children:e.jsx(lN,{onClick:()=>v(H=>Math.max(1,H-1)),className:j===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:N},(H,Z)=>Z+1).filter(H=>H===1||H===N||Math.abs(H-j)<=1).map((H,Z,re)=>{const ye=Z>0&&H-re[Z-1]>1;return e.jsxs(yo,{children:[ye&&e.jsx("span",{className:"px-2",children:"..."}),e.jsx(Fo,{onClick:()=>v(H),isActive:H===j,className:"cursor-pointer",children:H})]},H)}),e.jsx(yo,{children:e.jsx(nN,{onClick:()=>v(H=>Math.min(N,H+1)),className:j===N?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})})]})}function ck({pack:l,liked:n,liking:i,onLike:c,onView:u}){const m=h=>new Date(h).toLocaleDateString("zh-CN",{year:"numeric",month:"short",day:"numeric"});return e.jsxs(Oe,{className:"flex flex-col hover:shadow-md transition-shadow",children:[e.jsxs(ts,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ns,{className:"text-lg line-clamp-1",children:l.name}),e.jsxs(Ae,{variant:"secondary",className:"text-xs",children:["v",l.version]})]}),e.jsx(Qs,{className:"line-clamp-2 min-h-[40px]",children:l.description})]}),e.jsxs(We,{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cr,{className:"w-3.5 h-3.5"}),l.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bl,{className:"w-3.5 h-3.5"}),m(l.created_at)]})]}),e.jsxs("div",{className:"flex gap-4 text-sm",children:[e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"提供商数量",children:[e.jsx(wl,{className:"w-3.5 h-3.5"}),l.provider_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"模型数量",children:[e.jsx(Tn,{className:"w-3.5 h-3.5"}),l.model_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"任务配置数",children:[e.jsx(En,{className:"w-3.5 h-3.5"}),l.task_count]})]}),l.tags&&l.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[l.tags.slice(0,3).map(h=>e.jsxs(Ae,{variant:"outline",className:"text-xs",children:[e.jsx(Lm,{className:"w-2.5 h-2.5 mr-1"}),h]},h)),l.tags.length>3&&e.jsxs(Ae,{variant:"outline",className:"text-xs",children:["+",l.tags.length-3]})]})]}),e.jsx(Lo,{className:"pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"w-4 h-4"}),l.downloads]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),c()},disabled:i,className:`flex items-center gap-1 transition-colors ${n?"text-red-500":"hover:text-red-500"} ${i?"opacity-50":""}`,children:[e.jsx(So,{className:`w-4 h-4 ${n?"fill-current":""}`}),l.likes]})]}),e.jsx(C,{size:"sm",onClick:u,children:"查看详情"})]})})]})}var Ia="Accordion",ok=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ym,dk,uk]=ow(Ia),[Ko]=Do(Ia,[uk,Pg]),Xm=Pg(),rN=Ms.forwardRef((l,n)=>{const{type:i,...c}=l,u=c,m=c;return e.jsx(Ym.Provider,{scope:l.__scopeAccordion,children:i==="multiple"?e.jsx(fk,{...m,ref:n}):e.jsx(hk,{...u,ref:n})})});rN.displayName=Ia;var[iN,mk]=Ko(Ia),[cN,xk]=Ko(Ia,{collapsible:!1}),hk=Ms.forwardRef((l,n)=>{const{value:i,defaultValue:c,onValueChange:u=()=>{},collapsible:m=!1,...h}=l,[f,p]=zo({prop:i,defaultProp:c??"",onChange:u,caller:Ia});return e.jsx(iN,{scope:l.__scopeAccordion,value:Ms.useMemo(()=>f?[f]:[],[f]),onItemOpen:p,onItemClose:Ms.useCallback(()=>m&&p(""),[m,p]),children:e.jsx(cN,{scope:l.__scopeAccordion,collapsible:m,children:e.jsx(oN,{...h,ref:n})})})}),fk=Ms.forwardRef((l,n)=>{const{value:i,defaultValue:c,onValueChange:u=()=>{},...m}=l,[h,f]=zo({prop:i,defaultProp:c??[],onChange:u,caller:Ia}),p=Ms.useCallback(v=>f((N=[])=>[...N,v]),[f]),j=Ms.useCallback(v=>f((N=[])=>N.filter(b=>b!==v)),[f]);return e.jsx(iN,{scope:l.__scopeAccordion,value:h,onItemOpen:p,onItemClose:j,children:e.jsx(cN,{scope:l.__scopeAccordion,collapsible:!0,children:e.jsx(oN,{...m,ref:n})})})}),[pk,Qo]=Ko(Ia),oN=Ms.forwardRef((l,n)=>{const{__scopeAccordion:i,disabled:c,dir:u,orientation:m="vertical",...h}=l,f=Ms.useRef(null),p=Oo(f,n),j=dk(i),N=tj(u)==="ltr",b=Wl(l.onKeyDown,S=>{if(!ok.includes(S.key))return;const w=S.target,O=j().filter(ee=>!ee.ref.current?.disabled),M=O.findIndex(ee=>ee.ref.current===w),D=O.length;if(M===-1)return;S.preventDefault();let $=M;const E=0,_=D-1,T=()=>{$=M+1,$>_&&($=E)},P=()=>{$=M-1,$<E&&($=_)};switch(S.key){case"Home":$=E;break;case"End":$=_;break;case"ArrowRight":m==="horizontal"&&(N?T():P());break;case"ArrowDown":m==="vertical"&&T();break;case"ArrowLeft":m==="horizontal"&&(N?P():T());break;case"ArrowUp":m==="vertical"&&P();break}const A=$%D;O[A].ref.current?.focus()});return e.jsx(pk,{scope:i,disabled:c,direction:u,orientation:m,children:e.jsx(Ym.Slot,{scope:i,children:e.jsx(zn.div,{...h,"data-orientation":m,ref:p,onKeyDown:c?void 0:b})})})}),Ao="AccordionItem",[gk,Jm]=Ko(Ao),dN=Ms.forwardRef((l,n)=>{const{__scopeAccordion:i,value:c,...u}=l,m=Qo(Ao,i),h=mk(Ao,i),f=Xm(i),p=_m(),j=c&&h.value.includes(c)||!1,v=m.disabled||l.disabled;return e.jsx(gk,{scope:i,open:j,disabled:v,triggerId:p,children:e.jsx(Lg,{"data-orientation":m.orientation,"data-state":pN(j),...f,...u,ref:n,disabled:v,open:j,onOpenChange:N=>{N?h.onItemOpen(c):h.onItemClose(c)}})})});dN.displayName=Ao;var uN="AccordionHeader",mN=Ms.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=Qo(Ia,i),m=Jm(uN,i);return e.jsx(zn.h3,{"data-orientation":u.orientation,"data-state":pN(m.open),"data-disabled":m.disabled?"":void 0,...c,ref:n})});mN.displayName=uN;var Am="AccordionTrigger",xN=Ms.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=Qo(Ia,i),m=Jm(Am,i),h=xk(Am,i),f=Xm(i);return e.jsx(Ym.ItemSlot,{scope:i,children:e.jsx(L0,{"aria-disabled":m.open&&!h.collapsible||void 0,"data-orientation":u.orientation,id:m.triggerId,...f,...c,ref:n})})});xN.displayName=Am;var hN="AccordionContent",fN=Ms.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=Qo(Ia,i),m=Jm(hN,i),h=Xm(i);return e.jsx(U0,{role:"region","aria-labelledby":m.triggerId,"data-orientation":u.orientation,...h,...c,ref:n,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...l.style}})});fN.displayName=hN;function pN(l){return l?"open":"closed"}var jk=rN,vk=dN,Nk=mN,gN=xN,jN=fN;const bk=jk,vN=x.forwardRef(({className:l,...n},i)=>e.jsx(vk,{ref:i,className:L("border-b",l),...n}));vN.displayName="AccordionItem";const NN=x.forwardRef(({className:l,children:n,...i},c)=>e.jsx(Nk,{className:"flex",children:e.jsxs(gN,{ref:c,className:L("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",l),...i,children:[n,e.jsx(Ra,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));NN.displayName=gN.displayName;const bN=x.forwardRef(({className:l,children:n,...i},c)=>e.jsx(jN,{ref:c,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...i,children:e.jsx("div",{className:L("pb-4 pt-0",l),children:n})}));bN.displayName=jN.displayName;const yk={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"};function wk(){const{packId:l}=CN.useParams(),n=xa(),[i,c]=x.useState(null),[u,m]=x.useState(!0),[h,f]=x.useState(!1),[p,j]=x.useState(!1),[v,N]=x.useState(!1),[b,S]=x.useState(1),[w,O]=x.useState(null),[M,D]=x.useState(!1),[$,E]=x.useState(!1),[_,T]=x.useState({apply_providers:!0,apply_models:!0,apply_task_config:!0,task_mode:"append",selected_providers:void 0,selected_models:void 0,selected_tasks:void 0}),[P,A]=x.useState({}),[ee,H]=x.useState({}),Z=av(),re=x.useCallback(async()=>{if(l){m(!0);try{const z=await __(l);c(z);const Q=await tv(l,Z);f(Q)}catch(z){console.error("加载 Pack 失败:",z),qt({title:"加载模板失败",variant:"destructive"})}finally{m(!1)}}},[l,Z]);x.useEffect(()=>{re()},[re]);const ye=async()=>{if(!(!l||p)){j(!0);try{const z=await sv(l,Z);f(z.liked),i&&c({...i,likes:z.likes})}catch(z){console.error("点赞失败:",z),qt({title:"点赞失败",variant:"destructive"})}finally{j(!1)}}},de=async()=>{if(i){N(!0),S(1),D(!0);try{const z=await k_(i);O(z);const Q={};for(const U of z.existing_providers)Q[U.pack_provider.name]=U.local_providers[0].name;A(Q);const J={};for(const U of z.new_providers)J[U.name]="";H(J)}catch(z){console.error("检测冲突失败:",z),qt({title:"检测配置冲突失败",variant:"destructive"}),N(!1)}finally{D(!1)}}},ge=async()=>{if(i){if(_.apply_providers&&w){for(const z of w.new_providers)if(!ee[z.name]){qt({title:`请填写提供商 "${z.name}" 的 API Key`,variant:"destructive"});return}}E(!0);try{await T_(i,_,P,ee),await C_(i.id,Z),c({...i,downloads:i.downloads+1}),qt({title:"配置模板应用成功!"}),N(!1)}catch(z){console.error("应用 Pack 失败:",z),qt({title:z instanceof Error?z.message:"应用配置失败",variant:"destructive"})}finally{E(!1)}}},je=z=>new Date(z).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"});return u?e.jsx(Sk,{}):i?e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(Xe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>n({to:"/config/pack-market"}),className:"gap-2",children:[e.jsx(sn,{className:"w-4 h-4"}),"返回市场"]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(da,{className:"w-10 h-10 text-primary mt-1"}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[i.name,e.jsxs(Ae,{variant:"secondary",children:["v",i.version]})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:i.description})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cr,{className:"w-4 h-4"}),i.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bl,{className:"w-4 h-4"}),je(i.created_at)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"w-4 h-4"}),i.downloads," 次下载"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(So,{className:`w-4 h-4 ${h?"fill-red-500 text-red-500":""}`}),i.likes," 赞"]})]}),i.tags&&i.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:i.tags.map(z=>e.jsxs(Ae,{variant:"outline",children:[e.jsx(Lm,{className:"w-3 h-3 mr-1"}),z]},z))})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsxs(C,{size:"lg",onClick:de,children:[e.jsx(Kt,{className:"w-4 h-4 mr-2"}),"应用模板"]}),e.jsxs(C,{variant:"outline",onClick:ye,disabled:p,className:h?"text-red-500 border-red-200":"",children:[e.jsx(So,{className:`w-4 h-4 mr-2 ${h?"fill-current":""}`}),h?"已点赞":"点赞"]})]})]}),e.jsx(Dr,{}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Oe,{children:e.jsxs(We,{className:"flex items-center gap-3 py-4",children:[e.jsx(wl,{className:"w-8 h-8 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.providers.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"API 提供商"})]})]})}),e.jsx(Oe,{children:e.jsxs(We,{className:"flex items-center gap-3 py-4",children:[e.jsx(Tn,{className:"w-8 h-8 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.models.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"模型配置"})]})]})}),e.jsx(Oe,{children:e.jsxs(We,{className:"flex items-center gap-3 py-4",children:[e.jsx(En,{className:"w-8 h-8 text-purple-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:Object.keys(i.task_config).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"任务配置"})]})]})})]}),e.jsxs(ma,{defaultValue:"providers",className:"space-y-4",children:[e.jsxs(Xt,{children:[e.jsxs(ss,{value:"providers",children:[e.jsx(wl,{className:"w-4 h-4 mr-2"}),"提供商 (",i.providers.length,")"]}),e.jsxs(ss,{value:"models",children:[e.jsx(Tn,{className:"w-4 h-4 mr-2"}),"模型 (",i.models.length,")"]}),e.jsxs(ss,{value:"tasks",children:[e.jsx(En,{className:"w-4 h-4 mr-2"}),"任务配置 (",Object.keys(i.task_config).length,")"]})]}),e.jsx(Ss,{value:"providers",children:e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"API 提供商"}),e.jsx(Qs,{children:"模板中包含的 API 提供商配置(不含 API Key"})]}),e.jsx(We,{children:e.jsxs(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{children:"名称"}),e.jsx(Ye,{children:"Base URL"}),e.jsx(Ye,{children:"类型"})]})}),e.jsx(Cl,{children:i.providers.map(z=>e.jsxs(lt,{children:[e.jsx(Ge,{className:"font-medium",children:z.name}),e.jsx(Ge,{className:"text-muted-foreground font-mono text-sm",children:z.base_url}),e.jsx(Ge,{children:e.jsx(Ae,{variant:"outline",children:z.client_type})})]},z.name))})]})})]})}),e.jsx(Ss,{value:"models",children:e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"模型配置"}),e.jsx(Qs,{children:"模板中包含的模型配置"})]}),e.jsx(We,{children:e.jsxs(_l,{children:[e.jsx(Sl,{children:e.jsxs(lt,{children:[e.jsx(Ye,{children:"模型名称"}),e.jsx(Ye,{children:"标识符"}),e.jsx(Ye,{children:"提供商"}),e.jsx(Ye,{className:"text-right",children:"价格 (入/出)"})]})}),e.jsx(Cl,{children:i.models.map(z=>e.jsxs(lt,{children:[e.jsx(Ge,{className:"font-medium",children:z.name}),e.jsx(Ge,{className:"text-muted-foreground font-mono text-sm",children:z.model_identifier}),e.jsx(Ge,{children:z.api_provider}),e.jsxs(Ge,{className:"text-right text-muted-foreground",children:["¥",z.price_in," / ¥",z.price_out]})]},z.name))})]})})]})}),e.jsx(Ss,{value:"tasks",children:e.jsxs(Oe,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"任务配置"}),e.jsx(Qs,{children:"模板中各任务类型的模型分配"})]}),e.jsx(We,{children:e.jsx(bk,{type:"multiple",className:"w-full",children:Object.entries(i.task_config).map(([z,Q])=>e.jsxs(vN,{value:z,children:[e.jsx(NN,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dn,{className:"w-4 h-4"}),yk[z]||z,e.jsxs(Ae,{variant:"secondary",className:"ml-2",children:[Q.model_list.length," 个模型"]})]})}),e.jsx(bN,{children:e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"分配的模型:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Q.model_list.map(J=>e.jsx(Ae,{variant:"outline",children:J},J))}),Q.temperature!==void 0&&e.jsxs("div",{className:"text-sm",children:["Temperature: ",e.jsx("span",{className:"font-mono",children:Q.temperature})]}),Q.max_tokens!==void 0&&e.jsxs("div",{className:"text-sm",children:["Max Tokens: ",e.jsx("span",{className:"font-mono",children:Q.max_tokens})]})]})})]},z))})})]})})]}),e.jsx(_k,{open:v,onOpenChange:N,pack:i,step:b,setStep:S,conflicts:w,detectingConflicts:M,applying:$,options:_,setOptions:T,_providerMapping:P,_setProviderMapping:A,newProviderApiKeys:ee,setNewProviderApiKeys:H,onApply:ge})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(da,{className:"w-16 h-16 mx-auto mb-4 opacity-50"}),e.jsx("h2",{className:"text-xl font-semibold",children:"模板不存在"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"该配置模板可能已被删除或尚未通过审核"}),e.jsxs(C,{className:"mt-4",onClick:()=>n({to:"/config/pack-market"}),children:[e.jsx(sn,{className:"w-4 h-4 mr-2"}),"返回市场"]})]})}function _k({open:l,onOpenChange:n,pack:i,step:c,setStep:u,conflicts:m,detectingConflicts:h,applying:f,options:p,setOptions:j,_providerMapping:v,_setProviderMapping:N,newProviderApiKeys:b,setNewProviderApiKeys:S,onApply:w}){return e.jsx(Hs,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Rs,{children:[e.jsxs(Ls,{className:"flex items-center gap-2",children:[e.jsx(da,{className:"w-5 h-5"}),"应用配置模板"]}),e.jsxs(Ws,{children:["步骤 ",c," / ",3,"",c===1&&"选择要应用的内容",c===2&&"配置提供商映射",c===3&&"确认并应用"]})]}),h?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Xs,{className:"w-8 h-8 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"正在检测配置冲突..."})]}):e.jsxs(e.Fragment,{children:[c===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"apply_providers",checked:p.apply_providers,onCheckedChange:M=>j({...p,apply_providers:M})}),e.jsxs(k,{htmlFor:"apply_providers",className:"flex items-center gap-2",children:[e.jsx(wl,{className:"w-4 h-4"}),"应用提供商配置 (",i.providers.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"apply_models",checked:p.apply_models,onCheckedChange:M=>j({...p,apply_models:M})}),e.jsxs(k,{htmlFor:"apply_models",className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"w-4 h-4"}),"应用模型配置 (",i.models.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Js,{id:"apply_task_config",checked:p.apply_task_config,onCheckedChange:M=>j({...p,apply_task_config:M})}),e.jsxs(k,{htmlFor:"apply_task_config",className:"flex items-center gap-2",children:[e.jsx(En,{className:"w-4 h-4"}),"应用任务配置 (",Object.keys(i.task_config).length," 个)"]})]})]}),p.apply_task_config&&e.jsxs("div",{className:"pl-6 space-y-2 border-l-2 border-muted",children:[e.jsx(k,{className:"text-sm font-medium",children:"任务配置应用模式"}),e.jsxs(Qm,{value:p.task_mode,onValueChange:M=>j({...p,task_mode:M}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Mo,{value:"append",id:"mode_append"}),e.jsx(k,{htmlFor:"mode_append",className:"font-normal",children:"追加模式 - 将模板中的模型添加到现有配置"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Mo,{value:"replace",id:"mode_replace"}),e.jsx(k,{htmlFor:"mode_replace",className:"font-normal",children:"替换模式 - 用模板配置完全替换现有配置"})]})]})]})]}),c===2&&m&&e.jsxs("div",{className:"space-y-4",children:[p.apply_providers&&m.existing_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(Sn,{children:"发现已有的提供商"}),e.jsx(_t,{children:"以下提供商的 URL 与您本地配置中的提供商匹配,将自动使用本地提供商:"})]}),e.jsx("div",{className:"space-y-2",children:m.existing_providers.map(({pack_provider:M,local_providers:D})=>e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx(yt,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"font-medium flex-shrink-0",children:M.name}),e.jsx(wa,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),D.length===1?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:D[0].name}),e.jsx(Ae,{variant:"outline",className:"ml-auto",children:"URL 匹配"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($e,{value:v[M.name]||D[0].name,onValueChange:$=>N({...v,[M.name]:$}),children:[e.jsx(Le,{className:"w-[200px]",children:e.jsx(He,{})}),e.jsx(Ue,{children:D.map($=>e.jsx(le,{value:$.name,children:$.name},$.name))})]}),e.jsxs(Ae,{variant:"outline",className:"ml-auto",children:[D.length," 个匹配"]})]})]},M.name))})]}),p.apply_providers&&m.new_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(wt,{variant:"destructive",children:[e.jsx(oa,{className:"h-4 w-4"}),e.jsx(Sn,{children:"需要配置 API Key"}),e.jsx(_t,{children:"以下提供商在您的本地配置中不存在,需要填写 API Key"})]}),e.jsx("div",{className:"space-y-4",children:m.new_providers.map(M=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",M.base_url,")"]})]}),e.jsx(ce,{type:"password",placeholder:`输入 ${M.name} 的 API Key`,value:b[M.name]||"",onChange:D=>S({...b,[M.name]:D.target.value})})]},M.name))})]}),(!p.apply_providers||m.existing_providers.length===0&&m.new_providers.length===0)&&e.jsxs(wt,{children:[e.jsx(yt,{className:"h-4 w-4"}),e.jsx(Sn,{children:"无需配置"}),e.jsx(_t,{children:"模板中没有提供商配置,或您选择不应用提供商。"})]})]}),c===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(wt,{children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx(Sn,{children:"确认应用"}),e.jsx(_t,{children:"请确认以下将要应用的内容:"})]}),e.jsxs("div",{className:"space-y-2",children:[p.apply_providers&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(yt,{className:"w-4 h-4 text-green-500"}),e.jsx(wl,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",i.providers.length," 个提供商配置"]})]}),p.apply_models&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(yt,{className:"w-4 h-4 text-green-500"}),e.jsx(Tn,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",i.models.length," 个模型配置"]})]}),p.apply_task_config&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(yt,{className:"w-4 h-4 text-green-500"}),e.jsx(En,{className:"w-4 h-4"}),e.jsxs("span",{children:[p.task_mode==="append"?"追加":"替换"," ",Object.keys(i.task_config).length," 个任务配置"]})]})]}),m&&m.new_providers.length>0&&e.jsxs(wt,{variant:"destructive",children:[e.jsx(oa,{className:"h-4 w-4"}),e.jsxs(_t,{children:["将添加 ",m.new_providers.length," 个新提供商,请确保已填写正确的 API Key。"]})]})]})]}),e.jsxs(nt,{className:"flex justify-between",children:[e.jsx("div",{children:c>1&&!h&&e.jsx(C,{variant:"outline",onClick:()=>u(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:()=>n(!1),disabled:f,children:"取消"}),c<3?e.jsx(C,{onClick:()=>u(c+1),disabled:h,children:"下一步"}):e.jsxs(C,{onClick:w,disabled:f,children:[f&&e.jsx(Xs,{className:"w-4 h-4 mr-2 animate-spin"}),"应用模板"]})]})]})]})})}function Sk(){return e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(Xe,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Ks,{className:"h-9 w-24"}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ks,{className:"w-10 h-10"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Ks,{className:"h-8 w-2/3"}),e.jsx(Ks,{className:"h-4 w-full"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(Ks,{className:"h-4 w-24"}),e.jsx(Ks,{className:"h-4 w-32"}),e.jsx(Ks,{className:"h-4 w-28"}),e.jsx(Ks,{className:"h-4 w-20"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ks,{className:"h-6 w-20"}),e.jsx(Ks,{className:"h-6 w-24"}),e.jsx(Ks,{className:"h-6 w-16"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsx(Ks,{className:"h-10 w-full"}),e.jsx(Ks,{className:"h-10 w-full"})]})]}),e.jsx(Ks,{className:"h-px w-full"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ks,{className:"h-24"}),e.jsx(Ks,{className:"h-24"}),e.jsx(Ks,{className:"h-24"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ks,{className:"h-10 w-32"}),e.jsx(Ks,{className:"h-10 w-32"}),e.jsx(Ks,{className:"h-10 w-32"})]}),e.jsx(Ks,{className:"h-96 w-full"})]})]})})})}function Ck(){const l=xa(),[n,i]=x.useState(!0);return x.useEffect(()=>{let c=!1;return(async()=>{try{const m=await $i();!c&&!m&&l({to:"/auth"})}catch{c||l({to:"/auth"})}finally{c||i(!1)}})(),()=>{c=!0}},[l]),{checking:n}}async function kk(){return await $i()}const Tk=Mr("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"}}),yN=x.forwardRef(({className:l,size:n,abbrTitle:i,children:c,...u},m)=>e.jsx("kbd",{className:L(Tk({size:n,className:l})),ref:m,...u,children:i?e.jsx("abbr",{title:i,children:c}):c}));yN.displayName="Kbd";const Ek=[{icon:Ro,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:Ga,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:wl,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:yj,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:Dm,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:en,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:wj,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:Tr,title:"黑话管理",description:"管理麦麦学习到的黑话和俚语",path:"/resource/jargon",category:"资源"},{icon:Iw,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:da,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:Om,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:Dn,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function Mk({open:l,onOpenChange:n}){const[i,c]=x.useState(""),[u,m]=x.useState(0),h=xa(),f=Ek.filter(v=>v.title.toLowerCase().includes(i.toLowerCase())||v.description.toLowerCase().includes(i.toLowerCase())||v.category.toLowerCase().includes(i.toLowerCase()));x.useEffect(()=>{l&&(c(""),m(0))},[l]);const p=x.useCallback(v=>{h({to:v}),n(!1)},[h,n]),j=x.useCallback(v=>{v.key==="ArrowDown"?(v.preventDefault(),m(N=>(N+1)%f.length)):v.key==="ArrowUp"?(v.preventDefault(),m(N=>(N-1+f.length)%f.length)):v.key==="Enter"&&f[u]&&(v.preventDefault(),p(f[u].path))},[f,u,p]);return e.jsx(Hs,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(Rs,{className:"px-4 pt-4 pb-0",children:[e.jsx(Ls,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ce,{value:i,onChange:v=>{c(v.target.value),m(0)},onKeyDown:j,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(Xe,{className:"h-[400px]",children:f.length>0?e.jsx("div",{className:"p-2",children:f.map((v,N)=>{const b=v.icon;return e.jsxs("button",{onClick:()=>p(v.path),onMouseEnter:()=>m(N),className:L("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",N===u?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[e.jsx(b,{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(Vt,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),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"}),"关闭"]})]})})]})})}function Ak(){const l=window.location.protocol==="http:",n=sessionStorage.getItem("http-warning-dismissed")==="true",[i,c]=x.useState(l&&!n),[u,m]=x.useState(!1),h=()=>{m(!0),c(!1),sessionStorage.setItem("http-warning-dismissed","true")};return!i||u?null:e.jsx("div",{className:"relative bg-amber-500/10 border-b border-amber-500/20 backdrop-blur-sm",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(oa,{className:"h-5 w-5 text-amber-600 dark:text-amber-500 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:[e.jsx("span",{className:"font-semibold",children:"安全警告:"}),"您正在使用 ",e.jsx("strong",{children:"HTTP"})," 访问 MaiBot WebUI"]}),e.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200 mt-1",children:"如果这是公网服务器,您的数据(包括 Token、聊天记录等可能在传输过程中被窃取。强烈建议使用 HTTPS 访问或仅在本地网络使用。"})]})]}),e.jsx(C,{variant:"ghost",size:"icon",onClick:h,className:"h-8 w-8 text-amber-700 hover:text-amber-900 dark:text-amber-400 dark:hover:text-amber-200 flex-shrink-0","aria-label":"关闭警告",children:e.jsx(Ja,{className:"h-4 w-4"})})]})})})}const zk=uw,Dk=mw,Ok=xw,wN=x.forwardRef(({className:l,sideOffset:n=4,...i},c)=>e.jsx(dw,{children:e.jsx(aj,{ref:c,sideOffset:n,className:L("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]",l),...i})}));wN.displayName=aj.displayName;function Rk({children:l}){const{checking:n}=Ck(),[i,c]=x.useState(!0),[u,m]=x.useState(!1),[h,f]=x.useState(!1),{theme:p,setTheme:j}=Um(),v=Vy();if(x.useEffect(()=>{const O=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),f(!0))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[]),n)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"text-muted-foreground",children:"正在验证登录状态..."})});const N=[{title:"概览",items:[{icon:Ro,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:Ga,label:"麦麦主程序配置",path:"/config/bot"},{icon:wl,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:yj,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:Fp,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:Dm,label:"表情包管理",path:"/resource/emoji"},{icon:en,label:"表达方式管理",path:"/resource/expression"},{icon:Tr,label:"黑话管理",path:"/resource/jargon"},{icon:wj,label:"人物信息管理",path:"/resource/person"},{icon:gj,label:"知识库图谱可视化",path:"/resource/knowledge-graph"}]},{title:"扩展与监控",items:[{icon:da,label:"插件市场",path:"/plugins"},{icon:vj,label:"配置模板市场",path:"/config/pack-market"},{icon:Fp,label:"插件配置",path:"/plugin-config"},{icon:Om,label:"日志查看器",path:"/logs"},{icon:en,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:Dn,label:"系统设置",path:"/settings"}]}],S=p==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":p,w=async()=>{await _1()};return e.jsx(zk,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:L("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",i?"lg:w-64":"lg:w-16",u?"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:L("relative flex items-center justify-center flex-1 transition-all overflow-hidden","lg:flex-1",!i&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:L("flex items-baseline gap-2",!i&&"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:K1()})]}),!i&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(Xe,{className:L("flex-1 overflow-x-hidden",!i&&"lg:w-16"),children:e.jsx("nav",{className:L("p-4",!i&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:L("space-y-6",!i&&"lg:space-y-3 lg:w-full"),children:N.map((O,M)=>e.jsxs("li",{children:[e.jsx("div",{className:L("px-3 h-[1.25rem]","mb-2",!i&&"lg:mb-1 lg:invisible"),children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:O.title})}),!i&&M>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:O.items.map(D=>{const $=v({to:D.path}),E=D.icon,_=e.jsxs(e.Fragment,{children:[$&&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:L("flex items-center transition-all duration-300",i?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(E,{className:L("h-5 w-5 flex-shrink-0",$&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:L("text-sm font-medium whitespace-nowrap transition-all duration-300",$&&"font-semibold",i?"opacity-100 max-w-[200px]":"opacity-100 max-w-[200px] lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:D.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(Dk,{children:[e.jsx(Ok,{asChild:!0,children:e.jsx(br,{to:D.path,"data-tour":D.tourId,className:L("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",$?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground",i?"px-3":"px-3 lg:px-0 lg:justify-center lg:w-12 lg:mx-auto"),onClick:()=>m(!1),children:_})}),!i&&e.jsx(wN,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:D.label})})]})},D.path)})})]},O.title))})})})]}),u&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>m(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(Ak,{}),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:()=>m(!u),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(qw,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>c(!i),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:i?"收起侧边栏":"展开侧边栏",children:e.jsx(el,{className:L("h-5 w-5 transition-transform",!i&&"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(Vt,{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(yN,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(Mk,{open:h,onOpenChange:f}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(Vw,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:O=>{B1(S==="dark"?"light":"dark",j,O)},className:"rounded-lg p-2 hover:bg-accent",title:S==="dark"?"切换到浅色模式":"切换到深色模式",children:S==="dark"?e.jsx(uj,{className:"h-5 w-5"}):e.jsx(mj,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:w,className:"gap-2",title:"登出系统",children:[e.jsx(Fw,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:l})]})]})})}function Lk(l){const n=l.split(`
`).slice(1),i=[];for(const c of n){const u=c.trim();if(!u.startsWith("at "))continue;const m=u.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);m?i.push({functionName:m[1]||"<anonymous>",fileName:m[2],lineNumber:m[3],columnNumber:m[4],raw:u}):i.push({functionName:"<unknown>",fileName:"",lineNumber:"",columnNumber:"",raw:u})}return i}function Uk({error:l,errorInfo:n}){const[i,c]=x.useState(!0),[u,m]=x.useState(!1),[h,f]=x.useState(!1),p=l.stack?Lk(l.stack):[],j=async()=>{const v=`
Error: ${l.name}
Message: ${l.message}
Stack Trace:
${l.stack||"No stack trace available"}
Component Stack:
${n?.componentStack||"No component stack available"}
URL: ${window.location.href}
User Agent: ${navigator.userAgent}
Time: ${new Date().toISOString()}
`.trim();try{await navigator.clipboard.writeText(v),f(!0),setTimeout(()=>f(!1),2e3)}catch(N){console.error("Failed to copy:",N)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(wt,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(oa,{className:"h-4 w-4"}),e.jsxs(_t,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[l.name,":"]})," ",l.message]})]}),p.length>0&&e.jsxs(Pi,{open:i,onOpenChange:c,children:[e.jsx(Ii,{asChild:!0,children:e.jsxs(C,{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(Kw,{className:"h-4 w-4"}),"Stack Trace (",p.length," frames)"]}),i?e.jsx(kr,{className:"h-4 w-4"}):e.jsx(Ra,{className:"h-4 w-4"})]})}),e.jsx(qi,{children:e.jsx(Xe,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:p.map((v,N)=>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:[N+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]})]})]})]})},N))})})})]}),n?.componentStack&&e.jsxs(Pi,{open:u,onOpenChange:m,children:[e.jsx(Ii,{asChild:!0,children:e.jsxs(C,{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(oa,{className:"h-4 w-4"}),"Component Stack"]}),u?e.jsx(kr,{className:"h-4 w-4"}):e.jsx(Ra,{className:"h-4 w-4"})]})}),e.jsx(qi,{children:e.jsx(Xe,{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:n.componentStack})})})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:j,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(_o,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function _N({error:l,errorInfo:n}){const i=()=>{window.location.href="/"},c=()=>{window.location.reload()};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Oe,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(ts,{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(oa,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(ns,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(Qs,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(We,{className:"space-y-4",children:[e.jsx(Uk,{error:l,errorInfo:n}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:[e.jsxs(C,{onClick:c,className:"flex-1",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(C,{onClick:i,variant:"outline",className:"flex-1",children:[e.jsx(Ro,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class Bk extends x.Component{constructor(n){super(n),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){console.error("ErrorBoundary caught an error:",n,i),this.setState({errorInfo:i})}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(_N,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function SN({error:l}){return e.jsx(_N,{error:l,errorInfo:null})}const Yi=Fy({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(vg,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!kk())throw Qy({to:"/auth"})}}),$k=rt({getParentRoute:()=>Yi,path:"/auth",component:o2}),Hk=rt({getParentRoute:()=>Yi,path:"/setup",component:S2}),gt=rt({getParentRoute:()=>Yi,id:"protected",component:()=>e.jsx(Rk,{children:e.jsx(vg,{})}),errorComponent:({error:l})=>e.jsx(SN,{error:l})}),Gk=rt({getParentRoute:()=>gt,path:"/",component:O1}),Pk=rt({getParentRoute:()=>gt,path:"/config/bot",component:n_}),Ik=rt({getParentRoute:()=>gt,path:"/config/modelProvider",component:g_}),qk=rt({getParentRoute:()=>gt,path:"/config/model",component:I_}),Vk=rt({getParentRoute:()=>gt,path:"/config/adapter",component:mS}),Fk=rt({getParentRoute:()=>gt,path:"/resource/emoji",component:RS}),Kk=rt({getParentRoute:()=>gt,path:"/resource/expression",component:KS}),Qk=rt({getParentRoute:()=>gt,path:"/resource/person",component:g4}),Yk=rt({getParentRoute:()=>gt,path:"/resource/jargon",component:i4}),Xk=rt({getParentRoute:()=>gt,path:"/resource/knowledge-graph",component:C4}),Jk=rt({getParentRoute:()=>gt,path:"/logs",component:T4}),Zk=rt({getParentRoute:()=>gt,path:"/chat",component:fC}),Wk=rt({getParentRoute:()=>gt,path:"/plugins",component:W4}),e3=rt({getParentRoute:()=>gt,path:"/model-presets",component:sC}),s3=rt({getParentRoute:()=>gt,path:"/plugin-config",component:lC}),t3=rt({getParentRoute:()=>gt,path:"/plugin-mirrors",component:rC}),a3=rt({getParentRoute:()=>gt,path:"/settings",component:a2}),l3=rt({getParentRoute:()=>gt,path:"/config/pack-market",component:ik}),CN=rt({getParentRoute:()=>gt,path:"/config/pack-market/$packId",component:wk}),n3=rt({getParentRoute:()=>gt,path:"/survey/webui-feedback",component:AC}),r3=rt({getParentRoute:()=>gt,path:"/survey/maibot-feedback",component:zC}),i3=rt({getParentRoute:()=>Yi,path:"*",component:Fj}),c3=Yi.addChildren([$k,Hk,gt.addChildren([Gk,Pk,Ik,qk,Vk,Fk,Kk,Yk,Qk,Xk,Wk,e3,s3,t3,Jk,Zk,a3,l3,CN,n3,r3]),i3]),o3=Ky({routeTree:c3,defaultNotFoundComponent:Fj,defaultErrorComponent:({error:l})=>e.jsx(SN,{error:l})});function d3({children:l,defaultTheme:n="system",storageKey:i="ui-theme",...c}){const[u,m]=x.useState(()=>localStorage.getItem(i)||n);x.useEffect(()=>{const f=window.document.documentElement;if(f.classList.remove("light","dark"),u==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(p);return}f.classList.add(u)},[u]),x.useEffect(()=>{const f=localStorage.getItem("accent-color");if(f){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%)"}}[f];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 h={theme:u,setTheme:f=>{localStorage.setItem(i,f),m(f)}};return e.jsx(Hj.Provider,{...c,value:h,children:l})}function u3({children:l,defaultEnabled:n=!0,defaultWavesEnabled:i=!0,storageKey:c="enable-animations",wavesStorageKey:u="enable-waves-background"}){const[m,h]=x.useState(()=>{const v=localStorage.getItem(c);return v!==null?v==="true":n}),[f,p]=x.useState(()=>{const v=localStorage.getItem(u);return v!==null?v==="true":i});x.useEffect(()=>{const v=document.documentElement;m?v.classList.remove("no-animations"):v.classList.add("no-animations"),localStorage.setItem(c,String(m))},[m,c]),x.useEffect(()=>{localStorage.setItem(u,String(f))},[f,u]);const j={enableAnimations:m,setEnableAnimations:h,enableWavesBackground:f,setEnableWavesBackground:p};return e.jsx(Gj.Provider,{value:j,children:l})}const m3=hw,kN=x.forwardRef(({className:l,...n},i)=>e.jsx(lj,{ref:i,className:L("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px] gap-2",l),...n}));kN.displayName=lj.displayName;const x3=Mr("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"}}),TN=x.forwardRef(({className:l,variant:n,...i},c)=>e.jsx(nj,{ref:c,className:L(x3({variant:n}),l),...i}));TN.displayName=nj.displayName;const h3=x.forwardRef(({className:l,...n},i)=>e.jsx(rj,{ref:i,className:L("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",l),...n}));h3.displayName=rj.displayName;const EN=x.forwardRef(({className:l,...n},i)=>e.jsx(ij,{ref:i,className:L("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",l),"toast-close":"",...n,children:e.jsx(Ja,{className:"h-4 w-4"})}));EN.displayName=ij.displayName;const MN=x.forwardRef(({className:l,...n},i)=>e.jsx(cj,{ref:i,className:L("text-sm font-semibold [&+div]:text-xs",l),...n}));MN.displayName=cj.displayName;const AN=x.forwardRef(({className:l,...n},i)=>e.jsx(oj,{ref:i,className:L("text-sm opacity-90",l),...n}));AN.displayName=oj.displayName;function f3(){const{toasts:l}=et();return e.jsxs(m3,{children:[l.map(function({id:n,title:i,description:c,action:u,...m}){return e.jsxs(TN,{...m,children:[e.jsxs("div",{className:"grid gap-1",children:[i&&e.jsx(MN,{children:i}),c&&e.jsx(AN,{children:c})]}),u,e.jsx(EN,{})]},n)}),e.jsx(kN,{})]})}w1.createRoot(document.getElementById("root")).render(e.jsx(x.StrictMode,{children:e.jsx(Bk,{children:e.jsx(d3,{defaultTheme:"system",children:e.jsx(u3,{children:e.jsxs(u_,{children:[e.jsx(Yy,{router:o3}),e.jsx(h_,{}),e.jsx(f3,{})]})})})})}));