rt?(Bn=et,et=null):Bn=et.sibling;var gi=je(oe,et,wt.value,Re);if(gi===null){et===null&&(et=Bn);break}l&&et&&gi.alternate===null&&d(oe,et),ee=S(gi,ee,rt),Ze===null?Ue=gi:Ze.sibling=gi,Ze=gi,et=Bn}if(wt.done)return p(oe,et),nn&&uo(oe,rt),Ue;if(et===null){for(;!wt.done;rt++,wt=ue.next())wt=Ce(oe,wt.value,Re),wt!==null&&(ee=S(wt,ee,rt),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return nn&&uo(oe,rt),Ue}for(et=x(oe,et);!wt.done;rt++,wt=ue.next())wt=Le(et,oe,rt,wt.value,Re),wt!==null&&(l&&wt.alternate!==null&&et.delete(wt.key===null?rt:wt.key),ee=S(wt,ee,rt),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return l&&et.forEach(function(bE){return d(oe,bE)}),nn&&uo(oe,rt),Ue}function Nn(oe,ee,ue,Re){if(typeof ue=="object"&&ue!==null&&ue.type===L&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case P:e:{for(var Ue=ue.key,Ze=ee;Ze!==null;){if(Ze.key===Ue){if(Ue=ue.type,Ue===L){if(Ze.tag===7){p(oe,Ze.sibling),ee=w(Ze,ue.props.children),ee.return=oe,oe=ee;break e}}else if(Ze.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===G&&ib(Ue)===Ze.type){p(oe,Ze.sibling),ee=w(Ze,ue.props),ee.ref=Oc(oe,Ze,ue),ee.return=oe,oe=ee;break e}p(oe,Ze);break}else d(oe,Ze);Ze=Ze.sibling}ue.type===L?(ee=bo(ue.props.children,oe.mode,Re,ue.key),ee.return=oe,oe=ee):(Re=_u(ue.type,ue.key,ue.props,null,oe.mode,Re),Re.ref=Oc(oe,ee,ue),Re.return=oe,oe=Re)}return I(oe);case H:e:{for(Ze=ue.key;ee!==null;){if(ee.key===Ze)if(ee.tag===4&&ee.stateNode.containerInfo===ue.containerInfo&&ee.stateNode.implementation===ue.implementation){p(oe,ee.sibling),ee=w(ee,ue.children||[]),ee.return=oe,oe=ee;break e}else{p(oe,ee);break}else d(oe,ee);ee=ee.sibling}ee=Im(ue,oe.mode,Re),ee.return=oe,oe=ee}return I(oe);case G:return Ze=ue._init,Nn(oe,ee,Ze(ue._payload),Re)}if(Lt(ue))return $e(oe,ee,ue,Re);if(Y(ue))return We(oe,ee,ue,Re);fu(oe,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"?(ue=""+ue,ee!==null&&ee.tag===6?(p(oe,ee.sibling),ee=w(ee,ue),ee.return=oe,oe=ee):(p(oe,ee),ee=Am(ue,oe.mode,Re),ee.return=oe,oe=ee),I(oe)):p(oe,ee)}return Nn}var ml=ob(!0),lb=ob(!1),pu=ai(null),mu=null,gl=null,$p=null;function Bp(){$p=gl=mu=null}function Vp(l){var d=pu.current;Qt(pu),l._currentValue=d}function Hp(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function xl(l,d){mu=l,$p=gl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Os=!0),l.firstContext=null)}function ar(l){var d=l._currentValue;if($p!==l)if(l={context:l,memoizedValue:d,next:null},gl===null){if(mu===null)throw Error(n(308));gl=l,mu.dependencies={lanes:0,firstContext:l}}else gl=gl.next=l;return d}var ho=null;function Wp(l){ho===null?ho=[l]:ho.push(l)}function cb(l,d,p,x){var w=d.interleaved;return w===null?(p.next=p,Wp(d)):(p.next=w.next,w.next=p),d.interleaved=p,Ca(l,x)}function Ca(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var li=!1;function Up(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function db(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Ea(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function ci(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(vt&2)!==0){var w=x.pending;return w===null?d.next=d:(d.next=w.next,w.next=d),x.pending=d,Ca(l,p)}return w=x.interleaved,w===null?(d.next=d,Wp(x)):(d.next=w.next,w.next=d),x.interleaved=d,Ca(l,p)}function gu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}function ub(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var w=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var I={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?w=S=I:S=S.next=I,p=p.next}while(p!==null);S===null?w=S=d:S=S.next=d}else w=S=d;p={baseState:x.baseState,firstBaseUpdate:w,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function xu(l,d,p,x){var w=l.updateQueue;li=!1;var S=w.firstBaseUpdate,I=w.lastBaseUpdate,V=w.shared.pending;if(V!==null){w.shared.pending=null;var Q=V,fe=Q.next;Q.next=null,I===null?S=fe:I.next=fe,I=Q;var ke=l.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=fe:V.next=fe,ke.lastBaseUpdate=Q))}if(S!==null){var Ce=w.baseState;I=0,ke=fe=Q=null,V=S;do{var je=V.lane,Le=V.eventTime;if((x&je)===je){ke!==null&&(ke=ke.next={eventTime:Le,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var $e=l,We=V;switch(je=d,Le=p,We.tag){case 1:if($e=We.payload,typeof $e=="function"){Ce=$e.call(Le,Ce,je);break e}Ce=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=We.payload,je=typeof $e=="function"?$e.call(Le,Ce,je):$e,je==null)break e;Ce=U({},Ce,je);break e;case 2:li=!0}}V.callback!==null&&V.lane!==0&&(l.flags|=64,je=w.effects,je===null?w.effects=[V]:je.push(V))}else Le={eventTime:Le,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(fe=ke=Le,Q=Ce):ke=ke.next=Le,I|=je;if(V=V.next,V===null){if(V=w.shared.pending,V===null)break;je=V,V=je.next,je.next=null,w.lastBaseUpdate=je,w.shared.pending=null}}while(!0);if(ke===null&&(Q=Ce),w.baseState=Q,w.firstBaseUpdate=fe,w.lastBaseUpdate=ke,d=w.shared.interleaved,d!==null){w=d;do I|=w.lane,w=w.next;while(w!==d)}else S===null&&(w.shared.lanes=0);mo|=I,l.lanes=I,l.memoizedState=Ce}}function hb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Yp.transition;Yp.transition={};try{l(!1),d()}finally{ct=p,Yp.transition=x}}function Ib(){return ir().memoizedState}function H3(l,d,p){var x=fi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Rb(l))Pb(d,p);else if(p=cb(l,d,p,x),p!==null){var w=Ss();Tr(p,l,x,w),Ob(p,d,x)}}function W3(l,d,p){var x=fi(l),w={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Rb(l))Pb(d,w);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var I=d.lastRenderedState,V=S(I,p);if(w.hasEagerState=!0,w.eagerState=V,jr(V,I)){var Q=d.interleaved;Q===null?(w.next=w,Wp(d)):(w.next=Q.next,Q.next=w),d.interleaved=w;return}}catch{}finally{}p=cb(l,d,w,x),p!==null&&(w=Ss(),Tr(p,l,x,w),Ob(p,d,x))}}function Rb(l){var d=l.alternate;return l===on||d!==null&&d===on}function Pb(l,d){zc=vu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Ob(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}var ju={readContext:ar,useCallback:hs,useContext:hs,useEffect:hs,useImperativeHandle:hs,useInsertionEffect:hs,useLayoutEffect:hs,useMemo:hs,useReducer:hs,useRef:hs,useState:hs,useDebugValue:hs,useDeferredValue:hs,useTransition:hs,useMutableSource:hs,useSyncExternalStore:hs,useId:hs,unstable_isNewReconciler:!1},U3={readContext:ar,useCallback:function(l,d){return Yr().memoizedState=[l,d===void 0?null:d],l},useContext:ar,useEffect:jb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Nu(4194308,4,Cb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Nu(4194308,4,l,d)},useInsertionEffect:function(l,d){return Nu(4,2,l,d)},useMemo:function(l,d){var p=Yr();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=Yr();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=H3.bind(null,on,l),[x.memoizedState,l]},useRef:function(l){var d=Yr();return l={current:l},d.memoizedState=l},useState:Nb,useDebugValue:sm,useDeferredValue:function(l){return Yr().memoizedState=l},useTransition:function(){var l=Nb(!1),d=l[0];return l=V3.bind(null,l[1]),Yr().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=on,w=Yr();if(nn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),$n===null)throw Error(n(349));(po&30)!==0||gb(x,d,p)}w.memoizedState=p;var S={value:p,getSnapshot:d};return w.queue=S,jb(yb.bind(null,x,S,l),[l]),x.flags|=2048,Bc(9,xb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Yr(),d=$n.identifierPrefix;if(nn){var p=Sa,x=ka;p=(x&~(1<<32-ws(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=Fc++,0")&&(Q=Q.replace("",l.displayName)),Q}while(1<=I&&0<=V);break}}}finally{le=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function Ae(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=ye(l.type,!1),l;case 11:return l=ye(l.type.render,!1),l;case 1:return l=ye(l.type,!0),l;default:return""}}function ne(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case L:return"Fragment";case H:return"Portal";case O:return"Profiler";case R:return"StrictMode";case ce:return"Suspense";case me:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ie:return(l.displayName||"Context")+".Consumer";case se:return(l._context.displayName||"Context")+".Provider";case z:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case _:return d=l.displayName||null,d!==null?d:ne(l.type)||"Memo";case G:d=l._payload,l=l._init;try{return ne(l(d))}catch{}}return null}function K(l){var d=l.type;switch(l.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=d.render,l=l.displayName||l.name||"",d.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ne(d);case 8:return d===R?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function J(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ge(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ae(l){var d=ge(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var w=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return w.call(this)},set:function(I){x=""+I,S.call(this,I)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(I){x=""+I},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function pe(l){l._valueTracker||(l._valueTracker=ae(l))}function Se(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=ge(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function tt(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function it(l,d){var p=d.checked;return U({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function zt(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=J(d.value!=null?d.value:p),l._wrapperState={initialChecked:x,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function St(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function Rt(l,d){St(l,d);var p=J(d.value),x=d.type;if(p!=null)x==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?In(l,d.type,p):d.hasOwnProperty("defaultValue")&&In(l,d.type,J(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function Ht(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var x=d.type;if(!(x!=="submit"&&x!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+l._wrapperState.initialValue,p||d===l.value||(l.value=d),l.defaultValue=d}p=l.name,p!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,p!==""&&(l.name=p)}function In(l,d,p){(d!=="number"||tt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Ft=Array.isArray;function xn(l,d,p,x){if(l=l.options,d){d={};for(var w=0;w"+d.valueOf().toString()+"",d=Ct.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function _n(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var ls={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Un=["Webkit","ms","Moz","O"];Object.keys(ls).forEach(function(l){Un.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),ls[d]=ls[l]})});function q(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||ls.hasOwnProperty(l)&&ls[l]?(""+d).trim():d+"px"}function Le(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,w=q(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,w):l[p]=w}}var mt=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Pt(l,d){if(d){if(mt[l]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function ut(l,d){if(l.indexOf("-")===-1)return typeof d.is=="string";switch(l){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 nt=null;function Nt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var he=null,xe=null,jt=null;function rn(l){if(l=Pc(l)){if(typeof he!="function")throw Error(n(280));var d=l.stateNode;d&&(d=iu(d),he(l.stateNode,l.type,d))}}function da(l){xe?jt?jt.push(l):jt=[l]:xe=l}function ua(){if(xe){var l=xe,d=jt;if(jt=xe=null,rn(l),d)for(l=0;l>>=0,l===0?32:31-(Vr(l)/fc|0)|0}var xa=64,ya=4194304;function Hr(l){switch(l&-l){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: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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function yn(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,w=l.suspendedLanes,S=l.pingedLanes,I=p&268435455;if(I!==0){var V=I&~w;V!==0?x=Hr(V):(S&=I,S!==0&&(x=Hr(S)))}else I=p&~w,I!==0?x=Hr(I):S!==0&&(x=Hr(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&w)===0&&(w=x&-x,S=d&-d,w>=S||w===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function ze(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-ws(d),l[d]=p}function lt(l,d){var p=l.pendingLanes&~d;l.pendingLanes=d,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=d,l.mutableReadLanes&=d,l.entangledLanes&=d,d=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0=kc),jy=" ",ky=!1;function Sy(l,d){switch(l){case"keyup":return m3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var rl=!1;function x3(l,d){switch(l){case"compositionend":return Cy(d);case"keypress":return d.which!==32?null:(ky=!0,jy);case"textInput":return l=d.data,l===jy&&ky?null:l;default:return null}}function y3(l,d){if(rl)return l==="compositionend"||!gp&&Sy(l,d)?(l=wc(),sl=Nc=Kr=null,rl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:p,offset:d-l};l=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Py(p)}}function Dy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Dy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Ly(){for(var l=window,d=tt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=tt(l.document)}return d}function bp(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}function E3(l){var d=Ly(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Dy(p.ownerDocument.documentElement,p)){if(x!==null&&bp(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var w=p.textContent.length,S=Math.min(x.start,w);x=x.end===void 0?S:Math.min(x.end,w),!l.extend&&S>x&&(w=x,x=S,S=w),w=Oy(p,S);var I=Oy(p,x);w&&I&&(l.rangeCount!==1||l.anchorNode!==w.node||l.anchorOffset!==w.offset||l.focusNode!==I.node||l.focusOffset!==I.offset)&&(d=d.createRange(),d.setStart(w.node,w.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(I.node,I.offset)):(d.setEnd(I.node,I.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p=document.documentMode,al=null,vp=null,Tc=null,Np=!1;function _y(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Np||al==null||al!==tt(x)||(x=al,"selectionStart"in x&&bp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Tc&&Ec(Tc,x)||(Tc=x,x=su(vp,"onSelect"),0dl||(l.current=Pp[dl],Pp[dl]=null,dl--)}function Wt(l,d){dl++,Pp[dl]=l.current,l.current=d}var ii={},us=ai(ii),Rs=ai(!1),lo=ii;function ul(l,d){var p=l.type.contextTypes;if(!p)return ii;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var w={},S;for(S in p)w[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=w),w}function Ps(l){return l=l.childContextTypes,l!=null}function ou(){Qt(Rs),Qt(us)}function Xy(l,d,p){if(us.current!==ii)throw Error(n(168));Wt(us,d),Wt(Rs,p)}function Zy(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var w in x)if(!(w in d))throw Error(n(108,K(l)||"Unknown",w));return U({},p,x)}function lu(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ii,lo=us.current,Wt(us,l),Wt(Rs,Rs.current),!0}function eb(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Zy(l,d,lo),x.__reactInternalMemoizedMergedChildContext=l,Qt(Rs),Qt(us),Wt(us,l)):Qt(Rs),Wt(Rs,p)}var ja=null,cu=!1,Op=!1;function tb(l){ja===null?ja=[l]:ja.push(l)}function F3(l){cu=!0,tb(l)}function oi(){if(!Op&&ja!==null){Op=!0;var l=0,d=ct;try{var p=ja;for(ct=1;l>=I,w-=I,ka=1<<32-ws(d)+w|p<at?($n=et,et=null):$n=et.sibling;var wt=je(oe,et,ue[at],Re);if(wt===null){et===null&&(et=$n);break}l&&et&&wt.alternate===null&&d(oe,et),ee=S(wt,ee,at),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt,et=$n}if(at===ue.length)return p(oe,et),tn&&uo(oe,at),Ue;if(et===null){for(;atat?($n=et,et=null):$n=et.sibling;var gi=je(oe,et,wt.value,Re);if(gi===null){et===null&&(et=$n);break}l&&et&&gi.alternate===null&&d(oe,et),ee=S(gi,ee,at),Ze===null?Ue=gi:Ze.sibling=gi,Ze=gi,et=$n}if(wt.done)return p(oe,et),tn&&uo(oe,at),Ue;if(et===null){for(;!wt.done;at++,wt=ue.next())wt=Ce(oe,wt.value,Re),wt!==null&&(ee=S(wt,ee,at),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return tn&&uo(oe,at),Ue}for(et=x(oe,et);!wt.done;at++,wt=ue.next())wt=_e(et,oe,at,wt.value,Re),wt!==null&&(l&&wt.alternate!==null&&et.delete(wt.key===null?at:wt.key),ee=S(wt,ee,at),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return l&&et.forEach(function(bE){return d(oe,bE)}),tn&&uo(oe,at),Ue}function vn(oe,ee,ue,Re){if(typeof ue=="object"&&ue!==null&&ue.type===L&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case P:e:{for(var Ue=ue.key,Ze=ee;Ze!==null;){if(Ze.key===Ue){if(Ue=ue.type,Ue===L){if(Ze.tag===7){p(oe,Ze.sibling),ee=w(Ze,ue.props.children),ee.return=oe,oe=ee;break e}}else if(Ze.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===G&&ob(Ue)===Ze.type){p(oe,Ze.sibling),ee=w(Ze,ue.props),ee.ref=Oc(oe,Ze,ue),ee.return=oe,oe=ee;break e}p(oe,Ze);break}else d(oe,Ze);Ze=Ze.sibling}ue.type===L?(ee=bo(ue.props.children,oe.mode,Re,ue.key),ee.return=oe,oe=ee):(Re=_u(ue.type,ue.key,ue.props,null,oe.mode,Re),Re.ref=Oc(oe,ee,ue),Re.return=oe,oe=Re)}return I(oe);case H:e:{for(Ze=ue.key;ee!==null;){if(ee.key===Ze)if(ee.tag===4&&ee.stateNode.containerInfo===ue.containerInfo&&ee.stateNode.implementation===ue.implementation){p(oe,ee.sibling),ee=w(ee,ue.children||[]),ee.return=oe,oe=ee;break e}else{p(oe,ee);break}else d(oe,ee);ee=ee.sibling}ee=Im(ue,oe.mode,Re),ee.return=oe,oe=ee}return I(oe);case G:return Ze=ue._init,vn(oe,ee,Ze(ue._payload),Re)}if(Ft(ue))return Be(oe,ee,ue,Re);if(Y(ue))return We(oe,ee,ue,Re);fu(oe,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"?(ue=""+ue,ee!==null&&ee.tag===6?(p(oe,ee.sibling),ee=w(ee,ue),ee.return=oe,oe=ee):(p(oe,ee),ee=Am(ue,oe.mode,Re),ee.return=oe,oe=ee),I(oe)):p(oe,ee)}return vn}var ml=lb(!0),cb=lb(!1),pu=ai(null),mu=null,gl=null,$p=null;function Bp(){$p=gl=mu=null}function Vp(l){var d=pu.current;Qt(pu),l._currentValue=d}function Hp(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function xl(l,d){mu=l,$p=gl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Os=!0),l.firstContext=null)}function ar(l){var d=l._currentValue;if($p!==l)if(l={context:l,memoizedValue:d,next:null},gl===null){if(mu===null)throw Error(n(308));gl=l,mu.dependencies={lanes:0,firstContext:l}}else gl=gl.next=l;return d}var ho=null;function Wp(l){ho===null?ho=[l]:ho.push(l)}function db(l,d,p,x){var w=d.interleaved;return w===null?(p.next=p,Wp(d)):(p.next=w.next,w.next=p),d.interleaved=p,Ca(l,x)}function Ca(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var li=!1;function Up(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ub(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Ea(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function ci(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(vt&2)!==0){var w=x.pending;return w===null?d.next=d:(d.next=w.next,w.next=d),x.pending=d,Ca(l,p)}return w=x.interleaved,w===null?(d.next=d,Wp(x)):(d.next=w.next,w.next=d),x.interleaved=d,Ca(l,p)}function gu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}function hb(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var w=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var I={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?w=S=I:S=S.next=I,p=p.next}while(p!==null);S===null?w=S=d:S=S.next=d}else w=S=d;p={baseState:x.baseState,firstBaseUpdate:w,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function xu(l,d,p,x){var w=l.updateQueue;li=!1;var S=w.firstBaseUpdate,I=w.lastBaseUpdate,V=w.shared.pending;if(V!==null){w.shared.pending=null;var Q=V,fe=Q.next;Q.next=null,I===null?S=fe:I.next=fe,I=Q;var ke=l.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=fe:V.next=fe,ke.lastBaseUpdate=Q))}if(S!==null){var Ce=w.baseState;I=0,ke=fe=Q=null,V=S;do{var je=V.lane,_e=V.eventTime;if((x&je)===je){ke!==null&&(ke=ke.next={eventTime:_e,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Be=l,We=V;switch(je=d,_e=p,We.tag){case 1:if(Be=We.payload,typeof Be=="function"){Ce=Be.call(_e,Ce,je);break e}Ce=Be;break e;case 3:Be.flags=Be.flags&-65537|128;case 0:if(Be=We.payload,je=typeof Be=="function"?Be.call(_e,Ce,je):Be,je==null)break e;Ce=U({},Ce,je);break e;case 2:li=!0}}V.callback!==null&&V.lane!==0&&(l.flags|=64,je=w.effects,je===null?w.effects=[V]:je.push(V))}else _e={eventTime:_e,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(fe=ke=_e,Q=Ce):ke=ke.next=_e,I|=je;if(V=V.next,V===null){if(V=w.shared.pending,V===null)break;je=V,V=je.next,je.next=null,w.lastBaseUpdate=je,w.shared.pending=null}}while(!0);if(ke===null&&(Q=Ce),w.baseState=Q,w.firstBaseUpdate=fe,w.lastBaseUpdate=ke,d=w.shared.interleaved,d!==null){w=d;do I|=w.lane,w=w.next;while(w!==d)}else S===null&&(w.shared.lanes=0);mo|=I,l.lanes=I,l.memoizedState=Ce}}function fb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Yp.transition;Yp.transition={};try{l(!1),d()}finally{ct=p,Yp.transition=x}}function Rb(){return ir().memoizedState}function H3(l,d,p){var x=fi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Pb(l))Ob(d,p);else if(p=db(l,d,p,x),p!==null){var w=Ss();Tr(p,l,x,w),Db(p,d,x)}}function W3(l,d,p){var x=fi(l),w={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Pb(l))Ob(d,w);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var I=d.lastRenderedState,V=S(I,p);if(w.hasEagerState=!0,w.eagerState=V,jr(V,I)){var Q=d.interleaved;Q===null?(w.next=w,Wp(d)):(w.next=Q.next,Q.next=w),d.interleaved=w;return}}catch{}finally{}p=db(l,d,w,x),p!==null&&(w=Ss(),Tr(p,l,x,w),Db(p,d,x))}}function Pb(l){var d=l.alternate;return l===on||d!==null&&d===on}function Ob(l,d){zc=vu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Db(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}var ju={readContext:ar,useCallback:hs,useContext:hs,useEffect:hs,useImperativeHandle:hs,useInsertionEffect:hs,useLayoutEffect:hs,useMemo:hs,useReducer:hs,useRef:hs,useState:hs,useDebugValue:hs,useDeferredValue:hs,useTransition:hs,useMutableSource:hs,useSyncExternalStore:hs,useId:hs,unstable_isNewReconciler:!1},U3={readContext:ar,useCallback:function(l,d){return Yr().memoizedState=[l,d===void 0?null:d],l},useContext:ar,useEffect:kb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Nu(4194308,4,Eb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Nu(4194308,4,l,d)},useInsertionEffect:function(l,d){return Nu(4,2,l,d)},useMemo:function(l,d){var p=Yr();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=Yr();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=H3.bind(null,on,l),[x.memoizedState,l]},useRef:function(l){var d=Yr();return l={current:l},d.memoizedState=l},useState:wb,useDebugValue:sm,useDeferredValue:function(l){return Yr().memoizedState=l},useTransition:function(){var l=wb(!1),d=l[0];return l=V3.bind(null,l[1]),Yr().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=on,w=Yr();if(tn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Fn===null)throw Error(n(349));(po&30)!==0||xb(x,d,p)}w.memoizedState=p;var S={value:p,getSnapshot:d};return w.queue=S,kb(bb.bind(null,x,S,l),[l]),x.flags|=2048,Bc(9,yb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Yr(),d=Fn.identifierPrefix;if(tn){var p=Sa,x=ka;p=(x&~(1<<32-ws(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=Fc++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=I.createElement(p,{is:x.is}):(l=I.createElement(p),p==="select"&&(I=l,x.multiple?I.multiple=!0:x.size&&(I.size=x.size))):l=I.createElementNS(l,p),l[Gr]=d,l[Rc]=x,ev(l,d,!1,!1),d.stateNode=l;e:{switch(I=ot(p,x),p){case"dialog":Yt("cancel",l),Yt("close",l),w=x;break;case"iframe":case"object":case"embed":Yt("load",l),w=x;break;case"video":case"audio":for(w=0;wwl&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304)}else{if(!x)if(l=yu(I),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Vc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!I.alternate&&!nn)return fs(d),null}else 2*Jt()-S.renderingStartTime>wl&&p!==1073741824&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304);S.isBackwards?(I.sibling=d.child,d.child=I):(p=S.last,p!==null?p.sibling=I:d.child=I,S.last=I)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Jt(),d.sibling=null,p=an.current,Ht(an,x?p&1|2:p&1),d):(fs(d),null);case 22:case 23:return Em(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Us&1073741824)!==0&&(fs(d),d.subtreeFlags&6&&(d.flags|=8192)):fs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function Z3(l,d){switch(Lp(d),d.tag){case 1:return Ps(d.type)&&ou(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return yl(),Qt(Rs),Qt(us),Jp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return qp(d),null;case 13:if(Qt(an),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));pl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Qt(an),null;case 4:return yl(),null;case 10:return Vp(d.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var Eu=!1,ps=!1,eE=typeof WeakSet=="function"?WeakSet:Set,ze=null;function vl(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){un(l,d,x)}else p.current=null}function mm(l,d,p){try{p()}catch(x){un(l,d,x)}}var sv=!1;function tE(l,d){if(Ep=tl,l=Dy(),bp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var w=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var I=0,V=-1,Q=-1,fe=0,ke=0,Ce=l,je=null;t:for(;;){for(var Le;Ce!==p||w!==0&&Ce.nodeType!==3||(V=I+w),Ce!==S||x!==0&&Ce.nodeType!==3||(Q=I+x),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Le=Ce.firstChild)!==null;)je=Ce,Ce=Le;for(;;){if(Ce===l)break t;if(je===p&&++fe===w&&(V=I),je===S&&++ke===x&&(Q=I),(Le=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=Le}p=V===-1||Q===-1?null:{start:V,end:Q}}else p=null}p=p||{start:0,end:0}}else p=null;for(Tp={focusedElem:l,selectionRange:p},tl=!1,ze=d;ze!==null;)if(d=ze,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,ze=l;else for(;ze!==null;){d=ze;try{var $e=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if($e!==null){var We=$e.memoizedProps,Nn=$e.memoizedState,oe=d.stateNode,ee=oe.getSnapshotBeforeUpdate(d.elementType===d.type?We:Sr(d.type,We),Nn);oe.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ue=d.stateNode.containerInfo;ue.nodeType===1?ue.textContent="":ue.nodeType===9&&ue.documentElement&&ue.removeChild(ue.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){un(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,ze=l;break}ze=d.return}return $e=sv,sv=!1,$e}function Hc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var w=x=x.next;do{if((w.tag&l)===l){var S=w.destroy;w.destroy=void 0,S!==void 0&&mm(d,p,S)}w=w.next}while(w!==x)}}function Tu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function gm(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function rv(l){var d=l.alternate;d!==null&&(l.alternate=null,rv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Gr],delete d[Rc],delete d[Rp],delete d[_3],delete d[z3])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function av(l){return l.tag===5||l.tag===3||l.tag===4}function iv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||av(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function xm(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=au));else if(x!==4&&(l=l.child,l!==null))for(xm(l,d,p),l=l.sibling;l!==null;)xm(l,d,p),l=l.sibling}function ym(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(ym(l,d,p),l=l.sibling;l!==null;)ym(l,d,p),l=l.sibling}var Yn=null,Cr=!1;function di(l,d,p){for(p=p.child;p!==null;)ov(l,d,p),p=p.sibling}function ov(l,d,p){if(Ns&&typeof Ns.onCommitFiberUnmount=="function")try{Ns.onCommitFiberUnmount(Br,p)}catch{}switch(p.tag){case 5:ps||vl(p,d);case 6:var x=Yn,w=Cr;Yn=null,di(l,d,p),Yn=x,Cr=w,Yn!==null&&(Cr?(l=Yn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Yn.removeChild(p.stateNode));break;case 18:Yn!==null&&(Cr?(l=Yn,p=p.stateNode,l.nodeType===8?Ip(l.parentNode,p):l.nodeType===1&&Ip(l,p),ao(l)):Ip(Yn,p.stateNode));break;case 4:x=Yn,w=Cr,Yn=p.stateNode.containerInfo,Cr=!0,di(l,d,p),Yn=x,Cr=w;break;case 0:case 11:case 14:case 15:if(!ps&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){w=x=x.next;do{var S=w,I=S.destroy;S=S.tag,I!==void 0&&((S&2)!==0||(S&4)!==0)&&mm(p,d,I),w=w.next}while(w!==x)}di(l,d,p);break;case 1:if(!ps&&(vl(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(V){un(p,d,V)}di(l,d,p);break;case 21:di(l,d,p);break;case 22:p.mode&1?(ps=(x=ps)||p.memoizedState!==null,di(l,d,p),ps=x):di(l,d,p);break;default:di(l,d,p)}}function lv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new eE),d.forEach(function(x){var w=dE.bind(null,l,x);p.has(x)||(p.add(x),x.then(w,w))})}}function Er(l,d){var p=d.deletions;if(p!==null)for(var x=0;xw&&(w=I),x&=~S}if(x=w,x=Jt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*sE(x/1960))-x,10l?16:l,hi===null)var x=!1;else{if(l=hi,hi=null,Pu=0,(vt&6)!==0)throw Error(n(331));var w=vt;for(vt|=4,ze=l.current;ze!==null;){var S=ze,I=S.child;if((ze.flags&16)!==0){var V=S.deletions;if(V!==null){for(var Q=0;QJt()-Nm?xo(l,0):vm|=p),Ls(l,d)}function Nv(l,d){d===0&&((l.mode&1)===0?d=1:(d=ya,ya<<=1,(ya&130023424)===0&&(ya=4194304)));var p=Ss();l=Ca(l,d),l!==null&&(_e(l,d,p),Ls(l,p))}function cE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Nv(l,p)}function dE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,w=l.memoizedState;w!==null&&(p=w.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Nv(l,p)}var wv;wv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||Rs.current)Os=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Os=!1,Q3(l,d,p);Os=(l.flags&131072)!==0}else Os=!1,nn&&(d.flags&1048576)!==0&&tb(d,uu,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;Cu(l,d),l=d.pendingProps;var w=ul(d,us.current);xl(d,p),w=Xp(null,d,x,l,w,p);var S=Zp();return d.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Ps(x)?(S=!0,lu(d)):S=!1,d.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Up(d),w.updater=ku,d.stateNode=w,w._reactInternals=d,am(d,x,l,p),d=cm(null,d,x,!0,S,p)):(d.tag=0,nn&&S&&Dp(d),ks(null,d,w,p),d=d.child),d;case 16:x=d.elementType;e:{switch(Cu(l,d),l=d.pendingProps,w=x._init,x=w(x._payload),d.type=x,w=d.tag=hE(x),l=Sr(x,l),w){case 0:d=lm(null,d,x,l,p);break e;case 1:d=Gb(null,d,x,l,p);break e;case 11:d=Hb(null,d,x,l,p);break e;case 14:d=Wb(null,d,x,Sr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),lm(l,d,x,w,p);case 1:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Gb(l,d,x,w,p);case 3:e:{if(Jb(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,w=S.element,db(l,d),xu(d,x,null,p);var I=d.memoizedState;if(x=I.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){w=bl(Error(n(423)),d),d=Yb(l,d,x,p,w);break e}else if(x!==w){w=bl(Error(n(424)),d),d=Yb(l,d,x,p,w);break e}else for(Ws=ri(d.stateNode.containerInfo.firstChild),Hs=d,nn=!0,kr=null,p=lb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(pl(),x===w){d=Ta(l,d,p);break e}ks(l,d,x,p)}d=d.child}return d;case 5:return fb(d),l===null&&zp(d),x=d.type,w=d.pendingProps,S=l!==null?l.memoizedProps:null,I=w.children,Mp(x,w)?I=null:S!==null&&Mp(x,S)&&(d.flags|=32),qb(l,d),ks(l,d,I,p),d.child;case 6:return l===null&&zp(d),null;case 13:return Qb(l,d,p);case 4:return Kp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=ml(d,null,x,p):ks(l,d,x,p),d.child;case 11:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Hb(l,d,x,w,p);case 7:return ks(l,d,d.pendingProps,p),d.child;case 8:return ks(l,d,d.pendingProps.children,p),d.child;case 12:return ks(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,w=d.pendingProps,S=d.memoizedProps,I=w.value,Ht(pu,x._currentValue),x._currentValue=I,S!==null)if(jr(S.value,I)){if(S.children===w.children&&!Rs.current){d=Ta(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var V=S.dependencies;if(V!==null){I=S.child;for(var Q=V.firstContext;Q!==null;){if(Q.context===x){if(S.tag===1){Q=Ea(-1,p&-p),Q.tag=2;var fe=S.updateQueue;if(fe!==null){fe=fe.shared;var ke=fe.pending;ke===null?Q.next=Q:(Q.next=ke.next,ke.next=Q),fe.pending=Q}}S.lanes|=p,Q=S.alternate,Q!==null&&(Q.lanes|=p),Hp(S.return,p,d),V.lanes|=p;break}Q=Q.next}}else if(S.tag===10)I=S.type===d.type?null:S.child;else if(S.tag===18){if(I=S.return,I===null)throw Error(n(341));I.lanes|=p,V=I.alternate,V!==null&&(V.lanes|=p),Hp(I,p,d),I=S.sibling}else I=S.child;if(I!==null)I.return=S;else for(I=S;I!==null;){if(I===d){I=null;break}if(S=I.sibling,S!==null){S.return=I.return,I=S;break}I=I.return}S=I}ks(l,d,w.children,p),d=d.child}return d;case 9:return w=d.type,x=d.pendingProps.children,xl(d,p),w=ar(w),x=x(w),d.flags|=1,ks(l,d,x,p),d.child;case 14:return x=d.type,w=Sr(x,d.pendingProps),w=Sr(x.type,w),Wb(l,d,x,w,p);case 15:return Ub(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Cu(l,d),d.tag=1,Ps(x)?(l=!0,lu(d)):l=!1,xl(d,p),Lb(d,x,w),am(d,x,w,p),cm(null,d,x,!0,l,p);case 19:return Zb(l,d,p);case 22:return Kb(l,d,p)}throw Error(n(156,d.tag))};function jv(l,d){return Fr(l,d)}function uE(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lr(l,d,p,x){return new uE(l,d,p,x)}function Mm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function hE(l){if(typeof l=="function")return Mm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===z)return 11;if(l===_)return 14}return 2}function mi(l,d){var p=l.alternate;return p===null?(p=lr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function _u(l,d,p,x,w,S){var I=2;if(x=l,typeof l=="function")Mm(l)&&(I=1);else if(typeof l=="string")I=5;else e:switch(l){case L:return bo(p.children,w,S,d);case R:I=8,w|=8;break;case O:return l=lr(12,p,d,w|2),l.elementType=O,l.lanes=S,l;case ce:return l=lr(13,p,d,w),l.elementType=ce,l.lanes=S,l;case me:return l=lr(19,p,d,w),l.elementType=me,l.lanes=S,l;case $:return zu(p,w,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case se:I=10;break e;case ie:I=9;break e;case z:I=11;break e;case _:I=14;break e;case G:I=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=lr(I,p,d,w),d.elementType=l,d.type=x,d.lanes=S,d}function bo(l,d,p,x){return l=lr(7,l,x,d),l.lanes=p,l}function zu(l,d,p,x){return l=lr(22,l,x,d),l.elementType=$,l.lanes=p,l.stateNode={isHidden:!1},l}function Am(l,d,p){return l=lr(6,l,null,d),l.lanes=p,l}function Im(l,d,p){return d=lr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function fE(l,d,p,x,w){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pe(0),this.expirationTimes=Pe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.identifierPrefix=x,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Rm(l,d,p,x,w,S,I,V,Q){return l=new fE(l,d,p,V,Q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=lr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Up(S),l}function pE(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),zm.exports=CE(),zm.exports}var _v;function EE(){if(_v)return Uu;_v=1;var t=Ww();return Uu.createRoot=t.createRoot,Uu.hydrateRoot=t.hydrateRoot,Uu}var TE=EE(),Bd=Ww();const Uw=Hw(Bd);/**
+`+S.stack}return{value:l,source:d,stack:w,digest:null}}function im(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function om(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var G3=typeof WeakMap=="function"?WeakMap:Map;function Fb(l,d,p){p=Ea(-1,p),p.tag=3,p.payload={element:null};var x=d.value;return p.callback=function(){Iu||(Iu=!0,wm=x),om(l,d)},p}function $b(l,d,p){p=Ea(-1,p),p.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var w=d.value;p.payload=function(){return x(w)},p.callback=function(){om(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){om(l,d),typeof x!="function"&&(ui===null?ui=new Set([this]):ui.add(this));var I=d.stack;this.componentDidCatch(d.value,{componentStack:I!==null?I:""})}),p}function Bb(l,d,p){var x=l.pingCache;if(x===null){x=l.pingCache=new G3;var w=new Set;x.set(d,w)}else w=x.get(d),w===void 0&&(w=new Set,x.set(d,w));w.has(p)||(w.add(p),l=lE.bind(null,l,d,p),d.then(l,l))}function Vb(l){do{var d;if((d=l.tag===13)&&(d=l.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return l;l=l.return}while(l!==null);return null}function Hb(l,d,p,x,w){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=Ea(-1,1),d.tag=2,ci(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=w,l)}var J3=M.ReactCurrentOwner,Os=!1;function ks(l,d,p,x){d.child=l===null?cb(d,null,p,x):ml(d,l.child,p,x)}function Wb(l,d,p,x,w){p=p.render;var S=d.ref;return xl(d,w),x=Xp(l,d,p,x,S,w),p=Zp(),l!==null&&!Os?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~w,Ta(l,d,w)):(tn&&p&&Dp(d),d.flags|=1,ks(l,d,x,w),d.child)}function Ub(l,d,p,x,w){if(l===null){var S=p.type;return typeof S=="function"&&!Mm(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,Kb(l,d,S,x,w)):(l=_u(p.type,null,x,d,d.mode,w),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&w)===0){var I=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ec,p(I,x)&&l.ref===d.ref)return Ta(l,d,w)}return d.flags|=1,l=mi(S,x),l.ref=d.ref,l.return=d,d.child=l}function Kb(l,d,p,x,w){if(l!==null){var S=l.memoizedProps;if(Ec(S,x)&&l.ref===d.ref)if(Os=!1,d.pendingProps=x=S,(l.lanes&w)!==0)(l.flags&131072)!==0&&(Os=!0);else return d.lanes=l.lanes,Ta(l,d,w)}return lm(l,d,p,x,w)}function qb(l,d,p){var x=d.pendingProps,w=x.children,S=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wt(Nl,Us),Us|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,Wt(Nl,Us),Us|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=S!==null?S.baseLanes:p,Wt(Nl,Us),Us|=x}else S!==null?(x=S.baseLanes|p,d.memoizedState=null):x=p,Wt(Nl,Us),Us|=x;return ks(l,d,w,p),d.child}function Gb(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function lm(l,d,p,x,w){var S=Ps(p)?lo:us.current;return S=ul(d,S),xl(d,w),p=Xp(l,d,p,x,S,w),x=Zp(),l!==null&&!Os?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~w,Ta(l,d,w)):(tn&&x&&Dp(d),d.flags|=1,ks(l,d,p,w),d.child)}function Jb(l,d,p,x,w){if(Ps(p)){var S=!0;lu(d)}else S=!1;if(xl(d,w),d.stateNode===null)Cu(l,d),_b(d,p,x),am(d,p,x,w),x=!0;else if(l===null){var I=d.stateNode,V=d.memoizedProps;I.props=V;var Q=I.context,fe=p.contextType;typeof fe=="object"&&fe!==null?fe=ar(fe):(fe=Ps(p)?lo:us.current,fe=ul(d,fe));var ke=p.getDerivedStateFromProps,Ce=typeof ke=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==x||Q!==fe)&&zb(d,I,x,fe),li=!1;var je=d.memoizedState;I.state=je,xu(d,x,I,w),Q=d.memoizedState,V!==x||je!==Q||Rs.current||li?(typeof ke=="function"&&(rm(d,p,ke,x),Q=d.memoizedState),(V=li||Lb(d,p,V,x,je,Q,fe))?(Ce||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(d.flags|=4194308)):(typeof I.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=x,d.memoizedState=Q),I.props=x,I.state=Q,I.context=fe,x=V):(typeof I.componentDidMount=="function"&&(d.flags|=4194308),x=!1)}else{I=d.stateNode,ub(l,d),V=d.memoizedProps,fe=d.type===d.elementType?V:Sr(d.type,V),I.props=fe,Ce=d.pendingProps,je=I.context,Q=p.contextType,typeof Q=="object"&&Q!==null?Q=ar(Q):(Q=Ps(p)?lo:us.current,Q=ul(d,Q));var _e=p.getDerivedStateFromProps;(ke=typeof _e=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||je!==Q)&&zb(d,I,x,Q),li=!1,je=d.memoizedState,I.state=je,xu(d,x,I,w);var Be=d.memoizedState;V!==Ce||je!==Be||Rs.current||li?(typeof _e=="function"&&(rm(d,p,_e,x),Be=d.memoizedState),(fe=li||Lb(d,p,fe,x,je,Be,Q)||!1)?(ke||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(x,Be,Q),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(x,Be,Q)),typeof I.componentDidUpdate=="function"&&(d.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=1024),d.memoizedProps=x,d.memoizedState=Be),I.props=x,I.state=Be,I.context=Q,x=fe):(typeof I.componentDidUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=1024),x=!1)}return cm(l,d,p,x,S,w)}function cm(l,d,p,x,w,S){Gb(l,d);var I=(d.flags&128)!==0;if(!x&&!I)return w&&eb(d,p,!1),Ta(l,d,S);x=d.stateNode,J3.current=d;var V=I&&typeof p.getDerivedStateFromError!="function"?null:x.render();return d.flags|=1,l!==null&&I?(d.child=ml(d,l.child,null,S),d.child=ml(d,null,V,S)):ks(l,d,V,S),d.memoizedState=x.state,w&&eb(d,p,!0),d.child}function Yb(l){var d=l.stateNode;d.pendingContext?Xy(l,d.pendingContext,d.pendingContext!==d.context):d.context&&Xy(l,d.context,!1),Kp(l,d.containerInfo)}function Qb(l,d,p,x,w){return pl(),Fp(w),d.flags|=256,ks(l,d,p,x),d.child}var dm={dehydrated:null,treeContext:null,retryLane:0};function um(l){return{baseLanes:l,cachePool:null,transitions:null}}function Xb(l,d,p){var x=d.pendingProps,w=an.current,S=!1,I=(d.flags&128)!==0,V;if((V=I)||(V=l!==null&&l.memoizedState===null?!1:(w&2)!==0),V?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(w|=1),Wt(an,w&1),l===null)return zp(d),l=d.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((d.mode&1)===0?d.lanes=1:l.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(I=x.children,l=x.fallback,S?(x=d.mode,S=d.child,I={mode:"hidden",children:I},(x&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=I):S=zu(I,x,0,null),l=bo(l,x,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=um(p),d.memoizedState=dm,l):hm(d,I));if(w=l.memoizedState,w!==null&&(V=w.dehydrated,V!==null))return Y3(l,d,I,x,V,w,p);if(S){S=x.fallback,I=d.mode,w=l.child,V=w.sibling;var Q={mode:"hidden",children:x.children};return(I&1)===0&&d.child!==w?(x=d.child,x.childLanes=0,x.pendingProps=Q,d.deletions=null):(x=mi(w,Q),x.subtreeFlags=w.subtreeFlags&14680064),V!==null?S=mi(V,S):(S=bo(S,I,p,null),S.flags|=2),S.return=d,x.return=d,x.sibling=S,d.child=x,x=S,S=d.child,I=l.child.memoizedState,I=I===null?um(p):{baseLanes:I.baseLanes|p,cachePool:null,transitions:I.transitions},S.memoizedState=I,S.childLanes=l.childLanes&~p,d.memoizedState=dm,x}return S=l.child,l=S.sibling,x=mi(S,{mode:"visible",children:x.children}),(d.mode&1)===0&&(x.lanes=p),x.return=d,x.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=x,d.memoizedState=null,x}function hm(l,d){return d=zu({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function Su(l,d,p,x){return x!==null&&Fp(x),ml(d,l.child,null,p),l=hm(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function Y3(l,d,p,x,w,S,I){if(p)return d.flags&256?(d.flags&=-257,x=im(Error(n(422))),Su(l,d,I,x)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=x.fallback,w=d.mode,x=zu({mode:"visible",children:x.children},w,0,null),S=bo(S,w,I,null),S.flags|=2,x.return=d,S.return=d,x.sibling=S,d.child=x,(d.mode&1)!==0&&ml(d,l.child,null,I),d.child.memoizedState=um(I),d.memoizedState=dm,S);if((d.mode&1)===0)return Su(l,d,I,null);if(w.data==="$!"){if(x=w.nextSibling&&w.nextSibling.dataset,x)var V=x.dgst;return x=V,S=Error(n(419)),x=im(S,x,void 0),Su(l,d,I,x)}if(V=(I&l.childLanes)!==0,Os||V){if(x=Fn,x!==null){switch(I&-I){case 4:w=2;break;case 16:w=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(x.suspendedLanes|I))!==0?0:w,w!==0&&w!==S.retryLane&&(S.retryLane=w,Ca(l,w),Tr(x,l,w,-1))}return Tm(),x=im(Error(n(421))),Su(l,d,I,x)}return w.data==="$?"?(d.flags|=128,d.child=l.child,d=cE.bind(null,l),w._reactRetry=d,null):(l=S.treeContext,Ws=ri(w.nextSibling),Hs=d,tn=!0,kr=null,l!==null&&(sr[rr++]=ka,sr[rr++]=Sa,sr[rr++]=co,ka=l.id,Sa=l.overflow,co=d),d=hm(d,x.children),d.flags|=4096,d)}function Zb(l,d,p){l.lanes|=d;var x=l.alternate;x!==null&&(x.lanes|=d),Hp(l.return,d,p)}function fm(l,d,p,x,w){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:w}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=x,S.tail=p,S.tailMode=w)}function ev(l,d,p){var x=d.pendingProps,w=x.revealOrder,S=x.tail;if(ks(l,d,x.children,p),x=an.current,(x&2)!==0)x=x&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Zb(l,p,d);else if(l.tag===19)Zb(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(Wt(an,x),(d.mode&1)===0)d.memoizedState=null;else switch(w){case"forwards":for(p=d.child,w=null;p!==null;)l=p.alternate,l!==null&&yu(l)===null&&(w=p),p=p.sibling;p=w,p===null?(w=d.child,d.child=null):(w=p.sibling,p.sibling=null),fm(d,!1,w,p,S);break;case"backwards":for(p=null,w=d.child,d.child=null;w!==null;){if(l=w.alternate,l!==null&&yu(l)===null){d.child=w;break}l=w.sibling,w.sibling=p,p=w,w=l}fm(d,!0,p,null,S);break;case"together":fm(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function Cu(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function Ta(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),mo|=d.lanes,(p&d.childLanes)===0)return null;if(l!==null&&d.child!==l.child)throw Error(n(153));if(d.child!==null){for(l=d.child,p=mi(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=mi(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function Q3(l,d,p){switch(d.tag){case 3:Yb(d),pl();break;case 5:pb(d);break;case 1:Ps(d.type)&&lu(d);break;case 4:Kp(d,d.stateNode.containerInfo);break;case 10:var x=d.type._context,w=d.memoizedProps.value;Wt(pu,x._currentValue),x._currentValue=w;break;case 13:if(x=d.memoizedState,x!==null)return x.dehydrated!==null?(Wt(an,an.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Xb(l,d,p):(Wt(an,an.current&1),l=Ta(l,d,p),l!==null?l.sibling:null);Wt(an,an.current&1);break;case 19:if(x=(p&d.childLanes)!==0,(l.flags&128)!==0){if(x)return ev(l,d,p);d.flags|=128}if(w=d.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),Wt(an,an.current),x)break;return null;case 22:case 23:return d.lanes=0,qb(l,d,p)}return Ta(l,d,p)}var tv,pm,nv,sv;tv=function(l,d){for(var p=d.child;p!==null;){if(p.tag===5||p.tag===6)l.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},pm=function(){},nv=function(l,d,p,x){var w=l.memoizedProps;if(w!==x){l=d.stateNode,fo(Jr.current);var S=null;switch(p){case"input":w=it(l,w),x=it(l,x),S=[];break;case"select":w=U({},w,{value:void 0}),x=U({},x,{value:void 0}),S=[];break;case"textarea":w=ln(l,w),x=ln(l,x),S=[];break;default:typeof w.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=au)}Pt(p,x);var I;p=null;for(fe in w)if(!x.hasOwnProperty(fe)&&w.hasOwnProperty(fe)&&w[fe]!=null)if(fe==="style"){var V=w[fe];for(I in V)V.hasOwnProperty(I)&&(p||(p={}),p[I]="")}else fe!=="dangerouslySetInnerHTML"&&fe!=="children"&&fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&fe!=="autoFocus"&&(a.hasOwnProperty(fe)?S||(S=[]):(S=S||[]).push(fe,null));for(fe in x){var Q=x[fe];if(V=w!=null?w[fe]:void 0,x.hasOwnProperty(fe)&&Q!==V&&(Q!=null||V!=null))if(fe==="style")if(V){for(I in V)!V.hasOwnProperty(I)||Q&&Q.hasOwnProperty(I)||(p||(p={}),p[I]="");for(I in Q)Q.hasOwnProperty(I)&&V[I]!==Q[I]&&(p||(p={}),p[I]=Q[I])}else p||(S||(S=[]),S.push(fe,p)),p=Q;else fe==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,V=V?V.__html:void 0,Q!=null&&V!==Q&&(S=S||[]).push(fe,Q)):fe==="children"?typeof Q!="string"&&typeof Q!="number"||(S=S||[]).push(fe,""+Q):fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&(a.hasOwnProperty(fe)?(Q!=null&&fe==="onScroll"&&Yt("scroll",l),S||V===Q||(S=[])):(S=S||[]).push(fe,Q))}p&&(S=S||[]).push("style",p);var fe=S;(d.updateQueue=fe)&&(d.flags|=4)}},sv=function(l,d,p,x){p!==x&&(d.flags|=4)};function Vc(l,d){if(!tn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function fs(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,x=0;if(d)for(var w=l.child;w!==null;)p|=w.lanes|w.childLanes,x|=w.subtreeFlags&14680064,x|=w.flags&14680064,w.return=l,w=w.sibling;else for(w=l.child;w!==null;)p|=w.lanes|w.childLanes,x|=w.subtreeFlags,x|=w.flags,w.return=l,w=w.sibling;return l.subtreeFlags|=x,l.childLanes=p,d}function X3(l,d,p){var x=d.pendingProps;switch(Lp(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fs(d),null;case 1:return Ps(d.type)&&ou(),fs(d),null;case 3:return x=d.stateNode,yl(),Qt(Rs),Qt(us),Jp(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(hu(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,kr!==null&&(Sm(kr),kr=null))),pm(l,d),fs(d),null;case 5:qp(d);var w=fo(_c.current);if(p=d.type,l!==null&&d.stateNode!=null)nv(l,d,p,x,w),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!x){if(d.stateNode===null)throw Error(n(166));return fs(d),null}if(l=fo(Jr.current),hu(d)){x=d.stateNode,p=d.type;var S=d.memoizedProps;switch(x[Gr]=d,x[Rc]=S,l=(d.mode&1)!==0,p){case"dialog":Yt("cancel",x),Yt("close",x);break;case"iframe":case"object":case"embed":Yt("load",x);break;case"video":case"audio":for(w=0;w<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=I.createElement(p,{is:x.is}):(l=I.createElement(p),p==="select"&&(I=l,x.multiple?I.multiple=!0:x.size&&(I.size=x.size))):l=I.createElementNS(l,p),l[Gr]=d,l[Rc]=x,tv(l,d,!1,!1),d.stateNode=l;e:{switch(I=ut(p,x),p){case"dialog":Yt("cancel",l),Yt("close",l),w=x;break;case"iframe":case"object":case"embed":Yt("load",l),w=x;break;case"video":case"audio":for(w=0;wwl&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304)}else{if(!x)if(l=yu(I),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Vc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!I.alternate&&!tn)return fs(d),null}else 2*Jt()-S.renderingStartTime>wl&&p!==1073741824&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304);S.isBackwards?(I.sibling=d.child,d.child=I):(p=S.last,p!==null?p.sibling=I:d.child=I,S.last=I)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Jt(),d.sibling=null,p=an.current,Wt(an,x?p&1|2:p&1),d):(fs(d),null);case 22:case 23:return Em(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Us&1073741824)!==0&&(fs(d),d.subtreeFlags&6&&(d.flags|=8192)):fs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function Z3(l,d){switch(Lp(d),d.tag){case 1:return Ps(d.type)&&ou(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return yl(),Qt(Rs),Qt(us),Jp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return qp(d),null;case 13:if(Qt(an),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));pl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Qt(an),null;case 4:return yl(),null;case 10:return Vp(d.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var Eu=!1,ps=!1,eE=typeof WeakSet=="function"?WeakSet:Set,Fe=null;function vl(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){un(l,d,x)}else p.current=null}function mm(l,d,p){try{p()}catch(x){un(l,d,x)}}var rv=!1;function tE(l,d){if(Ep=tl,l=Ly(),bp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var w=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var I=0,V=-1,Q=-1,fe=0,ke=0,Ce=l,je=null;t:for(;;){for(var _e;Ce!==p||w!==0&&Ce.nodeType!==3||(V=I+w),Ce!==S||x!==0&&Ce.nodeType!==3||(Q=I+x),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(_e=Ce.firstChild)!==null;)je=Ce,Ce=_e;for(;;){if(Ce===l)break t;if(je===p&&++fe===w&&(V=I),je===S&&++ke===x&&(Q=I),(_e=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=_e}p=V===-1||Q===-1?null:{start:V,end:Q}}else p=null}p=p||{start:0,end:0}}else p=null;for(Tp={focusedElem:l,selectionRange:p},tl=!1,Fe=d;Fe!==null;)if(d=Fe,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Fe=l;else for(;Fe!==null;){d=Fe;try{var Be=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Be!==null){var We=Be.memoizedProps,vn=Be.memoizedState,oe=d.stateNode,ee=oe.getSnapshotBeforeUpdate(d.elementType===d.type?We:Sr(d.type,We),vn);oe.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ue=d.stateNode.containerInfo;ue.nodeType===1?ue.textContent="":ue.nodeType===9&&ue.documentElement&&ue.removeChild(ue.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){un(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,Fe=l;break}Fe=d.return}return Be=rv,rv=!1,Be}function Hc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var w=x=x.next;do{if((w.tag&l)===l){var S=w.destroy;w.destroy=void 0,S!==void 0&&mm(d,p,S)}w=w.next}while(w!==x)}}function Tu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function gm(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function av(l){var d=l.alternate;d!==null&&(l.alternate=null,av(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Gr],delete d[Rc],delete d[Rp],delete d[_3],delete d[z3])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function iv(l){return l.tag===5||l.tag===3||l.tag===4}function ov(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||iv(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function xm(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=au));else if(x!==4&&(l=l.child,l!==null))for(xm(l,d,p),l=l.sibling;l!==null;)xm(l,d,p),l=l.sibling}function ym(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(ym(l,d,p),l=l.sibling;l!==null;)ym(l,d,p),l=l.sibling}var Gn=null,Cr=!1;function di(l,d,p){for(p=p.child;p!==null;)lv(l,d,p),p=p.sibling}function lv(l,d,p){if(Ns&&typeof Ns.onCommitFiberUnmount=="function")try{Ns.onCommitFiberUnmount(Br,p)}catch{}switch(p.tag){case 5:ps||vl(p,d);case 6:var x=Gn,w=Cr;Gn=null,di(l,d,p),Gn=x,Cr=w,Gn!==null&&(Cr?(l=Gn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Gn.removeChild(p.stateNode));break;case 18:Gn!==null&&(Cr?(l=Gn,p=p.stateNode,l.nodeType===8?Ip(l.parentNode,p):l.nodeType===1&&Ip(l,p),ao(l)):Ip(Gn,p.stateNode));break;case 4:x=Gn,w=Cr,Gn=p.stateNode.containerInfo,Cr=!0,di(l,d,p),Gn=x,Cr=w;break;case 0:case 11:case 14:case 15:if(!ps&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){w=x=x.next;do{var S=w,I=S.destroy;S=S.tag,I!==void 0&&((S&2)!==0||(S&4)!==0)&&mm(p,d,I),w=w.next}while(w!==x)}di(l,d,p);break;case 1:if(!ps&&(vl(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(V){un(p,d,V)}di(l,d,p);break;case 21:di(l,d,p);break;case 22:p.mode&1?(ps=(x=ps)||p.memoizedState!==null,di(l,d,p),ps=x):di(l,d,p);break;default:di(l,d,p)}}function cv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new eE),d.forEach(function(x){var w=dE.bind(null,l,x);p.has(x)||(p.add(x),x.then(w,w))})}}function Er(l,d){var p=d.deletions;if(p!==null)for(var x=0;xw&&(w=I),x&=~S}if(x=w,x=Jt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*sE(x/1960))-x,10l?16:l,hi===null)var x=!1;else{if(l=hi,hi=null,Pu=0,(vt&6)!==0)throw Error(n(331));var w=vt;for(vt|=4,Fe=l.current;Fe!==null;){var S=Fe,I=S.child;if((Fe.flags&16)!==0){var V=S.deletions;if(V!==null){for(var Q=0;QJt()-Nm?xo(l,0):vm|=p),Ls(l,d)}function wv(l,d){d===0&&((l.mode&1)===0?d=1:(d=ya,ya<<=1,(ya&130023424)===0&&(ya=4194304)));var p=Ss();l=Ca(l,d),l!==null&&(ze(l,d,p),Ls(l,p))}function cE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),wv(l,p)}function dE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,w=l.memoizedState;w!==null&&(p=w.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),wv(l,p)}var jv;jv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||Rs.current)Os=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Os=!1,Q3(l,d,p);Os=(l.flags&131072)!==0}else Os=!1,tn&&(d.flags&1048576)!==0&&nb(d,uu,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;Cu(l,d),l=d.pendingProps;var w=ul(d,us.current);xl(d,p),w=Xp(null,d,x,l,w,p);var S=Zp();return d.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Ps(x)?(S=!0,lu(d)):S=!1,d.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Up(d),w.updater=ku,d.stateNode=w,w._reactInternals=d,am(d,x,l,p),d=cm(null,d,x,!0,S,p)):(d.tag=0,tn&&S&&Dp(d),ks(null,d,w,p),d=d.child),d;case 16:x=d.elementType;e:{switch(Cu(l,d),l=d.pendingProps,w=x._init,x=w(x._payload),d.type=x,w=d.tag=hE(x),l=Sr(x,l),w){case 0:d=lm(null,d,x,l,p);break e;case 1:d=Jb(null,d,x,l,p);break e;case 11:d=Wb(null,d,x,l,p);break e;case 14:d=Ub(null,d,x,Sr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),lm(l,d,x,w,p);case 1:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Jb(l,d,x,w,p);case 3:e:{if(Yb(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,w=S.element,ub(l,d),xu(d,x,null,p);var I=d.memoizedState;if(x=I.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){w=bl(Error(n(423)),d),d=Qb(l,d,x,p,w);break e}else if(x!==w){w=bl(Error(n(424)),d),d=Qb(l,d,x,p,w);break e}else for(Ws=ri(d.stateNode.containerInfo.firstChild),Hs=d,tn=!0,kr=null,p=cb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(pl(),x===w){d=Ta(l,d,p);break e}ks(l,d,x,p)}d=d.child}return d;case 5:return pb(d),l===null&&zp(d),x=d.type,w=d.pendingProps,S=l!==null?l.memoizedProps:null,I=w.children,Mp(x,w)?I=null:S!==null&&Mp(x,S)&&(d.flags|=32),Gb(l,d),ks(l,d,I,p),d.child;case 6:return l===null&&zp(d),null;case 13:return Xb(l,d,p);case 4:return Kp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=ml(d,null,x,p):ks(l,d,x,p),d.child;case 11:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Wb(l,d,x,w,p);case 7:return ks(l,d,d.pendingProps,p),d.child;case 8:return ks(l,d,d.pendingProps.children,p),d.child;case 12:return ks(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,w=d.pendingProps,S=d.memoizedProps,I=w.value,Wt(pu,x._currentValue),x._currentValue=I,S!==null)if(jr(S.value,I)){if(S.children===w.children&&!Rs.current){d=Ta(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var V=S.dependencies;if(V!==null){I=S.child;for(var Q=V.firstContext;Q!==null;){if(Q.context===x){if(S.tag===1){Q=Ea(-1,p&-p),Q.tag=2;var fe=S.updateQueue;if(fe!==null){fe=fe.shared;var ke=fe.pending;ke===null?Q.next=Q:(Q.next=ke.next,ke.next=Q),fe.pending=Q}}S.lanes|=p,Q=S.alternate,Q!==null&&(Q.lanes|=p),Hp(S.return,p,d),V.lanes|=p;break}Q=Q.next}}else if(S.tag===10)I=S.type===d.type?null:S.child;else if(S.tag===18){if(I=S.return,I===null)throw Error(n(341));I.lanes|=p,V=I.alternate,V!==null&&(V.lanes|=p),Hp(I,p,d),I=S.sibling}else I=S.child;if(I!==null)I.return=S;else for(I=S;I!==null;){if(I===d){I=null;break}if(S=I.sibling,S!==null){S.return=I.return,I=S;break}I=I.return}S=I}ks(l,d,w.children,p),d=d.child}return d;case 9:return w=d.type,x=d.pendingProps.children,xl(d,p),w=ar(w),x=x(w),d.flags|=1,ks(l,d,x,p),d.child;case 14:return x=d.type,w=Sr(x,d.pendingProps),w=Sr(x.type,w),Ub(l,d,x,w,p);case 15:return Kb(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Cu(l,d),d.tag=1,Ps(x)?(l=!0,lu(d)):l=!1,xl(d,p),_b(d,x,w),am(d,x,w,p),cm(null,d,x,!0,l,p);case 19:return ev(l,d,p);case 22:return qb(l,d,p)}throw Error(n(156,d.tag))};function kv(l,d){return Fr(l,d)}function uE(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lr(l,d,p,x){return new uE(l,d,p,x)}function Mm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function hE(l){if(typeof l=="function")return Mm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===z)return 11;if(l===_)return 14}return 2}function mi(l,d){var p=l.alternate;return p===null?(p=lr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function _u(l,d,p,x,w,S){var I=2;if(x=l,typeof l=="function")Mm(l)&&(I=1);else if(typeof l=="string")I=5;else e:switch(l){case L:return bo(p.children,w,S,d);case R:I=8,w|=8;break;case O:return l=lr(12,p,d,w|2),l.elementType=O,l.lanes=S,l;case ce:return l=lr(13,p,d,w),l.elementType=ce,l.lanes=S,l;case me:return l=lr(19,p,d,w),l.elementType=me,l.lanes=S,l;case $:return zu(p,w,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case se:I=10;break e;case ie:I=9;break e;case z:I=11;break e;case _:I=14;break e;case G:I=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=lr(I,p,d,w),d.elementType=l,d.type=x,d.lanes=S,d}function bo(l,d,p,x){return l=lr(7,l,x,d),l.lanes=p,l}function zu(l,d,p,x){return l=lr(22,l,x,d),l.elementType=$,l.lanes=p,l.stateNode={isHidden:!1},l}function Am(l,d,p){return l=lr(6,l,null,d),l.lanes=p,l}function Im(l,d,p){return d=lr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function fE(l,d,p,x,w){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pe(0),this.expirationTimes=Pe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.identifierPrefix=x,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Rm(l,d,p,x,w,S,I,V,Q){return l=new fE(l,d,p,V,Q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=lr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Up(S),l}function pE(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),zm.exports=CE(),zm.exports}var zv;function EE(){if(zv)return Uu;zv=1;var t=Uw();return Uu.createRoot=t.createRoot,Uu.hydrateRoot=t.hydrateRoot,Uu}var TE=EE(),Bd=Uw();const Kw=Ww(Bd);/**
* @remix-run/router v1.23.2
*
* Copyright (c) Remix Software Inc.
@@ -46,7 +46,7 @@ Error generating stack: `+S.message+`
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
- */function wd(){return wd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Xx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function AE(){return Math.random().toString(36).substr(2,8)}function Fv(t,e){return{usr:t.state,key:t.key,idx:e}}function Fg(t,e,n,s){return n===void 0&&(n=null),wd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Zl(e):e,{state:n,key:e&&e.key||s||AE()})}function Mh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function Zl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function IE(t,e,n,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,c=Ti.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(wd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=Ti.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:j.location,delta:k})}function g(v,k){c=Ti.Push;let C=Fg(j.location,v,k);h=f()+1;let E=Fv(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(M)}i&&u&&u({action:c,location:j.location,delta:1})}function y(v,k){c=Ti.Replace;let C=Fg(j.location,v,k);h=f();let E=Fv(C,h),M=j.createHref(C);o.replaceState(E,"",M),i&&u&&u({action:c,location:j.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof v=="string"?v:Mh(v);return C=C.replace(/ $/,"%20"),jn(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}let j={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(zv,m),u=v,()=>{a.removeEventListener(zv,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(v){return o.go(v)}};return j}var $v;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})($v||($v={}));function RE(t,e,n){return n===void 0&&(n="/"),PE(t,e,n)}function PE(t,e,n,s){let a=typeof e=="string"?Zl(e):e,i=Zx(a.pathname||"/",n);if(i==null)return null;let o=Kw(t);OE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(jn(u.relativePath.startsWith(s),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(s.length));let h=Ri([s,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(jn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Kw(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:BE(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of qw(i.path))a(i,o,u)}),e}function qw(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=qw(s.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function OE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:VE(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const DE=/^:[\w-]+$/,LE=3,_E=2,zE=1,FE=10,$E=-2,Bv=t=>t==="*";function BE(t,e){let n=t.split("/"),s=n.length;return n.some(Bv)&&(s+=$E),e&&(s+=_E),n.filter(a=>!Bv(a)).reduce((a,i)=>a+(DE.test(i)?LE:i===""?zE:FE),s)}function VE(t,e){return t.length===e.length&&t.slice(0,-1).every((s,a)=>s===e[a])?t[t.length-1]-e[e.length-1]:0}function HE(t,e,n){let{routesMeta:s}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=i.slice(0,i.length-j.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[g]=void 0:h[g]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function UE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Xx(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),s]}function KE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Xx(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function Zx(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const qE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,GE=t=>qE.test(t);function JE(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:a=""}=typeof t=="string"?Zl(t):t,i;if(n)if(GE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Xx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Vv(n.substring(1),"/"):i=Vv(n,e)}else i=e;return{pathname:i,search:XE(s),hash:ZE(a)}}function Vv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Bm(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function YE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function e0(t,e){let n=YE(t);return e?n.map((s,a)=>a===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function t0(t,e,n,s){s===void 0&&(s=!1);let a;typeof t=="string"?a=Zl(t):(a=wd({},t),jn(!a.pathname||!a.pathname.includes("?"),Bm("?","pathname","search",a)),jn(!a.pathname||!a.pathname.includes("#"),Bm("#","pathname","hash",a)),jn(!a.search||!a.search.includes("#"),Bm("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!s&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=JE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Ri=t=>t.join("/").replace(/\/\/+/g,"/"),QE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),XE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ZE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Gw=["post","put","patch","delete"];new Set(Gw);const tT=["get",...Gw];new Set(tT);/**
+ */function wd(){return wd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Zx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function AE(){return Math.random().toString(36).substr(2,8)}function $v(t,e){return{usr:t.state,key:t.key,idx:e}}function Fg(t,e,n,s){return n===void 0&&(n=null),wd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Zl(e):e,{state:n,key:e&&e.key||s||AE()})}function Mh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function Zl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function IE(t,e,n,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,c=Ti.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(wd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=Ti.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:j.location,delta:k})}function g(v,k){c=Ti.Push;let C=Fg(j.location,v,k);h=f()+1;let E=$v(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(M)}i&&u&&u({action:c,location:j.location,delta:1})}function y(v,k){c=Ti.Replace;let C=Fg(j.location,v,k);h=f();let E=$v(C,h),M=j.createHref(C);o.replaceState(E,"",M),i&&u&&u({action:c,location:j.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof v=="string"?v:Mh(v);return C=C.replace(/ $/,"%20"),wn(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}let j={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(Fv,m),u=v,()=>{a.removeEventListener(Fv,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(v){return o.go(v)}};return j}var Bv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Bv||(Bv={}));function RE(t,e,n){return n===void 0&&(n="/"),PE(t,e,n)}function PE(t,e,n,s){let a=typeof e=="string"?Zl(e):e,i=e0(a.pathname||"/",n);if(i==null)return null;let o=qw(t);OE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(wn(u.relativePath.startsWith(s),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(s.length));let h=Ri([s,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(wn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),qw(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:BE(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of Gw(i.path))a(i,o,u)}),e}function Gw(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=Gw(s.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function OE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:VE(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const DE=/^:[\w-]+$/,LE=3,_E=2,zE=1,FE=10,$E=-2,Vv=t=>t==="*";function BE(t,e){let n=t.split("/"),s=n.length;return n.some(Vv)&&(s+=$E),e&&(s+=_E),n.filter(a=>!Vv(a)).reduce((a,i)=>a+(DE.test(i)?LE:i===""?zE:FE),s)}function VE(t,e){return t.length===e.length&&t.slice(0,-1).every((s,a)=>s===e[a])?t[t.length-1]-e[e.length-1]:0}function HE(t,e,n){let{routesMeta:s}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=i.slice(0,i.length-j.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[g]=void 0:h[g]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function UE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Zx(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),s]}function KE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Zx(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function e0(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const qE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,GE=t=>qE.test(t);function JE(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:a=""}=typeof t=="string"?Zl(t):t,i;if(n)if(GE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Zx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Hv(n.substring(1),"/"):i=Hv(n,e)}else i=e;return{pathname:i,search:XE(s),hash:ZE(a)}}function Hv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Bm(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function YE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function t0(t,e){let n=YE(t);return e?n.map((s,a)=>a===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function n0(t,e,n,s){s===void 0&&(s=!1);let a;typeof t=="string"?a=Zl(t):(a=wd({},t),wn(!a.pathname||!a.pathname.includes("?"),Bm("?","pathname","search",a)),wn(!a.pathname||!a.pathname.includes("#"),Bm("#","pathname","hash",a)),wn(!a.search||!a.search.includes("#"),Bm("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!s&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=JE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Ri=t=>t.join("/").replace(/\/\/+/g,"/"),QE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),XE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ZE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Jw=["post","put","patch","delete"];new Set(Jw);const tT=["get",...Jw];new Set(tT);/**
* React Router v6.30.3
*
* Copyright (c) Remix Software Inc.
@@ -55,7 +55,7 @@ Error generating stack: `+S.message+`
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
- */function jd(){return jd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){s.go(h);return}let m=t0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Ri([e,m.pathname])),(f.replace?s.replace:s.push)(m,f.state,f)},[e,s,o,i,t])}const aT=b.createContext(null);function iT(t){let e=b.useContext(qa).outlet;return e&&b.createElement(aT.Provider,{value:t},e)}function Qw(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=b.useContext(Wi),{matches:a}=b.useContext(qa),{pathname:i}=Ui(),o=JSON.stringify(e0(a,s.v7_relativeSplatPath));return b.useMemo(()=>t0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function oT(t,e){return lT(t,e)}function lT(t,e,n,s){ec()||jn(!1);let{navigator:a}=b.useContext(Wi),{matches:i}=b.useContext(qa),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Ui(),f;if(e){var m;let v=typeof e=="string"?Zl(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||jn(!1),f=v}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let v=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=RE(t,{pathname:y}),j=fT(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:Ri([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:Ri([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,s);return e&&j?b.createElement(Pf.Provider,{value:{location:jd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Ti.Pop}},j):j}function cT(){let t=xT(),e=eT(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const dT=b.createElement(cT,null);class uT extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(qa.Provider,{value:this.props.routeContext},b.createElement(Jw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hT(t){let{routeContext:e,match:n,children:s}=t,a=b.useContext(n0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(qa.Provider,{value:e},s)}function fT(t,e,n,s){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||jn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&s&&s.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,N=!1,j=null,v=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||dT,u&&(h<0&&g===0?(bT("route-fallback"),N=!0,v=null):h===g&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:N?E=v:m.route.Component?E=b.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,b.createElement(hT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(uT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var Xw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Xw||{}),Zw=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(Zw||{});function pT(t){let e=b.useContext(n0);return e||jn(!1),e}function mT(t){let e=b.useContext(nT);return e||jn(!1),e}function gT(t){let e=b.useContext(qa);return e||jn(!1),e}function ej(t){let e=gT(),n=e.matches[e.matches.length-1];return n.route.id||jn(!1),n.route.id}function xT(){var t;let e=b.useContext(Jw),n=mT(),s=ej();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function yT(){let{router:t}=pT(Xw.UseNavigateStable),e=ej(Zw.UseNavigateStable),n=b.useRef(!1);return Yw(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,jd({fromRouteId:e},i)))},[t,e])}const Hv={};function bT(t,e,n){Hv[t]||(Hv[t]=!0)}function vT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vm(t){let{to:e,replace:n,state:s,relative:a}=t;ec()||jn(!1);let{future:i,static:o}=b.useContext(Wi),{matches:c}=b.useContext(qa),{pathname:u}=Ui(),h=Ki(),f=t0(e,e0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:s,relative:a}),[h,m,a,n,s]),null}function NT(t){return iT(t.context)}function Wt(t){jn(!1)}function wT(t){let{basename:e="/",children:n=null,location:s,navigationType:a=Ti.Pop,navigator:i,static:o=!1,future:c}=t;ec()&&jn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:jd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof s=="string"&&(s=Zl(s));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:N="default"}=s,j=b.useMemo(()=>{let v=Zx(f,u);return v==null?null:{location:{pathname:v,search:m,hash:g,state:y,key:N},navigationType:a}},[u,f,m,g,y,N,a]);return j==null?null:b.createElement(Wi.Provider,{value:h},b.createElement(Pf.Provider,{children:n,value:j}))}function jT(t){let{children:e,location:n}=t;return oT($g(e),n)}new Promise(()=>{});function $g(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(s,a)=>{if(!b.isValidElement(s))return;let i=[...e,a];if(s.type===b.Fragment){n.push.apply(n,$g(s.props.children,i));return}s.type!==Wt&&jn(!1),!s.props.index||!s.props.children||jn(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=$g(s.props.children,i)),n.push(o)}),n}/**
+ */function jd(){return jd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){s.go(h);return}let m=n0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Ri([e,m.pathname])),(f.replace?s.replace:s.push)(m,f.state,f)},[e,s,o,i,t])}const aT=b.createContext(null);function iT(t){let e=b.useContext(qa).outlet;return e&&b.createElement(aT.Provider,{value:t},e)}function Xw(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=b.useContext(Wi),{matches:a}=b.useContext(qa),{pathname:i}=Ui(),o=JSON.stringify(t0(a,s.v7_relativeSplatPath));return b.useMemo(()=>n0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function oT(t,e){return lT(t,e)}function lT(t,e,n,s){ec()||wn(!1);let{navigator:a}=b.useContext(Wi),{matches:i}=b.useContext(qa),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Ui(),f;if(e){var m;let v=typeof e=="string"?Zl(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||wn(!1),f=v}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let v=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=RE(t,{pathname:y}),j=fT(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:Ri([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:Ri([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,s);return e&&j?b.createElement(Pf.Provider,{value:{location:jd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Ti.Pop}},j):j}function cT(){let t=xT(),e=eT(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const dT=b.createElement(cT,null);class uT extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(qa.Provider,{value:this.props.routeContext},b.createElement(Yw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hT(t){let{routeContext:e,match:n,children:s}=t,a=b.useContext(s0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(qa.Provider,{value:e},s)}function fT(t,e,n,s){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||wn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&s&&s.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,N=!1,j=null,v=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||dT,u&&(h<0&&g===0?(bT("route-fallback"),N=!0,v=null):h===g&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:N?E=v:m.route.Component?E=b.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,b.createElement(hT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(uT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var Zw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Zw||{}),ej=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(ej||{});function pT(t){let e=b.useContext(s0);return e||wn(!1),e}function mT(t){let e=b.useContext(nT);return e||wn(!1),e}function gT(t){let e=b.useContext(qa);return e||wn(!1),e}function tj(t){let e=gT(),n=e.matches[e.matches.length-1];return n.route.id||wn(!1),n.route.id}function xT(){var t;let e=b.useContext(Yw),n=mT(),s=tj();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function yT(){let{router:t}=pT(Zw.UseNavigateStable),e=tj(ej.UseNavigateStable),n=b.useRef(!1);return Qw(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,jd({fromRouteId:e},i)))},[t,e])}const Wv={};function bT(t,e,n){Wv[t]||(Wv[t]=!0)}function vT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vm(t){let{to:e,replace:n,state:s,relative:a}=t;ec()||wn(!1);let{future:i,static:o}=b.useContext(Wi),{matches:c}=b.useContext(qa),{pathname:u}=Ui(),h=Ki(),f=n0(e,t0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:s,relative:a}),[h,m,a,n,s]),null}function NT(t){return iT(t.context)}function Ut(t){wn(!1)}function wT(t){let{basename:e="/",children:n=null,location:s,navigationType:a=Ti.Pop,navigator:i,static:o=!1,future:c}=t;ec()&&wn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:jd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof s=="string"&&(s=Zl(s));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:N="default"}=s,j=b.useMemo(()=>{let v=e0(f,u);return v==null?null:{location:{pathname:v,search:m,hash:g,state:y,key:N},navigationType:a}},[u,f,m,g,y,N,a]);return j==null?null:b.createElement(Wi.Provider,{value:h},b.createElement(Pf.Provider,{children:n,value:j}))}function jT(t){let{children:e,location:n}=t;return oT($g(e),n)}new Promise(()=>{});function $g(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(s,a)=>{if(!b.isValidElement(s))return;let i=[...e,a];if(s.type===b.Fragment){n.push.apply(n,$g(s.props.children,i));return}s.type!==Ut&&wn(!1),!s.props.index||!s.props.children||wn(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=$g(s.props.children,i)),n.push(o)}),n}/**
* React Router DOM v6.30.3
*
* Copyright (c) Remix Software Inc.
@@ -64,12 +64,12 @@ Error generating stack: `+S.message+`
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
- */function Bg(){return Bg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function ST(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function CT(t,e){return t.button===0&&(!e||e==="_self")&&!ST(t)}function Vg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let s=t[n];return e.concat(Array.isArray(s)?s.map(a=>[n,a]):[[n,s]])},[]))}function ET(t,e){let n=Vg(t);return e&&e.forEach((s,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const TT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],MT="6";try{window.__reactRouterVersion=MT}catch{}const AT="startTransition",Wv=Rf[AT];function IT(t){let{basename:e,children:n,future:s,window:a}=t,i=b.useRef();i.current==null&&(i.current=ME({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=s||{},f=b.useCallback(m=>{h&&Wv?Wv(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>vT(s),[s]),b.createElement(wT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:s})}const RT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",PT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Hg=b.forwardRef(function(e,n){let{onClick:s,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=kT(e,TT),{basename:y}=b.useContext(Wi),N,j=!1;if(typeof h=="string"&&PT.test(h)&&(N=h,RT))try{let E=new URL(window.location.href),M=h.startsWith("//")?new URL(E.protocol+h):new URL(h),P=Zx(M.pathname,y);M.origin===E.origin&&P!=null?h=P+M.search+M.hash:j=!0}catch{}let v=sT(h,{relative:a}),k=OT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function C(E){s&&s(E),E.defaultPrevented||k(E)}return b.createElement("a",Bg({},g,{href:N||v,onClick:j||i?s:C,ref:n,target:u}))});var Uv;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Uv||(Uv={}));var Kv;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Kv||(Kv={}));function OT(t,e){let{target:n,replace:s,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Ki(),h=Ui(),f=Qw(t,{relative:o});return b.useCallback(m=>{if(CT(m,n)){m.preventDefault();let g=s!==void 0?s:Mh(h)===Mh(f);u(t,{replace:g,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,s,a,n,t,i,o,c])}function tj(t){let e=b.useRef(Vg(t)),n=b.useRef(!1),s=Ui(),a=b.useMemo(()=>ET(s.search,n.current?null:e.current),[s.search]),i=Ki(),o=b.useCallback((c,u)=>{const h=Vg(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/**
+ */function Bg(){return Bg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function ST(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function CT(t,e){return t.button===0&&(!e||e==="_self")&&!ST(t)}function Vg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let s=t[n];return e.concat(Array.isArray(s)?s.map(a=>[n,a]):[[n,s]])},[]))}function ET(t,e){let n=Vg(t);return e&&e.forEach((s,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const TT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],MT="6";try{window.__reactRouterVersion=MT}catch{}const AT="startTransition",Uv=Rf[AT];function IT(t){let{basename:e,children:n,future:s,window:a}=t,i=b.useRef();i.current==null&&(i.current=ME({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=s||{},f=b.useCallback(m=>{h&&Uv?Uv(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>vT(s),[s]),b.createElement(wT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:s})}const RT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",PT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Hg=b.forwardRef(function(e,n){let{onClick:s,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=kT(e,TT),{basename:y}=b.useContext(Wi),N,j=!1;if(typeof h=="string"&&PT.test(h)&&(N=h,RT))try{let E=new URL(window.location.href),M=h.startsWith("//")?new URL(E.protocol+h):new URL(h),P=e0(M.pathname,y);M.origin===E.origin&&P!=null?h=P+M.search+M.hash:j=!0}catch{}let v=sT(h,{relative:a}),k=OT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function C(E){s&&s(E),E.defaultPrevented||k(E)}return b.createElement("a",Bg({},g,{href:N||v,onClick:j||i?s:C,ref:n,target:u}))});var Kv;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Kv||(Kv={}));var qv;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(qv||(qv={}));function OT(t,e){let{target:n,replace:s,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Ki(),h=Ui(),f=Xw(t,{relative:o});return b.useCallback(m=>{if(CT(m,n)){m.preventDefault();let g=s!==void 0?s:Mh(h)===Mh(f);u(t,{replace:g,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,s,a,n,t,i,o,c])}function nj(t){let e=b.useRef(Vg(t)),n=b.useRef(!1),s=Ui(),a=b.useMemo(()=>ET(s.search,n.current?null:e.current),[s.search]),i=Ki(),o=b.useCallback((c,u)=>{const h=Vg(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const DT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),LT=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,s)=>s?s.toUpperCase():n.toLowerCase()),qv=t=>{const e=LT(t);return e.charAt(0).toUpperCase()+e.slice(1)},nj=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim(),_T=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
+ */const DT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),LT=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,s)=>s?s.toUpperCase():n.toLowerCase()),Gv=t=>{const e=LT(t);return e.charAt(0).toUpperCase()+e.slice(1)},sj=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim(),_T=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -79,12 +79,12 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const FT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...zT,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:nj("lucide",a),...!i&&!_T(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(i)?i:[i]]));/**
+ */const FT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...zT,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:sj("lucide",a),...!i&&!_T(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(i)?i:[i]]));/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const Ie=(t,e)=>{const n=b.forwardRef(({className:s,...a},i)=>b.createElement(FT,{ref:i,iconNode:e,className:nj(`lucide-${DT(qv(t))}`,`lucide-${t}`,s),...a}));return n.displayName=qv(t),n};/**
+ */const Ie=(t,e)=>{const n=b.forwardRef(({className:s,...a},i)=>b.createElement(FT,{ref:i,iconNode:e,className:sj(`lucide-${DT(Gv(t))}`,`lucide-${t}`,s),...a}));return n.displayName=Gv(t),n};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -94,7 +94,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const BT=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Gv=Ie("bitcoin",BT);/**
+ */const BT=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Jv=Ie("bitcoin",BT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -139,17 +139,17 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const XT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],sj=Ie("chevron-up",XT);/**
+ */const XT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],rj=Ie("chevron-up",XT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const ZT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],rj=Ie("circle-alert",ZT);/**
+ */const ZT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aj=Ie("circle-alert",ZT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const eM=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Jv=Ie("circle-check-big",eM);/**
+ */const eM=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Yv=Ie("circle-check-big",eM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -159,7 +159,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const nM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aj=Ie("circle-question-mark",nM);/**
+ */const nM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ij=Ie("circle-question-mark",nM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -169,7 +169,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const rM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ij=Ie("circle-x",rM);/**
+ */const rM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],oj=Ie("circle-x",rM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -189,12 +189,12 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const dM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],s0=Ie("copy",dM);/**
+ */const dM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],r0=Ie("copy",dM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const uM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Yv=Ie("credit-card",uM);/**
+ */const uM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Qv=Ie("credit-card",uM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -224,17 +224,17 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const yM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],oj=Ie("file-text",yM);/**
+ */const yM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],lj=Ie("file-text",yM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const bM=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],lj=Ie("funnel",bM);/**
+ */const bM=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],cj=Ie("funnel",bM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const vM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],cj=Ie("gift",vM);/**
+ */const vM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],dj=Ie("gift",vM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -264,7 +264,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const MM=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Qv=Ie("hash",MM);/**
+ */const MM=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Xv=Ie("hash",MM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -289,7 +289,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const zM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],dj=Ie("image",zM);/**
+ */const zM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],uj=Ie("image",zM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -304,7 +304,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const VM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],uj=Ie("key",VM);/**
+ */const VM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],hj=Ie("key",VM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -344,7 +344,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const t5=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],hj=Ie("map-pin",t5);/**
+ */const t5=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],fj=Ie("map-pin",t5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -374,7 +374,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const u5=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ut=Ie("pen-line",u5);/**
+ */const u5=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Kt=Ie("pen-line",u5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -404,7 +404,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const v5=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Xv=Ie("qr-code",v5);/**
+ */const v5=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Zv=Ie("qr-code",v5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -419,12 +419,12 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const S5=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Fe=Ie("refresh-cw",S5);/**
+ */const S5=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],$e=Ie("refresh-cw",S5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const C5=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],wn=Ie("save",C5);/**
+ */const C5=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Nn=Ie("save",C5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -484,7 +484,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const B5=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Zn=Ie("trash-2",B5);/**
+ */const B5=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qn=Ie("trash-2",B5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -499,7 +499,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const W5=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],fj=Ie("undo-2",W5);/**
+ */const W5=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Zg=Ie("undo-2",W5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -524,7 +524,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const Y5=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],_n=Ie("users",Y5);/**
+ */const Y5=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Ln=Ie("users",Y5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -539,7 +539,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const Z5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Fa=Ie("zap",Z5),r0="admin_token";function Df(){try{return localStorage.getItem(r0)}catch{return null}}function eA(t){try{localStorage.setItem(r0,t)}catch{}}function Um(){try{localStorage.removeItem(r0)}catch{}}const tA="https://soulapi.quwanzhi.com",nA=15e3,Zv=6e4,sA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):tA};function Lo(t){const e=sA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Lf(t,e={}){const{data:n,...s}=e,a=Lo(t),i=new Headers(s.headers),o=Df();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):s.body,u=s.timeout??nA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...s,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),y=(m.headers.get("Content-Type")||"").includes("application/json")?await m.json():m,N=j=>{const v=j,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(y);const j=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw j.status=m.status,j.data=y,j}return N(y),y}function De(t,e){return Lf(t,{...e,method:"GET"})}function Nt(t,e,n){return Lf(t,{...n,method:"POST",data:e})}function Ot(t,e,n){return Lf(t,{...n,method:"PUT",data:e})}function ea(t,e){return Lf(t,{...e,method:"DELETE"})}function rA(){const[t,e]=b.useState(!1),[n,s]=b.useState("");return b.useEffect(()=>{const a=i=>{const o=i.detail;s(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?r.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(rj,{className:"w-5 h-5 shrink-0 text-red-400"}),r.jsxs("span",{className:"text-sm font-medium",children:[n,r.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),r.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:r.jsx(gs,{className:"w-4 h-4"})})]}):null}const aA=[{icon:WM,label:"数据概览",href:"/dashboard"},{icon:Ys,label:"内容管理",href:"/content"},{icon:_n,label:"用户管理",href:"/users"},{icon:wM,label:"找伙伴",href:"/find-partner"},{icon:Wl,label:"推广中心",href:"/distribution"}];function iA(){const t=Ui(),e=Ki(),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{s(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!Df()){e("/login",{replace:!0});return}return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(Um(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(Um(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{Um();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[r.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[r.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),r.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[aA.map(c=>{const u=t.pathname===c.href;return r.jsxs(Hg,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),r.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:r.jsxs(Hg,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(Mo,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),r.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:r.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[r.jsx(e5,{className:"w-5 h-5"}),r.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),r.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[r.jsx(rA,{}),r.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:r.jsx(NT,{})})]})]})}function e1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function a0(...t){return e=>{let n=!1;const s=t.map(a=>{const i=e1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=s;pj(i)&&typeof Ph=="function"&&(i=Ph(i._payload));const c=b.Children.toArray(i),u=c.find(uA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var gj=mj("Slot");function cA(t){const e=b.forwardRef((n,s)=>{let{children:a,...i}=n;if(pj(a)&&typeof Ph=="function"&&(a=Ph(a._payload)),b.isValidElement(a)){const o=fA(a),c=hA(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dA=Symbol("radix.slottable");function uA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dA}function hA(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function fA(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function xj(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,n1=yj,bj=(t,e)=>n=>{var s;if((e==null?void 0:e.variants)==null)return n1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const g=t1(f)||t1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(N=>{let[j,v]=N;return Array.isArray(v)?v.includes({...i,...c}[j]):{...i,...c}[j]===v})?[...h,m,g]:h},[]);return n1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},pA=(t,e)=>{const n=new Array(t.length+e.length);for(let s=0;s({classGroupId:t,validator:e}),vj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Oh="-",s1=[],gA="arbitrary..",xA=t=>{const e=bA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return yA(o);const c=o.split(Oh),u=c[0]===""&&c.length>1?1:0;return Nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=s[o],h=n[o];return u?h?pA(h,u):u:h||s1}return n[o]||s1}}},Nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=Nj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Oh):t.slice(e).join(Oh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),s=e.slice(0,n);return s?gA+s:void 0})(),bA=t=>{const{theme:e,classGroups:n}=t;return vA(n,e)},vA=(t,e)=>{const n=vj();for(const s in t){const a=t[s];i0(a,n,s,e)}return n},i0=(t,e,n,s)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){wA(t,e,n);return}if(typeof t=="function"){jA(t,e,n,s);return}kA(t,e,n,s)},wA=(t,e,n)=>{const s=t===""?e:wj(e,t);s.classGroupId=n},jA=(t,e,n,s)=>{if(SA(t)){i0(t(s),e,n,s);return}e.validators===null&&(e.validators=[]),e.validators.push(mA(n,t))},kA=(t,e,n,s)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const s=e.split(Oh),a=s.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,CA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),s=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,s=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Zg="!",r1=":",EA=[],a1=(t,e,n,s,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:s,isExternal:a}),TA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let s=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let j=0;ju?h-u:void 0;return a1(i,y,g,N)};if(e){const a=e+r1,i=s;s=o=>o.startsWith(a)?i(o.slice(a.length)):a1(EA,!1,o,void 0,!0)}if(n){const a=s;s=i=>n({className:i,parseClassName:a})}return s},MA=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,s)=>{e.set(n,1e6+s)}),n=>{const s=[];let a=[];for(let i=0;i0&&(a.sort(),s.push(...a),a=[]),s.push(o)):a.push(o)}return a.length>0&&(a.sort(),s.push(...a)),s}},AA=t=>({cache:CA(t.cacheSize),parseClassName:TA(t),sortModifiers:MA(t),...xA(t)}),IA=/\s+/,RA=(t,e)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(IA);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!j,k=s(v?N.substring(0,j):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=s(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const C=g.length===0?"":g.length===1?g[0]:i(g).join(":"),E=y?C+Zg:C,M=E+k;if(o.indexOf(M)>-1)continue;o.push(M);const P=a(k,v);for(let H=0;H0?" "+u:u)}return u},PA=(...t)=>{let e=0,n,s,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let s=0;s{let n,s,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=AA(h),s=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=s(u);if(h)return h;const f=RA(u,n);return a(u,f),f};return i=o,(...u)=>i(PA(...u))},DA=[],Dn=t=>{const e=n=>n[t]||DA;return e.isThemeGetter=!0,e},kj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Sj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,LA=/^\d+\/\d+$/,_A=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zA=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,FA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$A=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kl=t=>LA.test(t),ft=t=>!!t&&!Number.isNaN(Number(t)),xi=t=>!!t&&Number.isInteger(Number(t)),Km=t=>t.endsWith("%")&&ft(t.slice(0,-1)),Ia=t=>_A.test(t),VA=()=>!0,HA=t=>zA.test(t)&&!FA.test(t),Cj=()=>!1,WA=t=>$A.test(t),UA=t=>BA.test(t),KA=t=>!Be(t)&&!Ve(t),qA=t=>tc(t,Mj,Cj),Be=t=>kj.test(t),vo=t=>tc(t,Aj,HA),qm=t=>tc(t,XA,ft),i1=t=>tc(t,Ej,Cj),GA=t=>tc(t,Tj,UA),Gu=t=>tc(t,Ij,WA),Ve=t=>Sj.test(t),Jc=t=>nc(t,Aj),JA=t=>nc(t,ZA),o1=t=>nc(t,Ej),YA=t=>nc(t,Mj),QA=t=>nc(t,Tj),Ju=t=>nc(t,Ij,!0),tc=(t,e,n)=>{const s=kj.exec(t);return s?s[1]?e(s[1]):n(s[2]):!1},nc=(t,e,n=!1)=>{const s=Sj.exec(t);return s?s[1]?e(s[1]):n:!1},Ej=t=>t==="position"||t==="percentage",Tj=t=>t==="image"||t==="url",Mj=t=>t==="length"||t==="size"||t==="bg-size",Aj=t=>t==="length",XA=t=>t==="number",ZA=t=>t==="family-name",Ij=t=>t==="shadow",eI=()=>{const t=Dn("color"),e=Dn("font"),n=Dn("text"),s=Dn("font-weight"),a=Dn("tracking"),i=Dn("leading"),o=Dn("breakpoint"),c=Dn("container"),u=Dn("spacing"),h=Dn("radius"),f=Dn("shadow"),m=Dn("inset-shadow"),g=Dn("text-shadow"),y=Dn("drop-shadow"),N=Dn("blur"),j=Dn("perspective"),v=Dn("aspect"),k=Dn("ease"),C=Dn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...M(),Ve,Be],H=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],R=()=>[Ve,Be,u],O=()=>[kl,"full","auto",...R()],se=()=>[xi,"none","subgrid",Ve,Be],ie=()=>["auto",{span:["full",xi,Ve,Be]},xi,Ve,Be],z=()=>[xi,"auto",Ve,Be],ce=()=>["auto","min","max","fr",Ve,Be],me=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...R()],$=()=>[kl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],A=()=>[t,Ve,Be],Y=()=>[...M(),o1,i1,{position:[Ve,Be]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",YA,qA,{size:[Ve,Be]}],W=()=>[Km,Jc,vo],le=()=>["","none","full",h,Ve,Be],ye=()=>["",ft,Jc,vo],Ae=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[ft,Km,o1,i1],J=()=>["","none",N,Ve,Be],ge=()=>["none",ft,Ve,Be],ae=()=>["none",ft,Ve,Be],pe=()=>[ft,Ve,Be],Se=()=>[kl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ia],breakpoint:[Ia],color:[VA],container:[Ia],"drop-shadow":[Ia],ease:["in","out","in-out"],font:[KA],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ia],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ia],shadow:[Ia],spacing:["px",ft],text:[Ia],"text-shadow":[Ia],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kl,Be,Ve,v]}],container:["container"],columns:[{columns:[ft,Be,Ve,c]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[xi,"auto",Ve,Be]}],basis:[{basis:[kl,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ft,kl,"auto","initial","none",Be]}],grow:[{grow:["",ft,Ve,Be]}],shrink:[{shrink:["",ft,Ve,Be]}],order:[{order:[xi,"first","last","none",Ve,Be]}],"grid-cols":[{"grid-cols":se()}],"col-start-end":[{col:ie()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":se()}],"row-start-end":[{row:ie()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ce()}],"auto-rows":[{"auto-rows":ce()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...me(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...me()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":me()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],w:[{w:[c,"screen",...$()]}],"min-w":[{"min-w":[c,"screen","none",...$()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",n,Jc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,Ve,qm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Km,Be]}],"font-family":[{font:[JA,Be,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Ve,Be]}],"line-clamp":[{"line-clamp":[ft,"none",Ve,qm]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",Ve,Be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ve,Be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[ft,"from-font","auto",Ve,vo]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[ft,"auto",Ve,Be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ve,Be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ve,Be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xi,Ve,Be],radial:["",Ve,Be],conic:[xi,Ve,Be]},QA,GA]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:ye()}],"border-w-x":[{"border-x":ye()}],"border-w-y":[{"border-y":ye()}],"border-w-s":[{"border-s":ye()}],"border-w-e":[{"border-e":ye()}],"border-w-t":[{"border-t":ye()}],"border-w-r":[{"border-r":ye()}],"border-w-b":[{"border-b":ye()}],"border-w-l":[{"border-l":ye()}],"divide-x":[{"divide-x":ye()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ye()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ae(),"hidden","none"]}],"divide-style":[{divide:[...Ae(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...Ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ft,Ve,Be]}],"outline-w":[{outline:["",ft,Jc,vo]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",f,Ju,Gu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",m,Ju,Gu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[ft,vo]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ye()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",g,Ju,Gu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[ft,Ve,Be]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ft]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ve,Be]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[ft]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ve,Be]}],filter:[{filter:["","none",Ve,Be]}],blur:[{blur:J()}],brightness:[{brightness:[ft,Ve,Be]}],contrast:[{contrast:[ft,Ve,Be]}],"drop-shadow":[{"drop-shadow":["","none",y,Ju,Gu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",ft,Ve,Be]}],"hue-rotate":[{"hue-rotate":[ft,Ve,Be]}],invert:[{invert:["",ft,Ve,Be]}],saturate:[{saturate:[ft,Ve,Be]}],sepia:[{sepia:["",ft,Ve,Be]}],"backdrop-filter":[{"backdrop-filter":["","none",Ve,Be]}],"backdrop-blur":[{"backdrop-blur":J()}],"backdrop-brightness":[{"backdrop-brightness":[ft,Ve,Be]}],"backdrop-contrast":[{"backdrop-contrast":[ft,Ve,Be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ft,Ve,Be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ft,Ve,Be]}],"backdrop-invert":[{"backdrop-invert":["",ft,Ve,Be]}],"backdrop-opacity":[{"backdrop-opacity":[ft,Ve,Be]}],"backdrop-saturate":[{"backdrop-saturate":[ft,Ve,Be]}],"backdrop-sepia":[{"backdrop-sepia":["",ft,Ve,Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ve,Be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ft,"initial",Ve,Be]}],ease:[{ease:["linear","initial",k,Ve,Be]}],delay:[{delay:[ft,Ve,Be]}],animate:[{animate:["none",C,Ve,Be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Ve,Be]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:pe()}],"skew-x":[{"skew-x":pe()}],"skew-y":[{"skew-y":pe()}],transform:[{transform:[Ve,Be,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ve,Be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ve,Be]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[ft,Jc,vo,qm]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},tI=OA(eI);function Mt(...t){return tI(yj(t))}const nI=bj("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground 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 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:s=!1,...a}){const i=s?gj:"button";return r.jsx(i,{"data-slot":"button",className:Mt(nI({variant:e,size:n,className:t})),...a})}function re({className:t,type:e,...n}){return r.jsx("input",{type:e,"data-slot":"input",className:Mt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function sI(){const t=Ki(),[e,n]=b.useState(""),[s,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await Nt("/api/admin",{username:e.trim(),password:s});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){eA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return r.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),r.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),r.jsxs("div",{className:"w-full max-w-md relative z-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:r.jsx(od,{className:"w-8 h-8 text-[#38bdac]"})}),r.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),r.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),r.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[r.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ao,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"text",value:e,onChange:f=>n(f.target.value),placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),r.jsxs("div",{className:"relative",children:[r.jsx(XM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"password",value:s,onChange:f=>a(f.target.value),placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&r.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),r.jsx(X,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),r.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ee=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ee.displayName="Card";const Je=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex flex-col space-y-1.5 p-6",t),...e}));Je.displayName="CardHeader";const Ye=b.forwardRef(({className:t,...e},n)=>r.jsx("h3",{ref:n,className:Mt("font-semibold leading-none tracking-tight",t),...e}));Ye.displayName="CardTitle";const Ft=b.forwardRef(({className:t,...e},n)=>r.jsx("p",{ref:n,className:Mt("text-sm text-muted-foreground",t),...e}));Ft.displayName="CardDescription";const Te=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("p-6 pt-0",t),...e}));Te.displayName="CardContent";const rI=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex items-center p-6 pt-0",t),...e}));rI.displayName="CardFooter";const aI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Gm(t,e="info",n=3e3){const s=`toast-${Date.now()}`,a=aI[e],i=document.createElement("div");i.id=s,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(s),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const te={success:(t,e)=>Gm(t,"success",e),error:(t,e)=>Gm(t,"error",e),info:(t,e)=>Gm(t,"info",e)};function dt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function iI(t,e){const n=b.createContext(e),s=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:o})};s.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,a]}function qi(t,e=[]){let n=[];function s(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...N}=m,j=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,v=b.useMemo(()=>N,Object.values(N));return r.jsx(j.Provider,{value:v,children:y})};h.displayName=i+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[s,oI(a,...e)]}function oI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const s=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var xs=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},lI=Rf[" useId ".trim().toString()]||(()=>{}),cI=0;function Pi(t){const[e,n]=b.useState(lI());return xs(()=>{n(s=>s??String(cI++))},[t]),e?`radix-${e}`:""}var dI=Rf[" useInsertionEffect ".trim().toString()]||xs;function _o({prop:t,defaultProp:e,onChange:n=()=>{},caller:s}){const[a,i,o]=uI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const h=b.useCallback(f=>{var m;if(c){const g=hI(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else i(f)},[c,t,i,o]);return[u,h]}function uI({defaultProp:t,onChange:e}){const[n,s]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return dI(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,s,i]}function hI(t){return typeof t=="function"}function Sd(t){const e=fI(t),n=b.forwardRef((s,a)=>{const{children:i,...o}=s,c=b.Children.toArray(i),u=c.find(mI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function fI(t){const e=b.forwardRef((n,s)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=xI(a),c=gI(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pI=Symbol("radix.slottable");function mI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pI}function gI(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function xI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pt=yI.reduce((t,e)=>{const n=Sd(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function bI(t,e){t&&Bd.flushSync(()=>t.dispatchEvent(e))}function Fi(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var s;return(s=e.current)==null?void 0:s.call(e,...n)},[])}function vI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t);b.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[n,e])}var NI="DismissableLayer",ex="dismissableLayer.update",wI="dismissableLayer.pointerDownOutside",jI="dismissableLayer.focusOutside",l1,Rj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),o0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Rj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=Tt(e,L=>m(L)),j=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(v),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=k,P=CI(L=>{const R=L.target,O=[...h.branches].some(se=>se.contains(R));!M||O||(a==null||a(L),o==null||o(L),L.defaultPrevented||c==null||c())},g),H=EI(L=>{const R=L.target;[...h.branches].some(se=>se.contains(R))||(i==null||i(L),o==null||o(L),L.defaultPrevented||c==null||c())},g);return vI(L=>{C===h.layers.size-1&&(s==null||s(L),!L.defaultPrevented&&c&&(L.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(l1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),c1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=l1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),c1())},[f,h]),b.useEffect(()=>{const L=()=>y({});return document.addEventListener(ex,L),()=>document.removeEventListener(ex,L)},[]),r.jsx(pt.div,{...u,ref:N,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:dt(t.onFocusCapture,H.onFocusCapture),onBlurCapture:dt(t.onBlurCapture,H.onBlurCapture),onPointerDownCapture:dt(t.onPointerDownCapture,P.onPointerDownCapture)})});o0.displayName=NI;var kI="DismissableLayerBranch",SI=b.forwardRef((t,e)=>{const n=b.useContext(Rj),s=b.useRef(null),a=Tt(e,s);return b.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(pt.div,{...t,ref:a})});SI.displayName=kI;function CI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!s.current){let u=function(){Pj(wI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>s.current=!0}}function EI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!s.current&&Pj(jI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function c1(){const t=new CustomEvent(ex);document.dispatchEvent(t)}function Pj(t,e,n,{discrete:s}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),s?bI(a,i):a.dispatchEvent(i)}var Jm="focusScope.autoFocusOnMount",Ym="focusScope.autoFocusOnUnmount",d1={bubbles:!1,cancelable:!0},TI="FocusScope",l0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=Fi(a),f=Fi(i),m=b.useRef(null),g=Tt(e,j=>u(j)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:vi(m.current,{select:!0})},v=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||vi(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const P of E)P.removedNodes.length>0&&vi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",v);const C=new MutationObserver(k);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",v),C.disconnect()}}},[s,c,y.paused]),b.useEffect(()=>{if(c){h1.add(y);const j=document.activeElement;if(!c.contains(j)){const k=new CustomEvent(Jm,d1);c.addEventListener(Jm,h),c.dispatchEvent(k),k.defaultPrevented||(MI(OI(Oj(c)),{select:!0}),document.activeElement===j&&vi(c))}return()=>{c.removeEventListener(Jm,h),setTimeout(()=>{const k=new CustomEvent(Ym,d1);c.addEventListener(Ym,f),c.dispatchEvent(k),k.defaultPrevented||vi(j??document.body,{select:!0}),c.removeEventListener(Ym,f),h1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(j=>{if(!n&&!s||y.paused)return;const v=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(v&&k){const C=j.currentTarget,[E,M]=AI(C);E&&M?!j.shiftKey&&k===M?(j.preventDefault(),n&&vi(E,{select:!0})):j.shiftKey&&k===E&&(j.preventDefault(),n&&vi(M,{select:!0})):k===C&&j.preventDefault()}},[n,s,y.paused]);return r.jsx(pt.div,{tabIndex:-1,...o,ref:g,onKeyDown:N})});l0.displayName=TI;function MI(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(vi(s,{select:e}),document.activeElement!==n)return}function AI(t){const e=Oj(t),n=u1(e,t),s=u1(e.reverse(),t);return[n,s]}function Oj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function u1(t,e){for(const n of t)if(!II(n,{upTo:e}))return n}function II(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function RI(t){return t instanceof HTMLInputElement&&"select"in t}function vi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&RI(t)&&e&&t.select()}}var h1=PI();function PI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=f1(t,e),t.unshift(e)},remove(e){var n;t=f1(t,e),(n=t[0])==null||n.resume()}}}function f1(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}function OI(t){return t.filter(e=>e.tagName!=="A")}var DI="Portal",c0=b.forwardRef((t,e)=>{var c;const{container:n,...s}=t,[a,i]=b.useState(!1);xs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Uw.createPortal(r.jsx(pt.div,{...s,ref:e}),o):null});c0.displayName=DI;function LI(t,e){return b.useReducer((n,s)=>e[n][s]??n,t)}var Vd=t=>{const{present:e,children:n}=t,s=_I(e),a=typeof n=="function"?n({present:s.isPresent}):b.Children.only(n),i=Tt(s.ref,zI(a));return typeof n=="function"||s.isPresent?b.cloneElement(a,{ref:i}):null};Vd.displayName="Presence";function _I(t){const[e,n]=b.useState(),s=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=LI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=Yu(s.current);i.current=c==="mounted"?h:"none"},[c]),xs(()=>{const h=s.current,f=a.current;if(f!==t){const g=i.current,y=Yu(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),xs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=Yu(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=y=>{y.target===e&&(i.current=Yu(s.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{s.current=h?getComputedStyle(h):null,n(h)},[])}}function Yu(t){return(t==null?void 0:t.animationName)||"none"}function zI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Qm=0;function Dj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??p1()),document.body.insertAdjacentElement("beforeend",t[1]??p1()),Qm++,()=>{Qm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qm--}},[])}function p1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ta=function(){return ta=Object.assign||function(e){for(var n,s=1,a=arguments.length;s"u")return tR;var e=nR(t),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-n+e[2]-e[0])}},rR=Fj(),$l="data-scroll-locked",aR=function(t,e,n,s){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
+ */const Z5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Fa=Ie("zap",Z5),a0="admin_token";function Df(){try{return localStorage.getItem(a0)}catch{return null}}function eA(t){try{localStorage.setItem(a0,t)}catch{}}function Um(){try{localStorage.removeItem(a0)}catch{}}const tA="https://soulapi.quwanzhi.com",nA=15e3,e1=6e4,sA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):tA};function Lo(t){const e=sA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Lf(t,e={}){const{data:n,...s}=e,a=Lo(t),i=new Headers(s.headers),o=Df();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):s.body,u=s.timeout??nA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...s,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),y=(m.headers.get("Content-Type")||"").includes("application/json")?await m.json():m,N=j=>{const v=j,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(y);const j=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw j.status=m.status,j.data=y,j}return N(y),y}function De(t,e){return Lf(t,{...e,method:"GET"})}function yt(t,e,n){return Lf(t,{...n,method:"POST",data:e})}function _t(t,e,n){return Lf(t,{...n,method:"PUT",data:e})}function ea(t,e){return Lf(t,{...e,method:"DELETE"})}function rA(){const[t,e]=b.useState(!1),[n,s]=b.useState("");return b.useEffect(()=>{const a=i=>{const o=i.detail;s(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?r.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(aj,{className:"w-5 h-5 shrink-0 text-red-400"}),r.jsxs("span",{className:"text-sm font-medium",children:[n,r.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),r.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:r.jsx(gs,{className:"w-4 h-4"})})]}):null}const aA=[{icon:WM,label:"数据概览",href:"/dashboard"},{icon:Ys,label:"内容管理",href:"/content"},{icon:Ln,label:"用户管理",href:"/users"},{icon:wM,label:"找伙伴",href:"/find-partner"},{icon:Wl,label:"推广中心",href:"/distribution"}];function iA(){const t=Ui(),e=Ki(),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{s(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!Df()){e("/login",{replace:!0});return}return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(Um(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(Um(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{Um();try{await yt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[r.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[r.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),r.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[aA.map(c=>{const u=t.pathname===c.href;return r.jsxs(Hg,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),r.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:r.jsxs(Hg,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(Mo,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),r.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:r.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[r.jsx(e5,{className:"w-5 h-5"}),r.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),r.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[r.jsx(rA,{}),r.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:r.jsx(NT,{})})]})]})}function t1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function i0(...t){return e=>{let n=!1;const s=t.map(a=>{const i=t1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=s;pj(i)&&typeof Ph=="function"&&(i=Ph(i._payload));const c=b.Children.toArray(i),u=c.find(uA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var gj=mj("Slot");function cA(t){const e=b.forwardRef((n,s)=>{let{children:a,...i}=n;if(pj(a)&&typeof Ph=="function"&&(a=Ph(a._payload)),b.isValidElement(a)){const o=fA(a),c=hA(i,a.props);return a.type!==b.Fragment&&(c.ref=s?i0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dA=Symbol("radix.slottable");function uA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dA}function hA(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function fA(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function xj(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,s1=yj,bj=(t,e)=>n=>{var s;if((e==null?void 0:e.variants)==null)return s1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const g=n1(f)||n1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(N=>{let[j,v]=N;return Array.isArray(v)?v.includes({...i,...c}[j]):{...i,...c}[j]===v})?[...h,m,g]:h},[]);return s1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},pA=(t,e)=>{const n=new Array(t.length+e.length);for(let s=0;s({classGroupId:t,validator:e}),vj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Oh="-",r1=[],gA="arbitrary..",xA=t=>{const e=bA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return yA(o);const c=o.split(Oh),u=c[0]===""&&c.length>1?1:0;return Nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=s[o],h=n[o];return u?h?pA(h,u):u:h||r1}return n[o]||r1}}},Nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=Nj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Oh):t.slice(e).join(Oh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),s=e.slice(0,n);return s?gA+s:void 0})(),bA=t=>{const{theme:e,classGroups:n}=t;return vA(n,e)},vA=(t,e)=>{const n=vj();for(const s in t){const a=t[s];o0(a,n,s,e)}return n},o0=(t,e,n,s)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){wA(t,e,n);return}if(typeof t=="function"){jA(t,e,n,s);return}kA(t,e,n,s)},wA=(t,e,n)=>{const s=t===""?e:wj(e,t);s.classGroupId=n},jA=(t,e,n,s)=>{if(SA(t)){o0(t(s),e,n,s);return}e.validators===null&&(e.validators=[]),e.validators.push(mA(n,t))},kA=(t,e,n,s)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const s=e.split(Oh),a=s.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,CA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),s=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,s=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},ex="!",a1=":",EA=[],i1=(t,e,n,s,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:s,isExternal:a}),TA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let s=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let j=0;ju?h-u:void 0;return i1(i,y,g,N)};if(e){const a=e+a1,i=s;s=o=>o.startsWith(a)?i(o.slice(a.length)):i1(EA,!1,o,void 0,!0)}if(n){const a=s;s=i=>n({className:i,parseClassName:a})}return s},MA=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,s)=>{e.set(n,1e6+s)}),n=>{const s=[];let a=[];for(let i=0;i0&&(a.sort(),s.push(...a),a=[]),s.push(o)):a.push(o)}return a.length>0&&(a.sort(),s.push(...a)),s}},AA=t=>({cache:CA(t.cacheSize),parseClassName:TA(t),sortModifiers:MA(t),...xA(t)}),IA=/\s+/,RA=(t,e)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(IA);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!j,k=s(v?N.substring(0,j):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=s(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const C=g.length===0?"":g.length===1?g[0]:i(g).join(":"),E=y?C+ex:C,M=E+k;if(o.indexOf(M)>-1)continue;o.push(M);const P=a(k,v);for(let H=0;H0?" "+u:u)}return u},PA=(...t)=>{let e=0,n,s,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let s=0;s{let n,s,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=AA(h),s=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=s(u);if(h)return h;const f=RA(u,n);return a(u,f),f};return i=o,(...u)=>i(PA(...u))},DA=[],On=t=>{const e=n=>n[t]||DA;return e.isThemeGetter=!0,e},kj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Sj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,LA=/^\d+\/\d+$/,_A=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zA=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,FA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$A=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kl=t=>LA.test(t),ft=t=>!!t&&!Number.isNaN(Number(t)),xi=t=>!!t&&Number.isInteger(Number(t)),Km=t=>t.endsWith("%")&&ft(t.slice(0,-1)),Ia=t=>_A.test(t),VA=()=>!0,HA=t=>zA.test(t)&&!FA.test(t),Cj=()=>!1,WA=t=>$A.test(t),UA=t=>BA.test(t),KA=t=>!Ve(t)&&!He(t),qA=t=>tc(t,Mj,Cj),Ve=t=>kj.test(t),vo=t=>tc(t,Aj,HA),qm=t=>tc(t,XA,ft),o1=t=>tc(t,Ej,Cj),GA=t=>tc(t,Tj,UA),Gu=t=>tc(t,Ij,WA),He=t=>Sj.test(t),Jc=t=>nc(t,Aj),JA=t=>nc(t,ZA),l1=t=>nc(t,Ej),YA=t=>nc(t,Mj),QA=t=>nc(t,Tj),Ju=t=>nc(t,Ij,!0),tc=(t,e,n)=>{const s=kj.exec(t);return s?s[1]?e(s[1]):n(s[2]):!1},nc=(t,e,n=!1)=>{const s=Sj.exec(t);return s?s[1]?e(s[1]):n:!1},Ej=t=>t==="position"||t==="percentage",Tj=t=>t==="image"||t==="url",Mj=t=>t==="length"||t==="size"||t==="bg-size",Aj=t=>t==="length",XA=t=>t==="number",ZA=t=>t==="family-name",Ij=t=>t==="shadow",eI=()=>{const t=On("color"),e=On("font"),n=On("text"),s=On("font-weight"),a=On("tracking"),i=On("leading"),o=On("breakpoint"),c=On("container"),u=On("spacing"),h=On("radius"),f=On("shadow"),m=On("inset-shadow"),g=On("text-shadow"),y=On("drop-shadow"),N=On("blur"),j=On("perspective"),v=On("aspect"),k=On("ease"),C=On("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...M(),He,Ve],H=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],R=()=>[He,Ve,u],O=()=>[kl,"full","auto",...R()],se=()=>[xi,"none","subgrid",He,Ve],ie=()=>["auto",{span:["full",xi,He,Ve]},xi,He,Ve],z=()=>[xi,"auto",He,Ve],ce=()=>["auto","min","max","fr",He,Ve],me=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...R()],$=()=>[kl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],A=()=>[t,He,Ve],Y=()=>[...M(),l1,o1,{position:[He,Ve]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",YA,qA,{size:[He,Ve]}],W=()=>[Km,Jc,vo],le=()=>["","none","full",h,He,Ve],ye=()=>["",ft,Jc,vo],Ae=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[ft,Km,l1,o1],J=()=>["","none",N,He,Ve],ge=()=>["none",ft,He,Ve],ae=()=>["none",ft,He,Ve],pe=()=>[ft,He,Ve],Se=()=>[kl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ia],breakpoint:[Ia],color:[VA],container:[Ia],"drop-shadow":[Ia],ease:["in","out","in-out"],font:[KA],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ia],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ia],shadow:[Ia],spacing:["px",ft],text:[Ia],"text-shadow":[Ia],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kl,Ve,He,v]}],container:["container"],columns:[{columns:[ft,Ve,He,c]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[xi,"auto",He,Ve]}],basis:[{basis:[kl,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ft,kl,"auto","initial","none",Ve]}],grow:[{grow:["",ft,He,Ve]}],shrink:[{shrink:["",ft,He,Ve]}],order:[{order:[xi,"first","last","none",He,Ve]}],"grid-cols":[{"grid-cols":se()}],"col-start-end":[{col:ie()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":se()}],"row-start-end":[{row:ie()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ce()}],"auto-rows":[{"auto-rows":ce()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...me(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...me()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":me()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],w:[{w:[c,"screen",...$()]}],"min-w":[{"min-w":[c,"screen","none",...$()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",n,Jc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,He,qm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Km,Ve]}],"font-family":[{font:[JA,Ve,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,He,Ve]}],"line-clamp":[{"line-clamp":[ft,"none",He,qm]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",He,Ve]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",He,Ve]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[ft,"from-font","auto",He,vo]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[ft,"auto",He,Ve]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",He,Ve]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",He,Ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xi,He,Ve],radial:["",He,Ve],conic:[xi,He,Ve]},QA,GA]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:ye()}],"border-w-x":[{"border-x":ye()}],"border-w-y":[{"border-y":ye()}],"border-w-s":[{"border-s":ye()}],"border-w-e":[{"border-e":ye()}],"border-w-t":[{"border-t":ye()}],"border-w-r":[{"border-r":ye()}],"border-w-b":[{"border-b":ye()}],"border-w-l":[{"border-l":ye()}],"divide-x":[{"divide-x":ye()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ye()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ae(),"hidden","none"]}],"divide-style":[{divide:[...Ae(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...Ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ft,He,Ve]}],"outline-w":[{outline:["",ft,Jc,vo]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",f,Ju,Gu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",m,Ju,Gu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[ft,vo]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ye()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",g,Ju,Gu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[ft,He,Ve]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ft]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[He,Ve]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[ft]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ve]}],filter:[{filter:["","none",He,Ve]}],blur:[{blur:J()}],brightness:[{brightness:[ft,He,Ve]}],contrast:[{contrast:[ft,He,Ve]}],"drop-shadow":[{"drop-shadow":["","none",y,Ju,Gu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",ft,He,Ve]}],"hue-rotate":[{"hue-rotate":[ft,He,Ve]}],invert:[{invert:["",ft,He,Ve]}],saturate:[{saturate:[ft,He,Ve]}],sepia:[{sepia:["",ft,He,Ve]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ve]}],"backdrop-blur":[{"backdrop-blur":J()}],"backdrop-brightness":[{"backdrop-brightness":[ft,He,Ve]}],"backdrop-contrast":[{"backdrop-contrast":[ft,He,Ve]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ft,He,Ve]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ft,He,Ve]}],"backdrop-invert":[{"backdrop-invert":["",ft,He,Ve]}],"backdrop-opacity":[{"backdrop-opacity":[ft,He,Ve]}],"backdrop-saturate":[{"backdrop-saturate":[ft,He,Ve]}],"backdrop-sepia":[{"backdrop-sepia":["",ft,He,Ve]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",He,Ve]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ft,"initial",He,Ve]}],ease:[{ease:["linear","initial",k,He,Ve]}],delay:[{delay:[ft,He,Ve]}],animate:[{animate:["none",C,He,Ve]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,He,Ve]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:pe()}],"skew-x":[{"skew-x":pe()}],"skew-y":[{"skew-y":pe()}],transform:[{transform:[He,Ve,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",He,Ve]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",He,Ve]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[ft,Jc,vo,qm]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},tI=OA(eI);function It(...t){return tI(yj(t))}const nI=bj("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground 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 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:s=!1,...a}){const i=s?gj:"button";return r.jsx(i,{"data-slot":"button",className:It(nI({variant:e,size:n,className:t})),...a})}function re({className:t,type:e,...n}){return r.jsx("input",{type:e,"data-slot":"input",className:It("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function sI(){const t=Ki(),[e,n]=b.useState(""),[s,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await yt("/api/admin",{username:e.trim(),password:s});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){eA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return r.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),r.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),r.jsxs("div",{className:"w-full max-w-md relative z-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:r.jsx(od,{className:"w-8 h-8 text-[#38bdac]"})}),r.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),r.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),r.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[r.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ao,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"text",value:e,onChange:f=>n(f.target.value),placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),r.jsxs("div",{className:"relative",children:[r.jsx(XM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"password",value:s,onChange:f=>a(f.target.value),placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&r.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),r.jsx(X,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),r.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ee=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:It("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ee.displayName="Card";const Je=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:It("flex flex-col space-y-1.5 p-6",t),...e}));Je.displayName="CardHeader";const Ye=b.forwardRef(({className:t,...e},n)=>r.jsx("h3",{ref:n,className:It("font-semibold leading-none tracking-tight",t),...e}));Ye.displayName="CardTitle";const $t=b.forwardRef(({className:t,...e},n)=>r.jsx("p",{ref:n,className:It("text-sm text-muted-foreground",t),...e}));$t.displayName="CardDescription";const Te=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:It("p-6 pt-0",t),...e}));Te.displayName="CardContent";const rI=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:It("flex items-center p-6 pt-0",t),...e}));rI.displayName="CardFooter";const aI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Gm(t,e="info",n=3e3){const s=`toast-${Date.now()}`,a=aI[e],i=document.createElement("div");i.id=s,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(s),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const te={success:(t,e)=>Gm(t,"success",e),error:(t,e)=>Gm(t,"error",e),info:(t,e)=>Gm(t,"info",e)};function dt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function iI(t,e){const n=b.createContext(e),s=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:o})};s.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,a]}function qi(t,e=[]){let n=[];function s(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...N}=m,j=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,v=b.useMemo(()=>N,Object.values(N));return r.jsx(j.Provider,{value:v,children:y})};h.displayName=i+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[s,oI(a,...e)]}function oI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const s=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var xs=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},lI=Rf[" useId ".trim().toString()]||(()=>{}),cI=0;function Pi(t){const[e,n]=b.useState(lI());return xs(()=>{n(s=>s??String(cI++))},[t]),e?`radix-${e}`:""}var dI=Rf[" useInsertionEffect ".trim().toString()]||xs;function _o({prop:t,defaultProp:e,onChange:n=()=>{},caller:s}){const[a,i,o]=uI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const h=b.useCallback(f=>{var m;if(c){const g=hI(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else i(f)},[c,t,i,o]);return[u,h]}function uI({defaultProp:t,onChange:e}){const[n,s]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return dI(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,s,i]}function hI(t){return typeof t=="function"}function Sd(t){const e=fI(t),n=b.forwardRef((s,a)=>{const{children:i,...o}=s,c=b.Children.toArray(i),u=c.find(mI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function fI(t){const e=b.forwardRef((n,s)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=xI(a),c=gI(i,a.props);return a.type!==b.Fragment&&(c.ref=s?i0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pI=Symbol("radix.slottable");function mI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pI}function gI(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function xI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pt=yI.reduce((t,e)=>{const n=Sd(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function bI(t,e){t&&Bd.flushSync(()=>t.dispatchEvent(e))}function Fi(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var s;return(s=e.current)==null?void 0:s.call(e,...n)},[])}function vI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t);b.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[n,e])}var NI="DismissableLayer",tx="dismissableLayer.update",wI="dismissableLayer.pointerDownOutside",jI="dismissableLayer.focusOutside",c1,Rj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),l0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Rj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=At(e,L=>m(L)),j=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(v),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=k,P=CI(L=>{const R=L.target,O=[...h.branches].some(se=>se.contains(R));!M||O||(a==null||a(L),o==null||o(L),L.defaultPrevented||c==null||c())},g),H=EI(L=>{const R=L.target;[...h.branches].some(se=>se.contains(R))||(i==null||i(L),o==null||o(L),L.defaultPrevented||c==null||c())},g);return vI(L=>{C===h.layers.size-1&&(s==null||s(L),!L.defaultPrevented&&c&&(L.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(c1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),d1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=c1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),d1())},[f,h]),b.useEffect(()=>{const L=()=>y({});return document.addEventListener(tx,L),()=>document.removeEventListener(tx,L)},[]),r.jsx(pt.div,{...u,ref:N,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:dt(t.onFocusCapture,H.onFocusCapture),onBlurCapture:dt(t.onBlurCapture,H.onBlurCapture),onPointerDownCapture:dt(t.onPointerDownCapture,P.onPointerDownCapture)})});l0.displayName=NI;var kI="DismissableLayerBranch",SI=b.forwardRef((t,e)=>{const n=b.useContext(Rj),s=b.useRef(null),a=At(e,s);return b.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(pt.div,{...t,ref:a})});SI.displayName=kI;function CI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!s.current){let u=function(){Pj(wI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>s.current=!0}}function EI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!s.current&&Pj(jI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function d1(){const t=new CustomEvent(tx);document.dispatchEvent(t)}function Pj(t,e,n,{discrete:s}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),s?bI(a,i):a.dispatchEvent(i)}var Jm="focusScope.autoFocusOnMount",Ym="focusScope.autoFocusOnUnmount",u1={bubbles:!1,cancelable:!0},TI="FocusScope",c0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=Fi(a),f=Fi(i),m=b.useRef(null),g=At(e,j=>u(j)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:vi(m.current,{select:!0})},v=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||vi(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const P of E)P.removedNodes.length>0&&vi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",v);const C=new MutationObserver(k);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",v),C.disconnect()}}},[s,c,y.paused]),b.useEffect(()=>{if(c){f1.add(y);const j=document.activeElement;if(!c.contains(j)){const k=new CustomEvent(Jm,u1);c.addEventListener(Jm,h),c.dispatchEvent(k),k.defaultPrevented||(MI(OI(Oj(c)),{select:!0}),document.activeElement===j&&vi(c))}return()=>{c.removeEventListener(Jm,h),setTimeout(()=>{const k=new CustomEvent(Ym,u1);c.addEventListener(Ym,f),c.dispatchEvent(k),k.defaultPrevented||vi(j??document.body,{select:!0}),c.removeEventListener(Ym,f),f1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(j=>{if(!n&&!s||y.paused)return;const v=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(v&&k){const C=j.currentTarget,[E,M]=AI(C);E&&M?!j.shiftKey&&k===M?(j.preventDefault(),n&&vi(E,{select:!0})):j.shiftKey&&k===E&&(j.preventDefault(),n&&vi(M,{select:!0})):k===C&&j.preventDefault()}},[n,s,y.paused]);return r.jsx(pt.div,{tabIndex:-1,...o,ref:g,onKeyDown:N})});c0.displayName=TI;function MI(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(vi(s,{select:e}),document.activeElement!==n)return}function AI(t){const e=Oj(t),n=h1(e,t),s=h1(e.reverse(),t);return[n,s]}function Oj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function h1(t,e){for(const n of t)if(!II(n,{upTo:e}))return n}function II(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function RI(t){return t instanceof HTMLInputElement&&"select"in t}function vi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&RI(t)&&e&&t.select()}}var f1=PI();function PI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=p1(t,e),t.unshift(e)},remove(e){var n;t=p1(t,e),(n=t[0])==null||n.resume()}}}function p1(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}function OI(t){return t.filter(e=>e.tagName!=="A")}var DI="Portal",d0=b.forwardRef((t,e)=>{var c;const{container:n,...s}=t,[a,i]=b.useState(!1);xs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Kw.createPortal(r.jsx(pt.div,{...s,ref:e}),o):null});d0.displayName=DI;function LI(t,e){return b.useReducer((n,s)=>e[n][s]??n,t)}var Vd=t=>{const{present:e,children:n}=t,s=_I(e),a=typeof n=="function"?n({present:s.isPresent}):b.Children.only(n),i=At(s.ref,zI(a));return typeof n=="function"||s.isPresent?b.cloneElement(a,{ref:i}):null};Vd.displayName="Presence";function _I(t){const[e,n]=b.useState(),s=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=LI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=Yu(s.current);i.current=c==="mounted"?h:"none"},[c]),xs(()=>{const h=s.current,f=a.current;if(f!==t){const g=i.current,y=Yu(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),xs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=Yu(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=y=>{y.target===e&&(i.current=Yu(s.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{s.current=h?getComputedStyle(h):null,n(h)},[])}}function Yu(t){return(t==null?void 0:t.animationName)||"none"}function zI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Qm=0;function Dj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??m1()),document.body.insertAdjacentElement("beforeend",t[1]??m1()),Qm++,()=>{Qm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qm--}},[])}function m1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ta=function(){return ta=Object.assign||function(e){for(var n,s=1,a=arguments.length;s"u")return tR;var e=nR(t),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-n+e[2]-e[0])}},rR=Fj(),$l="data-scroll-locked",aR=function(t,e,n,s){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
.`.concat($I,` {
overflow: hidden `).concat(s,`;
padding-right: `).concat(c,"px ").concat(s,`;
@@ -576,23 +576,23 @@ Error generating stack: `+S.message+`
body[`).concat($l,`] {
`).concat(BI,": ").concat(c,`px;
}
-`)},g1=function(){var t=parseInt(document.body.getAttribute($l)||"0",10);return isFinite(t)?t:0},iR=function(){b.useEffect(function(){return document.body.setAttribute($l,(g1()+1).toString()),function(){var t=g1()-1;t<=0?document.body.removeAttribute($l):document.body.setAttribute($l,t.toString())}},[])},oR=function(t){var e=t.noRelative,n=t.noImportant,s=t.gapMode,a=s===void 0?"margin":s;iR();var i=b.useMemo(function(){return sR(a)},[a]);return b.createElement(rR,{styles:aR(i,!e,a,n?"":"!important")})},tx=!1;if(typeof window<"u")try{var Qu=Object.defineProperty({},"passive",{get:function(){return tx=!0,!0}});window.addEventListener("test",Qu,Qu),window.removeEventListener("test",Qu,Qu)}catch{tx=!1}var Sl=tx?{passive:!1}:!1,lR=function(t){return t.tagName==="TEXTAREA"},$j=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!lR(t)&&n[e]==="visible")},cR=function(t){return $j(t,"overflowY")},dR=function(t){return $j(t,"overflowX")},x1=function(t,e){var n=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Bj(t,s);if(a){var i=Vj(t,s),o=i[1],c=i[2];if(o>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},uR=function(t){var e=t.scrollTop,n=t.scrollHeight,s=t.clientHeight;return[e,n,s]},hR=function(t){var e=t.scrollLeft,n=t.scrollWidth,s=t.clientWidth;return[e,n,s]},Bj=function(t,e){return t==="v"?cR(e):dR(e)},Vj=function(t,e){return t==="v"?uR(e):hR(e)},fR=function(t,e){return t==="h"&&e==="rtl"?-1:1},pR=function(t,e,n,s,a){var i=fR(t,window.getComputedStyle(e).direction),o=i*s,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Vj(t,c),N=y[0],j=y[1],v=y[2],k=j-v-i*N;(N||k)&&Bj(t,c)&&(m+=k,g+=N);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},Xu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},y1=function(t){return[t.deltaX,t.deltaY]},b1=function(t){return t&&"current"in t?t.current:t},mR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},gR=function(t){return`
+`)},x1=function(){var t=parseInt(document.body.getAttribute($l)||"0",10);return isFinite(t)?t:0},iR=function(){b.useEffect(function(){return document.body.setAttribute($l,(x1()+1).toString()),function(){var t=x1()-1;t<=0?document.body.removeAttribute($l):document.body.setAttribute($l,t.toString())}},[])},oR=function(t){var e=t.noRelative,n=t.noImportant,s=t.gapMode,a=s===void 0?"margin":s;iR();var i=b.useMemo(function(){return sR(a)},[a]);return b.createElement(rR,{styles:aR(i,!e,a,n?"":"!important")})},nx=!1;if(typeof window<"u")try{var Qu=Object.defineProperty({},"passive",{get:function(){return nx=!0,!0}});window.addEventListener("test",Qu,Qu),window.removeEventListener("test",Qu,Qu)}catch{nx=!1}var Sl=nx?{passive:!1}:!1,lR=function(t){return t.tagName==="TEXTAREA"},$j=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!lR(t)&&n[e]==="visible")},cR=function(t){return $j(t,"overflowY")},dR=function(t){return $j(t,"overflowX")},y1=function(t,e){var n=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Bj(t,s);if(a){var i=Vj(t,s),o=i[1],c=i[2];if(o>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},uR=function(t){var e=t.scrollTop,n=t.scrollHeight,s=t.clientHeight;return[e,n,s]},hR=function(t){var e=t.scrollLeft,n=t.scrollWidth,s=t.clientWidth;return[e,n,s]},Bj=function(t,e){return t==="v"?cR(e):dR(e)},Vj=function(t,e){return t==="v"?uR(e):hR(e)},fR=function(t,e){return t==="h"&&e==="rtl"?-1:1},pR=function(t,e,n,s,a){var i=fR(t,window.getComputedStyle(e).direction),o=i*s,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Vj(t,c),N=y[0],j=y[1],v=y[2],k=j-v-i*N;(N||k)&&Bj(t,c)&&(m+=k,g+=N);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},Xu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},b1=function(t){return[t.deltaX,t.deltaY]},v1=function(t){return t&&"current"in t?t.current:t},mR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},gR=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
-`)},xR=0,Cl=[];function yR(t){var e=b.useRef([]),n=b.useRef([0,0]),s=b.useRef(),a=b.useState(xR++)[0],i=b.useState(Fj)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=FI([t.lockRef.current],(t.shards||[]).map(b1),!0).filter(Boolean);return j.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(j,v){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var k=Xu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-k[0],M="deltaY"in j?j.deltaY:C[1]-k[1],P,H=j.target,L=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&L==="h"&&H.type==="range")return!1;var R=window.getSelection(),O=R&&R.anchorNode,se=O?O===H||O.contains(H):!1;if(se)return!1;var ie=x1(L,H);if(!ie)return!0;if(ie?P=L:(P=L==="v"?"h":"v",ie=x1(L,H)),!ie)return!1;if(!s.current&&"changedTouches"in j&&(E||M)&&(s.current=P),!P)return!0;var z=s.current||P;return pR(z,v,j,z==="h"?E:M)},[]),u=b.useCallback(function(j){var v=j;if(!(!Cl.length||Cl[Cl.length-1]!==i)){var k="deltaY"in v?y1(v):Xu(v),C=e.current.filter(function(P){return P.name===v.type&&(P.target===v.target||v.target===P.shadowParent)&&mR(P.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(b1).filter(Boolean).filter(function(P){return P.contains(v.target)}),M=E.length>0?c(v,E[0]):!o.current.noIsolation;M&&v.cancelable&&v.preventDefault()}}},[]),h=b.useCallback(function(j,v,k,C){var E={name:j,delta:v,target:k,should:C,shadowParent:bR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=b.useCallback(function(j){n.current=Xu(j),s.current=void 0},[]),m=b.useCallback(function(j){h(j.type,y1(j),j.target,c(j,t.lockRef.current))},[]),g=b.useCallback(function(j){h(j.type,Xu(j),j.target,c(j,t.lockRef.current))},[]);b.useEffect(function(){return Cl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Sl),document.addEventListener("touchmove",u,Sl),document.addEventListener("touchstart",f,Sl),function(){Cl=Cl.filter(function(j){return j!==i}),document.removeEventListener("wheel",u,Sl),document.removeEventListener("touchmove",u,Sl),document.removeEventListener("touchstart",f,Sl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:gR(a)}):null,y?b.createElement(oR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const vR=GI(zj,yR);var d0=b.forwardRef(function(t,e){return b.createElement(_f,ta({},t,{ref:e,sideCar:vR}))});d0.classNames=_f.classNames;var NR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},El=new WeakMap,Zu=new WeakMap,eh={},tg=0,Hj=function(t){return t&&(t.host||Hj(t.parentNode))},wR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Hj(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},jR=function(t,e,n,s){var a=wR(e,Array.isArray(t)?t:[t]);eh[n]||(eh[n]=new WeakMap);var i=eh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(s),N=y!==null&&y!=="false",j=(El.get(g)||0)+1,v=(i.get(g)||0)+1;El.set(g,j),i.set(g,v),o.push(g),j===1&&N&&Zu.set(g,!0),v===1&&g.setAttribute(n,"true"),N||g.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),tg++,function(){o.forEach(function(m){var g=El.get(m)-1,y=i.get(m)-1;El.set(m,g),i.set(m,y),g||(Zu.has(m)||m.removeAttribute(s),Zu.delete(m)),y||m.removeAttribute(n)}),tg--,tg||(El=new WeakMap,El=new WeakMap,Zu=new WeakMap,eh={})}},Wj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),a=NR(t);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),jR(s,a,n,"aria-hidden")):function(){return null}},zf="Dialog",[Uj]=qi(zf),[kR,Dr]=Uj(zf),Kj=t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:zf});return r.jsx(kR,{scope:e,triggerRef:c,contentRef:u,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Kj.displayName=zf;var qj="DialogTrigger",SR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(qj,n),i=Tt(e,a.triggerRef);return r.jsx(pt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":f0(a.open),...s,ref:i,onClick:dt(t.onClick,a.onOpenToggle)})});SR.displayName=qj;var u0="DialogPortal",[CR,Gj]=Uj(u0,{forceMount:void 0}),Jj=t=>{const{__scopeDialog:e,forceMount:n,children:s,container:a}=t,i=Dr(u0,e);return r.jsx(CR,{scope:e,forceMount:n,children:b.Children.map(s,o=>r.jsx(Vd,{present:n||i.open,children:r.jsx(c0,{asChild:!0,container:a,children:o})}))})};Jj.displayName=u0;var Dh="DialogOverlay",Yj=b.forwardRef((t,e)=>{const n=Gj(Dh,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(Dh,t.__scopeDialog);return i.modal?r.jsx(Vd,{present:s||i.open,children:r.jsx(TR,{...a,ref:e})}):null});Yj.displayName=Dh;var ER=Sd("DialogOverlay.RemoveScroll"),TR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(Dh,n);return r.jsx(d0,{as:ER,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(pt.div,{"data-state":f0(a.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),zo="DialogContent",Qj=b.forwardRef((t,e)=>{const n=Gj(zo,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(zo,t.__scopeDialog);return r.jsx(Vd,{present:s||i.open,children:i.modal?r.jsx(MR,{...a,ref:e}):r.jsx(AR,{...a,ref:e})})});Qj.displayName=zo;var MR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(null),a=Tt(e,n.contentRef,s);return b.useEffect(()=>{const i=s.current;if(i)return Wj(i)},[]),r.jsx(Xj,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:dt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:dt(t.onFocusOutside,i=>i.preventDefault())})}),AR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(!1),a=b.useRef(!1);return r.jsx(Xj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Xj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Dr(zo,n),u=b.useRef(null),h=Tt(e,u);return Dj(),r.jsxs(r.Fragment,{children:[r.jsx(l0,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:r.jsx(o0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":f0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(IR,{titleId:c.titleId}),r.jsx(PR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),h0="DialogTitle",Zj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(h0,n);return r.jsx(pt.h2,{id:a.titleId,...s,ref:e})});Zj.displayName=h0;var ek="DialogDescription",tk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(ek,n);return r.jsx(pt.p,{id:a.descriptionId,...s,ref:e})});tk.displayName=ek;var nk="DialogClose",sk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(nk,n);return r.jsx(pt.button,{type:"button",...s,ref:e,onClick:dt(t.onClick,()=>a.onOpenChange(!1))})});sk.displayName=nk;function f0(t){return t?"open":"closed"}var rk="DialogTitleWarning",[YV,ak]=iI(rk,{contentName:zo,titleName:h0,docsSlug:"dialog"}),IR=({titleId:t})=>{const e=ak(rk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
+`)},xR=0,Cl=[];function yR(t){var e=b.useRef([]),n=b.useRef([0,0]),s=b.useRef(),a=b.useState(xR++)[0],i=b.useState(Fj)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=FI([t.lockRef.current],(t.shards||[]).map(v1),!0).filter(Boolean);return j.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(j,v){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var k=Xu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-k[0],M="deltaY"in j?j.deltaY:C[1]-k[1],P,H=j.target,L=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&L==="h"&&H.type==="range")return!1;var R=window.getSelection(),O=R&&R.anchorNode,se=O?O===H||O.contains(H):!1;if(se)return!1;var ie=y1(L,H);if(!ie)return!0;if(ie?P=L:(P=L==="v"?"h":"v",ie=y1(L,H)),!ie)return!1;if(!s.current&&"changedTouches"in j&&(E||M)&&(s.current=P),!P)return!0;var z=s.current||P;return pR(z,v,j,z==="h"?E:M)},[]),u=b.useCallback(function(j){var v=j;if(!(!Cl.length||Cl[Cl.length-1]!==i)){var k="deltaY"in v?b1(v):Xu(v),C=e.current.filter(function(P){return P.name===v.type&&(P.target===v.target||v.target===P.shadowParent)&&mR(P.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(v1).filter(Boolean).filter(function(P){return P.contains(v.target)}),M=E.length>0?c(v,E[0]):!o.current.noIsolation;M&&v.cancelable&&v.preventDefault()}}},[]),h=b.useCallback(function(j,v,k,C){var E={name:j,delta:v,target:k,should:C,shadowParent:bR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=b.useCallback(function(j){n.current=Xu(j),s.current=void 0},[]),m=b.useCallback(function(j){h(j.type,b1(j),j.target,c(j,t.lockRef.current))},[]),g=b.useCallback(function(j){h(j.type,Xu(j),j.target,c(j,t.lockRef.current))},[]);b.useEffect(function(){return Cl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Sl),document.addEventListener("touchmove",u,Sl),document.addEventListener("touchstart",f,Sl),function(){Cl=Cl.filter(function(j){return j!==i}),document.removeEventListener("wheel",u,Sl),document.removeEventListener("touchmove",u,Sl),document.removeEventListener("touchstart",f,Sl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:gR(a)}):null,y?b.createElement(oR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const vR=GI(zj,yR);var u0=b.forwardRef(function(t,e){return b.createElement(_f,ta({},t,{ref:e,sideCar:vR}))});u0.classNames=_f.classNames;var NR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},El=new WeakMap,Zu=new WeakMap,eh={},tg=0,Hj=function(t){return t&&(t.host||Hj(t.parentNode))},wR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Hj(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},jR=function(t,e,n,s){var a=wR(e,Array.isArray(t)?t:[t]);eh[n]||(eh[n]=new WeakMap);var i=eh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(s),N=y!==null&&y!=="false",j=(El.get(g)||0)+1,v=(i.get(g)||0)+1;El.set(g,j),i.set(g,v),o.push(g),j===1&&N&&Zu.set(g,!0),v===1&&g.setAttribute(n,"true"),N||g.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),tg++,function(){o.forEach(function(m){var g=El.get(m)-1,y=i.get(m)-1;El.set(m,g),i.set(m,y),g||(Zu.has(m)||m.removeAttribute(s),Zu.delete(m)),y||m.removeAttribute(n)}),tg--,tg||(El=new WeakMap,El=new WeakMap,Zu=new WeakMap,eh={})}},Wj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),a=NR(t);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),jR(s,a,n,"aria-hidden")):function(){return null}},zf="Dialog",[Uj]=qi(zf),[kR,Dr]=Uj(zf),Kj=t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:zf});return r.jsx(kR,{scope:e,triggerRef:c,contentRef:u,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Kj.displayName=zf;var qj="DialogTrigger",SR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(qj,n),i=At(e,a.triggerRef);return r.jsx(pt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":p0(a.open),...s,ref:i,onClick:dt(t.onClick,a.onOpenToggle)})});SR.displayName=qj;var h0="DialogPortal",[CR,Gj]=Uj(h0,{forceMount:void 0}),Jj=t=>{const{__scopeDialog:e,forceMount:n,children:s,container:a}=t,i=Dr(h0,e);return r.jsx(CR,{scope:e,forceMount:n,children:b.Children.map(s,o=>r.jsx(Vd,{present:n||i.open,children:r.jsx(d0,{asChild:!0,container:a,children:o})}))})};Jj.displayName=h0;var Dh="DialogOverlay",Yj=b.forwardRef((t,e)=>{const n=Gj(Dh,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(Dh,t.__scopeDialog);return i.modal?r.jsx(Vd,{present:s||i.open,children:r.jsx(TR,{...a,ref:e})}):null});Yj.displayName=Dh;var ER=Sd("DialogOverlay.RemoveScroll"),TR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(Dh,n);return r.jsx(u0,{as:ER,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(pt.div,{"data-state":p0(a.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),zo="DialogContent",Qj=b.forwardRef((t,e)=>{const n=Gj(zo,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(zo,t.__scopeDialog);return r.jsx(Vd,{present:s||i.open,children:i.modal?r.jsx(MR,{...a,ref:e}):r.jsx(AR,{...a,ref:e})})});Qj.displayName=zo;var MR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(null),a=At(e,n.contentRef,s);return b.useEffect(()=>{const i=s.current;if(i)return Wj(i)},[]),r.jsx(Xj,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:dt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:dt(t.onFocusOutside,i=>i.preventDefault())})}),AR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(!1),a=b.useRef(!1);return r.jsx(Xj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Xj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Dr(zo,n),u=b.useRef(null),h=At(e,u);return Dj(),r.jsxs(r.Fragment,{children:[r.jsx(c0,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:r.jsx(l0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":p0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(IR,{titleId:c.titleId}),r.jsx(PR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),f0="DialogTitle",Zj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(f0,n);return r.jsx(pt.h2,{id:a.titleId,...s,ref:e})});Zj.displayName=f0;var ek="DialogDescription",tk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(ek,n);return r.jsx(pt.p,{id:a.descriptionId,...s,ref:e})});tk.displayName=ek;var nk="DialogClose",sk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(nk,n);return r.jsx(pt.button,{type:"button",...s,ref:e,onClick:dt(t.onClick,()=>a.onOpenChange(!1))})});sk.displayName=nk;function p0(t){return t?"open":"closed"}var rk="DialogTitleWarning",[YV,ak]=iI(rk,{contentName:zo,titleName:f0,docsSlug:"dialog"}),IR=({titleId:t})=>{const e=ak(rk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
-For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},RR="DialogDescriptionWarning",PR=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ak(RR).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},OR=Kj,DR=Jj,LR=Yj,_R=Qj,zR=Zj,FR=tk,$R=sk;function It(t){return r.jsx(OR,{"data-slot":"dialog",...t})}function BR(t){return r.jsx(DR,{...t})}const ik=b.forwardRef(({className:t,...e},n)=>r.jsx(LR,{ref:n,className:Mt("fixed inset-0 z-50 bg-black/50",t),...e}));ik.displayName="DialogOverlay";const Ct=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...s},a)=>r.jsxs(BR,{children:[r.jsx(ik,{}),r.jsxs(_R,{ref:a,"aria-describedby":void 0,className:Mt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...s,children:[e,n&&r.jsxs($R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(gs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ct.displayName="DialogContent";function Rt({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function sn({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Pt(t){return r.jsx(zR,{className:"text-lg font-semibold leading-none",...t})}function Cd(t){return r.jsx(FR,{className:"text-sm text-muted-foreground",...t})}const VR=bj("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ke({className:t,variant:e,asChild:n=!1,...s}){const a=n?gj:"span";return r.jsx(a,{className:Mt(VR({variant:e}),t),...s})}var HR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],WR=HR.reduce((t,e)=>{const n=mj(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{}),UR="Label",ok=b.forwardRef((t,e)=>r.jsx(WR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ok.displayName=UR;var lk=ok;const Z=b.forwardRef(({className:t,...e},n)=>r.jsx(lk,{ref:n,className:Mt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=lk.displayName;function p0(t){const e=t+"CollectionProvider",[n,s]=qi(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:v,children:k}=j,C=Cs.useRef(null),E=Cs.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:E,collectionRef:C,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Sd(c),h=Cs.forwardRef((j,v)=>{const{scope:k,children:C}=j,E=i(c,k),M=Tt(v,E.collectionRef);return r.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Sd(f),y=Cs.forwardRef((j,v)=>{const{scope:k,children:C,...E}=j,M=Cs.useRef(null),P=Tt(v,M),H=i(f,k);return Cs.useEffect(()=>(H.itemMap.set(M,{ref:M,...E}),()=>void H.itemMap.delete(M))),r.jsx(g,{[m]:"",ref:P,children:C})});y.displayName=f;function N(j){const v=i(t+"CollectionConsumer",j);return Cs.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((H,L)=>E.indexOf(H.ref.current)-E.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,s]}var KR=b.createContext(void 0);function Ff(t){const e=b.useContext(KR);return t||e||"ltr"}var ng="rovingFocusGroup.onEntryFocus",qR={bubbles:!1,cancelable:!0},Hd="RovingFocusGroup",[nx,ck,GR]=p0(Hd),[JR,dk]=qi(Hd,[GR]),[YR,QR]=JR(Hd),uk=b.forwardRef((t,e)=>r.jsx(nx.Provider,{scope:t.__scopeRovingFocusGroup,children:r.jsx(nx.Slot,{scope:t.__scopeRovingFocusGroup,children:r.jsx(XR,{...t,ref:e})})}));uk.displayName=Hd;var XR=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=Tt(e,g),N=Ff(i),[j,v]=_o({prop:o,defaultProp:c??null,onChange:u,caller:Hd}),[k,C]=b.useState(!1),E=Fi(h),M=ck(n),P=b.useRef(!1),[H,L]=b.useState(0);return b.useEffect(()=>{const R=g.current;if(R)return R.addEventListener(ng,E),()=>R.removeEventListener(ng,E)},[E]),r.jsx(YR,{scope:n,orientation:s,dir:N,loop:a,currentTabStopId:j,onItemFocus:b.useCallback(R=>v(R),[v]),onItemShiftTab:b.useCallback(()=>C(!0),[]),onFocusableItemAdd:b.useCallback(()=>L(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>L(R=>R-1),[]),children:r.jsx(pt.div,{tabIndex:k||H===0?-1:0,"data-orientation":s,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:dt(t.onMouseDown,()=>{P.current=!0}),onFocus:dt(t.onFocus,R=>{const O=!P.current;if(R.target===R.currentTarget&&O&&!k){const se=new CustomEvent(ng,qR);if(R.currentTarget.dispatchEvent(se),!se.defaultPrevented){const ie=M().filter(G=>G.focusable),z=ie.find(G=>G.active),ce=ie.find(G=>G.id===j),_=[z,ce,...ie].filter(Boolean).map(G=>G.ref.current);pk(_,f)}}P.current=!1}),onBlur:dt(t.onBlur,()=>C(!1))})})}),hk="RovingFocusGroupItem",fk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Pi(),h=i||u,f=QR(hk,n),m=f.currentTabStopId===h,g=ck(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:j}=f;return b.useEffect(()=>{if(s)return y(),()=>N()},[s,y,N]),r.jsx(nx.ItemSlot,{scope:n,id:h,focusable:s,active:a,children:r.jsx(pt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:dt(t.onMouseDown,v=>{s?f.onItemFocus(h):v.preventDefault()}),onFocus:dt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:dt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=tP(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const M=E.indexOf(v.currentTarget);E=f.loop?nP(E,M+1):E.slice(M+1)}setTimeout(()=>pk(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});fk.displayName=hk;var ZR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function tP(t,e,n){const s=eP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return ZR[s]}function pk(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function nP(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var sP=uk,rP=fk,$f="Tabs",[aP]=qi($f,[dk]),mk=dk(),[iP,m0]=aP($f),gk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Ff(c),[m,g]=_o({prop:s,onChange:a,defaultProp:i??"",caller:$f});return r.jsx(iP,{scope:n,baseId:Pi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:r.jsx(pt.div,{dir:f,"data-orientation":o,...h,ref:e})})});gk.displayName=$f;var xk="TabsList",yk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...a}=t,i=m0(xk,n),o=mk(n);return r.jsx(sP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(pt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});yk.displayName=xk;var bk="TabsTrigger",vk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...i}=t,o=m0(bk,n),c=mk(n),u=jk(o.baseId,s),h=kk(o.baseId,s),f=s===o.value;return r.jsx(rP,{asChild:!0,...c,focusable:!a,active:f,children:r.jsx(pt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:dt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(s):m.preventDefault()}),onKeyDown:dt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(s)}),onFocus:dt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(s)})})})});vk.displayName=bk;var Nk="TabsContent",wk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:a,children:i,...o}=t,c=m0(Nk,n),u=jk(c.baseId,s),h=kk(c.baseId,s),f=s===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(Vd,{present:a||f,children:({present:g})=>r.jsx(pt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&i})})});wk.displayName=Nk;function jk(t,e){return`${t}-trigger-${e}`}function kk(t,e){return`${t}-content-${e}`}var oP=gk,Sk=yk,Ck=vk,Ek=wk;const Wd=oP,sc=b.forwardRef(({className:t,...e},n)=>r.jsx(Sk,{ref:n,className:Mt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));sc.displayName=Sk.displayName;const Zt=b.forwardRef(({className:t,...e},n)=>r.jsx(Ck,{ref:n,className:Mt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all 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",t),...e}));Zt.displayName=Ck.displayName;const en=b.forwardRef(({className:t,...e},n)=>r.jsx(Ek,{ref:n,className:Mt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));en.displayName=Ek.displayName;function g0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function x0(t){const[e,n]=b.useState(void 0);return xs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var Bf="Switch",[lP]=qi(Bf),[cP,dP]=lP(Bf),Tk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),N=Tt(e,E=>y(E)),j=b.useRef(!1),v=g?f||!!g.closest("form"):!0,[k,C]=_o({prop:a,defaultProp:i??!1,onChange:h,caller:Bf});return r.jsxs(cP,{scope:n,checked:k,disabled:c,children:[r.jsx(pt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":Rk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:dt(t.onClick,E=>{C(M=>!M),v&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),v&&r.jsx(Ik,{control:g,bubbles:!j.current,name:s,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Tk.displayName=Bf;var Mk="SwitchThumb",Ak=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,a=dP(Mk,n);return r.jsx(pt.span,{"data-state":Rk(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:e})});Ak.displayName=Mk;var uP="SwitchBubbleInput",Ik=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...a},i)=>{const o=b.useRef(null),c=Tt(o,i),u=g0(n),h=x0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:s});y.call(f,n),f.dispatchEvent(N)}},[u,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ik.displayName=uP;function Rk(t){return t?"checked":"unchecked"}var Pk=Tk,hP=Ak;const jt=b.forwardRef(({className:t,...e},n)=>r.jsx(Pk,{className:Mt("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-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:r.jsx(hP,{className:Mt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));jt.displayName=Pk.displayName;function y0({open:t,onClose:e,userId:n,onUserUpdated:s}){var tn;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(null),[g,y]=b.useState(!1),[N,j]=b.useState(!1),[v,k]=b.useState(!1),[C,E]=b.useState("info"),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState([]),[se,ie]=b.useState(""),[z,ce]=b.useState(""),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[U,D]=b.useState([]),[W,le]=b.useState(!1),[ye,Ae]=b.useState(""),[ne,K]=b.useState(""),[J,ge]=b.useState(!1),[ae,pe]=b.useState(!1),[Se,tt]=b.useState(null),[at,Dt]=b.useState(null),[kt,At]=b.useState(""),[Gt,In]=b.useState(""),[Lt,xn]=b.useState(""),[ln,Bs]=b.useState(!1),[yn,is]=b.useState(null),[Un,Kn]=b.useState("");b.useEffect(()=>{t&&n&&(E("info"),tt(null),Dt(null),is(null),Kn(""),ce(""),_(""),_t(),De("/api/db/vip-roles").then(he=>{he!=null&&he.success&&he.data&&D(he.data)}).catch(()=>{}))},[t,n]);async function _t(){if(n){y(!0);try{const he=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(he!=null&&he.success&&he.user){const xe=he.user;i(xe),P(xe.phone||""),L(xe.nickname||""),At(xe.phone||""),In(xe.wechatId||""),xn(xe.openId||"");try{O(typeof xe.tags=="string"?JSON.parse(xe.tags||"[]"):[])}catch{O([])}Y({isVip:!!(xe.isVip??!1),vipExpireDate:xe.vipExpireDate?String(xe.vipExpireDate).slice(0,10):"",vipRole:String(xe.vipRole??""),vipName:String(xe.vipName??""),vipProject:String(xe.vipProject??""),vipContact:String(xe.vipContact??""),vipBio:String(xe.vipBio??"")})}try{const xe=await De(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=50`);xe!=null&&xe.success&&xe.tracks&&c(xe.tracks)}catch{c([])}try{const xe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);xe!=null&&xe.success&&xe.referrals&&h(xe.referrals)}catch{h([])}try{const xe=await De(`/api/admin/users/${encodeURIComponent(n)}/balance`);xe!=null&&xe.success&&xe.data?m(xe.data):m(null)}catch{m(null)}}catch(he){console.error("Load user detail error:",he)}finally{y(!1)}}}async function qn(){if(!(a!=null&&a.phone)){te.info("用户未绑定手机号,无法同步");return}j(!0);try{const he=await Nt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});he!=null&&he.success?(te.success("同步成功"),_t()):te.error("同步失败: "+(he==null?void 0:he.error))}catch(he){console.error("Sync CKB error:",he),te.error("同步失败")}finally{j(!1)}}async function zn(){if(a){if(A.isVip&&!A.vipExpireDate.trim()){te.error("开启 VIP 请填写有效到期日");return}k(!0);try{const he={id:a.id,phone:M||void 0,nickname:H||void 0,tags:JSON.stringify(R),isVip:A.isVip,vipExpireDate:A.isVip?A.vipExpireDate:void 0,vipRole:A.vipRole||void 0,vipName:A.vipName||void 0,vipProject:A.vipProject||void 0,vipContact:A.vipContact||void 0,vipBio:A.vipBio||void 0},xe=await Ot("/api/db/users",he);xe!=null&&xe.success?(te.success("保存成功"),_t(),s==null||s()):te.error("保存失败: "+(xe==null?void 0:xe.error))}catch(he){console.error("Save user error:",he),te.error("保存失败")}finally{k(!1)}}}const ls=()=>{se&&!R.includes(se)&&(O([...R,se]),ie(""))},q=he=>O(R.filter(xe=>xe!==he));async function He(){if(a){if(!z){te.error("请输入新密码");return}if(z!==me){te.error("两次密码不一致");return}if(z.length<6){te.error("密码至少 6 位");return}$(!0);try{const he=await Ot("/api/db/users",{id:a.id,password:z});he!=null&&he.success?(te.success("修改成功"),ce(""),_("")):te.error("修改失败: "+((he==null?void 0:he.error)||""))}catch{te.error("修改失败")}finally{$(!1)}}}async function mt(){if(!a)return;const he=parseFloat(ye);if(Number.isNaN(he)||he===0){te.error("请输入有效金额(正数增加、负数扣减)");return}ge(!0);try{const xe=await Nt(`/api/admin/users/${a.id}/balance/adjust`,{amount:he,remark:ne||void 0});xe!=null&&xe.success?(te.success("余额已调整"),le(!1),Ae(""),K(""),_t(),s==null||s()):te.error("调整失败: "+((xe==null?void 0:xe.error)||""))}catch{te.error("调整失败")}finally{ge(!1)}}async function $t(){if(!kt&&!Lt&&!Gt){Dt("请至少输入手机号、微信号或 OpenID 中的一项");return}pe(!0),Dt(null),tt(null);try{const he=new URLSearchParams;kt&&he.set("phone",kt),Lt&&he.set("openId",Lt),Gt&&he.set("wechatId",Gt);const xe=await De(`/api/admin/shensheshou/query?${he}`);xe!=null&&xe.success&&xe.data?(tt(xe.data),a&&await ut(xe.data)):Dt((xe==null?void 0:xe.error)||"未查询到数据,该用户可能未在神射手收录")}catch(he){console.error("SSS query error:",he),Dt("请求失败,请检查神射手接口配置")}finally{pe(!1)}}async function ut(he){if(a)try{await Nt("/api/admin/shensheshou/enrich",{userId:a.id,phone:kt||a.phone||"",openId:Lt||a.openId||"",wechatId:Gt||a.wechatId||""}),_t()}catch(xe){console.error("SSS enrich error:",xe)}}async function ot(){if(a){Bs(!0),is(null);try{const he={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:R}]},xe=await Nt("/api/admin/shensheshou/ingest",he);xe!=null&&xe.success&&xe.data?is(xe.data):is({error:(xe==null?void 0:xe.error)||"推送失败"})}catch(he){console.error("SSS ingest error:",he),is({error:"请求失败"})}finally{Bs(!1)}}}const xt=he=>{const zt={view_chapter:Ys,purchase:Qg,match:_n,login:Ao,register:Ao,share:Rr,bind_phone:g5,bind_wechat:a5,fill_profile:ld,visit_page:Ll}[he]||Kg;return r.jsx(zt,{className:"w-4 h-4"})};return t?r.jsxs(r.Fragment,{children:[r.jsx(It,{open:t,onOpenChange:()=>e(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?r.jsxs("div",{className:"flex flex-col h-[75vh]",children:[r.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:a.avatar?r.jsx("img",{src:a.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((tn=a.nickname)==null?void 0:tn.charAt(0))||"?"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("h3",{className:"text-lg font-bold text-white",children:a.nickname}),a.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),a.hasFullBook&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),a.vipRole&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:a.vipRole})]}),r.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[a.phone?`📱 ${a.phone}`:"未绑定手机",a.wechatId&&` · 💬 ${a.wechatId}`,a.mbti&&` · ${a.mbti}`]}),r.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[r.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",a.id.slice(0,16),"…"]}),a.referralCode&&r.jsxs("p",{className:"text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"推广码:"}),r.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:a.referralCode})]})]})]}),r.jsxs("div",{className:"text-right shrink-0",children:[r.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(a.earnings||0).toFixed(2)]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),r.jsxs(Wd,{value:C,onValueChange:E,className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[r.jsx(Zt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),r.jsx(Zt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Ll,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),r.jsx(Zt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),r.jsxs(Zt,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Fa,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),r.jsxs(en,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:M,onChange:he=>P(he.target.value),disabled:!!(a!=null&&a.phone)}),(a==null?void 0:a.phone)&&r.jsx("p",{className:"text-xs text-gray-500",children:"编辑时手机号不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:H,onChange:he=>L(he.target.value)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.openId&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),r.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:a.openId})]}),a.region&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(hj,{className:"w-4 h-4 text-gray-500"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),r.jsx("p",{className:"text-white",children:a.region})]})]}),a.industry&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),r.jsx("p",{className:"text-white",children:a.industry})]}),a.position&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),r.jsx("p",{className:"text-white",children:a.position})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:a.referralCount??0})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),r.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(a.pendingEarnings??0).toFixed(2)]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg flex flex-col justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"当前余额"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac]",children:["¥",((f==null?void 0:f.balance)??0).toFixed(2)]})]}),r.jsx(X,{size:"sm",variant:"outline",className:"mt-2 border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 text-xs",onClick:()=>{Ae(""),K(""),le(!0)},children:"调整余额"})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),r.jsx("p",{className:"text-sm text-white",children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"-"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(uj,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:z,onChange:he=>ce(he.target.value)}),r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:me,onChange:he=>_(he.target.value)}),r.jsx(X,{size:"sm",onClick:He,disabled:G||!z||!me,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:G?"保存中...":"确认修改"})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),r.jsx(jt,{checked:A.isVip,onCheckedChange:he=>Y(xe=>({...xe,isVip:he}))})]}),A.isVip&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),r.jsx(re,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:A.vipExpireDate,onChange:he=>Y(xe=>({...xe,vipExpireDate:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),r.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:A.vipRole,onChange:he=>Y(xe=>({...xe,vipRole:he.target.value})),children:[r.jsx("option",{value:"",children:"请选择"}),U.map(he=>r.jsx("option",{value:he.name,children:he.name},he.id))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:A.vipName,onChange:he=>Y(xe=>({...xe,vipName:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"项目"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"如:某某科技",value:A.vipProject,onChange:he=>Y(xe=>({...xe,vipProject:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"联系方式"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"微信/手机等",value:A.vipContact,onChange:he=>Y(xe=>({...xe,vipContact:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"简介"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"简短介绍",value:A.vipBio,onChange:he=>Y(xe=>({...xe,vipBio:he.target.value}))})]})]})]})]}),a.isVip&&r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:a.vipRole||"VIP"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.vipName&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"展示名:"}),r.jsx("span",{className:"text-white",children:a.vipName})]}),a.vipProject&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"项目:"}),r.jsx("span",{className:"text-white",children:a.vipProject})]}),a.vipContact&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"联系方式:"}),r.jsx("span",{className:"text-white",children:a.vipContact})]}),a.vipExpireDate&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"到期时间:"}),r.jsx("span",{className:"text-white",children:new Date(a.vipExpireDate).toLocaleDateString()})]})]}),a.vipBio&&r.jsx("p",{className:"text-gray-400 text-sm mt-2",children:a.vipBio})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(zi,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"微信归属"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:Un,onChange:he=>Kn(he.target.value)}),r.jsxs(X,{size:"sm",onClick:async()=>{if(!(!Un||!a))try{await Ot("/api/db/users",{id:a.id,wechatId:Un}),te.success("已保存微信归属"),_t()}catch{te.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[r.jsx(wn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),a.wechatId&&r.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",r.jsx("span",{className:"text-purple-400",children:a.wechatId})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Rr,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),r.jsx(X,{size:"sm",onClick:qn,disabled:N||!a.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:N?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"同步状态:"}),a.ckbSyncedAt?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"最后同步:"}),r.jsx("span",{className:"text-gray-300 ml-1",children:a.ckbSyncedAt?new Date(a.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),r.jsxs(en,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(ld,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户标签"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),r.jsxs("div",{className:"mb-3 p-2.5 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-center gap-2 text-xs text-gray-400",children:[r.jsx(Ug,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),r.jsx("div",{className:"mb-4 space-y-3",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(he=>r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:he.category}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:he.tags.map(xe=>r.jsxs("button",{type:"button",onClick:()=>{R.includes(xe)?q(xe):O([...R,xe])},className:`px-2 py-0.5 rounded text-xs border transition-all ${R.includes(xe)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[R.includes(xe)?"✓ ":"",xe]},xe))})]},he.category))}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[R.map((he,xe)=>r.jsxs(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[he,r.jsx("button",{type:"button",onClick:()=>q(he),className:"ml-1 hover:text-red-400",children:r.jsx(gs,{className:"w-3 h-3"})})]},xe)),R.length===0&&r.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:se,onChange:he=>ie(he.target.value),onKeyDown:he=>he.key==="Enter"&&ls()}),r.jsx(X,{onClick:ls,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),(()=>{const he=a.tags||a.ckbTags||"";let xe=[];try{const Rn=typeof he=="string"?JSON.parse(he||"[]"):[];xe=Array.isArray(Rn)?Rn:typeof he=="string"?he.split(","):[]}catch{xe=typeof he=="string"?he.split(","):[]}const zt=xe.map(Rn=>String(Rn).trim()).filter(Boolean);return zt.length===0?null:r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(ld,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:zt.map((Rn,da)=>r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:Rn},da))})]})})()]}),r.jsxs(en,{value:"journey",className:"flex-1 overflow-auto",children:[r.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(Ll,{className:"w-4 h-4 text-[#38bdac]"}),r.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),r.jsx("div",{className:"space-y-2",children:o.length>0?o.map((he,xe)=>r.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:xt(he.action)}),xe0?u.map((he,xe)=>{var Rn;const zt=he;return r.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Rn=zt.nickname)==null?void 0:Rn.charAt(0))||"?"}),r.jsx("span",{className:"text-white text-sm",children:zt.nickname})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[zt.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),r.jsx("span",{className:"text-gray-500 text-xs",children:zt.createdAt?new Date(zt.createdAt).toLocaleDateString():""})]})]},zt.id||xe)}):r.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),r.jsxs(en,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fa,{className:"w-5 h-5 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:kt,onChange:he=>At(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Gt,onChange:he=>In(he.target.value)})]}),r.jsxs("div",{className:"col-span-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:Lt,onChange:he=>xn(he.target.value)})]})]}),r.jsx(X,{onClick:$t,disabled:ae,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:ae?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Ba,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),r.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),at&&r.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:at}),Se&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),r.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:Se.rfm_score??"-"})]}),r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:Se.user_level??"-"})]})]}),Se.tags&&Se.tags.length>0&&r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Se.tags.map((he,xe)=>r.jsx(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:he},xe))})]}),Se.last_active&&r.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",Se.last_active]})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Fa,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),r.jsx(X,{onClick:ot,disabled:ln||!a.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:ln?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):r.jsxs(r.Fragment,{children:[r.jsx(Fa,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!a.phone&&r.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),yn&&r.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:yn.error?r.jsx("p",{className:"text-red-400",children:String(yn.error)}):r.jsxs("div",{className:"space-y-1",children:[r.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[r.jsx(Ug,{className:"w-4 h-4"})," 推送成功"]}),yn.enriched!==void 0&&r.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(yn.new_tags_added??0)]})]})})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[r.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"关闭"]}),r.jsxs(X,{onClick:zn,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):r.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),r.jsx(It,{open:W,onOpenChange:le,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsx(Pt,{children:"调整余额"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ye,onChange:he=>Ae(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"备注(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:ne,onChange:he=>K(he.target.value)})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:mt,disabled:J,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:J?"提交中...":"确认调整"})]})]})})]}):null}function fP(){const t=Ki(),[e,n]=b.useState(!0),[s,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,N]=b.useState(0),[j,v]=b.useState(0),[k,C]=b.useState(0),[E,M]=b.useState(null),[P,H]=b.useState(null),[L,R]=b.useState(!1),[O,se]=b.useState(0),[ie,z]=b.useState(!1),[ce,me]=b.useState(null),[_,G]=b.useState("week"),[$,A]=b.useState(null),[Y,U]=b.useState(!1),D=K=>{const J=K;if((J==null?void 0:J.status)===401)M("登录已过期,请重新登录");else{if((J==null?void 0:J.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function W(K){const J=K?{signal:K}:void 0;n(!0),M(null);try{const pe=await De("/api/admin/dashboard/stats",J);pe!=null&&pe.success&&(g(pe.totalUsers??0),N(pe.paidOrderCount??0),v(pe.totalRevenue??0),C(pe.conversionRate??0))}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",pe);try{const Se=await De("/api/admin/dashboard/overview",J);Se!=null&&Se.success&&(g(Se.totalUsers??0),N(Se.paidOrderCount??0),v(Se.totalRevenue??0),C(Se.conversionRate??0))}catch(Se){D(Se)}}}finally{n(!1)}try{const pe=await De("/api/admin/balance/summary",J);pe!=null&&pe.success&&pe.data&&se(pe.data.totalGifted??0)}catch{}try{const pe=await De("/api/db/ckb-plan-stats",J);pe!=null&&pe.success&&pe.data?me({ckbTotal:pe.data.ckbTotal??0,withContact:pe.data.withContact??0}):me(null)}catch{me(null)}a(!0),o(!0);const ge=async()=>{try{const pe=await De("/api/admin/dashboard/recent-orders?limit=10",J);if(pe!=null&&pe.success&&pe.recentOrders)f(pe.recentOrders);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/admin/orders?page=1&pageSize=20&status=paid",J),at=((Se==null?void 0:Se.orders)??[]).filter(Dt=>["paid","completed","success"].includes(Dt.status||""));f(at.slice(0,5))}catch{f([])}}finally{a(!1)}},ae=async()=>{try{const pe=await De("/api/admin/dashboard/new-users",J);if(pe!=null&&pe.success&&pe.newUsers)u(pe.newUsers);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/db/users?page=1&pageSize=10",J);u((Se==null?void 0:Se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([ge(),ae()])}async function le(K){const J=K||_;U(!0);try{const ge=await De(`/api/admin/track/stats?period=${J}`);ge!=null&&ge.success&&A({total:ge.total??0,byModule:ge.byModule??{}})}catch{A(null)}finally{U(!1)}}b.useEffect(()=>{const K=new AbortController;W(K.signal),le();const J=setInterval(()=>{W(),le()},3e4);return()=>{K.abort(),clearInterval(J)}},[]);const ye=m,Ae=K=>{const J=K.productType||"",ge=K.description||"";if(J==="balance_recharge")return{title:`余额充值 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(J==="gift_pay")return{title:`代付 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(J==="gift_pay_batch"){const ae=typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2);return{title:ge||`代付分享 ¥${ae}`,subtitle:"代付分享"}}if(J==="section"&&ge.includes("代付领取"))return{title:ge.replace("代付领取 - ",""),subtitle:"代付领取"};if(ge){if(J==="section"&&ge.includes("章节")){if(ge.includes("-")){const ae=ge.split("-");if(ae.length>=3)return{title:`第${ae[1]}章 第${ae[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:ge,subtitle:"章节购买"}}return J==="fullbook"||ge.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"||ge.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"||ge.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:ge,subtitle:J==="section"?"单章":J==="fullbook"?"全书":"其他"}}return J==="section"?{title:`章节 ${K.productId||""}`,subtitle:"单章购买"}:J==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:J||"其他"}},ne=[{title:"总用户数",value:e?null:ye,sub:null,icon:_n,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:cd,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Qg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:Ys,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ce?ce.ckbTotal??0:null,sub:(ce==null?void 0:ce.withContact)!=null?`含联系方式 ${ce.withContact} 人`:null,icon:dd,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"}];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&r.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[r.jsx("span",{children:E}),r.jsx("button",{type:"button",onClick:()=>W(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:ne.map((K,J)=>r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>K.link&&t(K.link),children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsx(Ye,{className:"text-sm font-medium text-gray-400",children:K.title}),r.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:r.jsx(K.icon,{className:`w-4 h-4 ${K.color}`})})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:K.value!=null?K.value:r.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[r.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),K.sub&&r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:K.sub})]}),r.jsx(Dl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},J))}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ye,{className:"text-white",children:"最近订单"}),r.jsxs("button",{type:"button",onClick:()=>W(),disabled:s||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[s||i?r.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:s&&h.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[h.slice(0,ie?10:4).map(K=>{var Se;const J=K.referrerId?c.find(tt=>tt.id===K.referrerId):void 0,ge=K.referralCode||(J==null?void 0:J.referralCode)||(J==null?void 0:J.nickname)||(K.referrerId?String(K.referrerId).slice(0,8):""),ae=Ae(K),pe=K.userNickname||((Se=c.find(tt=>tt.id===K.userId))==null?void 0:Se.nickname)||"匿名用户";return r.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[K.userAvatar?r.jsx("img",{src:K.userAvatar,alt:pe,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:tt=>{tt.currentTarget.style.display="none";const at=tt.currentTarget.nextElementSibling;at&&at.classList.remove("hidden")}}):null,r.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${K.userAvatar?"hidden":""}`,children:pe.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("button",{type:"button",onClick:()=>{K.userId&&(H(K.userId),R(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:pe}),r.jsx("span",{className:"text-gray-600",children:"·"}),r.jsx("span",{className:"text-sm font-medium text-white truncate",children:ae.title})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[ae.subtitle&&ae.subtitle!=="章节购买"&&r.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:ae.subtitle}),r.jsx("span",{children:new Date(K.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),ge&&r.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",ge]})]})]}),r.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[r.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(K.amount).toFixed(2)]}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:K.paymentMethod||"微信"})]})]},K.id)}),h.length>4&&!ie&&r.jsx("button",{type:"button",onClick:()=>z(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!s&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Qg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"新注册用户"})}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:i&&c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[c.slice(0,5).map(K=>{var J;return r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((J=K.nickname)==null?void 0:J.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>{H(K.id),R(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:K.nickname||"匿名用户"}),r.jsx("p",{className:"text-xs text-gray-500",children:K.phone||"-"})]})]}),r.jsx("p",{className:"text-xs text-gray-400",children:K.createdAt?new Date(K.createdAt).toLocaleDateString():"-"})]},K.id)}),c.length===0&&!i&&r.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),r.jsxs(Ee,{className:"mt-8 bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wg,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),r.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(K=>r.jsx("button",{type:"button",onClick:()=>{G(K),le(K)},className:`px-3 py-1 text-xs rounded-full transition-colors ${_===K?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[K]},K))})]}),r.jsx(Te,{children:Y&&!$?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):$&&Object.keys($.byModule).length>0?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",r.jsx("span",{className:"text-white font-bold text-lg",children:$.total})," 次"]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries($.byModule).sort((K,J)=>J[1].reduce((ge,ae)=>ge+ae.count,0)-K[1].reduce((ge,ae)=>ge+ae.count,0)).map(([K,J])=>{const ge=J.reduce((pe,Se)=>pe+Se.count,0),ae={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:ae[K]||K}),r.jsxs("span",{className:"text-xs text-gray-500",children:[ge," 次"]})]}),r.jsx("div",{className:"space-y-2",children:J.sort((pe,Se)=>Se.count-pe.count).slice(0,8).map((pe,Se)=>{const tt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",rule_trigger:"规则触发",view_chapter:"浏览章节",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元"},at={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节"},Dt=tt[pe.target]||pe.target||at[pe.action]||pe.action;return r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${pe.action}: ${pe.target}`,children:Dt}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${ge>0?pe.count/ge*100:0}%`}})}),r.jsx("span",{className:"text-gray-400 w-8 text-right",children:pe.count})]})]},Se)})})]},K)})})]}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),r.jsx(y0,{open:L,onClose:()=>{R(!1),H(null)},userId:P,onUserUpdated:()=>W()})]})}const ss=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:Mt("w-full caption-bottom text-sm",t),...e})}));ss.displayName="Table";const rs=b.forwardRef(({className:t,...e},n)=>r.jsx("thead",{ref:n,className:Mt("[&_tr]:border-b",t),...e}));rs.displayName="TableHeader";const as=b.forwardRef(({className:t,...e},n)=>r.jsx("tbody",{ref:n,className:Mt("[&_tr:last-child]:border-0",t),...e}));as.displayName="TableBody";const it=b.forwardRef(({className:t,...e},n)=>r.jsx("tr",{ref:n,className:Mt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));it.displayName="TableRow";const we=b.forwardRef(({className:t,...e},n)=>r.jsx("th",{ref:n,className:Mt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));we.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>r.jsx("td",{ref:n,className:Mt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function b0(t,e){const[n,s]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>s(t),e);return()=>clearTimeout(a)},[t,e]),n}function Fs({page:t,totalPages:e,total:n,pageSize:s,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:r.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[r.jsxs("span",{children:["共 ",n," 条"]}),i&&r.jsx("select",{value:s,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>r.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),r.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),r.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),r.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),r.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function pP(){const[t,e]=b.useState([]),[n,s]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(""),v=b0(N,300),[k,C]=b.useState("all"),[E,M]=b.useState(!0),[P,H]=b.useState(null),[L,R]=b.useState(null),[O,se]=b.useState(""),[ie,z]=b.useState(!1);async function ce(){M(!0),H(null);try{const U=k==="all"?"":k==="completed"?"completed":k,D=new URLSearchParams({page:String(f),pageSize:String(g),...U&&{status:U},...v&&{search:v}}),[W,le]=await Promise.all([De(`/api/admin/orders?${D}`),De("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),le!=null&&le.success&&le.users&&s(le.users)}catch(U){console.error("加载订单失败",U),H("加载订单失败,请检查网络后重试")}finally{M(!1)}}b.useEffect(()=>{m(1)},[v,k]),b.useEffect(()=>{ce()},[f,g,v,k]);const me=U=>{var D;return U.userNickname||((D=n.find(W=>W.id===U.userId))==null?void 0:D.nickname)||"匿名用户"},_=U=>{var D;return((D=n.find(W=>W.id===U))==null?void 0:D.phone)||"-"},G=U=>{const D=U.productType||U.type||"",W=U.description||"";if(D==="balance_recharge")return{name:`余额充值 ¥${Number(U.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(D==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const le=W.split("-");if(le.length>=3)return{name:`第${le[1]}章 第${le[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return D==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:D==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:D==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return D==="section"?{name:`章节 ${U.productId||U.sectionId||""}`,type:"单章"}:D==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:D==="vip"?{name:"超级个体开通费用",type:"超级个体"}:D==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:D||"其他"}},$=Math.ceil(a/g)||1;async function A(){var U;if(!(!(L!=null&&L.orderSn)&&!(L!=null&&L.id))){z(!0),H(null);try{const D=await Ot("/api/admin/orders/refund",{orderSn:L.orderSn||L.id,reason:O||void 0});D!=null&&D.success?(R(null),se(""),ce()):H((D==null?void 0:D.error)||"退款失败")}catch(D){const W=D;H(((U=W==null?void 0:W.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{z(!1)}}}function Y(){if(t.length===0){te.info("暂无数据可导出");return}const U=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],D=t.map(ne=>{const K=G(ne);return[ne.orderSn||ne.id||"",me(ne),_(ne.userId),K.name,Number(ne.amount||0).toFixed(2),ne.paymentMethod==="wechat"?"微信支付":ne.paymentMethod==="balance"?"余额支付":ne.paymentMethod==="alipay"?"支付宝":ne.paymentMethod||"微信支付",ne.status==="refunded"?"已退款":ne.status==="paid"||ne.status==="completed"?"已完成":ne.status==="pending"||ne.status==="created"?"待支付":"已失败",ne.status==="refunded"&&ne.refundReason?ne.refundReason:"-",ne.referrerEarnings?Number(ne.referrerEarnings).toFixed(2):"-",ne.createdAt?new Date(ne.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[U.join(","),...D].join(`
-`),le=new Blob([W],{type:"text/csv;charset=utf-8"}),ye=URL.createObjectURL(le),Ae=document.createElement("a");Ae.href=ye,Ae.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,Ae.click(),URL.revokeObjectURL(ye)}return r.jsxs("div",{className:"p-8 w-full",children:[P&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:P}),r.jsx("button",{type:"button",onClick:()=>H(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"outline",onClick:ce,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-400",children:"总收入:"}),r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),r.jsx("span",{className:"text-gray-600",children:"|"}),r.jsx("span",{className:"text-gray-400",children:"今日:"}),r.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1 max-w-md",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:U=>j(U.target.value)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lj,{className:"w-4 h-4 text-gray-400"}),r.jsxs("select",{value:k,onChange:U=>C(U.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"created",children:"已创建"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]})]}),r.jsxs(X,{variant:"outline",onClick:Y,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(mM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:E?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"订单号"}),r.jsx(we,{className:"text-gray-400",children:"用户"}),r.jsx(we,{className:"text-gray-400",children:"商品"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"支付方式"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"退款原因"}),r.jsx(we,{className:"text-gray-400",children:"分销佣金"}),r.jsx(we,{className:"text-gray-400",children:"下单时间"}),r.jsx(we,{className:"text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[t.map(U=>{const D=G(U);return r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(U.orderSn||U.id||"").slice(0,12),"..."]}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[me(U),U.paymentMethod==="gift_pay"&&r.jsx(Ke,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),U.payerUserId&&U.paymentMethod!=="gift_pay"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:_(U.userId)}),U.payerUserId&&U.payerNickname&&r.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[U.paymentMethod==="gift_pay"?"赠送人:":"代付人:",U.payerNickname]})]})}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[D.name,(U.productType||U.type)==="vip"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:D.type})]})}),r.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(U.amount||0).toFixed(2)]}),r.jsx(ve,{className:"text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),r.jsx(ve,{children:U.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):U.status==="paid"||U.status==="completed"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),r.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),r.jsx(ve,{className:"text-[#FFD700]",children:U.referrerEarnings?`¥${Number(U.referrerEarnings).toFixed(2)}`:"-"}),r.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(U.createdAt).toLocaleString("zh-CN")}),r.jsx(ve,{children:(U.status==="paid"||U.status==="completed")&&U.paymentMethod!=="balance"&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{R(U),se("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)}),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),r.jsx(Fs,{page:f,totalPages:$,total:a,pageSize:g,onPageChange:m,onPageSizeChange:U=>{y(U),m(1)}})]})})}),r.jsx(It,{open:!!L,onOpenChange:U=>!U&&R(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"订单退款"})}),L&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",L.orderSn||L.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(L.amount||0).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:U=>se(U.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>R(null),disabled:ie,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:A,disabled:ie,children:ie?"退款中...":"确认退款"})]})]})})]})}const rc=b.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:Mt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm 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",t),ref:n,...e}));rc.displayName="Textarea";const th=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function mP(){var Hr,bn,so,ba,Wr;const[t,e]=tj(),n=t.get("pool"),s=t.get("tab")||"users",[a,i]=b.useState([]),[o,c]=b.useState(0),[u,h]=b.useState(1),[f,m]=b.useState(10),[g,y]=b.useState(""),N=b0(g,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[v,k]=b.useState(j),[C,E]=b.useState(!0),[M,P]=b.useState(!1),[H,L]=b.useState(null),[R,O]=b.useState(!1),[se,ie]=b.useState("desc");b.useEffect(()=>{n==="vip"?k("vip"):n==="complete"?k("complete"):n==="all"&&k("all")},[n]);const[z,ce]=b.useState(!1),[me,_]=b.useState(null),[G,$]=b.useState(!1),[A,Y]=b.useState(!1),[U,D]=b.useState({referrals:[],stats:{}}),[W,le]=b.useState(!1),[ye,Ae]=b.useState(null),[ne,K]=b.useState(!1),[J,ge]=b.useState(null),[ae,pe]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Se,tt]=b.useState([]),[at,Dt]=b.useState(!1),[kt,At]=b.useState(!1),[Gt,In]=b.useState(null),[Lt,xn]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[ln,Bs]=b.useState([]),[yn,is]=b.useState(!1),[Un,Kn]=b.useState(null),[_t,qn]=b.useState(null),[zn,ls]=b.useState({}),[q,He]=b.useState(!1),[mt,$t]=b.useState([]),[ut,ot]=b.useState(0),[xt,tn]=b.useState(1),[he]=b.useState(20),[xe,zt]=b.useState(!1),Rn=b.useCallback(async()=>{zt(!0);try{const F=await De(`/api/db/ckb-leads?mode=contact&page=${xt}&pageSize=${he}`);F!=null&&F.success&&($t(F.records||[]),ot(F.total??0))}catch{$t([]),ot(0)}finally{zt(!1)}},[xt,he]);b.useEffect(()=>{t.get("tab")==="leads"&&Rn()},[t.get("tab"),xt,Rn]);const[da,ua]=b.useState(null),_r=b.useCallback(async()=>{try{const F=await De("/api/admin/users/online-stats");F!=null&&F.success&&typeof F.onlineCount=="number"?ua(F.onlineCount):ua(0)}catch{ua(null)}},[]);b.useEffect(()=>{_r();const F=setInterval(_r,1e4);return()=>clearInterval(F)},[_r]);async function Zs(F=!1){var Pe;E(!0),F&&P(!0),L(null);try{if(R){const _e=new URLSearchParams({search:N,limit:String(f*5)}),lt=await De(`/api/db/users/rfm?${_e}`);if(lt!=null&<.success){let cn=lt.users||[];se==="asc"&&(cn=[...cn].reverse());const ct=(u-1)*f;i(cn.slice(ct,ct+f)),c(((Pe=lt.users)==null?void 0:Pe.length)??0),cn.length===0&&(O(!1),L("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else O(!1),L((lt==null?void 0:lt.error)||"RFM 加载失败,已切回普通模式")}else{const _e=new URLSearchParams({page:String(u),pageSize:String(f),search:N,...v==="vip"&&{vip:"true"},...v==="complete"&&{pool:"complete"}}),lt=await De(`/api/db/users?${_e}`);lt!=null&<.success?(i(lt.users||[]),c(lt.total??0)):L((lt==null?void 0:lt.error)||"加载失败")}}catch(_e){console.error("Load users error:",_e),L("网络错误")}finally{E(!1),F&&P(!1)}}b.useEffect(()=>{h(1)},[N,v,R]),b.useEffect(()=>{Zs()},[u,f,N,v,R,se]);const ha=Math.ceil(o/f)||1,Xo=()=>{R?se==="desc"?ie("asc"):(O(!1),ie("desc")):(O(!0),ie("desc"))},fa=F=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[F||""]||"bg-gray-500/20 text-gray-400";async function Zi(F){var Pe;if(confirm("确定要删除这个用户吗?"))try{const _e=await ea(`/api/db/users?id=${encodeURIComponent(F)}`);_e!=null&&_e.success?(te.success("已删除"),Zs()):te.error("删除失败: "+((_e==null?void 0:_e.error)||"未知错误"))}catch(_e){const lt=_e,cn=((Pe=lt==null?void 0:lt.data)==null?void 0:Pe.error)||(lt==null?void 0:lt.message)||"网络错误";te.error("删除失败: "+cn)}}const pa=F=>{_(F),pe({phone:F.phone||"",nickname:F.nickname||"",password:"",isAdmin:!!(F.isAdmin??!1),hasFullBook:!!(F.hasFullBook??!1)}),ce(!0)},dc=()=>{_(null),pe({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ce(!0)};async function mr(){if(!ae.phone||!ae.nickname){te.error("请填写手机号和昵称");return}$(!0);try{if(me){const F=await Ot("/api/db/users",{id:me.id,phone:ae.phone||void 0,nickname:ae.nickname,isAdmin:ae.isAdmin,hasFullBook:ae.hasFullBook,...ae.password&&{password:ae.password}});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await Nt("/api/db/users",{phone:ae.phone,nickname:ae.nickname,password:ae.password,isAdmin:ae.isAdmin});if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}ce(!1),Zs()}catch{te.error("保存失败")}finally{$(!1)}}async function ma(F){Ae(F),Y(!0),le(!0);try{const Pe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(F.id)}`);Pe!=null&&Pe.success?D({referrals:Pe.referrals||[],stats:Pe.stats||{}}):D({referrals:[],stats:{}})}catch{D({referrals:[],stats:{}})}finally{le(!1)}}const Vs=b.useCallback(async()=>{Dt(!0);try{const F=await De("/api/db/user-rules");F!=null&&F.success&&tt(F.rules||[])}catch{}finally{Dt(!1)}},[]);async function gr(){if(!Lt.title){te.error("请填写规则标题");return}$(!0);try{if(Gt){const F=await Ot("/api/db/user-rules",{id:Gt.id,...Lt});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await Nt("/api/db/user-rules",Lt);if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}At(!1),Vs()}catch{te.error("保存失败")}finally{$(!1)}}async function eo(F){if(confirm("确定删除?"))try{const Pe=await ea(`/api/db/user-rules?id=${F}`);Pe!=null&&Pe.success&&Vs()}catch{}}async function Zo(F){try{await Ot("/api/db/user-rules",{id:F.id,enabled:!F.enabled}),Vs()}catch{}}const yt=b.useCallback(async()=>{is(!0);try{const F=await De("/api/db/vip-members?limit=500");if(F!=null&&F.success&&F.data){const Pe=[...F.data].map((_e,lt)=>({..._e,vipSort:typeof _e.vipSort=="number"?_e.vipSort:lt+1}));Pe.sort((_e,lt)=>(_e.vipSort??999999)-(lt.vipSort??999999)),Bs(Pe)}else F&&F.error&&te.error(F.error)}catch{te.error("加载超级个体列表失败")}finally{is(!1)}},[]),[kn,zr]=b.useState(!1),[xr,to]=b.useState(null),[yr,ga]=b.useState(""),[Fr,er]=b.useState(!1),Ja=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],uc=F=>{to(F),ga(F.vipRole||""),zr(!0)},Jt=async F=>{const Pe=F.trim();if(xr){if(!Pe){te.error("请选择或输入标签");return}er(!0);try{const _e=await Ot("/api/db/users",{id:xr.id,vipRole:Pe});if(!(_e!=null&&_e.success)){te.error((_e==null?void 0:_e.error)||"更新超级个体标签失败");return}te.success("已更新超级个体标签"),zr(!1),to(null),await yt()}catch{te.error("更新超级个体标签失败")}finally{er(!1)}}},[hc,br]=b.useState(!1),[vr,$r]=b.useState(null),[Ya,no]=b.useState(""),[Br,Ns]=b.useState(!1),Qa=F=>{$r(F),no(F.vipSort!=null?String(F.vipSort):""),br(!0)},ws=async()=>{if(!vr)return;const F=Number(Ya);if(!Number.isFinite(F)){te.error("请输入有效的数字序号");return}Ns(!0);try{const Pe=await Ot("/api/db/users",{id:vr.id,vipSort:F});if(!(Pe!=null&&Pe.success)){te.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}te.success("已更新排序序号"),br(!1),$r(null),await yt()}catch{te.error("更新排序序号失败")}finally{Ns(!1)}},Vr=(F,Pe)=>{F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",Pe),Kn(Pe)},fc=(F,Pe)=>{F.preventDefault(),_t!==Pe&&qn(Pe)},pc=()=>{Kn(null),qn(null)},xa=async(F,Pe)=>{F.preventDefault();const _e=F.dataTransfer.getData("text/plain")||Un;if(Kn(null),qn(null),!_e||_e===Pe)return;const lt=ln.find(dn=>dn.id===_e),cn=ln.find(dn=>dn.id===Pe);if(!lt||!cn)return;const ct=lt.vipSort??ln.findIndex(dn=>dn.id===_e)+1,Xa=cn.vipSort??ln.findIndex(dn=>dn.id===Pe)+1;Bs(dn=>{const Gn=[...dn],Ms=Gn.findIndex(cs=>cs.id===_e),As=Gn.findIndex(cs=>cs.id===Pe);if(Ms===-1||As===-1)return dn;const Nr=[...Gn],[va,tr]=[Nr[Ms],Nr[As]];return Nr[Ms]={...tr,vipSort:ct},Nr[As]={...va,vipSort:Xa},Nr});try{const[dn,Gn]=await Promise.all([Ot("/api/db/users",{id:_e,vipSort:Xa}),Ot("/api/db/users",{id:Pe,vipSort:ct})]);if(!(dn!=null&&dn.success)||!(Gn!=null&&Gn.success)){te.error((dn==null?void 0:dn.error)||(Gn==null?void 0:Gn.error)||"更新排序失败"),await yt();return}te.success("已更新排序"),await yt()}catch{te.error("更新排序失败"),await yt()}},ya=b.useCallback(async()=>{He(!0);try{const F=await De("/api/db/users/journey-stats");F!=null&&F.success&&F.stats&&ls(F.stats)}catch{}finally{He(!1)}},[]);return r.jsxs("div",{className:"p-8 w-full",children:[H&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:H}),r.jsx("button",{type:"button",onClick:()=>L(null),children:"×"})]}),r.jsx("div",{className:"flex justify-between items-center mb-6",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),r.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",o," 位注册用户",da!==null&&r.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",da," 人"]}),R&&" · RFM 排序中"]})]})}),r.jsxs(Wd,{value:s,onValueChange:F=>{const Pe=new URLSearchParams(t);F==="users"?Pe.delete("tab"):Pe.set("tab",F),e(Pe)},className:"w-full",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[r.jsxs(Zt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[r.jsx(_n,{className:"w-4 h-4"})," 用户列表"]}),r.jsxs(Zt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Rn(),children:[r.jsx(dd,{className:"w-4 h-4"})," 获客列表"]}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ya,children:[r.jsx(Ll,{className:"w-4 h-4"})," 用户旅程总览"]}),r.jsxs(Zt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Vs,children:[r.jsx(Mo,{className:"w-4 h-4"})," 规则配置"]}),r.jsxs(Zt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:yt,children:[r.jsx(Fl,{className:"w-4 h-4"})," 超级个体列表"]})]}),r.jsxs(en,{value:"users",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[r.jsxs(X,{variant:"outline",onClick:()=>Zs(!0),disabled:M,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${M?"animate-spin":""}`})," 刷新"]}),r.jsxs("select",{value:v,onChange:F=>{const Pe=F.target.value;k(Pe),h(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:R,children:[r.jsx("option",{value:"all",children:"全部用户"}),r.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),r.jsx("option",{value:"complete",children:"完善资料用户"})]}),r.jsxs("div",{className:"relative",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:g,onChange:F=>y(F.target.value)})]}),r.jsxs(X,{onClick:dc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(dd,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:C?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"用户信息"}),r.jsx(we,{className:"text-gray-400",children:"绑定信息"}),r.jsx(we,{className:"text-gray-400",children:"购买状态"}),r.jsx(we,{className:"text-gray-400",children:"分销收益"}),r.jsxs(we,{className:"text-gray-400 cursor-pointer select-none",onClick:Xo,children:[r.jsxs("div",{className:"flex items-center gap-1 group",children:[r.jsx(cd,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"RFM分值"}),R?se==="desc"?r.jsx(kd,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(sj,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(Hm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),R&&r.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),r.jsx(we,{className:"text-gray-400",children:"注册时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[a.map(F=>{var Pe,_e,lt;return r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:F.avatar?r.jsx("img",{src:F.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Pe=F.nickname)==null?void 0:Pe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{type:"button",onClick:()=>{ge(F.id),K(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:F.nickname}),F.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),F.openId&&!((_e=F.id)!=null&&_e.startsWith("user_"))&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:F.openId?F.openId.slice(0,12)+"...":(lt=F.id)==null?void 0:lt.slice(0,12)})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[F.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"📱"}),r.jsx("span",{className:"text-gray-300",children:F.phone})]}),F.wechatId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"💬"}),r.jsx("span",{className:"text-gray-300",children:F.wechatId})]}),F.openId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"🔗"}),r.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:F.openId,children:[F.openId.slice(0,12),"..."]})]}),!F.phone&&!F.wechatId&&!F.openId&&r.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),r.jsx(ve,{children:F.hasFullBook?r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(F.earnings||0)).toFixed(2)]}),parseFloat(String(F.pendingEarnings||0))>0&&r.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(F.pendingEarnings||0)).toFixed(2)]}),r.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>ma(F),role:"button",tabIndex:0,onKeyDown:cn=>cn.key==="Enter"&&ma(F),children:[r.jsx(_n,{className:"w-3 h-3"})," 绑定",F.referralCount||0,"人"]})]})}),r.jsx(ve,{children:F.rfmScore!==void 0?r.jsx("div",{className:"flex flex-col gap-1",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-white font-bold text-base",children:F.rfmScore}),r.jsx(Ke,{className:`border-0 text-xs ${fa(F.rfmLevel)}`,children:F.rfmLevel})]})}):r.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",r.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleDateString():"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ge(F.id),K(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:r.jsx(qg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>pa(F),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Zi(F.id),title:"删除",children:r.jsx(Zn,{className:"w-4 h-4"})})]})})]},F.id)}),a.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),r.jsx(Fs,{page:u,totalPages:ha,total:o,pageSize:f,onPageChange:h,onPageSizeChange:F=>{m(F),h(1)}})]})})})]}),r.jsxs(en,{value:"leads",children:[r.jsx("div",{className:"flex items-center justify-end mb-4",children:r.jsxs(X,{variant:"outline",onClick:Rn,disabled:xe,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${xe?"animate-spin":""}`})," 刷新"]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:xe?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"手机号"}),r.jsx(we,{className:"text-gray-400",children:"微信号"}),r.jsx(we,{className:"text-gray-400",children:"对应 @人"}),r.jsx(we,{className:"text-gray-400",children:"获客计划"}),r.jsx(we,{className:"text-gray-400",children:"来源"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(as,{children:[mt.map(F=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:F.userNickname||F.name||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.phone||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.wechatId||"-"}),r.jsx(ve,{className:"text-[#38bdac]",children:F.personName||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.ckbPlanId?`#${F.ckbPlanId}`:"-"}),r.jsx(ve,{className:"text-gray-400",children:F.source||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleString():"-"})]},F.id)),mt.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无获客数据"})})]})]}),r.jsx(Fs,{page:xt,totalPages:Math.ceil(ut/he)||1,total:ut,pageSize:he,onPageChange:tn,onPageSizeChange:()=>{}})]})})})]}),r.jsxs(en,{value:"journey",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),r.jsxs(X,{variant:"outline",onClick:ya,disabled:q,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${q?"animate-spin":""}`})," 刷新数据"]})]}),r.jsxs("div",{className:"relative mb-8",children:[r.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),r.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:th.map((F,Pe)=>r.jsxs("div",{className:"relative flex flex-col items-center",children:[r.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${F.color} text-center cursor-default`,children:[r.jsx("div",{className:"text-2xl mb-1",children:F.icon}),r.jsx("div",{className:`text-xs font-medium ${F.color.split(" ").find(_e=>_e.startsWith("text-"))}`,children:F.label}),zn[F.id]!==void 0&&r.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[r.jsx("span",{className:"font-bold text-white",children:zn[F.id]})," 人"]}),r.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Pe+1})]}),Per.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:F.step}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-300",children:F.action}),r.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",F.next]})]})]},F.step))})]}),r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ys,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),r.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),q?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(zn).length>0?r.jsx("div",{className:"space-y-2",children:th.map(F=>{const Pe=zn[F.id]||0,_e=Math.max(...th.map(cn=>zn[cn.id]||0),1),lt=Math.round(Pe/_e*100);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[F.icon," ",F.label]}),r.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${lt}%`}})}),r.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},F.id)})}):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),r.jsxs(en,{value:"rules",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:Vs,disabled:at,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${at?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:()=>{In(null),xn({title:"",description:"",trigger:"",sort:0,enabled:!0}),At(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),at?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Se.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Ys,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),r.jsxs(X,{onClick:Vs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Fe,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):r.jsx("div",{className:"space-y-2",children:Se.map(F=>r.jsx("div",{className:`p-4 rounded-lg border transition-all ${F.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[r.jsx(Ut,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),r.jsx("span",{className:"text-white font-medium",children:F.title}),F.trigger&&r.jsxs(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",F.trigger]}),r.jsx(Ke,{className:`text-xs border-0 ${F.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:F.enabled?"启用":"禁用"})]}),F.description&&r.jsx("p",{className:"text-gray-400 text-sm ml-6",children:F.description})]}),r.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[r.jsx(jt,{checked:F.enabled,onCheckedChange:()=>Zo(F)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{In(F),xn({title:F.title,description:F.description,trigger:F.trigger,sort:F.sort,enabled:F.enabled}),At(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>eo(F.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Zn,{className:"w-4 h-4"})})]})]})},F.id))})]}),r.jsxs(en,{value:"vip-roles",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),r.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(X,{variant:"outline",onClick:yt,disabled:yn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${yn?"animate-spin":""}`})," ","刷新"]})})]}),yn?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ln.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Fl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-16",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序值"}),r.jsx(we,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),r.jsx(as,{children:ln.map((F,Pe)=>{var cn;const _e=Un===F.id,lt=_t===F.id;return r.jsxs(it,{draggable:!0,onDragStart:ct=>Vr(ct,F.id),onDragOver:ct=>fc(ct,F.id),onDrop:ct=>xa(ct,F.id),onDragEnd:pc,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${_e?"opacity-60":""} ${lt?"bg-[#38bdac]/10":""}`,children:[r.jsx(ve,{className:"text-gray-300",children:Pe+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[F.avatar?r.jsx("img",{src:F.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((cn=F.name)==null?void 0:cn[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:F.name})})]})}),r.jsx(ve,{className:"text-gray-300 whitespace-nowrap",children:F.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),r.jsx(ve,{className:"text-gray-300",children:F.vipSort??Pe+1}),r.jsx(ve,{className:"text-right text-xs text-gray-300",children:r.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>uc(F),title:"设置超级个体标签",children:r.jsx(ld,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{ge(F.id),K(!0)},title:"编辑资料",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Qa(F),title:"设置排序序号",children:r.jsx(Hm,{className:"w-3.5 h-3.5"})})]})})]},F.id)})})]})})})]})]}),r.jsx(It,{open:hc,onOpenChange:F=>{br(F),F||$r(null)},children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Hm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",vr==null?void 0:vr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ya,onChange:F=>no(F.target.value)})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>br(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:ws,disabled:Br,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),Br?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:kn,onOpenChange:F=>{zr(F),F||to(null)},children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Fl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",xr==null?void 0:xr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Ja.map(F=>r.jsx(X,{variant:yr===F?"default":"outline",size:"sm",className:yr===F?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ga(F),children:F},F))}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:yr,onChange:F=>ga(F.target.value)})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>zr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:()=>Jt(yr),disabled:Fr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),Fr?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:z,onOpenChange:ce,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[me?r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(dd,{className:"w-5 h-5 text-[#38bdac]"}),me?"编辑用户":"添加用户"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ae.phone,onChange:F=>pe({...ae,phone:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ae.nickname,onChange:F=>pe({...ae,nickname:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:me?"新密码 (留空则不修改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:me?"留空则不修改":"请输入密码",value:ae.password,onChange:F=>pe({...ae,password:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),r.jsx(jt,{checked:ae.isAdmin,onCheckedChange:F=>pe({...ae,isAdmin:F})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"已购全书"}),r.jsx(jt,{checked:ae.hasFullBook,onCheckedChange:F=>pe({...ae,hasFullBook:F})})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>ce(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:mr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:kt,onOpenChange:At,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}),Gt?"编辑规则":"添加规则"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Lt.title,onChange:F=>xn({...Lt,title:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则描述"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Lt.description,onChange:F=>xn({...Lt,description:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"触发条件"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Lt.trigger,onChange:F=>xn({...Lt,trigger:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:r.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),r.jsx(jt,{checked:Lt.enabled,onCheckedChange:F=>xn({...Lt,enabled:F})})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>At(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:gr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:A,onOpenChange:Y,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ye==null?void 0:ye.nickname]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Hr=U.stats)==null?void 0:Hr.total)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-green-400",children:((bn=U.stats)==null?void 0:bn.purchased)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((so=U.stats)==null?void 0:so.earnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((ba=U.stats)==null?void 0:ba.pendingEarnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),W?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Wr=U.referrals)==null?void 0:Wr.length)??0)>0?r.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(U.referrals??[]).map((F,Pe)=>{var lt;const _e=F;return r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((lt=_e.nickname)==null?void 0:lt.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white text-sm",children:_e.nickname}),r.jsx("div",{className:"text-xs text-gray-500",children:_e.phone||(_e.hasOpenId?"微信用户":"未绑定")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_e.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),_e.status==="paid"&&r.jsxs(Ke,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",_e.purchasedSections,"章"]}),_e.status==="free"&&r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),r.jsx("span",{className:"text-xs text-gray-500",children:_e.createdAt?new Date(_e.createdAt).toLocaleDateString():""})]})]},_e.id||Pe)})}):r.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),r.jsx(sn,{children:r.jsx(X,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),r.jsx(y0,{open:ne,onClose:()=>K(!1),userId:J,onUserUpdated:Zs})]})}function Lh(t,[e,n]){return Math.min(n,Math.max(e,t))}var Ok=["PageUp","PageDown"],Dk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ac="Slider",[sx,gP,xP]=p0(ac),[_k]=qi(ac,[xP]),[yP,Vf]=_k(ac),zk=b.forwardRef((t,e)=>{const{name:n,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[s],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:N,...j}=t,v=b.useRef(new Set),k=b.useRef(0),E=o==="horizontal"?bP:vP,[M=[],P]=_o({prop:f,defaultProp:h,onChange:ie=>{var ce;(ce=[...v.current][k.current])==null||ce.focus(),m(ie)}}),H=b.useRef(M);function L(ie){const z=SP(M,ie);se(ie,z)}function R(ie){se(ie,k.current)}function O(){const ie=H.current[k.current];M[k.current]!==ie&&g(M)}function se(ie,z,{commit:ce}={commit:!1}){const me=MP(i),_=AP(Math.round((ie-s)/i)*i+s,me),G=Lh(_,[s,a]);P(($=[])=>{const A=jP($,G,z);if(TP(A,u*i)){k.current=A.indexOf(G);const Y=String(A)!==String($);return Y&&ce&&g(A),Y?A:$}else return $})}return r.jsx(yP,{scope:t.__scopeSlider,name:n,disabled:c,min:s,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:M,orientation:o,form:N,children:r.jsx(sx.Provider,{scope:t.__scopeSlider,children:r.jsx(sx.Slot,{scope:t.__scopeSlider,children:r.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:dt(j.onPointerDown,()=>{c||(H.current=M)}),min:s,max:a,inverted:y,onSlideStart:c?void 0:L,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&se(s,0,{commit:!0}),onEndKeyDown:()=>!c&&se(a,M.length-1,{commit:!0}),onStepKeyDown:({event:ie,direction:z})=>{if(!c){const _=Ok.includes(ie.key)||ie.shiftKey&&Dk.includes(ie.key)?10:1,G=k.current,$=M[G],A=i*_*z;se($+A,G,{commit:!0})}}})})})})});zk.displayName=ac;var[Fk,$k]=_k(ac,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bP=b.forwardRef((t,e)=>{const{min:n,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=Tt(e,E=>g(E)),N=b.useRef(void 0),j=Ff(a),v=j==="ltr",k=v&&!i||!v&&i;function C(E){const M=N.current||m.getBoundingClientRect(),P=[0,M.width],L=v0(P,k?[n,s]:[s,n]);return N.current=M,L(E-M.left)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:r.jsx(Bk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const M=C(E.clientX);o==null||o(M)},onSlideMove:E=>{const M=C(E.clientX);c==null||c(M)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const P=Lk[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:P?-1:1})}})})}),vP=b.forwardRef((t,e)=>{const{min:n,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=Tt(e,f),g=b.useRef(void 0),y=!a;function N(j){const v=g.current||f.current.getBoundingClientRect(),k=[0,v.height],E=v0(k,y?[s,n]:[n,s]);return g.current=v,E(j-v.top)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:r.jsx(Bk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const v=N(j.clientY);i==null||i(v)},onSlideMove:j=>{const v=N(j.clientY);o==null||o(v)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const k=Lk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:k?-1:1})}})})}),Bk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Vf(ac,n);return r.jsx(pt.span,{...h,ref:e,onKeyDown:dt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Ok.concat(Dk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:dt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():s(m)}),onPointerMove:dt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:dt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Vk="SliderTrack",Hk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(Vk,n);return r.jsx(pt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:e})});Hk.displayName=Vk;var rx="SliderRange",Wk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(rx,n),i=$k(rx,n),o=b.useRef(null),c=Tt(e,o),u=a.values.length,h=a.values.map(g=>qk(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return r.jsx(pt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Wk.displayName=rx;var ax="SliderThumb",Uk=b.forwardRef((t,e)=>{const n=gP(t.__scopeSlider),[s,a]=b.useState(null),i=Tt(e,c=>a(c)),o=b.useMemo(()=>s?n().findIndex(c=>c.ref.current===s):-1,[n,s]);return r.jsx(NP,{...t,ref:i,index:o})}),NP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:s,name:a,...i}=t,o=Vf(ax,n),c=$k(ax,n),[u,h]=b.useState(null),f=Tt(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=x0(u),y=o.values[s],N=y===void 0?0:qk(y,o.min,o.max),j=kP(s,o.values.length),v=g==null?void 0:g[c.size],k=v?CP(v,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[r.jsx(sx.ItemSlot,{scope:t.__scopeSlider,children:r.jsx(pt.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:dt(t.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),m&&r.jsx(Kk,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},s)]})});Uk.displayName=ax;var wP="RadioBubbleInput",Kk=b.forwardRef(({__scopeSlider:t,value:e,...n},s)=>{const a=b.useRef(null),i=Tt(a,s),o=g0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(pt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});Kk.displayName=wP;function jP(t=[],e,n){const s=[...t];return s[n]=e,s.sort((a,i)=>a-i)}function qk(t,e,n){const i=100/(n-e)*(t-e);return Lh(i,[0,100])}function kP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function SP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),s=Math.min(...n);return n.indexOf(s)}function CP(t,e,n){const s=t/2,i=v0([0,50],[0,s]);return(s-i(e)*n)*n}function EP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function TP(t,e){if(e>0){const n=EP(t);return Math.min(...n)>=e}return!0}function v0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function MP(t){return(String(t).split(".")[1]||"").length}function AP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var IP=zk,RP=Hk,PP=Wk,OP=Uk;function DP({className:t,defaultValue:e,value:n,min:s=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[s,a],[n,e,s,a]);return r.jsxs(IP,{defaultValue:e,value:n,min:s,max:a,className:Mt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[r.jsx(RP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:r.jsx(PP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>r.jsx(OP,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const LP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Gk(t){const[e,n]=b.useState(LP),[s,a]=b.useState(!0),[i,o]=b.useState(!1);b.useEffect(()=>{De("/api/admin/referral-settings").then(h=>{const f=h==null?void 0:h.data;f&&typeof f=="object"&&n({distributorShare:f.distributorShare??90,minWithdrawAmount:f.minWithdrawAmount??10,bindingDays:f.bindingDays??30,userDiscount:f.userDiscount??5,withdrawFee:f.withdrawFee??5,enableAutoWithdraw:f.enableAutoWithdraw??!1,vipOrderShareVip:f.vipOrderShareVip??20,vipOrderShareNonVip:f.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>a(!1))},[]);const c=async()=>{o(!0);try{const h={distributorShare:Number(e.distributorShare)||0,minWithdrawAmount:Number(e.minWithdrawAmount)||0,bindingDays:Number(e.bindingDays)||0,userDiscount:Number(e.userDiscount)||0,withdrawFee:Number(e.withdrawFee)??5,enableAutoWithdraw:!!e.enableAutoWithdraw,vipOrderShareVip:Number(e.vipOrderShareVip)||20,vipOrderShareNonVip:Number(e.vipOrderShareNonVip)||10},f=await Nt("/api/admin/referral-settings",h);if(!f||f.success===!1){te.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}te.success(`✅ 分销配置已保存成功!
+For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},RR="DialogDescriptionWarning",PR=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ak(RR).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},OR=Kj,DR=Jj,LR=Yj,_R=Qj,zR=Zj,FR=tk,$R=sk;function Ot(t){return r.jsx(OR,{"data-slot":"dialog",...t})}function BR(t){return r.jsx(DR,{...t})}const ik=b.forwardRef(({className:t,...e},n)=>r.jsx(LR,{ref:n,className:It("fixed inset-0 z-50 bg-black/50",t),...e}));ik.displayName="DialogOverlay";const Tt=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...s},a)=>r.jsxs(BR,{children:[r.jsx(ik,{}),r.jsxs(_R,{ref:a,"aria-describedby":void 0,className:It("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...s,children:[e,n&&r.jsxs($R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(gs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tt.displayName="DialogContent";function Dt({className:t,...e}){return r.jsx("div",{className:It("flex flex-col gap-2 text-center sm:text-left",t),...e})}function nn({className:t,...e}){return r.jsx("div",{className:It("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Lt(t){return r.jsx(zR,{className:"text-lg font-semibold leading-none",...t})}function Cd(t){return r.jsx(FR,{className:"text-sm text-muted-foreground",...t})}const VR=bj("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ke({className:t,variant:e,asChild:n=!1,...s}){const a=n?gj:"span";return r.jsx(a,{className:It(VR({variant:e}),t),...s})}var HR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],WR=HR.reduce((t,e)=>{const n=mj(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{}),UR="Label",ok=b.forwardRef((t,e)=>r.jsx(WR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ok.displayName=UR;var lk=ok;const Z=b.forwardRef(({className:t,...e},n)=>r.jsx(lk,{ref:n,className:It("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=lk.displayName;function m0(t){const e=t+"CollectionProvider",[n,s]=qi(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:v,children:k}=j,C=Cs.useRef(null),E=Cs.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:E,collectionRef:C,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Sd(c),h=Cs.forwardRef((j,v)=>{const{scope:k,children:C}=j,E=i(c,k),M=At(v,E.collectionRef);return r.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Sd(f),y=Cs.forwardRef((j,v)=>{const{scope:k,children:C,...E}=j,M=Cs.useRef(null),P=At(v,M),H=i(f,k);return Cs.useEffect(()=>(H.itemMap.set(M,{ref:M,...E}),()=>void H.itemMap.delete(M))),r.jsx(g,{[m]:"",ref:P,children:C})});y.displayName=f;function N(j){const v=i(t+"CollectionConsumer",j);return Cs.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((H,L)=>E.indexOf(H.ref.current)-E.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,s]}var KR=b.createContext(void 0);function Ff(t){const e=b.useContext(KR);return t||e||"ltr"}var ng="rovingFocusGroup.onEntryFocus",qR={bubbles:!1,cancelable:!0},Hd="RovingFocusGroup",[sx,ck,GR]=m0(Hd),[JR,dk]=qi(Hd,[GR]),[YR,QR]=JR(Hd),uk=b.forwardRef((t,e)=>r.jsx(sx.Provider,{scope:t.__scopeRovingFocusGroup,children:r.jsx(sx.Slot,{scope:t.__scopeRovingFocusGroup,children:r.jsx(XR,{...t,ref:e})})}));uk.displayName=Hd;var XR=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=At(e,g),N=Ff(i),[j,v]=_o({prop:o,defaultProp:c??null,onChange:u,caller:Hd}),[k,C]=b.useState(!1),E=Fi(h),M=ck(n),P=b.useRef(!1),[H,L]=b.useState(0);return b.useEffect(()=>{const R=g.current;if(R)return R.addEventListener(ng,E),()=>R.removeEventListener(ng,E)},[E]),r.jsx(YR,{scope:n,orientation:s,dir:N,loop:a,currentTabStopId:j,onItemFocus:b.useCallback(R=>v(R),[v]),onItemShiftTab:b.useCallback(()=>C(!0),[]),onFocusableItemAdd:b.useCallback(()=>L(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>L(R=>R-1),[]),children:r.jsx(pt.div,{tabIndex:k||H===0?-1:0,"data-orientation":s,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:dt(t.onMouseDown,()=>{P.current=!0}),onFocus:dt(t.onFocus,R=>{const O=!P.current;if(R.target===R.currentTarget&&O&&!k){const se=new CustomEvent(ng,qR);if(R.currentTarget.dispatchEvent(se),!se.defaultPrevented){const ie=M().filter(G=>G.focusable),z=ie.find(G=>G.active),ce=ie.find(G=>G.id===j),_=[z,ce,...ie].filter(Boolean).map(G=>G.ref.current);pk(_,f)}}P.current=!1}),onBlur:dt(t.onBlur,()=>C(!1))})})}),hk="RovingFocusGroupItem",fk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Pi(),h=i||u,f=QR(hk,n),m=f.currentTabStopId===h,g=ck(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:j}=f;return b.useEffect(()=>{if(s)return y(),()=>N()},[s,y,N]),r.jsx(sx.ItemSlot,{scope:n,id:h,focusable:s,active:a,children:r.jsx(pt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:dt(t.onMouseDown,v=>{s?f.onItemFocus(h):v.preventDefault()}),onFocus:dt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:dt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=tP(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const M=E.indexOf(v.currentTarget);E=f.loop?nP(E,M+1):E.slice(M+1)}setTimeout(()=>pk(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});fk.displayName=hk;var ZR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function tP(t,e,n){const s=eP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return ZR[s]}function pk(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function nP(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var sP=uk,rP=fk,$f="Tabs",[aP]=qi($f,[dk]),mk=dk(),[iP,g0]=aP($f),gk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Ff(c),[m,g]=_o({prop:s,onChange:a,defaultProp:i??"",caller:$f});return r.jsx(iP,{scope:n,baseId:Pi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:r.jsx(pt.div,{dir:f,"data-orientation":o,...h,ref:e})})});gk.displayName=$f;var xk="TabsList",yk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...a}=t,i=g0(xk,n),o=mk(n);return r.jsx(sP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(pt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});yk.displayName=xk;var bk="TabsTrigger",vk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...i}=t,o=g0(bk,n),c=mk(n),u=jk(o.baseId,s),h=kk(o.baseId,s),f=s===o.value;return r.jsx(rP,{asChild:!0,...c,focusable:!a,active:f,children:r.jsx(pt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:dt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(s):m.preventDefault()}),onKeyDown:dt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(s)}),onFocus:dt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(s)})})})});vk.displayName=bk;var Nk="TabsContent",wk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:a,children:i,...o}=t,c=g0(Nk,n),u=jk(c.baseId,s),h=kk(c.baseId,s),f=s===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(Vd,{present:a||f,children:({present:g})=>r.jsx(pt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&i})})});wk.displayName=Nk;function jk(t,e){return`${t}-trigger-${e}`}function kk(t,e){return`${t}-content-${e}`}var oP=gk,Sk=yk,Ck=vk,Ek=wk;const Wd=oP,sc=b.forwardRef(({className:t,...e},n)=>r.jsx(Sk,{ref:n,className:It("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));sc.displayName=Sk.displayName;const Zt=b.forwardRef(({className:t,...e},n)=>r.jsx(Ck,{ref:n,className:It("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all 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",t),...e}));Zt.displayName=Ck.displayName;const en=b.forwardRef(({className:t,...e},n)=>r.jsx(Ek,{ref:n,className:It("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));en.displayName=Ek.displayName;function x0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function y0(t){const[e,n]=b.useState(void 0);return xs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var Bf="Switch",[lP]=qi(Bf),[cP,dP]=lP(Bf),Tk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),N=At(e,E=>y(E)),j=b.useRef(!1),v=g?f||!!g.closest("form"):!0,[k,C]=_o({prop:a,defaultProp:i??!1,onChange:h,caller:Bf});return r.jsxs(cP,{scope:n,checked:k,disabled:c,children:[r.jsx(pt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":Rk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:dt(t.onClick,E=>{C(M=>!M),v&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),v&&r.jsx(Ik,{control:g,bubbles:!j.current,name:s,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Tk.displayName=Bf;var Mk="SwitchThumb",Ak=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,a=dP(Mk,n);return r.jsx(pt.span,{"data-state":Rk(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:e})});Ak.displayName=Mk;var uP="SwitchBubbleInput",Ik=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...a},i)=>{const o=b.useRef(null),c=At(o,i),u=x0(n),h=y0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:s});y.call(f,n),f.dispatchEvent(N)}},[u,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ik.displayName=uP;function Rk(t){return t?"checked":"unchecked"}var Pk=Tk,hP=Ak;const kt=b.forwardRef(({className:t,...e},n)=>r.jsx(Pk,{className:It("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-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:r.jsx(hP,{className:It("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));kt.displayName=Pk.displayName;function b0({open:t,onClose:e,userId:n,onUserUpdated:s}){var Nt;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(null),[g,y]=b.useState(!1),[N,j]=b.useState(!1),[v,k]=b.useState(!1),[C,E]=b.useState("info"),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState([]),[se,ie]=b.useState(""),[z,ce]=b.useState(""),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[U,D]=b.useState([]),[W,le]=b.useState(!1),[ye,Ae]=b.useState(""),[ne,K]=b.useState(""),[J,ge]=b.useState(!1),[ae,pe]=b.useState(!1),[Se,tt]=b.useState(null),[it,zt]=b.useState(null),[St,Rt]=b.useState(""),[Ht,In]=b.useState(""),[Ft,xn]=b.useState(""),[ln,Bs]=b.useState(!1),[jn,Wn]=b.useState(null),[rs,as]=b.useState("");b.useEffect(()=>{t&&n&&(E("info"),tt(null),zt(null),Wn(null),as(""),ce(""),_(""),Ct(),De("/api/db/vip-roles").then(he=>{he!=null&&he.success&&he.data&&D(he.data)}).catch(()=>{}))},[t,n]);async function Ct(){if(n){y(!0);try{const he=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(he!=null&&he.success&&he.user){const xe=he.user;i(xe),P(xe.phone||""),L(xe.nickname||""),Rt(xe.phone||""),In(xe.wechatId||""),xn(xe.openId||"");try{O(typeof xe.tags=="string"?JSON.parse(xe.tags||"[]"):[])}catch{O([])}Y({isVip:!!(xe.isVip??!1),vipExpireDate:xe.vipExpireDate?String(xe.vipExpireDate).slice(0,10):"",vipRole:String(xe.vipRole??""),vipName:String(xe.vipName??""),vipProject:String(xe.vipProject??""),vipContact:String(xe.vipContact??""),vipBio:String(xe.vipBio??"")})}try{const xe=await De(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=50`);xe!=null&&xe.success&&xe.tracks&&c(xe.tracks)}catch{c([])}try{const xe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);xe!=null&&xe.success&&xe.referrals&&h(xe.referrals)}catch{h([])}try{const xe=await De(`/api/admin/users/${encodeURIComponent(n)}/balance`);xe!=null&&xe.success&&xe.data?m(xe.data):m(null)}catch{m(null)}}catch(he){console.error("Load user detail error:",he)}finally{y(!1)}}}async function is(){if(!(a!=null&&a.phone)){te.info("用户未绑定手机号,无法同步");return}j(!0);try{const he=await yt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});he!=null&&he.success?(te.success("同步成功"),Ct()):te.error("同步失败: "+(he==null?void 0:he.error))}catch(he){console.error("Sync CKB error:",he),te.error("同步失败")}finally{j(!1)}}async function _n(){if(a){if(A.isVip&&!A.vipExpireDate.trim()){te.error("开启 VIP 请填写有效到期日");return}k(!0);try{const he={id:a.id,phone:M||void 0,nickname:H||void 0,tags:JSON.stringify(R),isVip:A.isVip,vipExpireDate:A.isVip?A.vipExpireDate:void 0,vipRole:A.vipRole||void 0,vipName:A.vipName||void 0,vipProject:A.vipProject||void 0,vipContact:A.vipContact||void 0,vipBio:A.vipBio||void 0},xe=await _t("/api/db/users",he);xe!=null&&xe.success?(te.success("保存成功"),Ct(),s==null||s()):te.error("保存失败: "+(xe==null?void 0:xe.error))}catch(he){console.error("Save user error:",he),te.error("保存失败")}finally{k(!1)}}}const ls=()=>{se&&!R.includes(se)&&(O([...R,se]),ie(""))},Un=he=>O(R.filter(xe=>xe!==he));async function q(){if(a){if(!z){te.error("请输入新密码");return}if(z!==me){te.error("两次密码不一致");return}if(z.length<6){te.error("密码至少 6 位");return}$(!0);try{const he=await _t("/api/db/users",{id:a.id,password:z});he!=null&&he.success?(te.success("修改成功"),ce(""),_("")):te.error("修改失败: "+((he==null?void 0:he.error)||""))}catch{te.error("修改失败")}finally{$(!1)}}}async function Le(){if(!a)return;const he=parseFloat(ye);if(Number.isNaN(he)||he===0){te.error("请输入有效金额(正数增加、负数扣减)");return}ge(!0);try{const xe=await yt(`/api/admin/users/${a.id}/balance/adjust`,{amount:he,remark:ne||void 0});xe!=null&&xe.success?(te.success("余额已调整"),le(!1),Ae(""),K(""),Ct(),s==null||s()):te.error("调整失败: "+((xe==null?void 0:xe.error)||""))}catch{te.error("调整失败")}finally{ge(!1)}}async function mt(){if(!St&&!Ft&&!Ht){zt("请至少输入手机号、微信号或 OpenID 中的一项");return}pe(!0),zt(null),tt(null);try{const he=new URLSearchParams;St&&he.set("phone",St),Ft&&he.set("openId",Ft),Ht&&he.set("wechatId",Ht);const xe=await De(`/api/admin/shensheshou/query?${he}`);xe!=null&&xe.success&&xe.data?(tt(xe.data),a&&await Pt(xe.data)):zt((xe==null?void 0:xe.error)||"未查询到数据,该用户可能未在神射手收录")}catch(he){console.error("SSS query error:",he),zt("请求失败,请检查神射手接口配置")}finally{pe(!1)}}async function Pt(he){if(a)try{await yt("/api/admin/shensheshou/enrich",{userId:a.id,phone:St||a.phone||"",openId:Ft||a.openId||"",wechatId:Ht||a.wechatId||""}),Ct()}catch(xe){console.error("SSS enrich error:",xe)}}async function ut(){if(a){Bs(!0),Wn(null);try{const he={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:R}]},xe=await yt("/api/admin/shensheshou/ingest",he);xe!=null&&xe.success&&xe.data?Wn(xe.data):Wn({error:(xe==null?void 0:xe.error)||"推送失败"})}catch(he){console.error("SSS ingest error:",he),Wn({error:"请求失败"})}finally{Bs(!1)}}}const nt=he=>{const jt={view_chapter:Ys,purchase:Qg,match:Ln,login:Ao,register:Ao,share:Rr,bind_phone:g5,bind_wechat:a5,fill_profile:ld,visit_page:Ll}[he]||Kg;return r.jsx(jt,{className:"w-4 h-4"})};return t?r.jsxs(r.Fragment,{children:[r.jsx(Ot,{open:t,onOpenChange:()=>e(),children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?r.jsxs("div",{className:"flex flex-col h-[75vh]",children:[r.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:a.avatar?r.jsx("img",{src:a.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Nt=a.nickname)==null?void 0:Nt.charAt(0))||"?"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("h3",{className:"text-lg font-bold text-white",children:a.nickname}),a.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),a.hasFullBook&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),a.vipRole&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:a.vipRole})]}),r.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[a.phone?`📱 ${a.phone}`:"未绑定手机",a.wechatId&&` · 💬 ${a.wechatId}`,a.mbti&&` · ${a.mbti}`]}),r.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[r.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",a.id.slice(0,16),"…"]}),a.referralCode&&r.jsxs("p",{className:"text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"推广码:"}),r.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:a.referralCode})]})]})]}),r.jsxs("div",{className:"text-right shrink-0",children:[r.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(a.earnings||0).toFixed(2)]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),r.jsxs(Wd,{value:C,onValueChange:E,className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[r.jsx(Zt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),r.jsx(Zt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Ll,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),r.jsx(Zt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),r.jsxs(Zt,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Fa,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),r.jsxs(en,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:M,onChange:he=>P(he.target.value),disabled:!!(a!=null&&a.phone)}),(a==null?void 0:a.phone)&&r.jsx("p",{className:"text-xs text-gray-500",children:"编辑时手机号不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:H,onChange:he=>L(he.target.value)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.openId&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),r.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:a.openId})]}),a.region&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(fj,{className:"w-4 h-4 text-gray-500"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),r.jsx("p",{className:"text-white",children:a.region})]})]}),a.industry&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),r.jsx("p",{className:"text-white",children:a.industry})]}),a.position&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),r.jsx("p",{className:"text-white",children:a.position})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:a.referralCount??0})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),r.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(a.pendingEarnings??0).toFixed(2)]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg flex flex-col justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"当前余额"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac]",children:["¥",((f==null?void 0:f.balance)??0).toFixed(2)]})]}),r.jsx(X,{size:"sm",variant:"outline",className:"mt-2 border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 text-xs",onClick:()=>{Ae(""),K(""),le(!0)},children:"调整余额"})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),r.jsx("p",{className:"text-sm text-white",children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"-"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(hj,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:z,onChange:he=>ce(he.target.value)}),r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:me,onChange:he=>_(he.target.value)}),r.jsx(X,{size:"sm",onClick:q,disabled:G||!z||!me,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:G?"保存中...":"确认修改"})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),r.jsx(kt,{checked:A.isVip,onCheckedChange:he=>Y(xe=>({...xe,isVip:he}))})]}),A.isVip&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),r.jsx(re,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:A.vipExpireDate,onChange:he=>Y(xe=>({...xe,vipExpireDate:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),r.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:A.vipRole,onChange:he=>Y(xe=>({...xe,vipRole:he.target.value})),children:[r.jsx("option",{value:"",children:"请选择"}),U.map(he=>r.jsx("option",{value:he.name,children:he.name},he.id))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:A.vipName,onChange:he=>Y(xe=>({...xe,vipName:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"项目"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"如:某某科技",value:A.vipProject,onChange:he=>Y(xe=>({...xe,vipProject:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"联系方式"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"微信/手机等",value:A.vipContact,onChange:he=>Y(xe=>({...xe,vipContact:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"简介"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"简短介绍",value:A.vipBio,onChange:he=>Y(xe=>({...xe,vipBio:he.target.value}))})]})]})]})]}),a.isVip&&r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:a.vipRole||"VIP"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.vipName&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"展示名:"}),r.jsx("span",{className:"text-white",children:a.vipName})]}),a.vipProject&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"项目:"}),r.jsx("span",{className:"text-white",children:a.vipProject})]}),a.vipContact&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"联系方式:"}),r.jsx("span",{className:"text-white",children:a.vipContact})]}),a.vipExpireDate&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"到期时间:"}),r.jsx("span",{className:"text-white",children:new Date(a.vipExpireDate).toLocaleDateString()})]})]}),a.vipBio&&r.jsx("p",{className:"text-gray-400 text-sm mt-2",children:a.vipBio})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(zi,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"微信归属"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:rs,onChange:he=>as(he.target.value)}),r.jsxs(X,{size:"sm",onClick:async()=>{if(!(!rs||!a))try{await _t("/api/db/users",{id:a.id,wechatId:rs}),te.success("已保存微信归属"),Ct()}catch{te.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[r.jsx(Nn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),a.wechatId&&r.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",r.jsx("span",{className:"text-purple-400",children:a.wechatId})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Rr,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),r.jsx(X,{size:"sm",onClick:is,disabled:N||!a.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:N?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"同步状态:"}),a.ckbSyncedAt?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"最后同步:"}),r.jsx("span",{className:"text-gray-300 ml-1",children:a.ckbSyncedAt?new Date(a.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),r.jsxs(en,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(ld,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户标签"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),r.jsxs("div",{className:"mb-3 p-2.5 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-center gap-2 text-xs text-gray-400",children:[r.jsx(Ug,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),r.jsx("div",{className:"mb-4 space-y-3",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(he=>r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:he.category}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:he.tags.map(xe=>r.jsxs("button",{type:"button",onClick:()=>{R.includes(xe)?Un(xe):O([...R,xe])},className:`px-2 py-0.5 rounded text-xs border transition-all ${R.includes(xe)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[R.includes(xe)?"✓ ":"",xe]},xe))})]},he.category))}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[R.map((he,xe)=>r.jsxs(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[he,r.jsx("button",{type:"button",onClick:()=>Un(he),className:"ml-1 hover:text-red-400",children:r.jsx(gs,{className:"w-3 h-3"})})]},xe)),R.length===0&&r.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:se,onChange:he=>ie(he.target.value),onKeyDown:he=>he.key==="Enter"&&ls()}),r.jsx(X,{onClick:ls,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),(()=>{const he=a.tags||a.ckbTags||"";let xe=[];try{const rn=typeof he=="string"?JSON.parse(he||"[]"):[];xe=Array.isArray(rn)?rn:typeof he=="string"?he.split(","):[]}catch{xe=typeof he=="string"?he.split(","):[]}const jt=xe.map(rn=>String(rn).trim()).filter(Boolean);return jt.length===0?null:r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(ld,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:jt.map((rn,da)=>r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:rn},da))})]})})()]}),r.jsxs(en,{value:"journey",className:"flex-1 overflow-auto",children:[r.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(Ll,{className:"w-4 h-4 text-[#38bdac]"}),r.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),r.jsx("div",{className:"space-y-2",children:o.length>0?o.map((he,xe)=>r.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:nt(he.action)}),xe0?u.map((he,xe)=>{var rn;const jt=he;return r.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((rn=jt.nickname)==null?void 0:rn.charAt(0))||"?"}),r.jsx("span",{className:"text-white text-sm",children:jt.nickname})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[jt.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),r.jsx("span",{className:"text-gray-500 text-xs",children:jt.createdAt?new Date(jt.createdAt).toLocaleDateString():""})]})]},jt.id||xe)}):r.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),r.jsxs(en,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fa,{className:"w-5 h-5 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:St,onChange:he=>Rt(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Ht,onChange:he=>In(he.target.value)})]}),r.jsxs("div",{className:"col-span-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:Ft,onChange:he=>xn(he.target.value)})]})]}),r.jsx(X,{onClick:mt,disabled:ae,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:ae?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Ba,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),r.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),it&&r.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:it}),Se&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),r.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:Se.rfm_score??"-"})]}),r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:Se.user_level??"-"})]})]}),Se.tags&&Se.tags.length>0&&r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Se.tags.map((he,xe)=>r.jsx(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:he},xe))})]}),Se.last_active&&r.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",Se.last_active]})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Fa,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),r.jsx(X,{onClick:ut,disabled:ln||!a.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:ln?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):r.jsxs(r.Fragment,{children:[r.jsx(Fa,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!a.phone&&r.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),jn&&r.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:jn.error?r.jsx("p",{className:"text-red-400",children:String(jn.error)}):r.jsxs("div",{className:"space-y-1",children:[r.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[r.jsx(Ug,{className:"w-4 h-4"})," 推送成功"]}),jn.enriched!==void 0&&r.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(jn.new_tags_added??0)]})]})})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[r.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"关闭"]}),r.jsxs(X,{onClick:_n,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):r.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),r.jsx(Ot,{open:W,onOpenChange:le,children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsx(Dt,{children:r.jsx(Lt,{children:"调整余额"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ye,onChange:he=>Ae(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"备注(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:ne,onChange:he=>K(he.target.value)})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:Le,disabled:J,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:J?"提交中...":"确认调整"})]})]})})]}):null}function fP(){const t=Ki(),[e,n]=b.useState(!0),[s,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,N]=b.useState(0),[j,v]=b.useState(0),[k,C]=b.useState(0),[E,M]=b.useState(null),[P,H]=b.useState(null),[L,R]=b.useState(!1),[O,se]=b.useState(0),[ie,z]=b.useState(!1),[ce,me]=b.useState(null),[_,G]=b.useState("week"),[$,A]=b.useState(null),[Y,U]=b.useState(!1),D=K=>{const J=K;if((J==null?void 0:J.status)===401)M("登录已过期,请重新登录");else{if((J==null?void 0:J.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function W(K){const J=K?{signal:K}:void 0;n(!0),M(null);try{const pe=await De("/api/admin/dashboard/stats",J);pe!=null&&pe.success&&(g(pe.totalUsers??0),N(pe.paidOrderCount??0),v(pe.totalRevenue??0),C(pe.conversionRate??0))}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",pe);try{const Se=await De("/api/admin/dashboard/overview",J);Se!=null&&Se.success&&(g(Se.totalUsers??0),N(Se.paidOrderCount??0),v(Se.totalRevenue??0),C(Se.conversionRate??0))}catch(Se){D(Se)}}}finally{n(!1)}try{const pe=await De("/api/admin/balance/summary",J);pe!=null&&pe.success&&pe.data&&se(pe.data.totalGifted??0)}catch{}try{const pe=await De("/api/db/ckb-plan-stats",J);pe!=null&&pe.success&&pe.data?me({ckbTotal:pe.data.ckbTotal??0,withContact:pe.data.withContact??0}):me(null)}catch{me(null)}a(!0),o(!0);const ge=async()=>{try{const pe=await De("/api/admin/dashboard/recent-orders?limit=10",J);if(pe!=null&&pe.success&&pe.recentOrders)f(pe.recentOrders);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/admin/orders?page=1&pageSize=20&status=paid",J),it=((Se==null?void 0:Se.orders)??[]).filter(zt=>["paid","completed","success"].includes(zt.status||""));f(it.slice(0,5))}catch{f([])}}finally{a(!1)}},ae=async()=>{try{const pe=await De("/api/admin/dashboard/new-users",J);if(pe!=null&&pe.success&&pe.newUsers)u(pe.newUsers);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/db/users?page=1&pageSize=10",J);u((Se==null?void 0:Se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([ge(),ae()])}async function le(K){const J=K||_;U(!0);try{const ge=await De(`/api/admin/track/stats?period=${J}`);ge!=null&&ge.success&&A({total:ge.total??0,byModule:ge.byModule??{}})}catch{A(null)}finally{U(!1)}}b.useEffect(()=>{const K=new AbortController;W(K.signal),le();const J=setInterval(()=>{W(),le()},3e4);return()=>{K.abort(),clearInterval(J)}},[]);const ye=m,Ae=K=>{const J=K.productType||"",ge=K.description||"";if(J==="balance_recharge")return{title:`余额充值 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(J==="gift_pay")return{title:`代付 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(J==="gift_pay_batch"){const ae=typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2);return{title:ge||`代付分享 ¥${ae}`,subtitle:"代付分享"}}if(J==="section"&&ge.includes("代付领取"))return{title:ge.replace("代付领取 - ",""),subtitle:"代付领取"};if(ge){if(J==="section"&&ge.includes("章节")){if(ge.includes("-")){const ae=ge.split("-");if(ae.length>=3)return{title:`第${ae[1]}章 第${ae[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:ge,subtitle:"章节购买"}}return J==="fullbook"||ge.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"||ge.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"||ge.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:ge,subtitle:J==="section"?"单章":J==="fullbook"?"全书":"其他"}}return J==="section"?{title:`章节 ${K.productId||""}`,subtitle:"单章购买"}:J==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:J||"其他"}},ne=[{title:"总用户数",value:e?null:ye,sub:null,icon:Ln,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:cd,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Qg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:Ys,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ce?ce.ckbTotal??0:null,sub:(ce==null?void 0:ce.withContact)!=null?`含联系方式 ${ce.withContact} 人`:null,icon:dd,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"}];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&r.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[r.jsx("span",{children:E}),r.jsx("button",{type:"button",onClick:()=>W(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:ne.map((K,J)=>r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>K.link&&t(K.link),children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsx(Ye,{className:"text-sm font-medium text-gray-400",children:K.title}),r.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:r.jsx(K.icon,{className:`w-4 h-4 ${K.color}`})})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:K.value!=null?K.value:r.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[r.jsx($e,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),K.sub&&r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:K.sub})]}),r.jsx(Dl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},J))}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ye,{className:"text-white",children:"最近订单"}),r.jsxs("button",{type:"button",onClick:()=>W(),disabled:s||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[s||i?r.jsx($e,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx($e,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:s&&h.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[h.slice(0,ie?10:4).map(K=>{var Se;const J=K.referrerId?c.find(tt=>tt.id===K.referrerId):void 0,ge=K.referralCode||(J==null?void 0:J.referralCode)||(J==null?void 0:J.nickname)||(K.referrerId?String(K.referrerId).slice(0,8):""),ae=Ae(K),pe=K.userNickname||((Se=c.find(tt=>tt.id===K.userId))==null?void 0:Se.nickname)||"匿名用户";return r.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[K.userAvatar?r.jsx("img",{src:K.userAvatar,alt:pe,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:tt=>{tt.currentTarget.style.display="none";const it=tt.currentTarget.nextElementSibling;it&&it.classList.remove("hidden")}}):null,r.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${K.userAvatar?"hidden":""}`,children:pe.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("button",{type:"button",onClick:()=>{K.userId&&(H(K.userId),R(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:pe}),r.jsx("span",{className:"text-gray-600",children:"·"}),r.jsx("span",{className:"text-sm font-medium text-white truncate",children:ae.title})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[ae.subtitle&&ae.subtitle!=="章节购买"&&r.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:ae.subtitle}),r.jsx("span",{children:new Date(K.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),ge&&r.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",ge]})]})]}),r.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[r.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(K.amount).toFixed(2)]}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:K.paymentMethod||"微信"})]})]},K.id)}),h.length>4&&!ie&&r.jsx("button",{type:"button",onClick:()=>z(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!s&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Qg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"新注册用户"})}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:i&&c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[c.slice(0,5).map(K=>{var J;return r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((J=K.nickname)==null?void 0:J.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>{H(K.id),R(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:K.nickname||"匿名用户"}),r.jsx("p",{className:"text-xs text-gray-500",children:K.phone||"-"})]})]}),r.jsx("p",{className:"text-xs text-gray-400",children:K.createdAt?new Date(K.createdAt).toLocaleDateString():"-"})]},K.id)}),c.length===0&&!i&&r.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),r.jsxs(Ee,{className:"mt-8 bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wg,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),r.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(K=>r.jsx("button",{type:"button",onClick:()=>{G(K),le(K)},className:`px-3 py-1 text-xs rounded-full transition-colors ${_===K?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[K]},K))})]}),r.jsx(Te,{children:Y&&!$?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):$&&Object.keys($.byModule).length>0?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",r.jsx("span",{className:"text-white font-bold text-lg",children:$.total})," 次"]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries($.byModule).sort((K,J)=>J[1].reduce((ge,ae)=>ge+ae.count,0)-K[1].reduce((ge,ae)=>ge+ae.count,0)).map(([K,J])=>{const ge=J.reduce((pe,Se)=>pe+Se.count,0),ae={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:ae[K]||K}),r.jsxs("span",{className:"text-xs text-gray-500",children:[ge," 次"]})]}),r.jsx("div",{className:"space-y-2",children:J.sort((pe,Se)=>Se.count-pe.count).slice(0,8).map((pe,Se)=>{const tt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",rule_trigger:"规则触发",view_chapter:"浏览章节",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元"},it={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节"},zt=tt[pe.target]||pe.target||it[pe.action]||pe.action;return r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${pe.action}: ${pe.target}`,children:zt}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${ge>0?pe.count/ge*100:0}%`}})}),r.jsx("span",{className:"text-gray-400 w-8 text-right",children:pe.count})]})]},Se)})})]},K)})})]}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),r.jsx(b0,{open:L,onClose:()=>{R(!1),H(null)},userId:P,onUserUpdated:()=>W()})]})}const ts=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:It("w-full caption-bottom text-sm",t),...e})}));ts.displayName="Table";const ns=b.forwardRef(({className:t,...e},n)=>r.jsx("thead",{ref:n,className:It("[&_tr]:border-b",t),...e}));ns.displayName="TableHeader";const ss=b.forwardRef(({className:t,...e},n)=>r.jsx("tbody",{ref:n,className:It("[&_tr:last-child]:border-0",t),...e}));ss.displayName="TableBody";const ot=b.forwardRef(({className:t,...e},n)=>r.jsx("tr",{ref:n,className:It("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ot.displayName="TableRow";const we=b.forwardRef(({className:t,...e},n)=>r.jsx("th",{ref:n,className:It("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));we.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>r.jsx("td",{ref:n,className:It("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function v0(t,e){const[n,s]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>s(t),e);return()=>clearTimeout(a)},[t,e]),n}function Fs({page:t,totalPages:e,total:n,pageSize:s,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:r.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[r.jsxs("span",{children:["共 ",n," 条"]}),i&&r.jsx("select",{value:s,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>r.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),r.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),r.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),r.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),r.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function pP(){const[t,e]=b.useState([]),[n,s]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(""),v=v0(N,300),[k,C]=b.useState("all"),[E,M]=b.useState(!0),[P,H]=b.useState(null),[L,R]=b.useState(null),[O,se]=b.useState(""),[ie,z]=b.useState(!1);async function ce(){M(!0),H(null);try{const U=k==="all"?"":k==="completed"?"completed":k,D=new URLSearchParams({page:String(f),pageSize:String(g),...U&&{status:U},...v&&{search:v}}),[W,le]=await Promise.all([De(`/api/admin/orders?${D}`),De("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),le!=null&&le.success&&le.users&&s(le.users)}catch(U){console.error("加载订单失败",U),H("加载订单失败,请检查网络后重试")}finally{M(!1)}}b.useEffect(()=>{m(1)},[v,k]),b.useEffect(()=>{ce()},[f,g,v,k]);const me=U=>{var D;return U.userNickname||((D=n.find(W=>W.id===U.userId))==null?void 0:D.nickname)||"匿名用户"},_=U=>{var D;return((D=n.find(W=>W.id===U))==null?void 0:D.phone)||"-"},G=U=>{const D=U.productType||U.type||"",W=U.description||"";if(D==="balance_recharge")return{name:`余额充值 ¥${Number(U.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(D==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const le=W.split("-");if(le.length>=3)return{name:`第${le[1]}章 第${le[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return D==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:D==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:D==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return D==="section"?{name:`章节 ${U.productId||U.sectionId||""}`,type:"单章"}:D==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:D==="vip"?{name:"超级个体开通费用",type:"超级个体"}:D==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:D||"其他"}},$=Math.ceil(a/g)||1;async function A(){var U;if(!(!(L!=null&&L.orderSn)&&!(L!=null&&L.id))){z(!0),H(null);try{const D=await _t("/api/admin/orders/refund",{orderSn:L.orderSn||L.id,reason:O||void 0});D!=null&&D.success?(R(null),se(""),ce()):H((D==null?void 0:D.error)||"退款失败")}catch(D){const W=D;H(((U=W==null?void 0:W.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{z(!1)}}}function Y(){if(t.length===0){te.info("暂无数据可导出");return}const U=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],D=t.map(ne=>{const K=G(ne);return[ne.orderSn||ne.id||"",me(ne),_(ne.userId),K.name,Number(ne.amount||0).toFixed(2),ne.paymentMethod==="wechat"?"微信支付":ne.paymentMethod==="balance"?"余额支付":ne.paymentMethod==="alipay"?"支付宝":ne.paymentMethod||"微信支付",ne.status==="refunded"?"已退款":ne.status==="paid"||ne.status==="completed"?"已完成":ne.status==="pending"||ne.status==="created"?"待支付":"已失败",ne.status==="refunded"&&ne.refundReason?ne.refundReason:"-",ne.referrerEarnings?Number(ne.referrerEarnings).toFixed(2):"-",ne.createdAt?new Date(ne.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[U.join(","),...D].join(`
+`),le=new Blob([W],{type:"text/csv;charset=utf-8"}),ye=URL.createObjectURL(le),Ae=document.createElement("a");Ae.href=ye,Ae.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,Ae.click(),URL.revokeObjectURL(ye)}return r.jsxs("div",{className:"p-8 w-full",children:[P&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:P}),r.jsx("button",{type:"button",onClick:()=>H(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"outline",onClick:ce,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-400",children:"总收入:"}),r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),r.jsx("span",{className:"text-gray-600",children:"|"}),r.jsx("span",{className:"text-gray-400",children:"今日:"}),r.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1 max-w-md",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:U=>j(U.target.value)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(cj,{className:"w-4 h-4 text-gray-400"}),r.jsxs("select",{value:k,onChange:U=>C(U.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"created",children:"已创建"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]})]}),r.jsxs(X,{variant:"outline",onClick:Y,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(mM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:E?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ts,{children:[r.jsx(ns,{children:r.jsxs(ot,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"订单号"}),r.jsx(we,{className:"text-gray-400",children:"用户"}),r.jsx(we,{className:"text-gray-400",children:"商品"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"支付方式"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"退款原因"}),r.jsx(we,{className:"text-gray-400",children:"分销佣金"}),r.jsx(we,{className:"text-gray-400",children:"下单时间"}),r.jsx(we,{className:"text-gray-400",children:"操作"})]})}),r.jsxs(ss,{children:[t.map(U=>{const D=G(U);return r.jsxs(ot,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(U.orderSn||U.id||"").slice(0,12),"..."]}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[me(U),U.paymentMethod==="gift_pay"&&r.jsx(Ke,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),U.payerUserId&&U.paymentMethod!=="gift_pay"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:_(U.userId)}),U.payerUserId&&U.payerNickname&&r.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[U.paymentMethod==="gift_pay"?"赠送人:":"代付人:",U.payerNickname]})]})}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[D.name,(U.productType||U.type)==="vip"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:D.type})]})}),r.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(U.amount||0).toFixed(2)]}),r.jsx(ve,{className:"text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),r.jsx(ve,{children:U.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):U.status==="paid"||U.status==="completed"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),r.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),r.jsx(ve,{className:"text-[#FFD700]",children:U.referrerEarnings?`¥${Number(U.referrerEarnings).toFixed(2)}`:"-"}),r.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(U.createdAt).toLocaleString("zh-CN")}),r.jsx(ve,{children:(U.status==="paid"||U.status==="completed")&&U.paymentMethod!=="balance"&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{R(U),se("")},children:[r.jsx(Zg,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)}),t.length===0&&r.jsx(ot,{children:r.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),r.jsx(Fs,{page:f,totalPages:$,total:a,pageSize:g,onPageChange:m,onPageSizeChange:U=>{y(U),m(1)}})]})})}),r.jsx(Ot,{open:!!L,onOpenChange:U=>!U&&R(null),children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Dt,{children:r.jsx(Lt,{className:"text-white",children:"订单退款"})}),L&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",L.orderSn||L.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(L.amount||0).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:U=>se(U.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(nn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>R(null),disabled:ie,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:A,disabled:ie,children:ie?"退款中...":"确认退款"})]})]})})]})}const rc=b.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:It("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm 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",t),ref:n,...e}));rc.displayName="Textarea";const th=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function mP(){var Hr,yn,so,ba,Wr;const[t,e]=nj(),n=t.get("pool"),s=t.get("tab")||"users",[a,i]=b.useState([]),[o,c]=b.useState(0),[u,h]=b.useState(1),[f,m]=b.useState(10),[g,y]=b.useState(""),N=v0(g,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[v,k]=b.useState(j),[C,E]=b.useState(!0),[M,P]=b.useState(!1),[H,L]=b.useState(null),[R,O]=b.useState(!1),[se,ie]=b.useState("desc");b.useEffect(()=>{n==="vip"?k("vip"):n==="complete"?k("complete"):n==="all"&&k("all")},[n]);const[z,ce]=b.useState(!1),[me,_]=b.useState(null),[G,$]=b.useState(!1),[A,Y]=b.useState(!1),[U,D]=b.useState({referrals:[],stats:{}}),[W,le]=b.useState(!1),[ye,Ae]=b.useState(null),[ne,K]=b.useState(!1),[J,ge]=b.useState(null),[ae,pe]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Se,tt]=b.useState([]),[it,zt]=b.useState(!1),[St,Rt]=b.useState(!1),[Ht,In]=b.useState(null),[Ft,xn]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[ln,Bs]=b.useState([]),[jn,Wn]=b.useState(!1),[rs,as]=b.useState(null),[Ct,is]=b.useState(null),[_n,ls]=b.useState({}),[Un,q]=b.useState(!1),[Le,mt]=b.useState([]),[Pt,ut]=b.useState(0),[nt,Nt]=b.useState(1),[he]=b.useState(20),[xe,jt]=b.useState(!1),rn=b.useCallback(async()=>{jt(!0);try{const F=await De(`/api/db/ckb-leads?mode=contact&page=${nt}&pageSize=${he}`);F!=null&&F.success&&(mt(F.records||[]),ut(F.total??0))}catch{mt([]),ut(0)}finally{jt(!1)}},[nt,he]);b.useEffect(()=>{t.get("tab")==="leads"&&rn()},[t.get("tab"),nt,rn]);const[da,ua]=b.useState(null),_r=b.useCallback(async()=>{try{const F=await De("/api/admin/users/online-stats");F!=null&&F.success&&typeof F.onlineCount=="number"?ua(F.onlineCount):ua(0)}catch{ua(null)}},[]);b.useEffect(()=>{_r();const F=setInterval(_r,1e4);return()=>clearInterval(F)},[_r]);async function Zs(F=!1){var Pe;E(!0),F&&P(!0),L(null);try{if(R){const ze=new URLSearchParams({search:N,limit:String(f*5)}),lt=await De(`/api/db/users/rfm?${ze}`);if(lt!=null&<.success){let cn=lt.users||[];se==="asc"&&(cn=[...cn].reverse());const ct=(u-1)*f;i(cn.slice(ct,ct+f)),c(((Pe=lt.users)==null?void 0:Pe.length)??0),cn.length===0&&(O(!1),L("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else O(!1),L((lt==null?void 0:lt.error)||"RFM 加载失败,已切回普通模式")}else{const ze=new URLSearchParams({page:String(u),pageSize:String(f),search:N,...v==="vip"&&{vip:"true"},...v==="complete"&&{pool:"complete"}}),lt=await De(`/api/db/users?${ze}`);lt!=null&<.success?(i(lt.users||[]),c(lt.total??0)):L((lt==null?void 0:lt.error)||"加载失败")}}catch(ze){console.error("Load users error:",ze),L("网络错误")}finally{E(!1),F&&P(!1)}}b.useEffect(()=>{h(1)},[N,v,R]),b.useEffect(()=>{Zs()},[u,f,N,v,R,se]);const ha=Math.ceil(o/f)||1,Xo=()=>{R?se==="desc"?ie("asc"):(O(!1),ie("desc")):(O(!0),ie("desc"))},fa=F=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[F||""]||"bg-gray-500/20 text-gray-400";async function Zi(F){var Pe;if(confirm("确定要删除这个用户吗?"))try{const ze=await ea(`/api/db/users?id=${encodeURIComponent(F)}`);ze!=null&&ze.success?(te.success("已删除"),Zs()):te.error("删除失败: "+((ze==null?void 0:ze.error)||"未知错误"))}catch(ze){const lt=ze,cn=((Pe=lt==null?void 0:lt.data)==null?void 0:Pe.error)||(lt==null?void 0:lt.message)||"网络错误";te.error("删除失败: "+cn)}}const pa=F=>{_(F),pe({phone:F.phone||"",nickname:F.nickname||"",password:"",isAdmin:!!(F.isAdmin??!1),hasFullBook:!!(F.hasFullBook??!1)}),ce(!0)},dc=()=>{_(null),pe({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ce(!0)};async function mr(){if(!ae.phone||!ae.nickname){te.error("请填写手机号和昵称");return}$(!0);try{if(me){const F=await _t("/api/db/users",{id:me.id,phone:ae.phone||void 0,nickname:ae.nickname,isAdmin:ae.isAdmin,hasFullBook:ae.hasFullBook,...ae.password&&{password:ae.password}});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await yt("/api/db/users",{phone:ae.phone,nickname:ae.nickname,password:ae.password,isAdmin:ae.isAdmin});if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}ce(!1),Zs()}catch{te.error("保存失败")}finally{$(!1)}}async function ma(F){Ae(F),Y(!0),le(!0);try{const Pe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(F.id)}`);Pe!=null&&Pe.success?D({referrals:Pe.referrals||[],stats:Pe.stats||{}}):D({referrals:[],stats:{}})}catch{D({referrals:[],stats:{}})}finally{le(!1)}}const Vs=b.useCallback(async()=>{zt(!0);try{const F=await De("/api/db/user-rules");F!=null&&F.success&&tt(F.rules||[])}catch{}finally{zt(!1)}},[]);async function gr(){if(!Ft.title){te.error("请填写规则标题");return}$(!0);try{if(Ht){const F=await _t("/api/db/user-rules",{id:Ht.id,...Ft});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await yt("/api/db/user-rules",Ft);if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}Rt(!1),Vs()}catch{te.error("保存失败")}finally{$(!1)}}async function eo(F){if(confirm("确定删除?"))try{const Pe=await ea(`/api/db/user-rules?id=${F}`);Pe!=null&&Pe.success&&Vs()}catch{}}async function Zo(F){try{await _t("/api/db/user-rules",{id:F.id,enabled:!F.enabled}),Vs()}catch{}}const xt=b.useCallback(async()=>{Wn(!0);try{const F=await De("/api/db/vip-members?limit=500");if(F!=null&&F.success&&F.data){const Pe=[...F.data].map((ze,lt)=>({...ze,vipSort:typeof ze.vipSort=="number"?ze.vipSort:lt+1}));Pe.sort((ze,lt)=>(ze.vipSort??999999)-(lt.vipSort??999999)),Bs(Pe)}else F&&F.error&&te.error(F.error)}catch{te.error("加载超级个体列表失败")}finally{Wn(!1)}},[]),[kn,zr]=b.useState(!1),[xr,to]=b.useState(null),[yr,ga]=b.useState(""),[Fr,er]=b.useState(!1),Ja=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],uc=F=>{to(F),ga(F.vipRole||""),zr(!0)},Jt=async F=>{const Pe=F.trim();if(xr){if(!Pe){te.error("请选择或输入标签");return}er(!0);try{const ze=await _t("/api/db/users",{id:xr.id,vipRole:Pe});if(!(ze!=null&&ze.success)){te.error((ze==null?void 0:ze.error)||"更新超级个体标签失败");return}te.success("已更新超级个体标签"),zr(!1),to(null),await xt()}catch{te.error("更新超级个体标签失败")}finally{er(!1)}}},[hc,br]=b.useState(!1),[vr,$r]=b.useState(null),[Ya,no]=b.useState(""),[Br,Ns]=b.useState(!1),Qa=F=>{$r(F),no(F.vipSort!=null?String(F.vipSort):""),br(!0)},ws=async()=>{if(!vr)return;const F=Number(Ya);if(!Number.isFinite(F)){te.error("请输入有效的数字序号");return}Ns(!0);try{const Pe=await _t("/api/db/users",{id:vr.id,vipSort:F});if(!(Pe!=null&&Pe.success)){te.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}te.success("已更新排序序号"),br(!1),$r(null),await xt()}catch{te.error("更新排序序号失败")}finally{Ns(!1)}},Vr=(F,Pe)=>{F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",Pe),as(Pe)},fc=(F,Pe)=>{F.preventDefault(),Ct!==Pe&&is(Pe)},pc=()=>{as(null),is(null)},xa=async(F,Pe)=>{F.preventDefault();const ze=F.dataTransfer.getData("text/plain")||rs;if(as(null),is(null),!ze||ze===Pe)return;const lt=ln.find(dn=>dn.id===ze),cn=ln.find(dn=>dn.id===Pe);if(!lt||!cn)return;const ct=lt.vipSort??ln.findIndex(dn=>dn.id===ze)+1,Xa=cn.vipSort??ln.findIndex(dn=>dn.id===Pe)+1;Bs(dn=>{const Kn=[...dn],Ms=Kn.findIndex(cs=>cs.id===ze),As=Kn.findIndex(cs=>cs.id===Pe);if(Ms===-1||As===-1)return dn;const Nr=[...Kn],[va,tr]=[Nr[Ms],Nr[As]];return Nr[Ms]={...tr,vipSort:ct},Nr[As]={...va,vipSort:Xa},Nr});try{const[dn,Kn]=await Promise.all([_t("/api/db/users",{id:ze,vipSort:Xa}),_t("/api/db/users",{id:Pe,vipSort:ct})]);if(!(dn!=null&&dn.success)||!(Kn!=null&&Kn.success)){te.error((dn==null?void 0:dn.error)||(Kn==null?void 0:Kn.error)||"更新排序失败"),await xt();return}te.success("已更新排序"),await xt()}catch{te.error("更新排序失败"),await xt()}},ya=b.useCallback(async()=>{q(!0);try{const F=await De("/api/db/users/journey-stats");F!=null&&F.success&&F.stats&&ls(F.stats)}catch{}finally{q(!1)}},[]);return r.jsxs("div",{className:"p-8 w-full",children:[H&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:H}),r.jsx("button",{type:"button",onClick:()=>L(null),children:"×"})]}),r.jsx("div",{className:"flex justify-between items-center mb-6",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),r.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",o," 位注册用户",da!==null&&r.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",da," 人"]}),R&&" · RFM 排序中"]})]})}),r.jsxs(Wd,{value:s,onValueChange:F=>{const Pe=new URLSearchParams(t);F==="users"?Pe.delete("tab"):Pe.set("tab",F),e(Pe)},className:"w-full",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[r.jsxs(Zt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[r.jsx(Ln,{className:"w-4 h-4"})," 用户列表"]}),r.jsxs(Zt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>rn(),children:[r.jsx(dd,{className:"w-4 h-4"})," 获客列表"]}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ya,children:[r.jsx(Ll,{className:"w-4 h-4"})," 用户旅程总览"]}),r.jsxs(Zt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Vs,children:[r.jsx(Mo,{className:"w-4 h-4"})," 规则配置"]}),r.jsxs(Zt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:xt,children:[r.jsx(Fl,{className:"w-4 h-4"})," 超级个体列表"]})]}),r.jsxs(en,{value:"users",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[r.jsxs(X,{variant:"outline",onClick:()=>Zs(!0),disabled:M,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${M?"animate-spin":""}`})," 刷新"]}),r.jsxs("select",{value:v,onChange:F=>{const Pe=F.target.value;k(Pe),h(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:R,children:[r.jsx("option",{value:"all",children:"全部用户"}),r.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),r.jsx("option",{value:"complete",children:"完善资料用户"})]}),r.jsxs("div",{className:"relative",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:g,onChange:F=>y(F.target.value)})]}),r.jsxs(X,{onClick:dc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(dd,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:C?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ts,{children:[r.jsx(ns,{children:r.jsxs(ot,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"用户信息"}),r.jsx(we,{className:"text-gray-400",children:"绑定信息"}),r.jsx(we,{className:"text-gray-400",children:"购买状态"}),r.jsx(we,{className:"text-gray-400",children:"分销收益"}),r.jsxs(we,{className:"text-gray-400 cursor-pointer select-none",onClick:Xo,children:[r.jsxs("div",{className:"flex items-center gap-1 group",children:[r.jsx(cd,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"RFM分值"}),R?se==="desc"?r.jsx(kd,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(rj,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(Hm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),R&&r.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),r.jsx(we,{className:"text-gray-400",children:"注册时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ss,{children:[a.map(F=>{var Pe,ze,lt;return r.jsxs(ot,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:F.avatar?r.jsx("img",{src:F.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Pe=F.nickname)==null?void 0:Pe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{type:"button",onClick:()=>{ge(F.id),K(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:F.nickname}),F.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),F.openId&&!((ze=F.id)!=null&&ze.startsWith("user_"))&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:F.openId?F.openId.slice(0,12)+"...":(lt=F.id)==null?void 0:lt.slice(0,12)})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[F.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"📱"}),r.jsx("span",{className:"text-gray-300",children:F.phone})]}),F.wechatId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"💬"}),r.jsx("span",{className:"text-gray-300",children:F.wechatId})]}),F.openId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"🔗"}),r.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:F.openId,children:[F.openId.slice(0,12),"..."]})]}),!F.phone&&!F.wechatId&&!F.openId&&r.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),r.jsx(ve,{children:F.hasFullBook?r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(F.earnings||0)).toFixed(2)]}),parseFloat(String(F.pendingEarnings||0))>0&&r.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(F.pendingEarnings||0)).toFixed(2)]}),r.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>ma(F),role:"button",tabIndex:0,onKeyDown:cn=>cn.key==="Enter"&&ma(F),children:[r.jsx(Ln,{className:"w-3 h-3"})," 绑定",F.referralCount||0,"人"]})]})}),r.jsx(ve,{children:F.rfmScore!==void 0?r.jsx("div",{className:"flex flex-col gap-1",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-white font-bold text-base",children:F.rfmScore}),r.jsx(Ke,{className:`border-0 text-xs ${fa(F.rfmLevel)}`,children:F.rfmLevel})]})}):r.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",r.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleDateString():"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ge(F.id),K(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:r.jsx(qg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>pa(F),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:r.jsx(Kt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Zi(F.id),title:"删除",children:r.jsx(Qn,{className:"w-4 h-4"})})]})})]},F.id)}),a.length===0&&r.jsx(ot,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),r.jsx(Fs,{page:u,totalPages:ha,total:o,pageSize:f,onPageChange:h,onPageSizeChange:F=>{m(F),h(1)}})]})})})]}),r.jsxs(en,{value:"leads",children:[r.jsx("div",{className:"flex items-center justify-end mb-4",children:r.jsxs(X,{variant:"outline",onClick:rn,disabled:xe,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${xe?"animate-spin":""}`})," 刷新"]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:xe?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ts,{children:[r.jsx(ns,{children:r.jsxs(ot,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"手机号"}),r.jsx(we,{className:"text-gray-400",children:"微信号"}),r.jsx(we,{className:"text-gray-400",children:"对应 @人"}),r.jsx(we,{className:"text-gray-400",children:"获客计划"}),r.jsx(we,{className:"text-gray-400",children:"来源"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(ss,{children:[Le.map(F=>r.jsxs(ot,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:F.userNickname||F.name||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.phone||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.wechatId||"-"}),r.jsx(ve,{className:"text-[#38bdac]",children:F.personName||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.ckbPlanId?`#${F.ckbPlanId}`:"-"}),r.jsx(ve,{className:"text-gray-400",children:F.source||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleString():"-"})]},F.id)),Le.length===0&&r.jsx(ot,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无获客数据"})})]})]}),r.jsx(Fs,{page:nt,totalPages:Math.ceil(Pt/he)||1,total:Pt,pageSize:he,onPageChange:Nt,onPageSizeChange:()=>{}})]})})})]}),r.jsxs(en,{value:"journey",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),r.jsxs(X,{variant:"outline",onClick:ya,disabled:Un,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${Un?"animate-spin":""}`})," 刷新数据"]})]}),r.jsxs("div",{className:"relative mb-8",children:[r.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),r.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:th.map((F,Pe)=>r.jsxs("div",{className:"relative flex flex-col items-center",children:[r.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${F.color} text-center cursor-default`,children:[r.jsx("div",{className:"text-2xl mb-1",children:F.icon}),r.jsx("div",{className:`text-xs font-medium ${F.color.split(" ").find(ze=>ze.startsWith("text-"))}`,children:F.label}),_n[F.id]!==void 0&&r.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[r.jsx("span",{className:"font-bold text-white",children:_n[F.id]})," 人"]}),r.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Pe+1})]}),Per.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:F.step}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-300",children:F.action}),r.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",F.next]})]})]},F.step))})]}),r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ys,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),r.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),Un?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($e,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(_n).length>0?r.jsx("div",{className:"space-y-2",children:th.map(F=>{const Pe=_n[F.id]||0,ze=Math.max(...th.map(cn=>_n[cn.id]||0),1),lt=Math.round(Pe/ze*100);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[F.icon," ",F.label]}),r.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${lt}%`}})}),r.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},F.id)})}):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),r.jsxs(en,{value:"rules",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:Vs,disabled:it,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${it?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:()=>{In(null),xn({title:"",description:"",trigger:"",sort:0,enabled:!0}),Rt(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),it?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Se.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Ys,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),r.jsxs(X,{onClick:Vs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx($e,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):r.jsx("div",{className:"space-y-2",children:Se.map(F=>r.jsx("div",{className:`p-4 rounded-lg border transition-all ${F.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[r.jsx(Kt,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),r.jsx("span",{className:"text-white font-medium",children:F.title}),F.trigger&&r.jsxs(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",F.trigger]}),r.jsx(Ke,{className:`text-xs border-0 ${F.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:F.enabled?"启用":"禁用"})]}),F.description&&r.jsx("p",{className:"text-gray-400 text-sm ml-6",children:F.description})]}),r.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[r.jsx(kt,{checked:F.enabled,onCheckedChange:()=>Zo(F)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{In(F),xn({title:F.title,description:F.description,trigger:F.trigger,sort:F.sort,enabled:F.enabled}),Rt(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Kt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>eo(F.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Qn,{className:"w-4 h-4"})})]})]})},F.id))})]}),r.jsxs(en,{value:"vip-roles",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),r.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(X,{variant:"outline",onClick:xt,disabled:jn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${jn?"animate-spin":""}`})," ","刷新"]})})]}),jn?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ln.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Fl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:r.jsxs(ts,{children:[r.jsx(ns,{children:r.jsxs(ot,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-16",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序值"}),r.jsx(we,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),r.jsx(ss,{children:ln.map((F,Pe)=>{var cn;const ze=rs===F.id,lt=Ct===F.id;return r.jsxs(ot,{draggable:!0,onDragStart:ct=>Vr(ct,F.id),onDragOver:ct=>fc(ct,F.id),onDrop:ct=>xa(ct,F.id),onDragEnd:pc,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${ze?"opacity-60":""} ${lt?"bg-[#38bdac]/10":""}`,children:[r.jsx(ve,{className:"text-gray-300",children:Pe+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[F.avatar?r.jsx("img",{src:F.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((cn=F.name)==null?void 0:cn[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:F.name})})]})}),r.jsx(ve,{className:"text-gray-300 whitespace-nowrap",children:F.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),r.jsx(ve,{className:"text-gray-300",children:F.vipSort??Pe+1}),r.jsx(ve,{className:"text-right text-xs text-gray-300",children:r.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>uc(F),title:"设置超级个体标签",children:r.jsx(ld,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{ge(F.id),K(!0)},title:"编辑资料",children:r.jsx(Kt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Qa(F),title:"设置排序序号",children:r.jsx(Hm,{className:"w-3.5 h-3.5"})})]})})]},F.id)})})]})})})]})]}),r.jsx(Ot,{open:hc,onOpenChange:F=>{br(F),F||$r(null)},children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[r.jsx(Hm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",vr==null?void 0:vr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ya,onChange:F=>no(F.target.value)})]}),r.jsxs(nn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>br(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:ws,disabled:Br,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),Br?"保存中...":"保存"]})]})]})}),r.jsx(Ot,{open:kn,onOpenChange:F=>{zr(F),F||to(null)},children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[r.jsx(Fl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",xr==null?void 0:xr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Ja.map(F=>r.jsx(X,{variant:yr===F?"default":"outline",size:"sm",className:yr===F?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ga(F),children:F},F))}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:yr,onChange:F=>ga(F.target.value)})]})]}),r.jsxs(nn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>zr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:()=>Jt(yr),disabled:Fr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),Fr?"保存中...":"保存"]})]})]})}),r.jsx(Ot,{open:z,onOpenChange:ce,children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[me?r.jsx(Kt,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(dd,{className:"w-5 h-5 text-[#38bdac]"}),me?"编辑用户":"添加用户"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ae.phone,onChange:F=>pe({...ae,phone:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ae.nickname,onChange:F=>pe({...ae,nickname:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:me?"新密码 (留空则不修改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:me?"留空则不修改":"请输入密码",value:ae.password,onChange:F=>pe({...ae,password:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),r.jsx(kt,{checked:ae.isAdmin,onCheckedChange:F=>pe({...ae,isAdmin:F})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"已购全书"}),r.jsx(kt,{checked:ae.hasFullBook,onCheckedChange:F=>pe({...ae,hasFullBook:F})})]})]}),r.jsxs(nn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>ce(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:mr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(Ot,{open:St,onOpenChange:Rt,children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[r.jsx(Kt,{className:"w-5 h-5 text-[#38bdac]"}),Ht?"编辑规则":"添加规则"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Ft.title,onChange:F=>xn({...Ft,title:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则描述"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Ft.description,onChange:F=>xn({...Ft,description:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"触发条件"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Ft.trigger,onChange:F=>xn({...Ft,trigger:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:r.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),r.jsx(kt,{checked:Ft.enabled,onCheckedChange:F=>xn({...Ft,enabled:F})})]})]}),r.jsxs(nn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>Rt(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:gr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(Ot,{open:A,onOpenChange:Y,children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[r.jsx(Dt,{children:r.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ln,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ye==null?void 0:ye.nickname]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Hr=U.stats)==null?void 0:Hr.total)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-green-400",children:((yn=U.stats)==null?void 0:yn.purchased)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((so=U.stats)==null?void 0:so.earnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((ba=U.stats)==null?void 0:ba.pendingEarnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),W?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx($e,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Wr=U.referrals)==null?void 0:Wr.length)??0)>0?r.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(U.referrals??[]).map((F,Pe)=>{var lt;const ze=F;return r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((lt=ze.nickname)==null?void 0:lt.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white text-sm",children:ze.nickname}),r.jsx("div",{className:"text-xs text-gray-500",children:ze.phone||(ze.hasOpenId?"微信用户":"未绑定")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[ze.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),ze.status==="paid"&&r.jsxs(Ke,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",ze.purchasedSections,"章"]}),ze.status==="free"&&r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),r.jsx("span",{className:"text-xs text-gray-500",children:ze.createdAt?new Date(ze.createdAt).toLocaleDateString():""})]})]},ze.id||Pe)})}):r.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),r.jsx(nn,{children:r.jsx(X,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),r.jsx(b0,{open:ne,onClose:()=>K(!1),userId:J,onUserUpdated:Zs})]})}function Lh(t,[e,n]){return Math.min(n,Math.max(e,t))}var Ok=["PageUp","PageDown"],Dk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ac="Slider",[rx,gP,xP]=m0(ac),[_k]=qi(ac,[xP]),[yP,Vf]=_k(ac),zk=b.forwardRef((t,e)=>{const{name:n,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[s],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:N,...j}=t,v=b.useRef(new Set),k=b.useRef(0),E=o==="horizontal"?bP:vP,[M=[],P]=_o({prop:f,defaultProp:h,onChange:ie=>{var ce;(ce=[...v.current][k.current])==null||ce.focus(),m(ie)}}),H=b.useRef(M);function L(ie){const z=SP(M,ie);se(ie,z)}function R(ie){se(ie,k.current)}function O(){const ie=H.current[k.current];M[k.current]!==ie&&g(M)}function se(ie,z,{commit:ce}={commit:!1}){const me=MP(i),_=AP(Math.round((ie-s)/i)*i+s,me),G=Lh(_,[s,a]);P(($=[])=>{const A=jP($,G,z);if(TP(A,u*i)){k.current=A.indexOf(G);const Y=String(A)!==String($);return Y&&ce&&g(A),Y?A:$}else return $})}return r.jsx(yP,{scope:t.__scopeSlider,name:n,disabled:c,min:s,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:M,orientation:o,form:N,children:r.jsx(rx.Provider,{scope:t.__scopeSlider,children:r.jsx(rx.Slot,{scope:t.__scopeSlider,children:r.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:dt(j.onPointerDown,()=>{c||(H.current=M)}),min:s,max:a,inverted:y,onSlideStart:c?void 0:L,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&se(s,0,{commit:!0}),onEndKeyDown:()=>!c&&se(a,M.length-1,{commit:!0}),onStepKeyDown:({event:ie,direction:z})=>{if(!c){const _=Ok.includes(ie.key)||ie.shiftKey&&Dk.includes(ie.key)?10:1,G=k.current,$=M[G],A=i*_*z;se($+A,G,{commit:!0})}}})})})})});zk.displayName=ac;var[Fk,$k]=_k(ac,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bP=b.forwardRef((t,e)=>{const{min:n,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=At(e,E=>g(E)),N=b.useRef(void 0),j=Ff(a),v=j==="ltr",k=v&&!i||!v&&i;function C(E){const M=N.current||m.getBoundingClientRect(),P=[0,M.width],L=N0(P,k?[n,s]:[s,n]);return N.current=M,L(E-M.left)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:r.jsx(Bk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const M=C(E.clientX);o==null||o(M)},onSlideMove:E=>{const M=C(E.clientX);c==null||c(M)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const P=Lk[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:P?-1:1})}})})}),vP=b.forwardRef((t,e)=>{const{min:n,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=At(e,f),g=b.useRef(void 0),y=!a;function N(j){const v=g.current||f.current.getBoundingClientRect(),k=[0,v.height],E=N0(k,y?[s,n]:[n,s]);return g.current=v,E(j-v.top)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:r.jsx(Bk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const v=N(j.clientY);i==null||i(v)},onSlideMove:j=>{const v=N(j.clientY);o==null||o(v)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const k=Lk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:k?-1:1})}})})}),Bk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Vf(ac,n);return r.jsx(pt.span,{...h,ref:e,onKeyDown:dt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Ok.concat(Dk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:dt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():s(m)}),onPointerMove:dt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:dt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Vk="SliderTrack",Hk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(Vk,n);return r.jsx(pt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:e})});Hk.displayName=Vk;var ax="SliderRange",Wk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(ax,n),i=$k(ax,n),o=b.useRef(null),c=At(e,o),u=a.values.length,h=a.values.map(g=>qk(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return r.jsx(pt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Wk.displayName=ax;var ix="SliderThumb",Uk=b.forwardRef((t,e)=>{const n=gP(t.__scopeSlider),[s,a]=b.useState(null),i=At(e,c=>a(c)),o=b.useMemo(()=>s?n().findIndex(c=>c.ref.current===s):-1,[n,s]);return r.jsx(NP,{...t,ref:i,index:o})}),NP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:s,name:a,...i}=t,o=Vf(ix,n),c=$k(ix,n),[u,h]=b.useState(null),f=At(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=y0(u),y=o.values[s],N=y===void 0?0:qk(y,o.min,o.max),j=kP(s,o.values.length),v=g==null?void 0:g[c.size],k=v?CP(v,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[r.jsx(rx.ItemSlot,{scope:t.__scopeSlider,children:r.jsx(pt.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:dt(t.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),m&&r.jsx(Kk,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},s)]})});Uk.displayName=ix;var wP="RadioBubbleInput",Kk=b.forwardRef(({__scopeSlider:t,value:e,...n},s)=>{const a=b.useRef(null),i=At(a,s),o=x0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(pt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});Kk.displayName=wP;function jP(t=[],e,n){const s=[...t];return s[n]=e,s.sort((a,i)=>a-i)}function qk(t,e,n){const i=100/(n-e)*(t-e);return Lh(i,[0,100])}function kP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function SP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),s=Math.min(...n);return n.indexOf(s)}function CP(t,e,n){const s=t/2,i=N0([0,50],[0,s]);return(s-i(e)*n)*n}function EP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function TP(t,e){if(e>0){const n=EP(t);return Math.min(...n)>=e}return!0}function N0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function MP(t){return(String(t).split(".")[1]||"").length}function AP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var IP=zk,RP=Hk,PP=Wk,OP=Uk;function DP({className:t,defaultValue:e,value:n,min:s=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[s,a],[n,e,s,a]);return r.jsxs(IP,{defaultValue:e,value:n,min:s,max:a,className:It("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[r.jsx(RP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:r.jsx(PP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>r.jsx(OP,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const LP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Gk(t){const[e,n]=b.useState(LP),[s,a]=b.useState(!0),[i,o]=b.useState(!1);b.useEffect(()=>{De("/api/admin/referral-settings").then(h=>{const f=h==null?void 0:h.data;f&&typeof f=="object"&&n({distributorShare:f.distributorShare??90,minWithdrawAmount:f.minWithdrawAmount??10,bindingDays:f.bindingDays??30,userDiscount:f.userDiscount??5,withdrawFee:f.withdrawFee??5,enableAutoWithdraw:f.enableAutoWithdraw??!1,vipOrderShareVip:f.vipOrderShareVip??20,vipOrderShareNonVip:f.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>a(!1))},[]);const c=async()=>{o(!0);try{const h={distributorShare:Number(e.distributorShare)||0,minWithdrawAmount:Number(e.minWithdrawAmount)||0,bindingDays:Number(e.bindingDays)||0,userDiscount:Number(e.userDiscount)||0,withdrawFee:Number(e.withdrawFee)??5,enableAutoWithdraw:!!e.enableAutoWithdraw,vipOrderShareVip:Number(e.vipOrderShareVip)||20,vipOrderShareNonVip:Number(e.vipOrderShareNonVip)||10},f=await yt("/api/admin/referral-settings",h);if(!f||f.success===!1){te.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}te.success(`✅ 分销配置已保存成功!
• 小程序与网站的推广规则会一起生效
• 绑定关系会使用新的天数配置
• 佣金比例会立即应用到新订单
-如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),te.error("保存失败: "+(h instanceof Error?h.message:String(h)))}finally{o(!1)}},u=h=>f=>{const m=parseFloat(f.target.value||"0");n(g=>({...g,[h]:isNaN(m)?0:m}))};return s?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Wl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),r.jsxs(X,{onClick:c,disabled:i||s,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(p5,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),r.jsx(Ft,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(DP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),r.jsx(re,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",r.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),r.jsx(re,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),r.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Wl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),r.jsx(Ft,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),r.jsx(re,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提现手续费(%)"}),r.jsx(re,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:e.withdrawFee,onChange:u("withdrawFee")}),r.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",r.jsx(Ke,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx(jt,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),r.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[r.jsx(Ku,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),r.jsxs(Te,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[r.jsxs("p",{children:["1. 以上配置会写入"," ",r.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),r.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),r.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function _P(){var ls;const[t,e]=b.useState("overview"),[n,s]=b.useState([]),[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(""),[C,E]=b.useState("all"),[M,P]=b.useState(1),[H,L]=b.useState(10),[R,O]=b.useState(0),[se,ie]=b.useState(new Set),[z,ce]=b.useState(null),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState(null),[U,D]=b.useState(""),[W,le]=b.useState(!1),[ye,Ae]=b.useState(!1),[ne,K]=b.useState(!1),[J,ge]=b.useState([]),[ae,pe]=b.useState(1),[Se,tt]=b.useState(0),[at,Dt]=b.useState("");b.useEffect(()=>{kt()},[]),b.useEffect(()=>{P(1)},[t,C]),b.useEffect(()=>{At(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&At(t,!0),t==="giftPay"&&At("giftPay",!0)},[M,H,C,v,ae,at]),b.useEffect(()=>{t==="withdrawals"&&ln()},[t]);async function kt(){j(null);try{const q=await De("/api/admin/distribution/overview");q!=null&&q.success&&q.overview&&i(q.overview)}catch(q){console.error("[Admin] 概览接口异常:",q),j("加载概览失败")}try{const q=await De("/api/db/users");m((q==null?void 0:q.users)||[])}catch(q){console.error("[Admin] 用户数据加载失败:",q)}}async function At(q,He=!1){var mt;if(!(!He&&se.has(q))){y(!0);try{const $t=f;switch(q){case"overview":break;case"orders":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C},...v&&{search:v}}),ot=await De(`/api/admin/orders?${ut}`);if(ot!=null&&ot.success&&ot.orders){const xt=ot.orders.map(tn=>{const he=$t.find(zt=>zt.id===tn.userId),xe=tn.referrerId?$t.find(zt=>zt.id===tn.referrerId):null;return{...tn,amount:parseFloat(String(tn.amount))||0,userNickname:(he==null?void 0:he.nickname)||tn.userNickname||"未知用户",userPhone:(he==null?void 0:he.phone)||tn.userPhone||"-",referrerNickname:(xe==null?void 0:xe.nickname)||null,referrerCode:(xe==null?void 0:xe.referralCode)??null,type:tn.productType||tn.type}});s(xt),O(ot.total??xt.length)}else s([]),O(0)}catch(ut){console.error(ut),j("加载订单失败"),s([])}break}case"bindings":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C}}),ot=await De(`/api/db/distribution?${ut}`);c((ot==null?void 0:ot.bindings)||[]),O((ot==null?void 0:ot.total)??((mt=ot==null?void 0:ot.bindings)==null?void 0:mt.length)??0)}catch(ut){console.error(ut),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ut=C==="completed"?"success":C==="rejected"?"failed":C,ot=new URLSearchParams({...ut&&ut!=="all"&&{status:ut},page:String(M),pageSize:String(H)}),xt=await De(`/api/admin/withdrawals?${ot}`);if(xt!=null&&xt.success&&xt.withdrawals){const tn=xt.withdrawals.map(he=>({...he,account:he.account??"未绑定微信号",status:he.status==="success"?"completed":he.status==="failed"?"rejected":he.status}));h(tn),O((xt==null?void 0:xt.total)??tn.length)}else xt!=null&&xt.success||j(`获取提现记录失败: ${(xt==null?void 0:xt.error)||"未知错误"}`),h([])}catch(ut){console.error(ut),j("加载提现数据失败"),h([])}break}case"giftPay":{try{const ut=new URLSearchParams({page:String(ae),pageSize:"20",...at&&{status:at}}),ot=await De(`/api/admin/gift-pay-requests?${ut}`);ot!=null&&ot.success&&ot.data?(ge(ot.data),tt(ot.total??ot.data.length)):(ge([]),tt(0))}catch(ut){console.error(ut),j("加载代付请求失败"),ge([])}break}}ie(ut=>new Set(ut).add(q))}catch($t){console.error($t)}finally{y(!1)}}}async function Gt(){j(null),ie(q=>{const He=new Set(q);return He.delete(t),He}),t==="overview"&&kt(),await At(t,!0)}async function In(q){if(confirm("确认审核通过并打款?"))try{const He=await Ot("/api/admin/withdrawals",{id:q,action:"approve"});if(!(He!=null&&He.success)){const mt=(He==null?void 0:He.message)||(He==null?void 0:He.error)||"操作失败";te.error(mt);return}await Gt()}catch(He){console.error(He),te.error("操作失败")}}function Lt(q){Y(q),D("")}async function xn(){const q=A;if(!q)return;const He=U.trim();if(!He){te.error("请填写拒绝原因");return}le(!0);try{const mt=await Ot("/api/admin/withdrawals",{id:q,action:"reject",errorMessage:He});if(!(mt!=null&&mt.success)){te.error((mt==null?void 0:mt.error)||"操作失败");return}te.success("已拒绝该提现申请"),Y(null),D(""),await Gt()}catch(mt){console.error(mt),te.error("操作失败")}finally{le(!1)}}async function ln(){try{const q=await De("/api/admin/withdrawals/auto-approve");q!=null&&q.success&&typeof q.enableAutoApprove=="boolean"&&Ae(q.enableAutoApprove)}catch{}}async function Bs(q){K(!0);try{const He=await Ot("/api/admin/withdrawals/auto-approve",{enableAutoApprove:q});He!=null&&He.success?(Ae(q),te.success(q?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):te.error("更新失败: "+((He==null?void 0:He.error)??""))}catch{te.error("更新失败")}finally{K(!1)}}function yn(){A&&te.info("已取消操作"),Y(null),D("")}async function is(){var q;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){$(!0),j(null);try{const He=await Ot("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:me||void 0});He!=null&&He.success?(ce(null),_(""),await At("orders",!0)):j((He==null?void 0:He.error)||"退款失败")}catch(He){const mt=He;j(((q=mt==null?void 0:mt.data)==null?void 0:q.error)||"退款失败,请检查网络后重试")}finally{$(!1)}}}function Un(q){const He={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},mt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return r.jsx(Ke,{className:`${He[q]||"bg-gray-500/20 text-gray-400"} border-0`,children:mt[q]||q})}const Kn=Math.ceil(R/H)||1,_t=n,qn=o.filter(q=>{var mt,$t,ut,ot;if(!v)return!0;const He=v.toLowerCase();return((mt=q.refereeNickname)==null?void 0:mt.toLowerCase().includes(He))||(($t=q.refereePhone)==null?void 0:$t.includes(He))||((ut=q.referrerName)==null?void 0:ut.toLowerCase().includes(He))||((ot=q.referrerCode)==null?void 0:ot.toLowerCase().includes(He))}),zn=u.filter(q=>{var mt;if(!v)return!0;const He=v.toLowerCase();return((mt=q.userName)==null?void 0:mt.toLowerCase().includes(He))||q.account&&q.account.toLowerCase().includes(He)});return r.jsxs("div",{className:"p-8 w-full",children:[N&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex items-center justify-between mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),r.jsxs(X,{onClick:Gt,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),r.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:cd},{key:"orders",label:"订单管理",icon:Ih},{key:"bindings",label:"绑定管理",icon:Rr},{key:"withdrawals",label:"提现审核",icon:Wl},{key:"giftPay",label:"代付请求",icon:cj},{key:"settings",label:"推广设置",icon:Mo}].map(q=>r.jsxs("button",{type:"button",onClick:()=>{e(q.key),E("all"),k(""),q.key==="giftPay"&&(Dt(""),pe(1))},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===q.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[r.jsx(q.icon,{className:"w-4 h-4"}),q.label]},q.key))}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Fe,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[t==="overview"&&a&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayClicks}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(qg,{className:"w-6 h-6 text-blue-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayUniqueVisitors??0}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:r.jsx(_n,{className:"w-6 h-6 text-cyan-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(a.todayClickRate??0).toFixed(2)}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:r.jsx(cd,{className:"w-6 h-6 text-amber-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayBindings})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:r.jsx(Rr,{className:"w-6 h-6 text-green-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayConversions})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:r.jsx(Jv,{className:"w-6 h-6 text-purple-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",a.todayEarnings.toFixed(2)]})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:r.jsx(Ih,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((ls=a.todayClicksByPage)==null?void 0:ls.length)??0)>0&&r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(qg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),r.jsxs(X,{type:"button",size:"sm",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})}),r.jsx(Te,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),r.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),r.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),r.jsx("tbody",{children:[...a.todayClicksByPage??[]].sort((q,He)=>He.clicks-q.clicks).map((q,He)=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:q.page||"(未区分)"}),r.jsx("td",{className:"py-2 pr-4 text-right text-white",children:q.clicks}),r.jsxs("td",{className:"py-2 text-right text-gray-400",children:[a.todayClicks>0?(q.clicks/a.todayClicks*100).toFixed(1):0,"%"]})]},He))})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Ee,{className:"bg-orange-500/10 border-orange-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:r.jsx(Kg,{className:"w-6 h-6 text-orange-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.expiringBindings," 个"]}),r.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),r.jsx(Ee,{className:"bg-blue-500/10 border-blue-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(Wl,{className:"w-6 h-6 text-blue-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.pendingWithdrawals," 笔"]}),r.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",a.pendingWithdrawAmount.toFixed(2)]})]}),r.jsx(X,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthClicks})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthBindings})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.monthEarnings.toFixed(2)]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(cd,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),r.jsxs(Te,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalClicks.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalBindings.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.totalEarnings.toFixed(2)]})]})]}),r.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[r.jsx("span",{className:"text-gray-300",children:"点击转化率"}),r.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[a.conversionRate,"%"]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-white",children:a.totalDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-green-400",children:a.activeDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[n.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:_t.map(q=>{var He,mt;return r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(He=q.id)==null?void 0:He.slice(0,12),"..."]}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:q.userNickname}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.userPhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:(()=>{const $t=q.productType||q.type,ut=q.description||"",ot=String(q.productId||q.sectionId||""),xt=$t==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||ot.toLowerCase().includes("vip");return $t==="balance_recharge"?`余额充值 ¥${typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)}`:xt?"超级个体开通费用":$t==="fullbook"?`${q.bookName||"《底层逻辑》"} - 全本`:$t==="match"?"匹配次数购买":`${q.bookName||"《底层逻辑》"} - ${q.sectionTitle||q.chapterTitle||`章节${q.productId||q.sectionId||""}`}`})()}),r.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const $t=q.productType||q.type,ut=q.description||"",ot=String(q.productId||q.sectionId||""),xt=$t==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||ot.toLowerCase().includes("vip");return $t==="balance_recharge"?"余额充值":xt?"超级个体":$t==="fullbook"?"全书解锁":$t==="match"?"功能权益":q.chapterTitle||"单章购买"})()})]})}),r.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)]}),r.jsx("td",{className:"p-4 text-gray-300",children:q.paymentMethod==="wechat"?"微信支付":q.paymentMethod==="balance"?"余额支付":q.paymentMethod==="alipay"?"支付宝":q.paymentMethod||"微信支付"}),r.jsx("td",{className:"p-4",children:q.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):q.status==="completed"||q.status==="paid"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):q.status==="pending"||q.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:q.refundReason,children:q.status==="refunded"&&q.refundReason?q.refundReason:"-"}),r.jsx("td",{className:"p-4 text-gray-300 text-sm",children:q.referrerId||q.referralCode?r.jsxs("span",{title:q.referralCode||q.referrerCode||q.referrerId||"",children:[q.referrerNickname||q.referralCode||q.referrerCode||((mt=q.referrerId)==null?void 0:mt.slice(0,8)),(q.referralCode||q.referrerCode)&&` (${q.referralCode||q.referrerCode})`]}):"-"}),r.jsx("td",{className:"p-4 text-[#FFD700]",children:q.referrerEarnings?`¥${(typeof q.referrerEarnings=="number"?q.referrerEarnings:parseFloat(String(q.referrerEarnings))).toFixed(2)}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:(q.status==="paid"||q.status==="completed")&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{ce(q),_("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},q.id)})})]})}),t==="orders"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="bindings"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"active",children:"有效"}),r.jsx("option",{value:"converted",children:"已转化"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[qn.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:qn.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-medium",children:q.refereeNickname||"匿名用户"}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.refereePhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white",children:q.referrerName||"-"}),r.jsx("p",{className:"text-gray-500 text-xs font-mono",children:q.referrerCode})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.boundAt?new Date(q.boundAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.expiresAt?new Date(q.expiresAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Un(q.status)}),r.jsx("td",{className:"p-4",children:q.commission?r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",q.commission.toFixed(2)]}):r.jsx("span",{className:"text-gray-500",children:"-"})})]},q.id))})]})}),t==="bindings"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="withdrawals"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待审核"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"rejected",children:"已拒绝"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[r.jsx(Fa,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),r.jsx(jt,{checked:ye,onCheckedChange:Bs,disabled:ne,className:"data-[state=checked]:bg-[#38bdac]"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[zn.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:zn.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[q.userAvatar?r.jsx("img",{src:q.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(q.userName||q.name||"?").slice(0,1)}),r.jsx("p",{className:"text-white font-medium",children:q.userName||q.name})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",q.amount.toFixed(2)]})}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:q.method==="wechat"?"微信":"支付宝"})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-mono text-xs",children:q.account}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.name})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Un(q.status)}),r.jsx("td",{className:"p-4 max-w-[160px]",children:r.jsx("span",{className:`text-xs ${q.status==="rejected"||q.status==="failed"?"text-red-400":"text-gray-400"}`,title:q.remark,children:q.remark||"-"})}),r.jsx("td",{className:"p-4 text-right",children:q.status==="pending"&&r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsxs(X,{size:"sm",onClick:()=>In(q.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Jv,{className:"w-4 h-4 mr-1"}),"通过"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>Lt(q.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[r.jsx(ij,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},q.id))})]})}),t==="withdrawals"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="giftPay"&&r.jsx("div",{className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsx(Ye,{className:"text-white",children:"代付请求列表"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:at,onChange:q=>{Dt(q.target.value),pe(1)},children:[r.jsx("option",{value:"",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待支付(旧)"}),r.jsx("option",{value:"pending_pay",children:"待发起人支付"}),r.jsx("option",{value:"paid",children:"已支付"}),r.jsx("option",{value:"refunded",children:"已退款"}),r.jsx("option",{value:"cancelled",children:"已取消"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300",children:[r.jsx(Fe,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})]})}),r.jsxs(Te,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"请求号"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"发起人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"商品/金额"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"份数/已领"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"付款人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"创建时间"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:J.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[r.jsx("td",{className:"p-4 font-mono text-xs text-gray-400",children:q.requestSn}),r.jsx("td",{className:"p-4",children:r.jsx("p",{className:"text-white text-sm",children:q.initiatorNick||q.initiatorUserId})}),r.jsxs("td",{className:"p-4",children:[r.jsxs("p",{className:"text-white",children:[q.productType," · ¥",q.amount.toFixed(2)]}),q.description&&r.jsx("p",{className:"text-gray-500 text-xs",children:q.description})]}),r.jsx("td",{className:"p-4 text-gray-400",children:(q.quantity??1)>1?`${q.quantity}份 / 已领${q.redeemedCount??0}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.payerNick||(q.payerUserId?q.payerUserId:"-")}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.status==="paid"?"bg-green-500/20 text-green-400 border-0":q.status==="pending"||q.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":q.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:q.status==="paid"?"已支付":q.status==="pending"||q.status==="pending_pay"?"待支付":q.status==="refunded"?"已退款":q.status==="cancelled"?"已取消":"已过期"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"})]},q.id))})]})}),J.length===0&&!g&&r.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),Se>20&&r.jsx("div",{className:"mt-4 flex justify-center",children:r.jsx(Fs,{page:ae,totalPages:Math.ceil(Se/20),total:Se,pageSize:20,onPageChange:pe,onPageSizeChange:()=>{}})})]})]})})]}),r.jsx(It,{open:!!z,onOpenChange:q=>!q&&ce(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"订单退款"})}),z&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof z.amount=="number"?z.amount.toFixed(2):parseFloat(String(z.amount||"0")).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:me,onChange:q=>_(q.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>ce(null),disabled:G,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:is,disabled:G,children:G?"退款中...":"确认退款"})]})]})}),r.jsx(It,{open:!!A,onOpenChange:q=>!q&&yn(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:U,onChange:q=>D(q.target.value)})})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:yn,disabled:W,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:xn,disabled:W||!U.trim(),children:W?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&r.jsx("div",{className:"-mx-8 -mt-6",children:r.jsx(Gk,{embedded:!0})})]})}function zP(){const[t,e]=b.useState([]),[n,s]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(0),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(!1);async function R(){var _,G,$,A,Y,U,D;i(!0),c(null);try{const W=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),le=await De(`/api/admin/withdrawals?${W}`);if(le!=null&&le.success){const ye=le.withdrawals||[];e(ye),j(le.total??((_=le.stats)==null?void 0:_.total)??ye.length),s({total:((G=le.stats)==null?void 0:G.total)??le.total??ye.length,pendingCount:(($=le.stats)==null?void 0:$.pendingCount)??0,pendingAmount:((A=le.stats)==null?void 0:A.pendingAmount)??0,successCount:((Y=le.stats)==null?void 0:Y.successCount)??0,successAmount:((U=le.stats)==null?void 0:U.successAmount)??0,failedCount:((D=le.stats)==null?void 0:D.failedCount)??0})}else c("加载提现记录失败")}catch(W){console.error("Load withdrawals error:",W),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{R()},[u,f,g]);const O=Math.ceil(N/g)||1;async function se(_){const G=t.find($=>$.id===_);if(G!=null&&G.userCommissionInfo&&G.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${G.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
+如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),te.error("保存失败: "+(h instanceof Error?h.message:String(h)))}finally{o(!1)}},u=h=>f=>{const m=parseFloat(f.target.value||"0");n(g=>({...g,[h]:isNaN(m)?0:m}))};return s?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Wl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),r.jsxs(X,{onClick:c,disabled:i||s,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(p5,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),r.jsx($t,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ln,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(DP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),r.jsx(re,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",r.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ln,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),r.jsx(re,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),r.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Wl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),r.jsx($t,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),r.jsx(re,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提现手续费(%)"}),r.jsx(re,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:e.withdrawFee,onChange:u("withdrawFee")}),r.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",r.jsx(Ke,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx(kt,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),r.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[r.jsx(Ku,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),r.jsxs(Te,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[r.jsxs("p",{children:["1. 以上配置会写入"," ",r.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),r.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),r.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function _P(){var Un;const[t,e]=b.useState("overview"),[n,s]=b.useState([]),[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(""),[C,E]=b.useState("all"),[M,P]=b.useState(1),[H,L]=b.useState(10),[R,O]=b.useState(0),[se,ie]=b.useState(new Set),[z,ce]=b.useState(null),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState(null),[U,D]=b.useState(""),[W,le]=b.useState(!1),[ye,Ae]=b.useState(!1),[ne,K]=b.useState(!1),[J,ge]=b.useState([]),[ae,pe]=b.useState(1),[Se,tt]=b.useState(0),[it,zt]=b.useState("");b.useEffect(()=>{St()},[]),b.useEffect(()=>{P(1)},[t,C]),b.useEffect(()=>{Rt(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&Rt(t,!0),t==="giftPay"&&Rt("giftPay",!0)},[M,H,C,v,ae,it]),b.useEffect(()=>{t==="withdrawals"&&Bs()},[t]);async function St(){j(null);try{const q=await De("/api/admin/distribution/overview");q!=null&&q.success&&q.overview&&i(q.overview)}catch(q){console.error("[Admin] 概览接口异常:",q),j("加载概览失败")}try{const q=await De("/api/db/users");m((q==null?void 0:q.users)||[])}catch(q){console.error("[Admin] 用户数据加载失败:",q)}}async function Rt(q,Le=!1){var mt;if(!(!Le&&se.has(q))){y(!0);try{const Pt=f;switch(q){case"overview":break;case"orders":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C},...v&&{search:v}}),nt=await De(`/api/admin/orders?${ut}`);if(nt!=null&&nt.success&&nt.orders){const Nt=nt.orders.map(he=>{const xe=Pt.find(rn=>rn.id===he.userId),jt=he.referrerId?Pt.find(rn=>rn.id===he.referrerId):null;return{...he,amount:parseFloat(String(he.amount))||0,userNickname:(xe==null?void 0:xe.nickname)||he.userNickname||"未知用户",userPhone:(xe==null?void 0:xe.phone)||he.userPhone||"-",referrerNickname:(jt==null?void 0:jt.nickname)||null,referrerCode:(jt==null?void 0:jt.referralCode)??null,type:he.productType||he.type}});s(Nt),O(nt.total??Nt.length)}else s([]),O(0)}catch(ut){console.error(ut),j("加载订单失败"),s([])}break}case"bindings":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C}}),nt=await De(`/api/db/distribution?${ut}`);c((nt==null?void 0:nt.bindings)||[]),O((nt==null?void 0:nt.total)??((mt=nt==null?void 0:nt.bindings)==null?void 0:mt.length)??0)}catch(ut){console.error(ut),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ut=C==="completed"?"success":C==="rejected"?"failed":C,nt=new URLSearchParams({...ut&&ut!=="all"&&{status:ut},page:String(M),pageSize:String(H)}),Nt=await De(`/api/admin/withdrawals?${nt}`);if(Nt!=null&&Nt.success&&Nt.withdrawals){const he=Nt.withdrawals.map(xe=>({...xe,account:xe.account??"未绑定微信号",status:xe.status==="success"?"completed":xe.status==="failed"?"rejected":xe.status}));h(he),O((Nt==null?void 0:Nt.total)??he.length)}else Nt!=null&&Nt.success||j(`获取提现记录失败: ${(Nt==null?void 0:Nt.error)||"未知错误"}`),h([])}catch(ut){console.error(ut),j("加载提现数据失败"),h([])}break}case"giftPay":{try{const ut=new URLSearchParams({page:String(ae),pageSize:"20",...it&&{status:it}}),nt=await De(`/api/admin/gift-pay-requests?${ut}`);nt!=null&&nt.success&&nt.data?(ge(nt.data),tt(nt.total??nt.data.length)):(ge([]),tt(0))}catch(ut){console.error(ut),j("加载代付请求失败"),ge([])}break}}ie(ut=>new Set(ut).add(q))}catch(Pt){console.error(Pt)}finally{y(!1)}}}async function Ht(){j(null),ie(q=>{const Le=new Set(q);return Le.delete(t),Le}),t==="overview"&&St(),await Rt(t,!0)}async function In(q){if(confirm("确认审核通过并打款?"))try{const Le=await _t("/api/admin/withdrawals",{id:q,action:"approve"});if(!(Le!=null&&Le.success)){const mt=(Le==null?void 0:Le.message)||(Le==null?void 0:Le.error)||"操作失败";te.error(mt);return}await Ht()}catch(Le){console.error(Le),te.error("操作失败")}}function Ft(q){Y(q),D("")}async function xn(q){if(confirm("确认撤回该笔打款?资金将退回商户运营账户。"))try{const Le=await yt("/api/admin/withdrawals/cancel",{id:q});if(!(Le!=null&&Le.success)){te.error((Le==null?void 0:Le.error)||(Le==null?void 0:Le.message)||"撤回失败");return}te.success("已撤回打款"),await Ht()}catch(Le){console.error(Le),te.error("撤回失败")}}async function ln(){const q=A;if(!q)return;const Le=U.trim();if(!Le){te.error("请填写拒绝原因");return}le(!0);try{const mt=await _t("/api/admin/withdrawals",{id:q,action:"reject",errorMessage:Le});if(!(mt!=null&&mt.success)){te.error((mt==null?void 0:mt.error)||"操作失败");return}te.success("已拒绝该提现申请"),Y(null),D(""),await Ht()}catch(mt){console.error(mt),te.error("操作失败")}finally{le(!1)}}async function Bs(){try{const q=await De("/api/admin/withdrawals/auto-approve");q!=null&&q.success&&typeof q.enableAutoApprove=="boolean"&&Ae(q.enableAutoApprove)}catch{}}async function jn(q){K(!0);try{const Le=await _t("/api/admin/withdrawals/auto-approve",{enableAutoApprove:q});Le!=null&&Le.success?(Ae(q),te.success(q?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):te.error("更新失败: "+((Le==null?void 0:Le.error)??""))}catch{te.error("更新失败")}finally{K(!1)}}function Wn(){A&&te.info("已取消操作"),Y(null),D("")}async function rs(){var q;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){$(!0),j(null);try{const Le=await _t("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:me||void 0});Le!=null&&Le.success?(ce(null),_(""),await Rt("orders",!0)):j((Le==null?void 0:Le.error)||"退款失败")}catch(Le){const mt=Le;j(((q=mt==null?void 0:mt.data)==null?void 0:q.error)||"退款失败,请检查网络后重试")}finally{$(!1)}}}function as(q){const Le={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},mt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return r.jsx(Ke,{className:`${Le[q]||"bg-gray-500/20 text-gray-400"} border-0`,children:mt[q]||q})}const Ct=Math.ceil(R/H)||1,is=n,_n=o.filter(q=>{var mt,Pt,ut,nt;if(!v)return!0;const Le=v.toLowerCase();return((mt=q.refereeNickname)==null?void 0:mt.toLowerCase().includes(Le))||((Pt=q.refereePhone)==null?void 0:Pt.includes(Le))||((ut=q.referrerName)==null?void 0:ut.toLowerCase().includes(Le))||((nt=q.referrerCode)==null?void 0:nt.toLowerCase().includes(Le))}),ls=u.filter(q=>{var mt;if(!v)return!0;const Le=v.toLowerCase();return((mt=q.userName)==null?void 0:mt.toLowerCase().includes(Le))||q.account&&q.account.toLowerCase().includes(Le)});return r.jsxs("div",{className:"p-8 w-full",children:[N&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex items-center justify-between mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),r.jsxs(X,{onClick:Ht,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),r.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:cd},{key:"orders",label:"订单管理",icon:Ih},{key:"bindings",label:"绑定管理",icon:Rr},{key:"withdrawals",label:"提现审核",icon:Wl},{key:"giftPay",label:"代付请求",icon:dj},{key:"settings",label:"推广设置",icon:Mo}].map(q=>r.jsxs("button",{type:"button",onClick:()=>{e(q.key),E("all"),k(""),q.key==="giftPay"&&(zt(""),pe(1))},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===q.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[r.jsx(q.icon,{className:"w-4 h-4"}),q.label]},q.key))}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx($e,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[t==="overview"&&a&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayClicks}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(qg,{className:"w-6 h-6 text-blue-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayUniqueVisitors??0}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:r.jsx(Ln,{className:"w-6 h-6 text-cyan-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(a.todayClickRate??0).toFixed(2)}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:r.jsx(cd,{className:"w-6 h-6 text-amber-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayBindings})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:r.jsx(Rr,{className:"w-6 h-6 text-green-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayConversions})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:r.jsx(Yv,{className:"w-6 h-6 text-purple-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",a.todayEarnings.toFixed(2)]})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:r.jsx(Ih,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((Un=a.todayClicksByPage)==null?void 0:Un.length)??0)>0&&r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(qg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),r.jsxs(X,{type:"button",size:"sm",variant:"outline",onClick:()=>void Ht(),disabled:g,className:"border-gray-600 text-gray-300 shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})}),r.jsx(Te,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),r.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),r.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),r.jsx("tbody",{children:[...a.todayClicksByPage??[]].sort((q,Le)=>Le.clicks-q.clicks).map((q,Le)=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:q.page||"(未区分)"}),r.jsx("td",{className:"py-2 pr-4 text-right text-white",children:q.clicks}),r.jsxs("td",{className:"py-2 text-right text-gray-400",children:[a.todayClicks>0?(q.clicks/a.todayClicks*100).toFixed(1):0,"%"]})]},Le))})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Ee,{className:"bg-orange-500/10 border-orange-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:r.jsx(Kg,{className:"w-6 h-6 text-orange-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.expiringBindings," 个"]}),r.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),r.jsx(Ee,{className:"bg-blue-500/10 border-blue-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(Wl,{className:"w-6 h-6 text-blue-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.pendingWithdrawals," 笔"]}),r.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",a.pendingWithdrawAmount.toFixed(2)]})]}),r.jsx(X,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthClicks})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthBindings})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.monthEarnings.toFixed(2)]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(cd,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),r.jsxs(Te,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalClicks.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalBindings.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.totalEarnings.toFixed(2)]})]})]}),r.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[r.jsx("span",{className:"text-gray-300",children:"点击转化率"}),r.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[a.conversionRate,"%"]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ln,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-white",children:a.totalDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-green-400",children:a.activeDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Ht(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[n.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:is.map(q=>{var Le,mt;return r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Le=q.id)==null?void 0:Le.slice(0,12),"..."]}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:q.userNickname}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.userPhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:(()=>{const Pt=q.productType||q.type,ut=q.description||"",nt=String(q.productId||q.sectionId||""),Nt=Pt==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||nt.toLowerCase().includes("vip");return Pt==="balance_recharge"?`余额充值 ¥${typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)}`:Nt?"超级个体开通费用":Pt==="fullbook"?`${q.bookName||"《底层逻辑》"} - 全本`:Pt==="match"?"匹配次数购买":`${q.bookName||"《底层逻辑》"} - ${q.sectionTitle||q.chapterTitle||`章节${q.productId||q.sectionId||""}`}`})()}),r.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Pt=q.productType||q.type,ut=q.description||"",nt=String(q.productId||q.sectionId||""),Nt=Pt==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||nt.toLowerCase().includes("vip");return Pt==="balance_recharge"?"余额充值":Nt?"超级个体":Pt==="fullbook"?"全书解锁":Pt==="match"?"功能权益":q.chapterTitle||"单章购买"})()})]})}),r.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)]}),r.jsx("td",{className:"p-4 text-gray-300",children:q.paymentMethod==="wechat"?"微信支付":q.paymentMethod==="balance"?"余额支付":q.paymentMethod==="alipay"?"支付宝":q.paymentMethod||"微信支付"}),r.jsx("td",{className:"p-4",children:q.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):q.status==="completed"||q.status==="paid"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):q.status==="pending"||q.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:q.refundReason,children:q.status==="refunded"&&q.refundReason?q.refundReason:"-"}),r.jsx("td",{className:"p-4 text-gray-300 text-sm",children:q.referrerId||q.referralCode?r.jsxs("span",{title:q.referralCode||q.referrerCode||q.referrerId||"",children:[q.referrerNickname||q.referralCode||q.referrerCode||((mt=q.referrerId)==null?void 0:mt.slice(0,8)),(q.referralCode||q.referrerCode)&&` (${q.referralCode||q.referrerCode})`]}):"-"}),r.jsx("td",{className:"p-4 text-[#FFD700]",children:q.referrerEarnings?`¥${(typeof q.referrerEarnings=="number"?q.referrerEarnings:parseFloat(String(q.referrerEarnings))).toFixed(2)}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:(q.status==="paid"||q.status==="completed")&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{ce(q),_("")},children:[r.jsx(Zg,{className:"w-3 h-3 mr-1"}),"退款"]})})]},q.id)})})]})}),t==="orders"&&r.jsx(Fs,{page:M,totalPages:Ct,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="bindings"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"active",children:"有效"}),r.jsx("option",{value:"converted",children:"已转化"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Ht(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[_n.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:_n.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-medium",children:q.refereeNickname||"匿名用户"}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.refereePhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white",children:q.referrerName||"-"}),r.jsx("p",{className:"text-gray-500 text-xs font-mono",children:q.referrerCode})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.boundAt?new Date(q.boundAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.expiresAt?new Date(q.expiresAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:as(q.status)}),r.jsx("td",{className:"p-4",children:q.commission?r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",q.commission.toFixed(2)]}):r.jsx("span",{className:"text-gray-500",children:"-"})})]},q.id))})]})}),t==="bindings"&&r.jsx(Fs,{page:M,totalPages:Ct,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="withdrawals"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待审核"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"rejected",children:"已拒绝"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[r.jsx(Fa,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),r.jsx(kt,{checked:ye,onCheckedChange:jn,disabled:ne,className:"data-[state=checked]:bg-[#38bdac]"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Ht(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[ls.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ls.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[q.userAvatar?r.jsx("img",{src:q.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(q.userName||q.name||"?").slice(0,1)}),r.jsx("p",{className:"text-white font-medium",children:q.userName||q.name})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",q.amount.toFixed(2)]})}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:q.method==="wechat"?"微信":"支付宝"})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-mono text-xs",children:q.account}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.name})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:as(q.status)}),r.jsx("td",{className:"p-4 max-w-[160px]",children:r.jsx("span",{className:`text-xs ${q.status==="rejected"||q.status==="failed"?"text-red-400":"text-gray-400"}`,title:q.remark,children:q.remark||"-"})}),r.jsxs("td",{className:"p-4 text-right",children:[q.status==="pending"&&r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsxs(X,{size:"sm",onClick:()=>In(q.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Yv,{className:"w-4 h-4 mr-1"}),"通过"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>Ft(q.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[r.jsx(oj,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(q.status==="pending_confirm"||q.status==="processing")&&r.jsx("div",{className:"flex gap-2 justify-end",children:r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>xn(q.id),className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/20",children:[r.jsx(Zg,{className:"w-4 h-4 mr-1"}),"撤回打款"]})})]})]},q.id))})]})}),t==="withdrawals"&&r.jsx(Fs,{page:M,totalPages:Ct,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="giftPay"&&r.jsx("div",{className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsx(Ye,{className:"text-white",children:"代付请求列表"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:it,onChange:q=>{zt(q.target.value),pe(1)},children:[r.jsx("option",{value:"",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待支付(旧)"}),r.jsx("option",{value:"pending_pay",children:"待发起人支付"}),r.jsx("option",{value:"paid",children:"已支付"}),r.jsx("option",{value:"refunded",children:"已退款"}),r.jsx("option",{value:"cancelled",children:"已取消"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>void Ht(),disabled:g,className:"border-gray-600 text-gray-300",children:[r.jsx($e,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})]})}),r.jsxs(Te,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"请求号"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"发起人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"商品/金额"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"份数/已领"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"付款人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"创建时间"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:J.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[r.jsx("td",{className:"p-4 font-mono text-xs text-gray-400",children:q.requestSn}),r.jsx("td",{className:"p-4",children:r.jsx("p",{className:"text-white text-sm",children:q.initiatorNick||q.initiatorUserId})}),r.jsxs("td",{className:"p-4",children:[r.jsxs("p",{className:"text-white",children:[q.productType," · ¥",q.amount.toFixed(2)]}),q.description&&r.jsx("p",{className:"text-gray-500 text-xs",children:q.description})]}),r.jsx("td",{className:"p-4 text-gray-400",children:(q.quantity??1)>1?`${q.quantity}份 / 已领${q.redeemedCount??0}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.payerNick||(q.payerUserId?q.payerUserId:"-")}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.status==="paid"?"bg-green-500/20 text-green-400 border-0":q.status==="pending"||q.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":q.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:q.status==="paid"?"已支付":q.status==="pending"||q.status==="pending_pay"?"待支付":q.status==="refunded"?"已退款":q.status==="cancelled"?"已取消":"已过期"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"})]},q.id))})]})}),J.length===0&&!g&&r.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),Se>20&&r.jsx("div",{className:"mt-4 flex justify-center",children:r.jsx(Fs,{page:ae,totalPages:Math.ceil(Se/20),total:Se,pageSize:20,onPageChange:pe,onPageSizeChange:()=>{}})})]})]})})]}),r.jsx(Ot,{open:!!z,onOpenChange:q=>!q&&ce(null),children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Dt,{children:r.jsx(Lt,{className:"text-white",children:"订单退款"})}),z&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof z.amount=="number"?z.amount.toFixed(2):parseFloat(String(z.amount||"0")).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:me,onChange:q=>_(q.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(nn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>ce(null),disabled:G,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:rs,disabled:G,children:G?"退款中...":"确认退款"})]})]})}),r.jsx(Ot,{open:!!A,onOpenChange:q=>!q&&Wn(),children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Dt,{children:r.jsx(Lt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:U,onChange:q=>D(q.target.value)})})]})]}),r.jsxs(nn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Wn,disabled:W,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ln,disabled:W||!U.trim(),children:W?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&r.jsx("div",{className:"-mx-8 -mt-6",children:r.jsx(Gk,{embedded:!0})})]})}function zP(){const[t,e]=b.useState([]),[n,s]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(0),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(!1);async function R(){var _,G,$,A,Y,U,D;i(!0),c(null);try{const W=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),le=await De(`/api/admin/withdrawals?${W}`);if(le!=null&&le.success){const ye=le.withdrawals||[];e(ye),j(le.total??((_=le.stats)==null?void 0:_.total)??ye.length),s({total:((G=le.stats)==null?void 0:G.total)??le.total??ye.length,pendingCount:(($=le.stats)==null?void 0:$.pendingCount)??0,pendingAmount:((A=le.stats)==null?void 0:A.pendingAmount)??0,successCount:((Y=le.stats)==null?void 0:Y.successCount)??0,successAmount:((U=le.stats)==null?void 0:U.successAmount)??0,failedCount:((D=le.stats)==null?void 0:D.failedCount)??0})}else c("加载提现记录失败")}catch(W){console.error("Load withdrawals error:",W),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{R()},[u,f,g]);const O=Math.ceil(N/g)||1;async function se(_){const G=t.find($=>$.id===_);if(G!=null&&G.userCommissionInfo&&G.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${G.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
-确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(_);try{const $=await Ot("/api/admin/withdrawals",{id:_,action:"approve"});$!=null&&$.success?R():te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{k(null)}}function ie(_){E(_),P("")}async function z(){const _=C;if(!_)return;const G=M.trim();if(!G){te.error("请填写拒绝原因");return}L(!0);try{const $=await Ot("/api/admin/withdrawals",{id:_,action:"reject",errorMessage:G});$!=null&&$.success?(te.success("已拒绝该提现申请"),E(null),P(""),R()):te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{L(!1)}}function ce(){C&&te.info("已取消操作"),E(null),P("")}function me(_){switch(_){case"pending":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return r.jsx(Ke,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:_})}}return r.jsxs("div",{className:"p-8 w-full",children:[o&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:o}),r.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),r.jsxs(X,{variant:"outline",onClick:R,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:r.jsx(Te,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),r.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",r.jsx("span",{className:"text-white font-medium",children:"90%"})]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),r.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),r.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),r.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),r.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),r.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(_=>r.jsx(X,{variant:u===_?"default":"outline",size:"sm",onClick:()=>h(_),className:u===_?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:_==="all"?"全部":_==="pending"?"待处理":_==="success"?"已完成":"已拒绝"},_))}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:a?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(_=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4 text-gray-400",children:new Date(_.createdAt??"").toLocaleString()}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[_.userAvatar?r.jsx("img",{src:_.userAvatar,alt:_.userName??"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(_.userName??"?").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-white",children:_.userName??"未知"}),r.jsx("p",{className:"text-xs text-gray-500",children:_.userPhone??_.referralCode??(_.userId??"").slice(0,10)})]})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(_.amount).toFixed(2)]})}),r.jsx("td",{className:"p-4",children:_.userCommissionInfo?r.jsxs("div",{className:"text-xs space-y-1",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",_.userCommissionInfo.totalCommission.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"已提现:"}),r.jsxs("span",{className:"text-gray-400",children:["¥",_.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"待审核:"}),r.jsxs("span",{className:"text-orange-400",children:["¥",_.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[r.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),r.jsxs("span",{className:_.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",_.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),r.jsx("td",{className:"p-4",children:me(_.status)}),r.jsx("td",{className:"p-4 max-w-[180px]",children:r.jsx("span",{className:`text-xs ${_.status==="rejected"||_.status==="failed"?"text-red-400":"text-gray-400"}`,title:_.remark,children:_.remark||"-"})}),r.jsx("td",{className:"p-4 text-gray-400",children:_.processedAt?new Date(_.processedAt).toLocaleString():"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:_.userConfirmedAt?r.jsxs("span",{className:"text-green-400",title:_.userConfirmedAt,children:["已确认 ",new Date(_.userConfirmedAt).toLocaleString()]}):"-"}),r.jsxs("td",{className:"p-4 text-right",children:[(_.status==="pending"||_.status==="pending_confirm")&&r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs(X,{size:"sm",onClick:()=>se(_.id),disabled:v===_.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[r.jsx(Of,{className:"w-4 h-4 mr-1"}),"批准"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>ie(_.id),disabled:v===_.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(_.status==="success"||_.status==="completed")&&_.transactionId&&r.jsx("span",{className:"text-xs text-gray-500 font-mono",children:_.transactionId})]})]},_.id))})]})}),r.jsx(Fs,{page:f,totalPages:O,total:N,pageSize:g,onPageChange:m,onPageSizeChange:_=>{y(_),m(1)}})]})})}),r.jsx(It,{open:!!C,onOpenChange:_=>!_&&ce(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:_=>P(_.target.value)})})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:H,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:z,disabled:H||!M.trim(),children:H?"提交中...":"确认拒绝"})]})]})})]})}var sg={exports:{}},rg={};/**
+确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(_);try{const $=await _t("/api/admin/withdrawals",{id:_,action:"approve"});$!=null&&$.success?R():te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{k(null)}}function ie(_){E(_),P("")}async function z(){const _=C;if(!_)return;const G=M.trim();if(!G){te.error("请填写拒绝原因");return}L(!0);try{const $=await _t("/api/admin/withdrawals",{id:_,action:"reject",errorMessage:G});$!=null&&$.success?(te.success("已拒绝该提现申请"),E(null),P(""),R()):te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{L(!1)}}function ce(){C&&te.info("已取消操作"),E(null),P("")}function me(_){switch(_){case"pending":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return r.jsx(Ke,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:_})}}return r.jsxs("div",{className:"p-8 w-full",children:[o&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:o}),r.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),r.jsxs(X,{variant:"outline",onClick:R,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:r.jsx(Te,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),r.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",r.jsx("span",{className:"text-white font-medium",children:"90%"})]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),r.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),r.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),r.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),r.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),r.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(_=>r.jsx(X,{variant:u===_?"default":"outline",size:"sm",onClick:()=>h(_),className:u===_?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:_==="all"?"全部":_==="pending"?"待处理":_==="success"?"已完成":"已拒绝"},_))}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:a?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(_=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4 text-gray-400",children:new Date(_.createdAt??"").toLocaleString()}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[_.userAvatar?r.jsx("img",{src:_.userAvatar,alt:_.userName??"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(_.userName??"?").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-white",children:_.userName??"未知"}),r.jsx("p",{className:"text-xs text-gray-500",children:_.userPhone??_.referralCode??(_.userId??"").slice(0,10)})]})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(_.amount).toFixed(2)]})}),r.jsx("td",{className:"p-4",children:_.userCommissionInfo?r.jsxs("div",{className:"text-xs space-y-1",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",_.userCommissionInfo.totalCommission.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"已提现:"}),r.jsxs("span",{className:"text-gray-400",children:["¥",_.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"待审核:"}),r.jsxs("span",{className:"text-orange-400",children:["¥",_.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[r.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),r.jsxs("span",{className:_.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",_.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),r.jsx("td",{className:"p-4",children:me(_.status)}),r.jsx("td",{className:"p-4 max-w-[180px]",children:r.jsx("span",{className:`text-xs ${_.status==="rejected"||_.status==="failed"?"text-red-400":"text-gray-400"}`,title:_.remark,children:_.remark||"-"})}),r.jsx("td",{className:"p-4 text-gray-400",children:_.processedAt?new Date(_.processedAt).toLocaleString():"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:_.userConfirmedAt?r.jsxs("span",{className:"text-green-400",title:_.userConfirmedAt,children:["已确认 ",new Date(_.userConfirmedAt).toLocaleString()]}):"-"}),r.jsxs("td",{className:"p-4 text-right",children:[(_.status==="pending"||_.status==="pending_confirm")&&r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs(X,{size:"sm",onClick:()=>se(_.id),disabled:v===_.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[r.jsx(Of,{className:"w-4 h-4 mr-1"}),"批准"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>ie(_.id),disabled:v===_.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(_.status==="success"||_.status==="completed")&&_.transactionId&&r.jsx("span",{className:"text-xs text-gray-500 font-mono",children:_.transactionId})]})]},_.id))})]})}),r.jsx(Fs,{page:f,totalPages:O,total:N,pageSize:g,onPageChange:m,onPageSizeChange:_=>{y(_),m(1)}})]})})}),r.jsx(Ot,{open:!!C,onOpenChange:_=>!_&&ce(),children:r.jsxs(Tt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Dt,{children:r.jsx(Lt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:_=>P(_.target.value)})})]})]}),r.jsxs(nn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:H,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:z,disabled:H||!M.trim(),children:H?"提交中...":"确认拒绝"})]})]})})]})}var sg={exports:{}},rg={};/**
* @license React
* use-sync-external-store-shim.production.js
*
@@ -600,19 +600,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var v1;function FP(){if(v1)return rg;v1=1;var t=$d();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),N=s({inst:{value:y,getSnapshot:g}}),j=N[0].inst,v=N[1];return i(function(){j.value=y,j.getSnapshot=g,u(j)&&v({inst:j})},[m,y,g]),a(function(){return u(j)&&v({inst:j}),m(function(){u(j)&&v({inst:j})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return rg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,rg}var N1;function Jk(){return N1||(N1=1,sg.exports=FP()),sg.exports}var Yk=Jk();function Xn(t){this.content=t}Xn.prototype={constructor:Xn,find:function(t){for(var e=0;e>1}};Xn.from=function(t){if(t instanceof Xn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xn(e)};function Qk(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(s),i=e.child(s);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=Qk(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function Xk(t,e,n,s){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:s};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,s-=u;continue}if(!o.sameMarkup(c))return{a:n,b:s};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&s(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),s,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&s&&(o?o=!1:i+=s),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),s.push(c),a+=c.nodeSize),o=u}return new Ne(s,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-s.nodeSize;return a[e]=n,new Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),i=s+a.nodeSize;if(i>=e)return i==e?nh(n+1,i):nh(n,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,s=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),s=!0),n&&n.push(i)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;ns.type.rank-a.type.rank),n}};Vt.none=[];class zh extends Error{}class Oe{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=eS(this.content,e+this.openStart,n);return s&&new Oe(s,this.openStart,this.openEnd)}removeBetween(e,n){return new Oe(Zk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Oe.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Oe(Ne.fromJSON(e,n.content),s,a)}static maxOpen(e,n=!0){let s=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Oe(e,s,a)}}Oe.empty=new Oe(Ne.empty,0,0);function Zk(t,e,n){let{index:s,offset:a}=t.findIndex(e),i=t.maybeChild(s),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,i.copy(Zk(i.content,e-a-1,n-a-1)))}function eS(t,e,n,s){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return s&&!s.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=eS(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function $P(t,e,n){if(n.openStart>t.depth)throw new zh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zh("Inconsistent open depths");return tS(t,e,n,0)}function tS(t,e,n,s){let a=t.index(s),i=t.node(s);if(a==e.index(s)&&s=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ud(t,e,n,s){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Io(t.nodeAfter,s),i++));for(let c=i;ca&&ox(t,e,a+1),o=s.depth>a&&ox(n,s,a+1),c=[];return ud(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(nS(i,o),Io(Ro(i,sS(t,e,n,s,a+1)),c)):(i&&Io(Ro(i,Fh(t,e,a+1)),c),ud(e,n,a,c),o&&Io(Ro(o,Fh(n,s,a+1)),c)),ud(s,null,a,c),new Ne(c)}function Fh(t,e,n){let s=[];if(ud(null,t,n,s),t.depth>n){let a=ox(t,e,n+1);Io(Ro(a,Fh(t,e,n+1)),s)}return ud(e,null,n,s),new Ne(s)}function BP(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Ed{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=e.child(n);return s?e.child(n).cut(s):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new $h(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(s.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Ed(n,s,i)}static resolveCached(e,n){let s=w1.get(e);if(s)for(let i=0;ie&&this.nodesBetween(e,n,i=>(s.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),rS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=Ne.empty,a=0,i=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;un.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let a=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,s);return i.type.checkAttrs(i.attrs),i}};Va.prototype.text=void 0;class Bh extends Va{constructor(e,n,s,a){if(super(e,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function rS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new UP(e,n);if(s.next==null)return Fo.empty;let a=aS(s);s.next&&s.err("Unexpected trailing text");let i=XP(QP(a));return ZP(i,s),i}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let a=0;a{let i=a+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return i}).join(`
-`)}}Fo.empty=new Fo(!0);class UP{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function aS(t){let e=[];do e.push(KP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KP(t){let e=[];do e.push(qP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qP(t){let e=YP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=GP(t,e);else break;return e}function j1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function GP(t,e){let n=j1(t),s=n;return t.eat(",")&&(t.next!="}"?s=j1(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function JP(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function YP(t){if(t.eat("(")){let e=aS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=JP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function QP(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function s(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return s(c,u),a(i(o.expr,u),u),[s(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[s(u)]}else{if(o.type=="opt")return[s(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[s.join(",")]=new Fo(s.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lS(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Va(this,this.computeAttrs(e),Ne.from(n),Vt.setFrom(s))}createChecked(e=null,n,s){return n=Ne.from(n),this.checkContent(n),new Va(this,this.computeAttrs(e),n,Vt.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new Va(this,e,n.append(i),Vt.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;ns[i]=new uS(i,n,o));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function eO(t,e,n){let s=n.split("|");return a=>{let i=a===null?"null":typeof a;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${i}`)}}class tO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?eO(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Hf{constructor(e,n,s,a){this.name=e,this.rank=n,this.schema=s,this.spec=a,this.attrs=dS(e,a.attrs),this.excluded=null;let i=oS(this.attrs);this.instance=i?new Vt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Vt(this,lS(this.attrs,e))}static compile(e,n){let s=Object.create(null),a=0;return e.forEach((i,o)=>s[i]=new Hf(i,a++,n,o)),s}removeFromSet(e){for(var n=0;n-1}}class hS{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in e)n[a]=e[a];n.nodes=Xn.from(e.nodes),n.marks=Xn.from(e.marks||{}),this.nodes=S1.compile(this.spec.nodes,this),this.marks=Hf.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=s[o]||(s[o]=Fo.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?C1(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let a in this.marks){let i=this.marks[a],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:C1(this,o.split(" "))}this.nodeFromJSON=a=>Va.fromJSON(this,a),this.markFromJSON=a=>Vt.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof S1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,a)}text(e,n){let s=this.nodes.text;return new Bh(s,s.defaultAttrs,e,Vt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function C1(t,e){let n=[];for(let s=0;s-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function nO(t){return t.tag!=null}function sO(t){return t.style!=null}class Oi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(nO(a))this.tags.push(a);else if(sO(a)){let i=/[^=]*/.exec(a.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let s=new T1(this,n,!1);return s.addAll(e,Vt.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new T1(this,n,!0);return s.addAll(e,Vt.none,n.from,n.to),Oe.maxOpen(s.finish())}matchTag(e,n,s){for(let a=s?this.tags.indexOf(s)+1:0;ae.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function s(a){let i=a.priority==null?50:a.priority,o=0;for(;o{s(o=M1(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{s(o=M1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Oi(e,Oi.schemaRules(e)))}}const fS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},pS={ol:!0,ul:!0},Td=1,cx=2,hd=4;function E1(t,e,n){return e!=null?(e?Td:0)|(e==="full"?cx:0):t&&t.whitespace=="pre"?Td|cx:n&~hd}class sh{constructor(e,n,s,a,i,o){this.type=e,this.attrs=n,this.marks=s,this.solid=a,this.options=o,this.content=[],this.activeMarks=Vt.none,this.match=i||(o&hd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(e.type))?(this.match=s,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Td)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class T1{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=E1(null,n.preserveWhitespace,0)|(s?hd:0);a?i=new sh(a.type,a.attrs,Vt.none,!0,n.topMatch||a.type.contentMatch,o):s?i=new sh(null,null,Vt.none,!0,null,o):i=new sh(e.schema.topNodeType,null,Vt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,a=this.top,i=a.options&cx?"full":this.localPreserveWS||(a.options&Td)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(i)if(i==="full")s=s.replace(/\r\n?/g,`
+ */var N1;function FP(){if(N1)return rg;N1=1;var t=$d();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),N=s({inst:{value:y,getSnapshot:g}}),j=N[0].inst,v=N[1];return i(function(){j.value=y,j.getSnapshot=g,u(j)&&v({inst:j})},[m,y,g]),a(function(){return u(j)&&v({inst:j}),m(function(){u(j)&&v({inst:j})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return rg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,rg}var w1;function Jk(){return w1||(w1=1,sg.exports=FP()),sg.exports}var Yk=Jk();function Yn(t){this.content=t}Yn.prototype={constructor:Yn,find:function(t){for(var e=0;e>1}};Yn.from=function(t){if(t instanceof Yn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yn(e)};function Qk(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(s),i=e.child(s);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=Qk(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function Xk(t,e,n,s){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:s};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,s-=u;continue}if(!o.sameMarkup(c))return{a:n,b:s};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&s(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),s,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&s&&(o?o=!1:i+=s),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),s.push(c),a+=c.nodeSize),o=u}return new Ne(s,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-s.nodeSize;return a[e]=n,new Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),i=s+a.nodeSize;if(i>=e)return i==e?nh(n+1,i):nh(n,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,s=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),s=!0),n&&n.push(i)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;ns.type.rank-a.type.rank),n}};Vt.none=[];class zh extends Error{}class Oe{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=eS(this.content,e+this.openStart,n);return s&&new Oe(s,this.openStart,this.openEnd)}removeBetween(e,n){return new Oe(Zk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Oe.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Oe(Ne.fromJSON(e,n.content),s,a)}static maxOpen(e,n=!0){let s=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Oe(e,s,a)}}Oe.empty=new Oe(Ne.empty,0,0);function Zk(t,e,n){let{index:s,offset:a}=t.findIndex(e),i=t.maybeChild(s),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,i.copy(Zk(i.content,e-a-1,n-a-1)))}function eS(t,e,n,s){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return s&&!s.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=eS(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function $P(t,e,n){if(n.openStart>t.depth)throw new zh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zh("Inconsistent open depths");return tS(t,e,n,0)}function tS(t,e,n,s){let a=t.index(s),i=t.node(s);if(a==e.index(s)&&s=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ud(t,e,n,s){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Io(t.nodeAfter,s),i++));for(let c=i;ca&&lx(t,e,a+1),o=s.depth>a&&lx(n,s,a+1),c=[];return ud(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(nS(i,o),Io(Ro(i,sS(t,e,n,s,a+1)),c)):(i&&Io(Ro(i,Fh(t,e,a+1)),c),ud(e,n,a,c),o&&Io(Ro(o,Fh(n,s,a+1)),c)),ud(s,null,a,c),new Ne(c)}function Fh(t,e,n){let s=[];if(ud(null,t,n,s),t.depth>n){let a=lx(t,e,n+1);Io(Ro(a,Fh(t,e,n+1)),s)}return ud(e,null,n,s),new Ne(s)}function BP(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Ed{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=e.child(n);return s?e.child(n).cut(s):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new $h(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(s.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Ed(n,s,i)}static resolveCached(e,n){let s=j1.get(e);if(s)for(let i=0;ie&&this.nodesBetween(e,n,i=>(s.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),rS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=Ne.empty,a=0,i=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;un.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let a=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,s);return i.type.checkAttrs(i.attrs),i}};Va.prototype.text=void 0;class Bh extends Va{constructor(e,n,s,a){if(super(e,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function rS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new UP(e,n);if(s.next==null)return Fo.empty;let a=aS(s);s.next&&s.err("Unexpected trailing text");let i=XP(QP(a));return ZP(i,s),i}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let a=0;a{let i=a+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return i}).join(`
+`)}}Fo.empty=new Fo(!0);class UP{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function aS(t){let e=[];do e.push(KP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KP(t){let e=[];do e.push(qP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qP(t){let e=YP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=GP(t,e);else break;return e}function k1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function GP(t,e){let n=k1(t),s=n;return t.eat(",")&&(t.next!="}"?s=k1(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function JP(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function YP(t){if(t.eat("(")){let e=aS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=JP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function QP(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function s(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return s(c,u),a(i(o.expr,u),u),[s(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[s(u)]}else{if(o.type=="opt")return[s(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[s.join(",")]=new Fo(s.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lS(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Va(this,this.computeAttrs(e),Ne.from(n),Vt.setFrom(s))}createChecked(e=null,n,s){return n=Ne.from(n),this.checkContent(n),new Va(this,this.computeAttrs(e),n,Vt.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new Va(this,e,n.append(i),Vt.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;ns[i]=new uS(i,n,o));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function eO(t,e,n){let s=n.split("|");return a=>{let i=a===null?"null":typeof a;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${i}`)}}class tO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?eO(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Hf{constructor(e,n,s,a){this.name=e,this.rank=n,this.schema=s,this.spec=a,this.attrs=dS(e,a.attrs),this.excluded=null;let i=oS(this.attrs);this.instance=i?new Vt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Vt(this,lS(this.attrs,e))}static compile(e,n){let s=Object.create(null),a=0;return e.forEach((i,o)=>s[i]=new Hf(i,a++,n,o)),s}removeFromSet(e){for(var n=0;n-1}}class hS{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in e)n[a]=e[a];n.nodes=Yn.from(e.nodes),n.marks=Yn.from(e.marks||{}),this.nodes=C1.compile(this.spec.nodes,this),this.marks=Hf.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=s[o]||(s[o]=Fo.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?E1(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let a in this.marks){let i=this.marks[a],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:E1(this,o.split(" "))}this.nodeFromJSON=a=>Va.fromJSON(this,a),this.markFromJSON=a=>Vt.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof C1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,a)}text(e,n){let s=this.nodes.text;return new Bh(s,s.defaultAttrs,e,Vt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function E1(t,e){let n=[];for(let s=0;s-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function nO(t){return t.tag!=null}function sO(t){return t.style!=null}class Oi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(nO(a))this.tags.push(a);else if(sO(a)){let i=/[^=]*/.exec(a.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let s=new M1(this,n,!1);return s.addAll(e,Vt.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new M1(this,n,!0);return s.addAll(e,Vt.none,n.from,n.to),Oe.maxOpen(s.finish())}matchTag(e,n,s){for(let a=s?this.tags.indexOf(s)+1:0;ae.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function s(a){let i=a.priority==null?50:a.priority,o=0;for(;o{s(o=A1(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{s(o=A1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Oi(e,Oi.schemaRules(e)))}}const fS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},pS={ol:!0,ul:!0},Td=1,dx=2,hd=4;function T1(t,e,n){return e!=null?(e?Td:0)|(e==="full"?dx:0):t&&t.whitespace=="pre"?Td|dx:n&~hd}class sh{constructor(e,n,s,a,i,o){this.type=e,this.attrs=n,this.marks=s,this.solid=a,this.options=o,this.content=[],this.activeMarks=Vt.none,this.match=i||(o&hd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(e.type))?(this.match=s,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Td)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class M1{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=T1(null,n.preserveWhitespace,0)|(s?hd:0);a?i=new sh(a.type,a.attrs,Vt.none,!0,n.topMatch||a.type.contentMatch,o):s?i=new sh(null,null,Vt.none,!0,null,o):i=new sh(e.schema.topNodeType,null,Vt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,a=this.top,i=a.options&dx?"full":this.localPreserveWS||(a.options&Td)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(i)if(i==="full")s=s.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let u=0;u!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,s,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let u=this.enter(o,n.attrs||null,s,n.preserveWhitespace);u&&(i=!0,s=u)}else{let u=this.parser.schema.marks[n.mark];s=s.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,s,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,s,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,s),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,s,a){let i=s||0;for(let o=s?e.childNodes[s]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,s){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(s)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):A1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new sh(e,n,u,a,null,c)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Td)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)e+=s[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:s&&u>=i?s.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function aO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&pS.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function iO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function M1(t){let e={};for(let n in t)e[n]=t[n];return e}function A1(t,e){let n=e.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,n,s={}){let a=this.marks[e.type.name];return a&&Nh(ig(s),a(e,n),null,e.attrs)}static renderSpec(e,n,s=null,a){return Nh(e,n,s,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Jo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=I1(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return I1(e.marks)}}function I1(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function ig(t){return t.document||window.document}const R1=new WeakMap;function oO(t){let e=R1.get(t);return e===void 0&&R1.set(t,e=lO(t)),e}function lO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:N}=Nh(t,g,n,s);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const mS=65535,gS=Math.pow(2,16);function cO(t,e){return t+e*gS}function P1(t){return t&mS}function dO(t){return(t-(t&mS))/gS}const xS=1,yS=2,wh=4,bS=8;class dx{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&bS)>0}get deletedBefore(){return(this.delInfo&(xS|wh))>0}get deletedAfter(){return(this.delInfo&(yS|wh))>0}get deletedAcross(){return(this.delInfo&wh)>0}}class Gs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Gs.empty)return Gs.empty}recover(e){let n=0,s=P1(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(s)return y;let N=e==(n<0?u:m)?null:cO(c/3,e-u),j=e==u?yS:e==m?xS:wh;return(n<0?e!=u:e!=m)&&(j|=bS),new dx(y,j,N)}a+=f-h}return s?e+a:new dx(e+a,0,null)}touches(e,n){let s=0,a=P1(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;s+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let e=new Md;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;si&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,i)}invert(){return new Ir(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Mi(n.pos,s.pos,this.mark)}merge(e){return e instanceof Mi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mi(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("addMark",Mi);class Ir extends vs{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new Oe(N0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,s)}invert(){return new Mi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Ir(n.pos,s.pos,this.mark)}merge(e){return e instanceof Ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ir(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ir(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("removeMark",Ir);class Ai extends vs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Tn.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Tn.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;as.pos?null:new Hn(n.pos,s.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Hn(n.from,n.to,n.gapFrom,n.gapTo,Oe.fromJSON(e,n.slice),n.insert,!!n.structure)}}vs.jsonID("replaceAround",Hn);function ux(t,e,n){let s=t.resolve(e),a=n-e,i=s.depth;for(;a>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,a--;if(a>0){let o=s.node(i).maybeChild(s.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function uO(t,e,n,s){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!s.isInSet(m)&&f.type.allowsMarkType(s.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),N=s.addToSet(m);for(let j=0;jt.step(u)),i.forEach(u=>t.step(u))}function hO(t,e,n,s){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(s instanceof Hf){let h=o.marks,f;for(;f=s.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else s?s.isInSet(o.marks)&&(u=[s]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new Ir(o.from,o.to,o.style)))}function w0(t,e,n,s=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function fO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ic(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,a=0,i=0;;--s){let o=t.$from.node(s),c=t.$from.index(s)+a,u=t.$to.indexAfter(s)-i;if(sn;N--)j||s.index(N)>0?(j=!0,f=Ne.from(s.node(N).copy(f)),m++):u--;let g=Ne.empty,y=0;for(let N=i,j=!1;N>n;N--)j||a.after(N+1)=0;o--){if(s.size){let c=n[o].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Ne.from(n[o].type.create(n[o].attrs,s))}let a=e.start,i=e.end;t.step(new Hn(a,i,a,i,new Oe(s,0,0),n.length,!0))}function yO(t,e,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(s,u)&&bO(t.doc,t.mapping.slice(i).map(c),s)){let h=null;if(s.schema.linebreakReplacement){let y=s.whitespace=="pre",N=!!s.contentMatch.matchType(s.schema.linebreakReplacement);y&&!N?h=!1:!y&&N&&(h=!0)}h===!1&&NS(t,o,c,i),w0(t,t.mapping.slice(i).map(c,1),s,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new Hn(m,g,m+1,g-1,new Oe(Ne.from(s.create(u,null,o.marks)),0,0),1,!0)),h===!0&&vS(t,o,c,i),!1}})}function vS(t,e,n,s){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(s).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function NS(t,e,n,s){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(s).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
-`))}})}function bO(t,e,n){let s=t.resolve(e),a=s.index();return s.parent.canReplaceWith(a,a+1,n)}function vO(t,e,n,s,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(s,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Hn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Oe(Ne.from(o),0,0),1,!0))}function Ha(t,e,n=1,s){let a=t.resolve(e),i=a.depth-n,o=s&&s[s.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),g=a.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),N=s&&s[f+1];N&&(y=y.replaceChild(0,N.type.create(N.attrs)));let j=s&&s[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=a.indexAfter(i),u=s&&s[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function NO(t,e,n=1,s){let a=t.doc.resolve(e),i=Ne.empty,o=Ne.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ne.from(a.node(c).copy(i));let f=s&&s[h];o=Ne.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Vn(e,e,new Oe(i.append(o),n,n),!0))}function Gi(t,e){let n=t.resolve(e),s=n.index();return wS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function wO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let a=0;a0?(i=s.node(a+1),c++,o=s.node(a).maybeChild(c)):(i=s.node(a).maybeChild(c-1),o=s.node(a+1)),i&&!i.isTextblock&&wS(i,o)&&s.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?s.before(a):s.after(a)}}function jO(t,e,n){let s=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?s=!1:!f&&m&&(s=!0)}let c=t.steps.length;if(s===!1){let f=t.doc.resolve(e+n);NS(t,f.node(),f.before(),c)}o.inlineContent&&w0(t,e+n-1,o,i.node().contentMatchAt(i.index()),s==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Vn(h,u.map(e+n,-1),Oe.empty,!0)),s===!0){let f=t.doc.resolve(h);vS(t,f.node(),f.before(),t.steps.length)}return t}function kO(t,e,n){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),n))return e;if(s.parentOffset==0)for(let a=s.depth-1;a>=0;a--){let i=s.index(a);if(s.node(a).canReplaceWith(i,i,n))return s.before(a+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let a=s.depth-1;a>=0;a--){let i=s.indexAfter(a);if(s.node(a).canReplaceWith(i,i,n))return s.after(a+1);if(i=0;o--){let c=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,u=s.index(o)+(c>0?1:0),h=s.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?s.pos:c<0?s.before(o+1):s.after(o+1)}return null}function Uf(t,e,n=e,s=Oe.empty){if(e==n&&!s.size)return null;let a=t.resolve(e),i=t.resolve(n);return kS(a,i,s)?new Vn(e,n,s):new SO(a,i,s).fit()}function kS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class SO{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=Ne.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ne.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,a=this.close(e<0?this.$to:s.doc.resolve(e));if(!a)return null;let i=this.placed,o=s.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new Oe(i,o,c);return e>-1?new Hn(s.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||s.pos!=this.$to.pos?new Vn(s.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,a=this.unplaced.openEnd;s1&&(a=0),i.type.spec.isolating&&a<=s){e=s;break}n=i.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let a,i=null;s?(i=lg(this.unplaced.content,s-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(Ne.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Oe(e,n+1,Math.max(s,a.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Oe(ed(e,n-1,1),n-1,i?n-1:s)}else this.unplaced=new Oe(ed(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let j=0;j1||u==0||j.content.size)&&(m=v,f.push(SS(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let N=h==c.childCount;N||(y=-1),this.placed=td(this.placed,n,Ne.from(f)),this.frontier[n].match=m,N&&y<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,v=c;j1&&a==this.$to.end(--s);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=cg(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=td(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let a=e.node(s),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(s));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,s){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=td(this.placed,this.depth,Ne.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ne.empty,!0);n.childCount&&(this.placed=td(this.placed,this.frontier.length,n))}}function ed(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ed(t.firstChild.content,e-1,n)))}function td(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(td(t.lastChild.content,e-1,n)))}function lg(t,e){for(let n=0;n1&&(s=s.replaceChild(0,SS(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(Ne.empty,!0)))),t.copy(s)}function cg(t,e,n,s,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=s.fillBefore(i.content,!0,o);return c&&!CO(n,i.content,o)?c:null}function CO(t,e,n){for(let s=n;s0;g--,y--){let N=a.node(g).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=s.openStart;for(let g=s.content,y=0;;y++){let N=g.firstChild;if(h.push(N),y==s.openStart)break;g=N.content}for(let g=f-1;g>=0;g--){let y=h[g],N=EO(y.type);if(N&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(N||!y.type.isTextblock)break}for(let g=s.openStart;g>=0;g--){let y=(g+f+1)%(s.openStart+1),N=h[y];if(N)for(let j=0;j=0&&(t.replace(e,n,s),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function CS(t,e,n,s,a){if(es){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ne.empty,!0))}return t}function MO(t,e,n,s){if(!s.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=kO(t.doc,e,s.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Oe(Ne.from(s),0,0))}function AO(t,e,n){let s=t.doc.resolve(e),a=t.doc.resolve(n),i=ES(s,a);for(let o=0;o0&&(u||s.node(c-1).canReplace(s.index(c-1),a.indexAfter(c-1))))return t.delete(s.before(c),a.after(c))}for(let o=1;o<=s.depth&&o<=a.depth;o++)if(e-s.start(o)==s.depth-o&&n>s.end(o)&&a.end(o)-n!=a.depth-o&&s.start(o-1)==a.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),a.index(o-1)))return t.delete(s.before(o),n);t.delete(e,n)}function ES(t,e){let n=[],s=Math.min(t.depth,e.depth);for(let a=s;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class Bl extends vs{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return Tn.fail("No node at attribute step's position");let s=Object.create(null);for(let i in n.attrs)s[i]=n.attrs[i];s[this.attr]=this.value;let a=n.type.create(s,null,n.marks);return Tn.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(a),0,n.isLeaf?0:1))}getMap(){return Gs.empty}invert(e){return new Bl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Bl(n.pos,n.attr,n.value)}}vs.jsonID("attr",Bl);class Ad extends vs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return Tn.ok(s)}getMap(){return Gs.empty}invert(e){return new Ad(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ad(n.attr,n.value)}}vs.jsonID("docAttr",Ad);let Ul=class extends Error{};Ul=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ul.prototype=Object.create(Error.prototype);Ul.prototype.constructor=Ul;Ul.prototype.name="TransformError";class k0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Md}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ul(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let s=0;s{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,s=Oe.empty){let a=Uf(this.doc,e,n,s);return a&&this.step(a),this}replaceWith(e,n,s){return this.replace(e,n,new Oe(Ne.from(s),0,0))}delete(e,n){return this.replace(e,n,Oe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,s){return TO(this,e,n,s),this}replaceRangeWith(e,n,s){return MO(this,e,n,s),this}deleteRange(e,n){return AO(this,e,n),this}lift(e,n){return pO(this,e,n),this}join(e,n=1){return jO(this,e,n),this}wrap(e,n){return xO(this,e,n),this}setBlockType(e,n=e,s,a=null){return yO(this,e,n,s,a),this}setNodeMarkup(e,n,s=null,a){return vO(this,e,n,s,a),this}setNodeAttribute(e,n,s){return this.step(new Bl(e,n,s)),this}setDocAttribute(e,n){return this.step(new Ad(e,n)),this}addNodeMark(e,n){return this.step(new Ai(e,n)),this}removeNodeMark(e,n){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(n instanceof Vt)n.isInSet(s.marks)&&this.step(new $o(e,n));else{let a=s.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new $o(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,s){return NO(this,e,n,s),this}addMark(e,n,s){return uO(this,e,n,s),this}removeMark(e,n,s){return hO(this,e,n,s),this}clearIncompatible(e,n,s){return w0(this,e,n,s),this}}const dg=Object.create(null);class nt{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new TS(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let o=n<0?Al(e.node(0),e.node(i),e.before(i+1),e.index(i),n,s):Al(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,s);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qs(e.node(0))}static atStart(e){return Al(e,e,0,0,1)||new Qs(e)}static atEnd(e){return Al(e,e,e.content.size,e.childCount,-1)||new Qs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=dg[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in dg)throw new RangeError("Duplicate use of selection JSON ID "+e);return dg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Xe.between(this.$anchor,this.$head).getBookmark()}}nt.prototype.visible=!0;class TS{constructor(e,n){this.$from=e,this.$to=n}}let D1=!1;function L1(t){!D1&&!t.parent.inlineContent&&(D1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Xe extends nt{constructor(e,n=e){L1(e),L1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return nt.near(s);let a=e.resolve(n.map(this.anchor));return new Xe(a.parent.inlineContent?a:s,s)}replace(e,n=Oe.empty){if(super.replace(e,n),n==Oe.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof Xe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Kf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let a=e.resolve(n);return new this(a,s==n?a:e.resolve(s))}static between(e,n,s){let a=e.pos-n.pos;if((!s||a)&&(s=a>=0?1:-1),!n.parent.inlineContent){let i=nt.findFrom(n,s,!0)||nt.findFrom(n,-s,!0);if(i)n=i.$head;else return nt.near(n,s)}return e.parent.inlineContent||(a==0?e=n:(e=(nt.findFrom(e,-s,!0)||nt.findFrom(e,s,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&Qe.isSelectable(c))return Qe.create(t,n-(a<0?c.nodeSize:0))}else{let u=Al(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function _1(t,e,n){let s=t.steps.length-1;if(s{o==null&&(o=f)}),t.setSelection(nt.near(t.doc.resolve(o),n))}const z1=1,rh=2,F1=4;class RO extends k0{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=rh,this}ensureMarks(e){return Vt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&rh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~rh,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let s=this.selection;return n&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||Vt.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,s){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(s==null&&(s=n),!e)return this.deleteRange(n,s);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=s==n?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(n,s,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(nt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=F1,this}get scrolledIntoView(){return(this.updated&F1)>0}}function $1(t,e){return!e||!t?t:t.bind(e)}class nd{constructor(e,n,s){this.name=e,this.init=$1(n.init,s),this.apply=$1(n.apply,s)}}const PO=[new nd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new nd("selection",{init(t,e){return t.selection||nt.atStart(e.doc)},apply(t){return t.selection}}),new nd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new nd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ug{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=PO.slice(),n&&n.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new nd(s.key,s.spec.state,s))})}}class zl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[s],i=a.spec.state;i&&i.toJSON&&(n[s]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,s){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new ug(e.schema,e.plugins),i=new zl(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Va.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=nt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let c in s){let u=s[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function MS(t,e,n){for(let s in t){let a=t[s];a instanceof Function?a=a.bind(e):s=="handleDOMEvents"&&(a=MS(a,e,{})),n[s]=a}return n}class qt{constructor(e){this.spec=e,this.props={},e.props&&MS(e.props,this,this.props),this.key=e.key?e.key.key:AS("plugin")}getState(e){return e[this.key]}}const hg=Object.create(null);function AS(t){return t in hg?t+"$"+ ++hg[t]:(hg[t]=0,t+"$")}class rn{constructor(e="key"){this.key=AS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const C0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const RS=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);if(!a){let o=s.blockRange(),c=o&&ic(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(BS(t,a,e,-1))return!0;if(s.parent.content.size==0&&(Kl(i,"end")||Qe.isSelectable(i)))for(let o=s.depth;;o--){let c=Uf(t.doc,s.before(o),s.after(o),Oe.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==s.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},OO=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);return a?PS(t,a,e):!1},DO=(t,e,n)=>{let s=DS(t,n);if(!s)return!1;let a=T0(s);return a?PS(t,a,e):!1};function PS(t,e,n){let s=e.nodeBefore,a=s,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=Uf(t.doc,i,u,Oe.empty);if(!h||h.from!=i||h instanceof Vn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(Xe.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Kl(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const OS=(t,e,n)=>{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;i=E0(s)}let o=i&&i.nodeBefore;return!o||!Qe.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qe.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function E0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function DS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let s=DS(t,n);if(!s)return!1;let a=T0(s);if(!a)return!1;let i=a.nodeAfter;if(BS(t,a,e,1))return!0;if(s.parent.content.size==0&&(Kl(i,"start")||Qe.isSelectable(i))){let o=Uf(t.doc,s.before(),s.after(),Oe.empty);if(o&&o.slice.size{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,s=n instanceof Qe,a;if(s){if(n.node.isTextblock||!Gi(t.doc,n.from))return!1;a=n.from}else if(a=Wf(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);s&&i.setSelection(Qe.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},_O=(t,e)=>{let n=t.selection,s;if(n instanceof Qe){if(n.node.isTextblock||!Gi(t.doc,n.to))return!1;s=n.to}else if(s=Wf(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},zO=(t,e)=>{let{$from:n,$to:s}=t.selection,a=n.blockRange(s),i=a&&ic(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},zS=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(`
-`).scrollIntoView()),!0)};function M0(t){for(let e=0;e{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=M0(a.contentMatchAt(i));if(!o||!a.canReplaceWith(i,i,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(nt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},FS=(t,e)=>{let n=t.selection,{$from:s,$to:a}=n;if(n instanceof Qs||s.parent.inlineContent||a.parent.inlineContent)return!1;let i=M0(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!s.parentOffset&&a.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ha(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let s=n.blockRange(),a=s&&ic(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)};function $O(t){return(e,n)=>{let{$from:s,$to:a}=e.selection;if(e.selection instanceof Qe&&e.selection.node.isBlock)return!s.parentOffset||!Ha(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=s.depth;;y--)if(s.node(y).isBlock){u=s.end(y)==s.pos+(s.depth-y),h=s.start(y)==s.pos-(s.depth-y),c=M0(s.node(y-1).contentMatchAt(s.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof Xe||e.selection instanceof Qs)&&f.deleteSelection();let m=f.mapping.map(s.pos),g=Ha(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=Ha(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&s.node(o).type!=c){let y=f.mapping.map(s.before(o)),N=f.doc.resolve(y);c&&s.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(s.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const BO=$O(),VO=(t,e)=>{let{$from:n,to:s}=t.selection,a,i=n.sharedDepth(s);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(Qe.create(t.doc,a))),!0)};function HO(t,e,n){let s=e.nodeBefore,a=e.nodeAfter,i=e.index();return!s||!a||!s.type.compatibleContent(a.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||Gi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function BS(t,e,n,s){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&HO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,N=Ne.empty;for(let k=o.length-1;k>=0;k--)N=Ne.from(o[k].create(null,N));N=Ne.from(a.copy(N));let j=t.tr.step(new Hn(e.pos-1,y,e.pos,y,new Oe(N,1,0),o.length,!0)),v=j.doc.resolve(y+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&Gi(j.doc,v.pos)&&j.join(v.pos),n(j.scrollIntoView())}return!0}let f=i.type.spec.isolating||s>0&&u?null:nt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&ic(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Kl(i,"start",!0)&&Kl(a,"end")){let y=a,N=[];for(;N.push(y),!y.isTextblock;)y=y.lastChild;let j=i,v=1;for(;!j.isTextblock;j=j.firstChild)v++;if(y.canReplace(y.childCount,y.childCount,j.content)){if(n){let k=Ne.empty;for(let E=N.length-1;E>=0;E--)k=Ne.from(N[E].copy(k));let C=t.tr.step(new Hn(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Oe(k,N.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function VS(t){return function(e,n){let s=e.selection,a=t<0?s.$from:s.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(Xe.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const WO=VS(-1),UO=VS(1);function KO(t,e=null){return function(n,s){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&j0(o,t,e);return c?(s&&s(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function B1(t,e=null){return function(n,s){let a=!1;for(let i=0;i{if(a)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)a=!0;else{let f=n.doc.resolve(h),m=f.index();a=f.parent.canReplaceWith(m,m+1,t)}})}if(!a)return!1;if(s){let i=n.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);i=new $h(u,u,e.depth),e.endIndex=0;f--)i=Ne.from(n[f].type.create(n[f].attrs,i));t.step(new Hn(e.start-(s?2:0),e.end,e.start,e.end,new Oe(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?s.node(i.depth-1).type==t?QO(e,n,t,i):XO(e,n,i):!0:!1}}function QO(t,e,n,s){let a=t.tr,i=s.end,o=s.$to.end(s.depth);ij;N--)y-=a.child(N).nodeSize,s.delete(y-1,y+1);let i=s.doc.resolve(n.start),o=i.nodeAfter;if(s.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ne.empty:Ne.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return s.step(new Hn(m-(c?1:0),g+(u?1:0),m+1,g-1,new Oe((c?Ne.empty:Ne.from(a.copy(Ne.empty))).append(u?Ne.empty:Ne.from(a.copy(Ne.empty))),c?0:1,u?0:1),c?0:1)),e(s.scrollIntoView()),!0}function ZO(t){return function(e,n){let{$from:s,$to:a}=e.selection,i=s.blockRange(a,h=>h.childCount>0&&h.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=Ne.from(h?t.create():null),m=new Oe(Ne.from(t.create(null,Ne.from(c.type.create(null,f)))),h?3:1,0),g=i.start,y=i.end;n(e.tr.step(new Hn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const es=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ql=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let hx=null;const _a=function(t,e,n){let s=hx||(hx=document.createRange());return s.setEnd(t,n??t.nodeValue.length),s.setStart(t,e||0),s},eD=function(){hx=null},Bo=function(t,e,n,s){return n&&(V1(t,e,n,s,-1)||V1(t,e,n,s,1))},tD=/^(img|br|input|textarea|hr)$/i;function V1(t,e,n,s,a){for(var i;;){if(t==n&&e==s)return!0;if(e==(a<0?0:hr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ud(t)||tD.test(t.nodeName)||t.contentEditable=="false")return!1;e=es(t)+(a<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(a<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=a;else return!1;else t=o,e=a<0?hr(t):0}else return!1}}function hr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nD(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=hr(t)}else if(t.parentNode&&!Ud(t))e=es(t),t=t.parentNode;else return null}}function sD(t,e){for(;;){if(t.nodeType==3&&e2),ur=Gl||(aa?/Mac/.test(aa.platform):!1),US=aa?/Win/.test(aa.platform):!1,$a=/Android \d/.test(Ji),Kd=!!H1&&"webkitFontSmoothing"in H1.documentElement.style,oD=Kd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function lD(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ra(t,e){return typeof t=="number"?t:t[e]}function cD(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*s}}function W1(t,e,n){let s=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=ql(o);continue}let c=o,u=c==i.body,h=u?lD(i):cD(c),f=0,m=0;if(e.toph.bottom-Ra(s,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+Ra(a,"top")-h.top:e.bottom-h.bottom+Ra(a,"bottom")),e.lefth.right-Ra(s,"right")&&(f=e.right-h.right+Ra(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,v=c.scrollTop-N;e={left:e.left-j,top:e.top-v,right:e.right-j,bottom:e.bottom-v}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:ql(o)}}function dD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),s,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){s=c,a=u.top;break}}return{refDOM:s,refTop:a,stack:KS(t.dom)}}function KS(t){let e=[],n=t.ownerDocument;for(let s=t;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),t!=n);s=ql(s));return e}function uD({refDOM:t,refTop:e,stack:n}){let s=t?t.getBoundingClientRect().top:0;qS(n,s==0?0:s-e)}function qS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let j=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,s=0),n&&n.nodeType==3?fD(n,a):!n||s&&n.nodeType==1?{node:t,offset:i}:GS(n,a)}function fD(t,e){let n=t.nodeValue.length,s=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return s.detach(),a||{node:t,offset:0}}function I0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(s,a,i)}function gD(t,e,n,s){let a=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>s.left||u.top>s.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function JS(t,e,n){let s=t.childNodes.length;if(s&&n.tope.top&&a++}let h;Kd&&a&&s.nodeType==1&&(h=s.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,s==t.dom&&a==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||s.nodeType!=1||s.childNodes[a-1].nodeName!="BR")&&(c=gD(t,s,a,e))}c==null&&(c=mD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function U1(t){return t.top=0&&a==s.nodeValue.length?(u--,f=1):n<0?u--:h++,Yc(Ni(_a(s,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==hr(s))){let u=s.childNodes[a-1];if(u.nodeType==1)return fg(u.getBoundingClientRect(),!1)}if(i==null&&a
=0)}if(i==null&&a&&(n<0||a==hr(s))){let u=s.childNodes[a-1],h=u.nodeType==3?_a(u,hr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Yc(Ni(h,1),!1)}if(i==null&&a
=0)}function Yc(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function fg(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function QS(t,e,n){let s=t.state,a=t.root.activeElement;s!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{s!=e&&t.updateState(s),a!=t.dom&&a&&a.focus()}}function bD(t,e,n){let s=e.selection,a=n=="up"?s.$from:s.$to;return QS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=YS(t,a.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=_a(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}const vD=/[\u0590-\u08ac]/;function ND(t,e,n){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let a=s.parentOffset,i=!a,o=a==s.parent.content.size,c=t.domSelection();return c?!vD.test(s.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:QS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=s.depth?t.docView.domAfterPos(s.before()):t.dom,{focusNode:N,focusOffset:j}=t.domSelectionRange(),v=N&&!y.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==j;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),v}):s.pos==s.start()||s.pos==s.end()}let K1=null,q1=null,G1=!1;function wD(t,e,n){return K1==e&&q1==n?G1:(K1=e,q1=n,G1=n=="up"||n=="down"?bD(t,e,n):ND(t,e,n))}const pr=0,J1=1,So=2,ia=3;class qd{constructor(e,n,s,a){this.parent=e,this.children=n,this.dom=s,this.contentDOM=a,this.dirty=pr,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nes(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!1;break}if(i.previousSibling)break}if(a==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!0;break}if(i.nextSibling)break}}return a??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let s=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(s&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))s=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let s=n;s;s=s.parent)if(s==this)return n}posFromDOM(e,n,s){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,s)}return-1}descAt(e){for(let n=0,s=0;ne||o instanceof ZS){a=e-i;break}i=c}if(a)return this.children[s].domFromPos(a-this.children[s].border,n);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof XS&&i.side>=0;s--);if(n<=0){let i,o=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?es(i.dom)+1:0}}else{let i,o=!0;for(;i=s=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=es(g.dom)+1;break}e-=g.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let s=0,a=0;a=s:es){let c=s+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==s||n==o?So:J1,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ia:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?So:ia}s=o}this.dirty=So}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let s=e==1?So:J1;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==pr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jD extends qd{constructor(e,n,s,a){super(e,[],n,null),this.textDOM=s,this.text=a}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Vo extends qd{constructor(e,n,s,a,i){super(e,[],s,a),this.mark=n,this.spec=i}static create(e,n,s,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,s);return(!o||!o.dom)&&(o=Jo.renderSpec(document,n.type.spec.toDOM(n,s),null,n.attrs)),new Vo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ia||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ia&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=pr){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(i=xx(i,0,e,s));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},s,a),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=Jo.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let g=f;return f=n2(f,s,n),h?u=new kD(e,n,s,a,f,m||null,g,h,i,o+1):n.isText?new Gf(e,n,s,a,f,g,i):new Li(e,n,s,a,f,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ne.empty)}return e}matchesNode(e,n,s){return this.dirty==pr&&e.eq(this.node)&&Vh(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let s=this.node.inlineContent,a=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new CD(this,o&&o.node,e);MD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,s,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Vt.none:this.node.child(f).marks,s,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,s,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],s,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==So)&&(o&&this.protectLocalComposition(e,o),e2(this.contentDOM,this.children,e),Gl&&AD(this.dom))}localCompositionInfo(e,n){let{from:s,to:a}=e.state.selection;if(!(e.state.selection instanceof Xe)||sn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,c=ID(this.node.content,o,s-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:s,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new jD(this,i,n,a);e.input.compositionNodes.push(o),this.children=xx(this.children,s,s+a.length,e,o)}update(e,n,s,a){return this.dirty==ia||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,s,a),!0)}updateInner(e,n,s,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=pr}updateOuterDeco(e){if(Vh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=t2(this.dom,this.nodeDOM,gx(this.outerDeco,this.node,n),gx(e,this.node,n)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Y1(t,e,n,s,a){n2(s,e,t);let i=new Li(void 0,t,e,n,s,s,s,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Gf extends Li{constructor(e,n,s,a,i,o,c){super(e,n,s,a,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,s,a){return this.dirty==ia||this.dirty!=pr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=pr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=e,this.dirty=pr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,s){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,s){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Gf(this.parent,a,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ia)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ZS extends qd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kD extends Li{constructor(e,n,s,a,i,o,c,u,h,f){super(e,n,s,a,i,o,c,h,f),this.spec=u}update(e,n,s,a){if(this.dirty==ia)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,s);return i&&this.updateInner(e,n,s,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,s,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,s,a){this.spec.setSelection?this.spec.setSelection(e,n,s.root):super.setSelection(e,n,s,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function e2(t,e,n){let s=t.firstChild,a=!1;for(let i=0;i>1,c=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=Vo.create(this.top,e[o],n,s);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,s,a){let i=-1,o;if(a>=this.preMatch.index&&(o=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,s))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c0;){let c;for(;;)if(s){let h=n.children[s-1];if(h instanceof Vo)n=h,s=h.children.length;else{c=h,s--;break}}else{if(n==e)break e;s=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(a-1))break;--a,i.set(c,a),o.push(c)}}return{index:a,matched:i,matches:o.reverse()}}function TD(t,e){return t.type.side-e.type.side}function MD(t,e,n,s){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let N=i+g.nodeSize;if(g.isText){let v=N;o!v.inline):c.slice();s(g,j,e.forChild(i,g),y),i=N}}function AD(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ID(t,e,n,s){for(let a=0,i=0;a=n){if(i>=s&&u.slice(s-e.length-c,s-c)==e)return s-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==s&&u.length>=s+e.length-c&&u.slice(s-c,s-c+e.length)==e)return s}}return-1}function xx(t,e,n,s,a){let i=[];for(let o=0,c=0;o=n||f<=e?i.push(u):(hn&&i.push(u.slice(n-h,u.size,s)))}return i}function R0(t,e=null){let n=t.domSelectionRange(),s=t.state.doc;if(!n.focusNode)return null;let a=t.docView.nearestDesc(n.focusNode),i=a&&a.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=s.resolve(o),u,h;if(qf(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Qe.isSelectable(m)&&a.parent&&!(m.isInline&&rD(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new Qe(o==g?c:s.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y{(n.anchorNode!=s||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!s2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function PD(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,s=n.nodeName=="IMG";s?e.collapse(n.parentNode,es(n)+1):e.collapse(n,0),!s&&!t.state.selection.visible&&$s&&Di<=11&&(n.disabled=!0,n.disabled=!1)}function r2(t,e){if(e instanceof Qe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tN(t)}function tN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function P0(t,e,n,s){return t.someProp("createSelectionBetween",a=>a(t,e,n))||Xe.between(e,n,s)}function nN(t){return t.editable&&!t.hasFocus()?!1:a2(t)}function a2(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function OD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Bo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function yx(t,e){let{$anchor:n,$head:s}=t.selection,a=e>0?n.max(s):n.min(s),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&nt.findFrom(i,e)}function wi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function sN(t,e,n){let s=t.state.selection;if(s instanceof Xe)if(n.indexOf("s")>-1){let{$head:a}=s,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(a.pos+i.nodeSize*(e<0?-1:1));return wi(t,new Xe(s.$anchor,o))}else if(s.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=yx(t.state,e);return a&&a instanceof Qe?wi(t,a):!1}else if(!(ur&&n.indexOf("m")>-1)){let a=s.$head,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?a.pos-i.nodeSize:a.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Qe.isSelectable(i)?wi(t,new Qe(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Kd?wi(t,new Xe(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof Qe&&s.node.isInline)return wi(t,new Xe(e>0?s.$to:s.$from));{let a=yx(t.state,e);return a?wi(t,a):!1}}}function Hh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pd(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ml(t,e){return e<0?DD(t):LD(t)}function DD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a,i,o=!1;for(fr&&n.nodeType==1&&s0){if(n.nodeType!=1)break;{let c=n.childNodes[s-1];if(pd(c,-1))a=n,i=--s;else if(c.nodeType==3)n=c,s=n.nodeValue.length;else break}}else{if(i2(n))break;{let c=n.previousSibling;for(;c&&pd(c,-1);)a=n.parentNode,i=es(c),c=c.previousSibling;if(c)n=c,s=Hh(n);else{if(n=n.parentNode,n==t.dom)break;s=0}}}o?bx(t,n,s):a&&bx(t,a,i)}function LD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a=Hh(n),i,o;for(;;)if(s{t.state==a&&Wa(t)},50)}function rN(t,e){let n=t.state.doc.resolve(e);if(!(ns||US)&&n.parent.inlineContent){let a=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>a.top&&o1)return i.lefta.top&&o1)return i.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function aN(t,e,n){let s=t.state.selection;if(s instanceof Xe&&!s.empty||n.indexOf("s")>-1||ur&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=s;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=yx(t.state,e);if(o&&o instanceof Qe)return wi(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=s instanceof Qs?nt.near(o,e):nt.findFrom(o,e);return c?wi(t,c):!1}return!1}function iN(t,e){if(!(t.state.selection instanceof Xe))return!0;let{$head:n,$anchor:s,empty:a}=t.state.selection;if(!n.sameParent(s))return!0;if(!a)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function oN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function FD(t){if(!ys||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;oN(t,s,"true"),setTimeout(()=>oN(t,s,"false"),20)}return!1}function $D(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function BD(t,e){let n=e.keyCode,s=$D(e);if(n==8||ur&&n==72&&s=="c")return iN(t,-1)||Ml(t,-1);if(n==46&&!e.shiftKey||ur&&n==68&&s=="c")return iN(t,1)||Ml(t,1);if(n==13||n==27)return!0;if(n==37||ur&&n==66&&s=="c"){let a=n==37?rN(t,t.state.selection.from)=="ltr"?-1:1:-1;return sN(t,a,s)||Ml(t,a)}else if(n==39||ur&&n==70&&s=="c"){let a=n==39?rN(t,t.state.selection.from)=="ltr"?1:-1:1;return sN(t,a,s)||Ml(t,a)}else{if(n==38||ur&&n==80&&s=="c")return aN(t,-1,s)||Ml(t,-1);if(n==40||ur&&n==78&&s=="c")return FD(t)||aN(t,1,s)||Ml(t,1);if(s==(ur?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function O0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:s,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){a--,i--;let y=s.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),s=y.content}let o=t.someProp("clipboardSerializer")||Jo.fromSchema(t.state.schema),c=h2(),u=c.createElement("div");u.appendChild(o.serializeFragment(s,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=u2[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let N=c.createElement(f[y]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,`
+`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let s=e.style;if(s&&s.length)for(let a=0;a!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,s,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let u=this.enter(o,n.attrs||null,s,n.preserveWhitespace);u&&(i=!0,s=u)}else{let u=this.parser.schema.marks[n.mark];s=s.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,s,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,s,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,s),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,s,a){let i=s||0;for(let o=s?e.childNodes[s]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,s){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(s)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):I1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new sh(e,n,u,a,null,c)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Td)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)e+=s[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:s&&u>=i?s.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function aO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&pS.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function iO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function A1(t){let e={};for(let n in t)e[n]=t[n];return e}function I1(t,e){let n=e.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,n,s={}){let a=this.marks[e.type.name];return a&&Nh(ig(s),a(e,n),null,e.attrs)}static renderSpec(e,n,s=null,a){return Nh(e,n,s,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Jo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=R1(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return R1(e.marks)}}function R1(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function ig(t){return t.document||window.document}const P1=new WeakMap;function oO(t){let e=P1.get(t);return e===void 0&&P1.set(t,e=lO(t)),e}function lO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:N}=Nh(t,g,n,s);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const mS=65535,gS=Math.pow(2,16);function cO(t,e){return t+e*gS}function O1(t){return t&mS}function dO(t){return(t-(t&mS))/gS}const xS=1,yS=2,wh=4,bS=8;class ux{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&bS)>0}get deletedBefore(){return(this.delInfo&(xS|wh))>0}get deletedAfter(){return(this.delInfo&(yS|wh))>0}get deletedAcross(){return(this.delInfo&wh)>0}}class Gs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Gs.empty)return Gs.empty}recover(e){let n=0,s=O1(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(s)return y;let N=e==(n<0?u:m)?null:cO(c/3,e-u),j=e==u?yS:e==m?xS:wh;return(n<0?e!=u:e!=m)&&(j|=bS),new ux(y,j,N)}a+=f-h}return s?e+a:new ux(e+a,0,null)}touches(e,n){let s=0,a=O1(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;s+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let e=new Md;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;si&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,i)}invert(){return new Ir(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Mi(n.pos,s.pos,this.mark)}merge(e){return e instanceof Mi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mi(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("addMark",Mi);class Ir extends vs{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new Oe(w0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,s)}invert(){return new Mi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Ir(n.pos,s.pos,this.mark)}merge(e){return e instanceof Ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ir(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ir(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("removeMark",Ir);class Ai extends vs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Tn.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Tn.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;a