vt?(ys=dt,dt=null):ys=dt.sibling;var lo=Me(me,dt,Ht.value,De);if(lo===null){dt===null&&(dt=ys);break}l&&dt&&lo.alternate===null&&d(me,dt),ae=S(lo,ae,vt),ct===null?rt=lo:ct.sibling=lo,ct=lo,dt=ys}if(Ht.done)return p(me,dt),kn&&tl(me,vt),rt;if(dt===null){for(;!Ht.done;vt++,Ht=ge.next())Ht=Re(me,Ht.value,De),Ht!==null&&(ae=S(Ht,ae,vt),ct===null?rt=Ht:ct.sibling=Ht,ct=Ht);return kn&&tl(me,vt),rt}for(dt=g(me,dt);!Ht.done;vt++,Ht=ge.next())Ht=Je(dt,me,vt,Ht.value,De),Ht!==null&&(l&&Ht.alternate!==null&&dt.delete(Ht.key===null?vt:Ht.key),ae=S(Ht,ae,vt),ct===null?rt=Ht:ct.sibling=Ht,ct=Ht);return l&&dt.forEach(function(LE){return d(me,LE)}),kn&&tl(me,vt),rt}function Hn(me,ae,ge,De){if(typeof ge=="object"&&ge!==null&&ge.type===z&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case L:e:{for(var rt=ge.key,ct=ae;ct!==null;){if(ct.key===rt){if(rt=ge.type,rt===z){if(ct.tag===7){p(me,ct.sibling),ae=j(ct,ge.props.children),ae.return=me,me=ae;break e}}else if(ct.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===I&&Pb(rt)===ct.type){p(me,ct.sibling),ae=j(ct,ge.props),ae.ref=Nd(me,ct,ge),ae.return=me,me=ae;break e}p(me,ct);break}else d(me,ct);ct=ct.sibling}ge.type===z?(ae=cl(ge.props.children,me.mode,De,ge.key),ae.return=me,me=ae):(De=Nh(ge.type,ge.key,ge.props,null,me.mode,De),De.ref=Nd(me,ae,ge),De.return=me,me=De)}return A(me);case q:e:{for(ct=ge.key;ae!==null;){if(ae.key===ct)if(ae.tag===4&&ae.stateNode.containerInfo===ge.containerInfo&&ae.stateNode.implementation===ge.implementation){p(me,ae.sibling),ae=j(ae,ge.children||[]),ae.return=me,me=ae;break e}else{p(me,ae);break}else d(me,ae);ae=ae.sibling}ae=px(ge,me.mode,De),ae.return=me,me=ae}return A(me);case I:return ct=ge._init,Hn(me,ae,ct(ge._payload),De)}if(dn(ge))return et(me,ae,ge,De);if(xe(ge))return st(me,ae,ge,De);Yu(me,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ae!==null&&ae.tag===6?(p(me,ae.sibling),ae=j(ae,ge),ae.return=me,me=ae):(p(me,ae),ae=fx(ge,me.mode,De),ae.return=me,me=ae),A(me)):p(me,ae)}return Hn}var cc=Rb(!0),Lb=Rb(!1),Xu=Yi(null),Zu=null,dc=null,jm=null;function km(){jm=dc=Zu=null}function Sm(l){var d=Xu.current;xn(Xu),l._currentValue=d}function Cm(l,d,p){for(;l!==null;){var g=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,g!==null&&(g.childLanes|=d)):g!==null&&(g.childLanes&d)!==d&&(g.childLanes|=d),l===p)break;l=l.return}}function uc(l,d){Zu=l,jm=dc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(xr=!0),l.firstContext=null)}function Gr(l){var d=l._currentValue;if(jm!==l)if(l={context:l,memoizedValue:d,next:null},dc===null){if(Zu===null)throw Error(n(308));dc=l,Zu.dependencies={lanes:0,firstContext:l}}else dc=dc.next=l;return d}var nl=null;function Em(l){nl===null?nl=[l]:nl.push(l)}function Ob(l,d,p,g){var j=d.interleaved;return j===null?(p.next=p,Em(d)):(p.next=j.next,j.next=p),d.interleaved=p,fi(l,g)}function fi(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 eo=!1;function Tm(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 pi(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function to(l,d,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(Bt&2)!==0){var j=g.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),g.pending=d,fi(l,p)}return j=g.interleaved,j===null?(d.next=d,Em(g)):(d.next=j.next,j.next=d),g.interleaved=d,fi(l,p)}function eh(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var g=d.lanes;g&=l.pendingLanes,p|=g,d.lanes=p,ti(l,p)}}function _b(l,d){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var j=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var A={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?j=S=A:S=S.next=A,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:g.baseState,firstBaseUpdate:j,lastBaseUpdate:S,shared:g.shared,effects:g.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function th(l,d,p,g){var j=l.updateQueue;eo=!1;var S=j.firstBaseUpdate,A=j.lastBaseUpdate,W=j.shared.pending;if(W!==null){j.shared.pending=null;var ee=W,ye=ee.next;ee.next=null,A===null?S=ye:A.next=ye,A=ee;var Ae=l.alternate;Ae!==null&&(Ae=Ae.updateQueue,W=Ae.lastBaseUpdate,W!==A&&(W===null?Ae.firstBaseUpdate=ye:W.next=ye,Ae.lastBaseUpdate=ee))}if(S!==null){var Re=j.baseState;A=0,Ae=ye=ee=null,W=S;do{var Me=W.lane,Je=W.eventTime;if((g&Me)===Me){Ae!==null&&(Ae=Ae.next={eventTime:Je,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var et=l,st=W;switch(Me=d,Je=p,st.tag){case 1:if(et=st.payload,typeof et=="function"){Re=et.call(Je,Re,Me);break e}Re=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=st.payload,Me=typeof et=="function"?et.call(Je,Re,Me):et,Me==null)break e;Re=Z({},Re,Me);break e;case 2:eo=!0}}W.callback!==null&&W.lane!==0&&(l.flags|=64,Me=j.effects,Me===null?j.effects=[W]:Me.push(W))}else Je={eventTime:Je,lane:Me,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Ae===null?(ye=Ae=Je,ee=Re):Ae=Ae.next=Je,A|=Me;if(W=W.next,W===null){if(W=j.shared.pending,W===null)break;Me=W,W=Me.next,Me.next=null,j.lastBaseUpdate=Me,j.shared.pending=null}}while(!0);if(Ae===null&&(ee=Re),j.baseState=ee,j.firstBaseUpdate=ye,j.lastBaseUpdate=Ae,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);al|=A,l.lanes=A,l.memoizedState=Re}}function zb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var g=Rm.transition;Rm.transition={};try{l(!1),d()}finally{bt=p,Rm.transition=g}}function sv(){return Jr().memoizedState}function rE(l,d,p){var g=ao(l);if(p={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null},rv(l))av(d,p);else if(p=Ob(l,d,p,g),p!==null){var j=nr();xa(p,l,g,j),iv(p,d,g)}}function aE(l,d,p){var g=ao(l),j={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null};if(rv(l))av(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var A=d.lastRenderedState,W=S(A,p);if(j.hasEagerState=!0,j.eagerState=W,ua(W,A)){var ee=d.interleaved;ee===null?(j.next=j,Em(d)):(j.next=ee.next,ee.next=j),d.interleaved=j;return}}catch{}finally{}p=Ob(l,d,j,g),p!==null&&(j=nr(),xa(p,l,g,j),iv(p,d,g))}}function rv(l){var d=l.alternate;return l===An||d!==null&&d===An}function av(l,d){Sd=rh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function iv(l,d,p){if((p&4194240)!==0){var g=d.lanes;g&=l.pendingLanes,p|=g,d.lanes=p,ti(l,p)}}var oh={readContext:Gr,useCallback:Bs,useContext:Bs,useEffect:Bs,useImperativeHandle:Bs,useInsertionEffect:Bs,useLayoutEffect:Bs,useMemo:Bs,useReducer:Bs,useRef:Bs,useState:Bs,useDebugValue:Bs,useDeferredValue:Bs,useTransition:Bs,useMutableSource:Bs,useSyncExternalStore:Bs,useId:Bs,unstable_isNewReconciler:!1},iE={readContext:Gr,useCallback:function(l,d){return Da().memoizedState=[l,d===void 0?null:d],l},useContext:Gr,useEffect:Jb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,ah(4194308,4,Xb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return ah(4194308,4,l,d)},useInsertionEffect:function(l,d){return ah(4,2,l,d)},useMemo:function(l,d){var p=Da();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var g=Da();return d=p!==void 0?p(d):d,g.memoizedState=g.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},g.queue=l,l=l.dispatch=rE.bind(null,An,l),[g.memoizedState,l]},useRef:function(l){var d=Da();return l={current:l},d.memoizedState=l},useState:qb,useDebugValue:Fm,useDeferredValue:function(l){return Da().memoizedState=l},useTransition:function(){var l=qb(!1),d=l[0];return l=sE.bind(null,l[1]),Da().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var g=An,j=Da();if(kn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),gs===null)throw Error(n(349));(rl&30)!==0||Vb(g,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,Jb(Ub.bind(null,g,S,l),[l]),g.flags|=2048,Td(9,Hb.bind(null,g,S,p,d),void 0,null),p},useId:function(){var l=Da(),d=gs.identifierPrefix;if(kn){var p=hi,g=ui;p=(g&~(1<<32-Ot(g)-1)).toString(32)+p,d=":"+d+"R"+p,p=Cd++,0<\/script>",l=l.removeChild(l.firstChild)):typeof g.is=="string"?l=A.createElement(p,{is:g.is}):(l=A.createElement(p),p==="select"&&(A=l,g.multiple?A.multiple=!0:g.size&&(A.size=g.size))):l=A.createElementNS(l,p),l[La]=d,l[bd]=g,Cv(l,d,!1,!1),d.stateNode=l;e:{switch(A=is(p,g),p){case"dialog":mn("cancel",l),mn("close",l),j=g;break;case"iframe":case"object":case"embed":mn("load",l),j=g;break;case"video":case"audio":for(j=0;jxc&&(d.flags|=128,g=!0,Md(S,!1),d.lanes=4194304)}else{if(!g)if(l=nh(A),l!==null){if(d.flags|=128,g=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Md(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!kn)return Vs(d),null}else 2*zt()-S.renderingStartTime>xc&&p!==1073741824&&(d.flags|=128,g=!0,Md(S,!1),d.lanes=4194304);S.isBackwards?(A.sibling=d.child,d.child=A):(p=S.last,p!==null?p.sibling=A:d.child=A,S.last=A)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=zt(),d.sibling=null,p=Mn.current,un(Mn,g?p&1|2:p&1),d):(Vs(d),null);case 22:case 23:return dx(),g=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==g&&(d.flags|=8192),g&&(d.mode&1)!==0?(Dr&1073741824)!==0&&(Vs(d),d.subtreeFlags&6&&(d.flags|=8192)):Vs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function pE(l,d){switch(bm(d),d.tag){case 1:return mr(d.type)&&Wu(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return hc(),xn(pr),xn(Fs),Pm(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Am(d),null;case 13:if(xn(Mn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));lc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return xn(Mn),null;case 4:return hc(),null;case 10:return Sm(d.type._context),null;case 22:case 23:return dx(),null;case 24:return null;default:return null}}var uh=!1,Hs=!1,mE=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function pc(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(g){Rn(l,d,g)}else p.current=null}function Xm(l,d,p){try{p()}catch(g){Rn(l,d,g)}}var Mv=!1;function xE(l,d){if(dm=$s,l=ob(),nm(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var j=g.anchorOffset,S=g.focusNode;g=g.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var A=0,W=-1,ee=-1,ye=0,Ae=0,Re=l,Me=null;t:for(;;){for(var Je;Re!==p||j!==0&&Re.nodeType!==3||(W=A+j),Re!==S||g!==0&&Re.nodeType!==3||(ee=A+g),Re.nodeType===3&&(A+=Re.nodeValue.length),(Je=Re.firstChild)!==null;)Me=Re,Re=Je;for(;;){if(Re===l)break t;if(Me===p&&++ye===j&&(W=A),Me===S&&++Ae===g&&(ee=A),(Je=Re.nextSibling)!==null)break;Re=Me,Me=Re.parentNode}Re=Je}p=W===-1||ee===-1?null:{start:W,end:ee}}else p=null}p=p||{start:0,end:0}}else p=null;for(um={focusedElem:l,selectionRange:p},$s=!1,Xe=d;Xe!==null;)if(d=Xe,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Xe=l;else for(;Xe!==null;){d=Xe;try{var et=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(et!==null){var st=et.memoizedProps,Hn=et.memoizedState,me=d.stateNode,ae=me.getSnapshotBeforeUpdate(d.elementType===d.type?st:fa(d.type,st),Hn);me.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ge=d.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){Rn(d,d.return,De)}if(l=d.sibling,l!==null){l.return=d.return,Xe=l;break}Xe=d.return}return et=Mv,Mv=!1,et}function Ad(l,d,p){var g=d.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var j=g=g.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&Xm(d,p,S)}j=j.next}while(j!==g)}}function hh(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 g=p.create;p.destroy=g()}p=p.next}while(p!==d)}}function Zm(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[La],delete d[bd],delete d[mm],delete d[X4],delete d[Z4])),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 Pv(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 ex(l,d,p){var g=l.tag;if(g===5||g===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=Hu));else if(g!==4&&(l=l.child,l!==null))for(ex(l,d,p),l=l.sibling;l!==null;)ex(l,d,p),l=l.sibling}function tx(l,d,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(g!==4&&(l=l.child,l!==null))for(tx(l,d,p),l=l.sibling;l!==null;)tx(l,d,p),l=l.sibling}var Ms=null,pa=!1;function no(l,d,p){for(p=p.child;p!==null;)Rv(l,d,p),p=p.sibling}function Rv(l,d,p){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(ht,p)}catch{}switch(p.tag){case 5:Hs||pc(p,d);case 6:var g=Ms,j=pa;Ms=null,no(l,d,p),Ms=g,pa=j,Ms!==null&&(pa?(l=Ms,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Ms.removeChild(p.stateNode));break;case 18:Ms!==null&&(pa?(l=Ms,p=p.stateNode,l.nodeType===8?pm(l.parentNode,p):l.nodeType===1&&pm(l,p),Ts(l)):pm(Ms,p.stateNode));break;case 4:g=Ms,j=pa,Ms=p.stateNode.containerInfo,pa=!0,no(l,d,p),Ms=g,pa=j;break;case 0:case 11:case 14:case 15:if(!Hs&&(g=p.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){j=g=g.next;do{var S=j,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&Xm(p,d,A),j=j.next}while(j!==g)}no(l,d,p);break;case 1:if(!Hs&&(pc(p,d),g=p.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=p.memoizedProps,g.state=p.memoizedState,g.componentWillUnmount()}catch(W){Rn(p,d,W)}no(l,d,p);break;case 21:no(l,d,p);break;case 22:p.mode&1?(Hs=(g=Hs)||p.memoizedState!==null,no(l,d,p),Hs=g):no(l,d,p);break;default:no(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 mE),d.forEach(function(g){var j=SE.bind(null,l,g);p.has(g)||(p.add(g),g.then(j,j))})}}function ma(l,d){var p=d.deletions;if(p!==null)for(var g=0;gj&&(j=A),g&=~S}if(g=j,g=zt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*yE(g/1960))-g,10l?16:l,ro===null)var g=!1;else{if(l=ro,ro=null,gh=0,(Bt&6)!==0)throw Error(n(331));var j=Bt;for(Bt|=4,Xe=l.current;Xe!==null;){var S=Xe,A=S.child;if((Xe.flags&16)!==0){var W=S.deletions;if(W!==null){for(var ee=0;eezt()-rx?ol(l,0):sx|=p),yr(l,d)}function qv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Cs,Cs<<=1,(Cs&130023424)===0&&(Cs=4194304)));var p=nr();l=fi(l,d),l!==null&&(oa(l,d,p),yr(l,p))}function kE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),qv(l,p)}function SE(l,d){var p=0;switch(l.tag){case 13:var g=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:g=l.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(d),qv(l,p)}var Gv;Gv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||pr.current)xr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return xr=!1,hE(l,d,p);xr=(l.flags&131072)!==0}else xr=!1,kn&&(d.flags&1048576)!==0&&Eb(d,Ju,d.index);switch(d.lanes=0,d.tag){case 2:var g=d.type;dh(l,d),l=d.pendingProps;var j=ac(d,Fs.current);uc(d,p),j=Om(null,d,g,l,j,p);var S=Dm();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,mr(g)?(S=!0,Ku(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Tm(d),j.updater=lh,d.stateNode=j,j._reactInternals=d,Vm(d,g,l,p),d=Km(null,d,g,!0,S,p)):(d.tag=0,kn&&S&&ym(d),tr(null,d,j,p),d=d.child),d;case 16:g=d.elementType;e:{switch(dh(l,d),l=d.pendingProps,j=g._init,g=j(g._payload),d.type=g,j=d.tag=EE(g),l=fa(g,l),j){case 0:d=Wm(null,d,g,l,p);break e;case 1:d=vv(null,d,g,l,p);break e;case 11:d=mv(null,d,g,l,p);break e;case 14:d=xv(null,d,g,fa(g.type,l),p);break e}throw Error(n(306,g,""))}return d;case 0:return g=d.type,j=d.pendingProps,j=d.elementType===g?j:fa(g,j),Wm(l,d,g,j,p);case 1:return g=d.type,j=d.pendingProps,j=d.elementType===g?j:fa(g,j),vv(l,d,g,j,p);case 3:e:{if(Nv(d),l===null)throw Error(n(387));g=d.pendingProps,S=d.memoizedState,j=S.element,Db(l,d),th(d,g,null,p);var A=d.memoizedState;if(g=A.element,S.isDehydrated)if(S={element:g,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=fc(Error(n(423)),d),d=wv(l,d,g,p,j);break e}else if(g!==j){j=fc(Error(n(424)),d),d=wv(l,d,g,p,j);break e}else for(Or=Qi(d.stateNode.containerInfo.firstChild),Lr=d,kn=!0,ha=null,p=Lb(d,null,g,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(lc(),g===j){d=mi(l,d,p);break e}tr(l,d,g,p)}d=d.child}return d;case 5:return $b(d),l===null&&Nm(d),g=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,A=j.children,hm(g,j)?A=null:S!==null&&hm(g,S)&&(d.flags|=32),bv(l,d),tr(l,d,A,p),d.child;case 6:return l===null&&Nm(d),null;case 13:return jv(l,d,p);case 4:return Mm(d,d.stateNode.containerInfo),g=d.pendingProps,l===null?d.child=cc(d,null,g,p):tr(l,d,g,p),d.child;case 11:return g=d.type,j=d.pendingProps,j=d.elementType===g?j:fa(g,j),mv(l,d,g,j,p);case 7:return tr(l,d,d.pendingProps,p),d.child;case 8:return tr(l,d,d.pendingProps.children,p),d.child;case 12:return tr(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(g=d.type._context,j=d.pendingProps,S=d.memoizedProps,A=j.value,un(Xu,g._currentValue),g._currentValue=A,S!==null)if(ua(S.value,A)){if(S.children===j.children&&!pr.current){d=mi(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var W=S.dependencies;if(W!==null){A=S.child;for(var ee=W.firstContext;ee!==null;){if(ee.context===g){if(S.tag===1){ee=pi(-1,p&-p),ee.tag=2;var ye=S.updateQueue;if(ye!==null){ye=ye.shared;var Ae=ye.pending;Ae===null?ee.next=ee:(ee.next=Ae.next,Ae.next=ee),ye.pending=ee}}S.lanes|=p,ee=S.alternate,ee!==null&&(ee.lanes|=p),Cm(S.return,p,d),W.lanes|=p;break}ee=ee.next}}else if(S.tag===10)A=S.type===d.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(n(341));A.lanes|=p,W=A.alternate,W!==null&&(W.lanes|=p),Cm(A,p,d),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===d){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}tr(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,g=d.pendingProps.children,uc(d,p),j=Gr(j),g=g(j),d.flags|=1,tr(l,d,g,p),d.child;case 14:return g=d.type,j=fa(g,d.pendingProps),j=fa(g.type,j),xv(l,d,g,j,p);case 15:return gv(l,d,d.type,d.pendingProps,p);case 17:return g=d.type,j=d.pendingProps,j=d.elementType===g?j:fa(g,j),dh(l,d),d.tag=1,mr(g)?(l=!0,Ku(d)):l=!1,uc(d,p),lv(d,g,j),Vm(d,g,j,p),Km(null,d,g,!0,l,p);case 19:return Sv(l,d,p);case 22:return yv(l,d,p)}throw Error(n(156,d.tag))};function Jv(l,d){return Ca(l,d)}function CE(l,d,p,g){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=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yr(l,d,p,g){return new CE(l,d,p,g)}function hx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function EE(l){if(typeof l=="function")return hx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===V)return 11;if(l===he)return 14}return 2}function oo(l,d){var p=l.alternate;return p===null?(p=Yr(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 Nh(l,d,p,g,j,S){var A=2;if(g=l,typeof l=="function")hx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case z:return cl(p.children,j,S,d);case H:A=8,j|=8;break;case R:return l=Yr(12,p,d,j|2),l.elementType=R,l.lanes=S,l;case ie:return l=Yr(13,p,d,j),l.elementType=ie,l.lanes=S,l;case le:return l=Yr(19,p,d,j),l.elementType=le,l.lanes=S,l;case Q:return wh(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case se:A=10;break e;case X:A=9;break e;case V:A=11;break e;case he:A=14;break e;case I:A=16,g=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Yr(A,p,d,j),d.elementType=l,d.type=g,d.lanes=S,d}function cl(l,d,p,g){return l=Yr(7,l,g,d),l.lanes=p,l}function wh(l,d,p,g){return l=Yr(22,l,g,d),l.elementType=Q,l.lanes=p,l.stateNode={isHidden:!1},l}function fx(l,d,p){return l=Yr(6,l,null,d),l.lanes=p,l}function px(l,d,p){return d=Yr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function TE(l,d,p,g,j){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=Ta(0),this.expirationTimes=Ta(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ta(0),this.identifierPrefix=g,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function mx(l,d,p,g,j,S,A,W,ee){return l=new TE(l,d,p,W,ee),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Yr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:g,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Tm(S),l}function ME(l,d,p){var g=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Nx.exports=BE(),Nx.exports}var c1;function VE(){if(c1)return Mh;c1=1;var t=Cj();return Mh.createRoot=t.createRoot,Mh.hydrateRoot=t.hydrateRoot,Mh}var HE=VE(),Yc=Cj();const Ej=Sj(Yc);/**
- * @remix-run/router v1.23.2
- *
- * Copyright (c) Remix Software Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE.md file in the root directory of this source tree.
- *
- * @license MIT
- */function ou(){return ou=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function P0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function WE(){return Math.random().toString(36).substr(2,8)}function u1(t,e){return{usr:t.state,key:t.key,idx:e}}function Ng(t,e,n,r){return n===void 0&&(n=null),ou({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Xc(e):e,{state:n,key:e&&e.key||r||WE()})}function mf(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Xc(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function KE(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=No.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(ou({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=No.Pop;let N=f(),k=N==null?null:N-h;h=N,u&&u({action:c,location:w.location,delta:k})}function x(N,k){c=No.Push;let T=Ng(w.location,N,k);h=f()+1;let C=u1(T,h),P=w.createHref(T);try{o.pushState(C,"",P)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(P)}i&&u&&u({action:c,location:w.location,delta:1})}function b(N,k){c=No.Replace;let T=Ng(w.location,N,k);h=f();let C=u1(T,h),P=w.createHref(T);o.replaceState(C,"",P),i&&u&&u({action:c,location:w.location,delta:0})}function v(N){let k=a.location.origin!=="null"?a.location.origin:a.location.href,T=typeof N=="string"?N:mf(N);return T=T.replace(/ $/,"%20"),Kn(k,"No window.location.(origin|href) available to create URL for href: "+T),new URL(T,k)}let w={get action(){return c},get location(){return t(a,o)},listen(N){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(d1,m),u=N,()=>{a.removeEventListener(d1,m),u=null}},createHref(N){return e(a,N)},createURL:v,encodeLocation(N){let k=v(N);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:x,replace:b,go(N){return o.go(N)}};return w}var h1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(h1||(h1={}));function qE(t,e,n){return n===void 0&&(n="/"),GE(t,e,n)}function GE(t,e,n,r){let a=typeof e=="string"?Xc(e):e,i=R0(a.pathname||"/",n);if(i==null)return null;let o=Tj(t);JE(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("/")&&(Kn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=Eo([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(Kn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Tj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:nT(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 Mj(i.path))a(i,o,u)}),e}function Mj(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=Mj(r.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 JE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:sT(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const QE=/^:[\w-]+$/,YE=3,XE=2,ZE=1,eT=10,tT=-2,f1=t=>t==="*";function nT(t,e){let n=t.split("/"),r=n.length;return n.some(f1)&&(r+=tT),e&&(r+=XE),n.filter(a=>!f1(a)).reduce((a,i)=>a+(QE.test(i)?YE:i===""?ZE:eT),r)}function sT(t,e){return t.length===e.length&&t.slice(0,-1).every((r,a)=>r===e[a])?t[t.length-1]-e[e.length-1]:0}function rT(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:x,isOptional:b}=f;if(x==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const v=c[m];return b&&!v?h[x]=void 0:h[x]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function iT(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),P0(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 r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),r]}function oT(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return P0(!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 R0(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const lT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,cT=t=>lT.test(t);function dT(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?Xc(t):t,i;if(n)if(cT(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),P0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=p1(n.substring(1),"/"):i=p1(n,e)}else i=e;return{pathname:i,search:fT(r),hash:pT(a)}}function p1(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 kx(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. 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 uT(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function L0(t,e){let n=uT(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function O0(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=Xc(t):(a=ou({},t),Kn(!a.pathname||!a.pathname.includes("?"),kx("?","pathname","search",a)),Kn(!a.pathname||!a.pathname.includes("#"),kx("#","pathname","hash",a)),Kn(!a.search||!a.search.includes("#"),kx("#","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(!r&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),m-=1;a.pathname=x.join("/")}c=m>=0?e[m]:"/"}let u=dT(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Eo=t=>t.join("/").replace(/\/\/+/g,"/"),hT=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),fT=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,pT=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function mT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Aj=["post","put","patch","delete"];new Set(Aj);const xT=["get",...Aj];new Set(xT);/**
- * React Router v6.30.3
- *
- * Copyright (c) Remix Software Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE.md file in the root directory of this source tree.
- *
- * @license MIT
- */function lu(){return lu=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),y.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=O0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Eo([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const vT=y.createContext(null);function NT(t){let e=y.useContext(Di).outlet;return e&&y.createElement(vT.Provider,{value:t},e)}function Rj(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=y.useContext($o),{matches:a}=y.useContext(Di),{pathname:i}=Fo(),o=JSON.stringify(L0(a,r.v7_relativeSplatPath));return y.useMemo(()=>O0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function wT(t,e){return jT(t,e)}function jT(t,e,n,r){Zc()||Kn(!1);let{navigator:a}=y.useContext($o),{matches:i}=y.useContext(Di),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Fo(),f;if(e){var m;let N=typeof e=="string"?Xc(e):e;u==="/"||(m=N.pathname)!=null&&m.startsWith(u)||Kn(!1),f=N}else f=h;let x=f.pathname||"/",b=x;if(u!=="/"){let N=u.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(N.length).join("/")}let v=qE(t,{pathname:b}),w=TT(v&&v.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Eo([u,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?u:Eo([u,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),i,n,r);return e&&w?y.createElement(vp.Provider,{value:{location:lu({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:No.Pop}},w):w}function kT(){let t=PT(),e=mT(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 y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},e),n?y.createElement("pre",{style:a},n):null,null)}const ST=y.createElement(kT,null);class CT extends y.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?y.createElement(Di.Provider,{value:this.props.routeContext},y.createElement(Ij.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function ET(t){let{routeContext:e,match:n,children:r}=t,a=y.useContext(D0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),y.createElement(Di.Provider,{value:e},r)}function TT(t,e,n,r){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=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||Kn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,x)=>{let b,v=!1,w=null,N=null;n&&(b=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||ST,u&&(h<0&&x===0?(LT("route-fallback"),v=!0,N=null):h===x&&(v=!0,N=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,x+1)),T=()=>{let C;return b?C=w:v?C=N:m.route.Component?C=y.createElement(m.route.Component,null):m.route.element?C=m.route.element:C=f,y.createElement(ET,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:C})};return n&&(m.route.ErrorBoundary||m.route.errorElement||x===0)?y.createElement(CT,{location:n.location,revalidation:n.revalidation,component:w,error:b,children:T(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):T()},null)}var Lj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Lj||{}),Oj=(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})(Oj||{});function MT(t){let e=y.useContext(D0);return e||Kn(!1),e}function AT(t){let e=y.useContext(gT);return e||Kn(!1),e}function IT(t){let e=y.useContext(Di);return e||Kn(!1),e}function Dj(t){let e=IT(),n=e.matches[e.matches.length-1];return n.route.id||Kn(!1),n.route.id}function PT(){var t;let e=y.useContext(Ij),n=AT(),r=Dj();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function RT(){let{router:t}=MT(Lj.UseNavigateStable),e=Dj(Oj.UseNavigateStable),n=y.useRef(!1);return Pj(()=>{n.current=!0}),y.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,lu({fromRouteId:e},i)))},[t,e])}const m1={};function LT(t,e,n){m1[t]||(m1[t]=!0)}function OT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Ah(t){let{to:e,replace:n,state:r,relative:a}=t;Zc()||Kn(!1);let{future:i,static:o}=y.useContext($o),{matches:c}=y.useContext(Di),{pathname:u}=Fo(),h=Ga(),f=O0(e,L0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return y.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function DT(t){return NT(t.context)}function hn(t){Kn(!1)}function _T(t){let{basename:e="/",children:n=null,location:r,navigationType:a=No.Pop,navigator:i,static:o=!1,future:c}=t;Zc()&&Kn(!1);let u=e.replace(/^\/*/,"/"),h=y.useMemo(()=>({basename:u,navigator:i,static:o,future:lu({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=Xc(r));let{pathname:f="/",search:m="",hash:x="",state:b=null,key:v="default"}=r,w=y.useMemo(()=>{let N=R0(f,u);return N==null?null:{location:{pathname:N,search:m,hash:x,state:b,key:v},navigationType:a}},[u,f,m,x,b,v,a]);return w==null?null:y.createElement($o.Provider,{value:h},y.createElement(vp.Provider,{children:n,value:w}))}function zT(t){let{children:e,location:n}=t;return wT(wg(e),n)}new Promise(()=>{});function wg(t,e){e===void 0&&(e=[]);let n=[];return y.Children.forEach(t,(r,a)=>{if(!y.isValidElement(r))return;let i=[...e,a];if(r.type===y.Fragment){n.push.apply(n,wg(r.props.children,i));return}r.type!==hn&&Kn(!1),!r.props.index||!r.props.children||Kn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=wg(r.props.children,i)),n.push(o)}),n}/**
- * React Router DOM v6.30.3
- *
- * Copyright (c) Remix Software Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE.md file in the root directory of this source tree.
- *
- * @license MIT
- */function jg(){return jg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function FT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function BT(t,e){return t.button===0&&(!e||e==="_self")&&!FT(t)}function kg(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 r=t[n];return e.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function VT(t,e){let n=kg(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const HT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],UT="6";try{window.__reactRouterVersion=UT}catch{}const WT="startTransition",x1=bp[WT];function KT(t){let{basename:e,children:n,future:r,window:a}=t,i=y.useRef();i.current==null&&(i.current=UE({window:a,v5Compat:!0}));let o=i.current,[c,u]=y.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=y.useCallback(m=>{h&&x1?x1(()=>u(m)):u(m)},[u,h]);return y.useLayoutEffect(()=>o.listen(f),[o,f]),y.useEffect(()=>OT(r),[r]),y.createElement(_T,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const qT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",GT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fc=y.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,x=$T(e,HT),{basename:b}=y.useContext($o),v,w=!1;if(typeof h=="string"&>.test(h)&&(v=h,qT))try{let C=new URL(window.location.href),P=h.startsWith("//")?new URL(C.protocol+h):new URL(h),L=R0(P.pathname,b);P.origin===C.origin&&L!=null?h=L+P.search+P.hash:w=!0}catch{}let N=yT(h,{relative:a}),k=JT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function T(C){r&&r(C),C.defaultPrevented||k(C)}return y.createElement("a",jg({},x,{href:v||N,onClick:w||i?r:T,ref:n,target:u}))});var g1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(g1||(g1={}));var y1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(y1||(y1={}));function JT(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Ga(),h=Fo(),f=Rj(t,{relative:o});return y.useCallback(m=>{if(BT(m,n)){m.preventDefault();let x=r!==void 0?r:mf(h)===mf(f);u(t,{replace:x,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function _0(t){let e=y.useRef(kg(t)),n=y.useRef(!1),r=Fo(),a=y.useMemo(()=>VT(r.search,n.current?null:e.current),[r.search]),i=Ga(),o=y.useCallback((c,u)=>{const h=kg(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 QT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),YT=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),b1=t=>{const e=YT(t);return e.charAt(0).toUpperCase()+e.slice(1)},_j=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),XT=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.
- * See the LICENSE file in the root directory of this source tree.
- */var ZT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
- * @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 e5=y.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:o,...c},u)=>y.createElement("svg",{ref:u,...ZT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_j("lucide",a),...!i&&!XT(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>y.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=y.forwardRef(({className:r,...a},i)=>y.createElement(e5,{ref:i,iconNode:e,className:_j(`lucide-${QT(b1(t))}`,`lucide-${t}`,r),...a}));return n.displayName=b1(t),n};/**
- * @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 t5=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Sx=Ie("arrow-up-down",t5);/**
- * @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 n5=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],s5=Ie("at-sign",n5);/**
- * @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 r5=[["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"}]],v1=Ie("bitcoin",r5);/**
- * @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 a5=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],i5=Ie("bold",a5);/**
- * @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 o5=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],wr=Ie("book-open",o5);/**
- * @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 l5=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Sg=Ie("calendar",l5);/**
- * @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:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Sc=Ie("chart-column",c5);/**
- * @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 d5=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Np=Ie("check",d5);/**
- * @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 u5=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Sl=Ie("chevron-down",u5);/**
- * @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 h5=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],f5=Ie("chevron-left",h5);/**
- * @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 p5=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ml=Ie("chevron-right",p5);/**
- * @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 m5=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Cg=Ie("chevron-up",m5);/**
- * @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 x5=[["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"}]],zj=Ie("circle-alert",x5);/**
- * @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 g5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Cx=Ie("circle-check-big",g5);/**
- * @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 y5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$j=Ie("circle-check",y5);/**
- * @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 b5=[["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"}]],Fj=Ie("circle-question-mark",b5);/**
- * @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 v5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],Ih=Ie("circle-user",v5);/**
- * @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 N5=[["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"}]],Bj=Ie("circle-x",N5);/**
- * @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 w5=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Eg=Ie("clock",w5);/**
- * @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 j5=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],N1=Ie("cloud",j5);/**
- * @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 k5=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],S5=Ie("code",k5);/**
- * @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=[["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"}]],Vj=Ie("copy",C5);/**
- * @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 E5=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],w1=Ie("credit-card",E5);/**
- * @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 T5=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],Oc=Ie("crown",T5);/**
- * @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 M5=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],xf=Ie("dollar-sign",M5);/**
- * @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 A5=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],I5=Ie("download",A5);/**
- * @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 P5=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Pi=Ie("external-link",P5);/**
- * @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 R5=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],L5=Ie("eye-off",R5);/**
- * @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 O5=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],gf=Ie("eye",O5);/**
- * @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 D5=[["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"}]],Hj=Ie("file-text",D5);/**
- * @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 _5=[["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"}]],Uj=Ie("funnel",_5);/**
- * @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 z5=[["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"}]],Tg=Ie("gift",z5);/**
- * @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 $5=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],F5=Ie("git-merge",$5);/**
- * @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 B5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Mg=Ie("globe",B5);/**
- * @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 V5=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],H5=Ie("graduation-cap",V5);/**
- * @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 U5=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],gi=Ie("grip-vertical",U5);/**
- * @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 W5=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],K5=Ie("handshake",W5);/**
- * @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 q5=[["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"}]],j1=Ie("hash",q5);/**
- * @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 G5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],J5=Ie("heading-1",G5);/**
- * @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 Q5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Y5=Ie("heading-2",Q5);/**
- * @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 X5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Z5=Ie("heading-3",X5);/**
- * @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:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],tM=Ie("house",eM);/**
- * @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 nM=[["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"}]],Wj=Ie("image",nM);/**
- * @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 sM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ph=Ie("info",sM);/**
- * @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 rM=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],aM=Ie("italic",rM);/**
- * @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 iM=[["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"}]],Ag=Ie("key",iM);/**
- * @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 oM=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],lM=Ie("layout-dashboard",oM);/**
- * @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 cM=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],dM=Ie("layout-grid",cM);/**
- * @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=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ba=Ie("link-2",uM);/**
- * @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 hM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Ig=Ie("link",hM);/**
- * @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 fM=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],pM=Ie("list-ordered",fM);/**
- * @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 mM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],xM=Ie("list",mM);/**
- * @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 gM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],yM=Ie("lock",gM);/**
- * @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:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],vM=Ie("log-out",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 NM=[["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"}]],Kj=Ie("map-pin",NM);/**
- * @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 wM=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],jM=Ie("menu",wM);/**
- * @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 kM=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],SM=Ie("message-circle",kM);/**
- * @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 CM=[["path",{d:"M5 12h14",key:"1ays0h"}]],EM=Ie("minus",CM);/**
- * @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 TM=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],ya=Ie("navigation",TM);/**
- * @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 MM=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],AM=Ie("palette",MM);/**
- * @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 IM=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],PM=Ie("paperclip",IM);/**
- * @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 RM=[["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"}]],rn=Ie("pen-line",RM);/**
- * @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 LM=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],k1=Ie("pencil",LM);/**
- * @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 OM=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],DM=Ie("percent",OM);/**
- * @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 _M=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],S1=Ie("phone",_M);/**
- * @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 zM=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],C1=Ie("pin",zM);/**
- * @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 $M=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Un=Ie("plus",$M);/**
- * @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 FM=[["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"}]],E1=Ie("qr-code",FM);/**
- * @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:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],VM=Ie("quote",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 HM=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],UM=Ie("redo",HM);/**
- * @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 WM=[["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"}]],Ve=Ie("refresh-cw",WM);/**
- * @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 KM=[["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"}]],In=Ie("save",KM);/**
- * @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 qM=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],va=Ie("search",qM);/**
- * @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 GM=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],JM=Ie("send",GM);/**
- * @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 QM=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],wo=Ie("settings",QM);/**
- * @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 YM=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Rh=Ie("settings-2",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 XM=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],ZM=Ie("share-2",XM);/**
- * @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 eA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Pc=Ie("shield-check",eA);/**
- * @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 tA=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],Gd=Ie("shopping-bag",tA);/**
- * @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 nA=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Cl=Ie("smartphone",nA);/**
- * @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 sA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],rA=Ie("smile",sA);/**
- * @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 aA=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],iA=Ie("sparkles",aA);/**
- * @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 oA=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Rc=Ie("star",oA);/**
- * @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 lA=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],cA=Ie("strikethrough",lA);/**
- * @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 dA=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],uA=Ie("table",dA);/**
- * @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 hA=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Jd=Ie("tag",hA);/**
- * @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 fA=[["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"}]],Yn=Ie("trash-2",fA);/**
- * @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 pA=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],yf=Ie("trending-up",pA);/**
- * @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 mA=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],Pg=Ie("trophy",mA);/**
- * @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 xA=[["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"}]],qj=Ie("undo-2",xA);/**
- * @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 gA=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],yA=Ie("undo",gA);/**
- * @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 bA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],bf=Ie("upload",bA);/**
- * @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 vA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],jo=Ie("user-plus",vA);/**
- * @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 NA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ci=Ie("user",NA);/**
- * @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 wA=[["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"}]],Wn=Ie("users",wA);/**
- * @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 jA=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],kA=Ie("video",jA);/**
- * @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 SA=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Bc=Ie("wallet",SA);/**
- * @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 CA=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],EA=Ie("wand-sparkles",CA);/**
- * @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 TA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rs=Ie("x",TA);/**
- * @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 MA=[["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"}]],Ri=Ie("zap",MA),z0="admin_token";function ku(){try{return localStorage.getItem(z0)}catch{return null}}function AA(t){try{localStorage.setItem(z0,t)}catch{}}function Ex(){try{localStorage.removeItem(z0)}catch{}}const IA="https://soulapi.quwanzhi.com",PA=15e3,T1=6e4,RA=()=>IA;function El(t){const e=RA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function wp(t,e={}){const{data:n,...r}=e,a=El(t),i=new Headers(r.headers),o=ku();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):r.body,u=r.timeout??PA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),x=m.headers.get("Content-Type")||"";let b;if(x.includes("application/json"))try{b=await m.json()}catch{throw new Error(`API 响应解析失败 (${m.status})`)}else{const w=await m.text();throw new Error(`API 返回非 JSON 响应 (${m.status}): ${w.slice(0,100)}`)}const v=w=>{const N=w,k=((N==null?void 0:N.message)||(N==null?void 0:N.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){v(b);const w=new Error((b==null?void 0:b.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=b,w}return v(b),b}function Oe(t,e){return wp(t,{...e,method:"GET"})}function jt(t,e,n){return wp(t,{...n,method:"POST",data:e})}function tn(t,e,n){return wp(t,{...n,method:"PUT",data:e})}function Ei(t,e){return wp(t,{...e,method:"DELETE"})}function LA(){const[t,e]=y.useState(!1),[n,r]=y.useState("");return y.useEffect(()=>{const a=i=>{const o=i.detail;r(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?s.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:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(zj,{className:"w-5 h-5 shrink-0 text-red-400"}),s.jsxs("span",{className:"text-sm font-medium",children:[n,s.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),s.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:s.jsx(rs,{className:"w-4 h-4"})})]}):null}const OA=[{icon:lM,label:"数据概览",href:"/dashboard"},{icon:wr,label:"内容管理",href:"/content"},{icon:Wn,label:"用户管理",href:"/users"},{icon:F5,label:"找伙伴",href:"/find-partner"},{icon:Bc,label:"推广中心",href:"/distribution"}];function DA(){const t=Fo(),e=Ga(),[n,r]=y.useState(!1),[a,i]=y.useState(!1);y.useEffect(()=>{r(!0)},[]),y.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!ku()){e("/login",{replace:!0});return}return Oe("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(Ex(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(Ex(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{Ex();try{await jt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[OA.map(c=>{const u=t.pathname===c.href;return s.jsxs(Fc,{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:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(Fc,{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:[s.jsx(wo,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.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:[s.jsx(vM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(LA,{}),s.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:s.jsx(DT,{})})]})]})}function M1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function $0(...t){return e=>{let n=!1;const r=t.map(a=>{const i=M1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;Gj(i)&&typeof vf=="function"&&(i=vf(i._payload));const c=y.Children.toArray(i),u=c.find(BA);if(u){const h=u.props.children,f=c.map(m=>m===u?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:y.isValidElement(h)?y.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var Qj=Jj("Slot");function $A(t){const e=y.forwardRef((n,r)=>{let{children:a,...i}=n;if(Gj(a)&&typeof vf=="function"&&(a=vf(a._payload)),y.isValidElement(a)){const o=HA(a),c=VA(i,a.props);return a.type!==y.Fragment&&(c.ref=r?$0(r,o):o),y.cloneElement(a,c)}return y.Children.count(a)>1?y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var FA=Symbol("radix.slottable");function BA(t){return y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===FA}function VA(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function HA(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 Yj(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=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,I1=Xj,Zj=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return I1(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 x=A1(f)||A1(m);return a[h][x]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,x]=f;return x===void 0||(h[m]=x),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:x,...b}=f;return Object.entries(b).every(v=>{let[w,N]=v;return Array.isArray(N)?N.includes({...i,...c}[w]):{...i,...c}[w]===N})?[...h,m,x]:h},[]);return I1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},UA=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),ek=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Nf="-",P1=[],KA="arbitrary..",qA=t=>{const e=JA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return GA(o);const c=o.split(Nf),u=c[0]===""&&c.length>1?1:0;return tk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?UA(h,u):u:h||P1}return n[o]||P1}}},tk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=tk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Nf):t.slice(e).join(Nf),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?KA+r:void 0})(),JA=t=>{const{theme:e,classGroups:n}=t;return QA(n,e)},QA=(t,e)=>{const n=ek();for(const r in t){const a=t[r];F0(a,n,r,e)}return n},F0=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){XA(t,e,n);return}if(typeof t=="function"){ZA(t,e,n,r);return}eI(t,e,n,r)},XA=(t,e,n)=>{const r=t===""?e:nk(e,t);r.classGroupId=n},ZA=(t,e,n,r)=>{if(tI(t)){F0(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(WA(n,t))},eI=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(Nf),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,nI=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Rg="!",R1=":",sI=[],L1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),rI=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let w=0;wu?h-u:void 0;return L1(i,b,x,v)};if(e){const a=e+R1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):L1(sI,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},aI=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let i=0;i0&&(a.sort(),r.push(...a),a=[]),r.push(o)):a.push(o)}return a.length>0&&(a.sort(),r.push(...a)),r}},iI=t=>({cache:nI(t.cacheSize),parseClassName:rI(t),sortModifiers:aI(t),...qA(t)}),oI=/\s+/,lI=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(oI);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:b,baseClassName:v,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let N=!!w,k=r(N?v.substring(0,w):v);if(!k){if(!N){u=f+(u.length>0?" "+u:u);continue}if(k=r(v),!k){u=f+(u.length>0?" "+u:u);continue}N=!1}const T=x.length===0?"":x.length===1?x[0]:i(x).join(":"),C=b?T+Rg:T,P=C+k;if(o.indexOf(P)>-1)continue;o.push(P);const L=a(k,N);for(let q=0;q0?" "+u:u)}return u},cI=(...t)=>{let e=0,n,r,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=iI(h),r=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=lI(u,n);return a(u,f),f};return i=o,(...u)=>i(cI(...u))},uI=[],ss=t=>{const e=n=>n[t]||uI;return e.isThemeGetter=!0,e},rk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ak=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hI=/^\d+\/\d+$/,fI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,pI=/\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$/,mI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,xI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yc=t=>hI.test(t),Pt=t=>!!t&&!Number.isNaN(Number(t)),co=t=>!!t&&Number.isInteger(Number(t)),Tx=t=>t.endsWith("%")&&Pt(t.slice(0,-1)),yi=t=>fI.test(t),yI=()=>!0,bI=t=>pI.test(t)&&!mI.test(t),ik=()=>!1,vI=t=>xI.test(t),NI=t=>gI.test(t),wI=t=>!tt(t)&&!nt(t),jI=t=>ed(t,ck,ik),tt=t=>rk.test(t),dl=t=>ed(t,dk,bI),Mx=t=>ed(t,TI,Pt),O1=t=>ed(t,ok,ik),kI=t=>ed(t,lk,NI),Lh=t=>ed(t,uk,vI),nt=t=>ak.test(t),Dd=t=>td(t,dk),SI=t=>td(t,MI),D1=t=>td(t,ok),CI=t=>td(t,ck),EI=t=>td(t,lk),Oh=t=>td(t,uk,!0),ed=(t,e,n)=>{const r=rk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},td=(t,e,n=!1)=>{const r=ak.exec(t);return r?r[1]?e(r[1]):n:!1},ok=t=>t==="position"||t==="percentage",lk=t=>t==="image"||t==="url",ck=t=>t==="length"||t==="size"||t==="bg-size",dk=t=>t==="length",TI=t=>t==="number",MI=t=>t==="family-name",uk=t=>t==="shadow",AI=()=>{const t=ss("color"),e=ss("font"),n=ss("text"),r=ss("font-weight"),a=ss("tracking"),i=ss("leading"),o=ss("breakpoint"),c=ss("container"),u=ss("spacing"),h=ss("radius"),f=ss("shadow"),m=ss("inset-shadow"),x=ss("text-shadow"),b=ss("drop-shadow"),v=ss("blur"),w=ss("perspective"),N=ss("aspect"),k=ss("ease"),T=ss("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...P(),nt,tt],q=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],H=()=>[nt,tt,u],R=()=>[yc,"full","auto",...H()],se=()=>[co,"none","subgrid",nt,tt],X=()=>["auto",{span:["full",co,nt,tt]},co,nt,tt],V=()=>[co,"auto",nt,tt],ie=()=>["auto","min","max","fr",nt,tt],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],he=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...H()],Q=()=>[yc,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...H()],$=()=>[t,nt,tt],xe=()=>[...P(),D1,O1,{position:[nt,tt]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",CI,jI,{size:[nt,tt]}],U=()=>[Tx,Dd,dl],pe=()=>["","none","full",h,nt,tt],fe=()=>["",Pt,Dd,dl],oe=()=>["solid","dashed","dotted","double"],D=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[Pt,Tx,D1,O1],_=()=>["","none",v,nt,tt],Y=()=>["none",Pt,nt,tt],te=()=>["none",Pt,nt,tt],Ne=()=>[Pt,nt,tt],Fe=()=>[yc,"full",...H()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[yi],breakpoint:[yi],color:[yI],container:[yi],"drop-shadow":[yi],ease:["in","out","in-out"],font:[wI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[yi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[yi],shadow:[yi],spacing:["px",Pt],text:[yi],"text-shadow":[yi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yc,tt,nt,N]}],container:["container"],columns:[{columns:[Pt,tt,nt,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"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:L()}],overflow:[{overflow:q()}],"overflow-x":[{"overflow-x":q()}],"overflow-y":[{"overflow-y":q()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{start:R()}],end:[{end:R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[co,"auto",nt,tt]}],basis:[{basis:[yc,"full","auto",c,...H()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pt,yc,"auto","initial","none",tt]}],grow:[{grow:["",Pt,nt,tt]}],shrink:[{shrink:["",Pt,nt,tt]}],order:[{order:[co,"first","last","none",nt,tt]}],"grid-cols":[{"grid-cols":se()}],"col-start-end":[{col:X()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":se()}],"row-start-end":[{row:X()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:H()}],"gap-x":[{"gap-x":H()}],"gap-y":[{"gap-y":H()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...he(),"normal"]}],"justify-self":[{"justify-self":["auto",...he()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...he(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...he(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...he(),"baseline"]}],"place-self":[{"place-self":["auto",...he()]}],p:[{p:H()}],px:[{px:H()}],py:[{py:H()}],ps:[{ps:H()}],pe:[{pe:H()}],pt:[{pt:H()}],pr:[{pr:H()}],pb:[{pb:H()}],pl:[{pl:H()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":H()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":H()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Dd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,nt,Mx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Tx,tt]}],"font-family":[{font:[SI,tt,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,nt,tt]}],"line-clamp":[{"line-clamp":[Pt,"none",nt,Mx]}],leading:[{leading:[i,...H()]}],"list-image":[{"list-image":["none",nt,tt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",nt,tt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pt,"from-font","auto",nt,dl]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[Pt,"auto",nt,tt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:H()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",nt,tt]}],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",nt,tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},co,nt,tt],radial:["",nt,tt],conic:[co,nt,tt]},EI,kI]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:fe()}],"border-w-x":[{"border-x":fe()}],"border-w-y":[{"border-y":fe()}],"border-w-s":[{"border-s":fe()}],"border-w-e":[{"border-e":fe()}],"border-w-t":[{"border-t":fe()}],"border-w-r":[{"border-r":fe()}],"border-w-b":[{"border-b":fe()}],"border-w-l":[{"border-l":fe()}],"divide-x":[{"divide-x":fe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":fe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pt,nt,tt]}],"outline-w":[{outline:["",Pt,Dd,dl]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",f,Oh,Lh]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",m,Oh,Lh]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:fe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[Pt,dl]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":fe()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",x,Oh,Lh]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[Pt,nt,tt]}],"mix-blend":[{"mix-blend":[...D(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":D()}],"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":[Pt]}],"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":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"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":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"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":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"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":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"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":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"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":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"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":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[nt,tt]}],"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":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"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":P()}],"mask-image-conic-pos":[{"mask-conic":[Pt]}],"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":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",nt,tt]}],filter:[{filter:["","none",nt,tt]}],blur:[{blur:_()}],brightness:[{brightness:[Pt,nt,tt]}],contrast:[{contrast:[Pt,nt,tt]}],"drop-shadow":[{"drop-shadow":["","none",b,Oh,Lh]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",Pt,nt,tt]}],"hue-rotate":[{"hue-rotate":[Pt,nt,tt]}],invert:[{invert:["",Pt,nt,tt]}],saturate:[{saturate:[Pt,nt,tt]}],sepia:[{sepia:["",Pt,nt,tt]}],"backdrop-filter":[{"backdrop-filter":["","none",nt,tt]}],"backdrop-blur":[{"backdrop-blur":_()}],"backdrop-brightness":[{"backdrop-brightness":[Pt,nt,tt]}],"backdrop-contrast":[{"backdrop-contrast":[Pt,nt,tt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pt,nt,tt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pt,nt,tt]}],"backdrop-invert":[{"backdrop-invert":["",Pt,nt,tt]}],"backdrop-opacity":[{"backdrop-opacity":[Pt,nt,tt]}],"backdrop-saturate":[{"backdrop-saturate":[Pt,nt,tt]}],"backdrop-sepia":[{"backdrop-sepia":["",Pt,nt,tt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":H()}],"border-spacing-x":[{"border-spacing-x":H()}],"border-spacing-y":[{"border-spacing-y":H()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",nt,tt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pt,"initial",nt,tt]}],ease:[{ease:["linear","initial",k,nt,tt]}],delay:[{delay:[Pt,nt,tt]}],animate:[{animate:["none",T,nt,tt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,nt,tt]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Y()}],"rotate-x":[{"rotate-x":Y()}],"rotate-y":[{"rotate-y":Y()}],"rotate-z":[{"rotate-z":Y()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:Ne()}],"skew-x":[{"skew-x":Ne()}],"skew-y":[{"skew-y":Ne()}],transform:[{transform:[nt,tt,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"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",nt,tt]}],"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":H()}],"scroll-mx":[{"scroll-mx":H()}],"scroll-my":[{"scroll-my":H()}],"scroll-ms":[{"scroll-ms":H()}],"scroll-me":[{"scroll-me":H()}],"scroll-mt":[{"scroll-mt":H()}],"scroll-mr":[{"scroll-mr":H()}],"scroll-mb":[{"scroll-mb":H()}],"scroll-ml":[{"scroll-ml":H()}],"scroll-p":[{"scroll-p":H()}],"scroll-px":[{"scroll-px":H()}],"scroll-py":[{"scroll-py":H()}],"scroll-ps":[{"scroll-ps":H()}],"scroll-pe":[{"scroll-pe":H()}],"scroll-pt":[{"scroll-pt":H()}],"scroll-pr":[{"scroll-pr":H()}],"scroll-pb":[{"scroll-pb":H()}],"scroll-pl":[{"scroll-pl":H()}],"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",nt,tt]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[Pt,Dd,dl,Mx]}],stroke:[{stroke:["none",...$()]}],"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"]}},II=dI(AI);function $t(...t){return II(Xj(t))}function Ua(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const PI=Zj("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 J({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?Qj:"button";return s.jsx(i,{"data-slot":"button",className:$t(PI({variant:e,size:n,className:t})),...a})}function ce({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:$t("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 RI(){const t=Ga(),[e,n]=y.useState(""),[r,a]=y.useState(""),[i,o]=y.useState(""),[c,u]=y.useState(!1);y.useEffect(()=>{ku()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await jt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){AA(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 s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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:s.jsx(Pc,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ce,{type:"text",value:e,onChange:f=>{n(f.target.value),i&&o("")},placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(yM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ce,{type:"password",value:r,onChange:f=>{a(f.target.value),i&&o("")},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&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),s.jsx(J,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const _e=y.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:$t("rounded-xl border bg-card text-card-foreground shadow",t),...e}));_e.displayName="Card";const ft=y.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:$t("flex flex-col space-y-1.5 p-6",t),...e}));ft.displayName="CardHeader";const pt=y.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:$t("font-semibold leading-none tracking-tight",t),...e}));pt.displayName="CardTitle";const nn=y.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:$t("text-sm text-muted-foreground",t),...e}));nn.displayName="CardDescription";const ze=y.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:$t("p-6 pt-0",t),...e}));ze.displayName="CardContent";const LI=y.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:$t("flex items-center p-6 pt-0",t),...e}));LI.displayName="CardFooter";const OI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Ax(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=OI[e],i=document.createElement("div");i.id=r,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(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const G={success:(t,e)=>Ax(t,"success",e),error:(t,e)=>Ax(t,"error",e),info:(t,e)=>Ax(t,"info",e)};function Tt(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 DI(t,e){const n=y.createContext(e),r=i=>{const{children:o,...c}=i,u=y.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=y.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function Bo(t,e=[]){let n=[];function r(i,o){const c=y.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:x,children:b,...v}=m,w=((k=x==null?void 0:x[t])==null?void 0:k[u])||c,N=y.useMemo(()=>v,Object.values(v));return s.jsx(w.Provider,{value:N,children:b})};h.displayName=i+"Provider";function f(m,x){var w;const b=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,v=y.useContext(b);if(v)return v;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=>y.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return y.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,_I(a,...e)]}function _I(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return y.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Ws=globalThis!=null&&globalThis.document?y.useLayoutEffect:()=>{},zI=bp[" useId ".trim().toString()]||(()=>{}),$I=0;function To(t){const[e,n]=y.useState(zI());return Ws(()=>{n(r=>r??String($I++))},[t]),e?`radix-${e}`:""}var FI=bp[" useInsertionEffect ".trim().toString()]||Ws;function Tl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=BI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=y.useRef(t!==void 0);y.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} 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,r])}const h=y.useCallback(f=>{var m;if(c){const x=VI(f)?f(t):f;x!==t&&((m=o.current)==null||m.call(o,x))}else i(f)},[c,t,i,o]);return[u,h]}function BI({defaultProp:t,onChange:e}){const[n,r]=y.useState(t),a=y.useRef(n),i=y.useRef(e);return FI(()=>{i.current=e},[e]),y.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function VI(t){return typeof t=="function"}function cu(t){const e=HI(t),n=y.forwardRef((r,a)=>{const{children:i,...o}=r,c=y.Children.toArray(i),u=c.find(WI);if(u){const h=u.props.children,f=c.map(m=>m===u?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:y.isValidElement(h)?y.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function HI(t){const e=y.forwardRef((n,r)=>{const{children:a,...i}=n;if(y.isValidElement(a)){const o=qI(a),c=KI(i,a.props);return a.type!==y.Fragment&&(c.ref=r?$0(r,o):o),y.cloneElement(a,c)}return y.Children.count(a)>1?y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var UI=Symbol("radix.slottable");function WI(t){return y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===UI}function KI(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function qI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 GI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=GI.reduce((t,e)=>{const n=cu(`Primitive.${e}`),r=y.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function JI(t,e){t&&Yc.flushSync(()=>t.dispatchEvent(e))}function Ro(t){const e=y.useRef(t);return y.useEffect(()=>{e.current=t}),y.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function QI(t,e=globalThis==null?void 0:globalThis.document){const n=Ro(t);y.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var YI="DismissableLayer",Lg="dismissableLayer.update",XI="dismissableLayer.pointerDownOutside",ZI="dismissableLayer.focusOutside",_1,hk=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),B0=y.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=y.useContext(hk),[f,m]=y.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=y.useState({}),v=Zt(e,z=>m(z)),w=Array.from(h.layers),[N]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(N),T=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,P=T>=k,L=nP(z=>{const H=z.target,R=[...h.branches].some(se=>se.contains(H));!P||R||(a==null||a(z),o==null||o(z),z.defaultPrevented||c==null||c())},x),q=sP(z=>{const H=z.target;[...h.branches].some(se=>se.contains(H))||(i==null||i(z),o==null||o(z),z.defaultPrevented||c==null||c())},x);return QI(z=>{T===h.layers.size-1&&(r==null||r(z),!z.defaultPrevented&&c&&(z.preventDefault(),c()))},x),y.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(_1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),z1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=_1)}},[f,x,n,h]),y.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),z1())},[f,h]),y.useEffect(()=>{const z=()=>b({});return document.addEventListener(Lg,z),()=>document.removeEventListener(Lg,z)},[]),s.jsx(Rt.div,{...u,ref:v,style:{pointerEvents:C?P?"auto":"none":void 0,...t.style},onFocusCapture:Tt(t.onFocusCapture,q.onFocusCapture),onBlurCapture:Tt(t.onBlurCapture,q.onBlurCapture),onPointerDownCapture:Tt(t.onPointerDownCapture,L.onPointerDownCapture)})});B0.displayName=YI;var eP="DismissableLayerBranch",tP=y.forwardRef((t,e)=>{const n=y.useContext(hk),r=y.useRef(null),a=Zt(e,r);return y.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Rt.div,{...t,ref:a})});tP.displayName=eP;function nP(t,e=globalThis==null?void 0:globalThis.document){const n=Ro(t),r=y.useRef(!1),a=y.useRef(()=>{});return y.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){fk(XI,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);r.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:()=>r.current=!0}}function sP(t,e=globalThis==null?void 0:globalThis.document){const n=Ro(t),r=y.useRef(!1);return y.useEffect(()=>{const a=i=>{i.target&&!r.current&&fk(ZI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function z1(){const t=new CustomEvent(Lg);document.dispatchEvent(t)}function fk(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?JI(a,i):a.dispatchEvent(i)}var Ix="focusScope.autoFocusOnMount",Px="focusScope.autoFocusOnUnmount",$1={bubbles:!1,cancelable:!0},rP="FocusScope",V0=y.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=y.useState(null),h=Ro(a),f=Ro(i),m=y.useRef(null),x=Zt(e,w=>u(w)),b=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let w=function(C){if(b.paused||!c)return;const P=C.target;c.contains(P)?m.current=P:fo(m.current,{select:!0})},N=function(C){if(b.paused||!c)return;const P=C.relatedTarget;P!==null&&(c.contains(P)||fo(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const L of C)L.removedNodes.length>0&&fo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",N);const T=new MutationObserver(k);return c&&T.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",N),T.disconnect()}}},[r,c,b.paused]),y.useEffect(()=>{if(c){B1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Ix,$1);c.addEventListener(Ix,h),c.dispatchEvent(k),k.defaultPrevented||(aP(dP(pk(c)),{select:!0}),document.activeElement===w&&fo(c))}return()=>{c.removeEventListener(Ix,h),setTimeout(()=>{const k=new CustomEvent(Px,$1);c.addEventListener(Px,f),c.dispatchEvent(k),k.defaultPrevented||fo(w??document.body,{select:!0}),c.removeEventListener(Px,f),B1.remove(b)},0)}}},[c,h,f,b]);const v=y.useCallback(w=>{if(!n&&!r||b.paused)return;const N=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(N&&k){const T=w.currentTarget,[C,P]=iP(T);C&&P?!w.shiftKey&&k===P?(w.preventDefault(),n&&fo(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&fo(P,{select:!0})):k===T&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Rt.div,{tabIndex:-1,...o,ref:x,onKeyDown:v})});V0.displayName=rP;function aP(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(fo(r,{select:e}),document.activeElement!==n)return}function iP(t){const e=pk(t),n=F1(e,t),r=F1(e.reverse(),t);return[n,r]}function pk(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function F1(t,e){for(const n of t)if(!oP(n,{upTo:e}))return n}function oP(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 lP(t){return t instanceof HTMLInputElement&&"select"in t}function fo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&lP(t)&&e&&t.select()}}var B1=cP();function cP(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=V1(t,e),t.unshift(e)},remove(e){var n;t=V1(t,e),(n=t[0])==null||n.resume()}}}function V1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function dP(t){return t.filter(e=>e.tagName!=="A")}var uP="Portal",H0=y.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=y.useState(!1);Ws(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Ej.createPortal(s.jsx(Rt.div,{...r,ref:e}),o):null});H0.displayName=uP;function hP(t,e){return y.useReducer((n,r)=>e[n][r]??n,t)}var Su=t=>{const{present:e,children:n}=t,r=fP(e),a=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),i=Zt(r.ref,pP(a));return typeof n=="function"||r.isPresent?y.cloneElement(a,{ref:i}):null};Su.displayName="Presence";function fP(t){const[e,n]=y.useState(),r=y.useRef(null),a=y.useRef(t),i=y.useRef("none"),o=t?"mounted":"unmounted",[c,u]=hP(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const h=Dh(r.current);i.current=c==="mounted"?h:"none"},[c]),Ws(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Dh(h);t?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),Ws(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Dh(r.current).includes(CSS.escape(b.animationName));if(b.target===e&&w&&(u("ANIMATION_END"),!a.current)){const N=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=N)})}},x=b=>{b.target===e&&(i.current=Dh(r.current))};return e.addEventListener("animationstart",x),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",x),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:y.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Dh(t){return(t==null?void 0:t.animationName)||"none"}function pP(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 Rx=0;function mk(){y.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??H1()),document.body.insertAdjacentElement("beforeend",t[1]??H1()),Rx++,()=>{Rx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Rx--}},[])}function H1(){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 Fa=function(){return Fa=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return IP;var e=PP(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},LP=bk(),Dc="data-scroll-locked",OP=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
- .`.concat(xP,` {
- overflow: hidden `).concat(r,`;
- padding-right: `).concat(c,"px ").concat(r,`;
- }
- body[`).concat(Dc,`] {
- overflow: hidden `).concat(r,`;
- overscroll-behavior: contain;
- `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
- padding-left: `.concat(a,`px;
- padding-top: `).concat(i,`px;
- padding-right: `).concat(o,`px;
- margin-left:0;
- margin-top:0;
- margin-right: `).concat(c,"px ").concat(r,`;
- `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
- }
-
- .`).concat(rf,` {
- right: `).concat(c,"px ").concat(r,`;
- }
-
- .`).concat(af,` {
- margin-right: `).concat(c,"px ").concat(r,`;
- }
-
- .`).concat(rf," .").concat(rf,` {
- right: 0 `).concat(r,`;
- }
-
- .`).concat(af," .").concat(af,` {
- margin-right: 0 `).concat(r,`;
- }
-
- body[`).concat(Dc,`] {
- `).concat(gP,": ").concat(c,`px;
- }
-`)},W1=function(){var t=parseInt(document.body.getAttribute(Dc)||"0",10);return isFinite(t)?t:0},DP=function(){y.useEffect(function(){return document.body.setAttribute(Dc,(W1()+1).toString()),function(){var t=W1()-1;t<=0?document.body.removeAttribute(Dc):document.body.setAttribute(Dc,t.toString())}},[])},_P=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;DP();var i=y.useMemo(function(){return RP(a)},[a]);return y.createElement(LP,{styles:OP(i,!e,a,n?"":"!important")})},Og=!1;if(typeof window<"u")try{var _h=Object.defineProperty({},"passive",{get:function(){return Og=!0,!0}});window.addEventListener("test",_h,_h),window.removeEventListener("test",_h,_h)}catch{Og=!1}var bc=Og?{passive:!1}:!1,zP=function(t){return t.tagName==="TEXTAREA"},vk=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!zP(t)&&n[e]==="visible")},$P=function(t){return vk(t,"overflowY")},FP=function(t){return vk(t,"overflowX")},K1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Nk(t,r);if(a){var i=wk(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},BP=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},VP=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Nk=function(t,e){return t==="v"?$P(e):FP(e)},wk=function(t,e){return t==="v"?BP(e):VP(e)},HP=function(t,e){return t==="h"&&e==="rtl"?-1:1},UP=function(t,e,n,r,a){var i=HP(t,window.getComputedStyle(e).direction),o=i*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,x=0;do{if(!c)break;var b=wk(t,c),v=b[0],w=b[1],N=b[2],k=w-N-i*v;(v||k)&&Nk(t,c)&&(m+=k,x+=v);var T=c.parentNode;c=T&&T.nodeType===Node.DOCUMENT_FRAGMENT_NODE?T.host:T}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(x)<1)&&(h=!0),h},zh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},q1=function(t){return[t.deltaX,t.deltaY]},G1=function(t){return t&&"current"in t?t.current:t},WP=function(t,e){return t[0]===e[0]&&t[1]===e[1]},KP=function(t){return`
- .block-interactivity-`.concat(t,` {pointer-events: none;}
- .allow-interactivity-`).concat(t,` {pointer-events: all;}
-`)},qP=0,vc=[];function GP(t){var e=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(qP++)[0],i=y.useState(bk)[0],o=y.useRef(t);y.useEffect(function(){o.current=t},[t]),y.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=mP([t.lockRef.current],(t.shards||[]).map(G1),!0).filter(Boolean);return w.forEach(function(N){return N.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=y.useCallback(function(w,N){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=zh(w),T=n.current,C="deltaX"in w?w.deltaX:T[0]-k[0],P="deltaY"in w?w.deltaY:T[1]-k[1],L,q=w.target,z=Math.abs(C)>Math.abs(P)?"h":"v";if("touches"in w&&z==="h"&&q.type==="range")return!1;var H=window.getSelection(),R=H&&H.anchorNode,se=R?R===q||R.contains(q):!1;if(se)return!1;var X=K1(z,q);if(!X)return!0;if(X?L=z:(L=z==="v"?"h":"v",X=K1(z,q)),!X)return!1;if(!r.current&&"changedTouches"in w&&(C||P)&&(r.current=L),!L)return!0;var V=r.current||L;return UP(V,N,w,V==="h"?C:P)},[]),u=y.useCallback(function(w){var N=w;if(!(!vc.length||vc[vc.length-1]!==i)){var k="deltaY"in N?q1(N):zh(N),T=e.current.filter(function(L){return L.name===N.type&&(L.target===N.target||N.target===L.shadowParent)&&WP(L.delta,k)})[0];if(T&&T.should){N.cancelable&&N.preventDefault();return}if(!T){var C=(o.current.shards||[]).map(G1).filter(Boolean).filter(function(L){return L.contains(N.target)}),P=C.length>0?c(N,C[0]):!o.current.noIsolation;P&&N.cancelable&&N.preventDefault()}}},[]),h=y.useCallback(function(w,N,k,T){var C={name:w,delta:N,target:k,should:T,shadowParent:JP(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(P){return P!==C})},1)},[]),f=y.useCallback(function(w){n.current=zh(w),r.current=void 0},[]),m=y.useCallback(function(w){h(w.type,q1(w),w.target,c(w,t.lockRef.current))},[]),x=y.useCallback(function(w){h(w.type,zh(w),w.target,c(w,t.lockRef.current))},[]);y.useEffect(function(){return vc.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,bc),document.addEventListener("touchmove",u,bc),document.addEventListener("touchstart",f,bc),function(){vc=vc.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,bc),document.removeEventListener("touchmove",u,bc),document.removeEventListener("touchstart",f,bc)}},[]);var b=t.removeScrollBar,v=t.inert;return y.createElement(y.Fragment,null,v?y.createElement(i,{styles:KP(a)}):null,b?y.createElement(_P,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function JP(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const QP=kP(yk,GP);var U0=y.forwardRef(function(t,e){return y.createElement(jp,Fa({},t,{ref:e,sideCar:QP}))});U0.classNames=jp.classNames;var YP=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Nc=new WeakMap,$h=new WeakMap,Fh={},_x=0,jk=function(t){return t&&(t.host||jk(t.parentNode))},XP=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=jk(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},ZP=function(t,e,n,r){var a=XP(e,Array.isArray(t)?t:[t]);Fh[n]||(Fh[n]=new WeakMap);var i=Fh[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(x){if(c.has(x))f(x);else try{var b=x.getAttribute(r),v=b!==null&&b!=="false",w=(Nc.get(x)||0)+1,N=(i.get(x)||0)+1;Nc.set(x,w),i.set(x,N),o.push(x),w===1&&v&&$h.set(x,!0),N===1&&x.setAttribute(n,"true"),v||x.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",x,k)}})};return f(e),c.clear(),_x++,function(){o.forEach(function(m){var x=Nc.get(m)-1,b=i.get(m)-1;Nc.set(m,x),i.set(m,b),x||($h.has(m)||m.removeAttribute(r),$h.delete(m)),b||m.removeAttribute(n)}),_x--,_x||(Nc=new WeakMap,Nc=new WeakMap,$h=new WeakMap,Fh={})}},kk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=YP(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),ZP(r,a,n,"aria-hidden")):function(){return null}},kp="Dialog",[Sk]=Bo(kp),[eR,ka]=Sk(kp),Ck=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=y.useRef(null),u=y.useRef(null),[h,f]=Tl({prop:r,defaultProp:a??!1,onChange:i,caller:kp});return s.jsx(eR,{scope:e,triggerRef:c,contentRef:u,contentId:To(),titleId:To(),descriptionId:To(),open:h,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Ck.displayName=kp;var Ek="DialogTrigger",tR=y.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ka(Ek,n),i=Zt(e,a.triggerRef);return s.jsx(Rt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":q0(a.open),...r,ref:i,onClick:Tt(t.onClick,a.onOpenToggle)})});tR.displayName=Ek;var W0="DialogPortal",[nR,Tk]=Sk(W0,{forceMount:void 0}),Mk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=ka(W0,e);return s.jsx(nR,{scope:e,forceMount:n,children:y.Children.map(r,o=>s.jsx(Su,{present:n||i.open,children:s.jsx(H0,{asChild:!0,container:a,children:o})}))})};Mk.displayName=W0;var wf="DialogOverlay",Ak=y.forwardRef((t,e)=>{const n=Tk(wf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=ka(wf,t.__scopeDialog);return i.modal?s.jsx(Su,{present:r||i.open,children:s.jsx(rR,{...a,ref:e})}):null});Ak.displayName=wf;var sR=cu("DialogOverlay.RemoveScroll"),rR=y.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ka(wf,n);return s.jsx(U0,{as:sR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Rt.div,{"data-state":q0(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ml="DialogContent",Ik=y.forwardRef((t,e)=>{const n=Tk(Ml,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=ka(Ml,t.__scopeDialog);return s.jsx(Su,{present:r||i.open,children:i.modal?s.jsx(aR,{...a,ref:e}):s.jsx(iR,{...a,ref:e})})});Ik.displayName=Ml;var aR=y.forwardRef((t,e)=>{const n=ka(Ml,t.__scopeDialog),r=y.useRef(null),a=Zt(e,n.contentRef,r);return y.useEffect(()=>{const i=r.current;if(i)return kk(i)},[]),s.jsx(Pk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Tt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Tt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:Tt(t.onFocusOutside,i=>i.preventDefault())})}),iR=y.forwardRef((t,e)=>{const n=ka(Ml,t.__scopeDialog),r=y.useRef(!1),a=y.useRef(!1);return s.jsx(Pk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(r.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()}})}),Pk=y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=ka(Ml,n),u=y.useRef(null),h=Zt(e,u);return mk(),s.jsxs(s.Fragment,{children:[s.jsx(V0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(B0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":q0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(oR,{titleId:c.titleId}),s.jsx(cR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),K0="DialogTitle",Rk=y.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ka(K0,n);return s.jsx(Rt.h2,{id:a.titleId,...r,ref:e})});Rk.displayName=K0;var Lk="DialogDescription",Ok=y.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ka(Lk,n);return s.jsx(Rt.p,{id:a.descriptionId,...r,ref:e})});Ok.displayName=Lk;var Dk="DialogClose",_k=y.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ka(Dk,n);return s.jsx(Rt.button,{type:"button",...r,ref:e,onClick:Tt(t.onClick,()=>a.onOpenChange(!1))})});_k.displayName=Dk;function q0(t){return t?"open":"closed"}var zk="DialogTitleWarning",[BV,$k]=DI(zk,{contentName:Ml,titleName:K0,docsSlug:"dialog"}),oR=({titleId:t})=>{const e=$k(zk),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 y.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},lR="DialogDescriptionWarning",cR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$k(lR).contentName}}.`;return y.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},dR=Ck,uR=Mk,hR=Ak,fR=Ik,pR=Rk,mR=Ok,xR=_k;function Wt(t){return s.jsx(dR,{"data-slot":"dialog",...t})}function gR(t){return s.jsx(uR,{...t})}const Fk=y.forwardRef(({className:t,...e},n)=>s.jsx(hR,{ref:n,className:$t("fixed inset-0 z-50 bg-black/50",t),...e}));Fk.displayName="DialogOverlay";const Ut=y.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(gR,{children:[s.jsx(Fk,{}),s.jsxs(fR,{ref:a,"aria-describedby":void 0,className:$t("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),...r,children:[e,n&&s.jsxs(xR,{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:[s.jsx(rs,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ut.displayName="DialogContent";function Kt({className:t,...e}){return s.jsx("div",{className:$t("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Sn({className:t,...e}){return s.jsx("div",{className:$t("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function qt(t){return s.jsx(pR,{className:"text-lg font-semibold leading-none",...t})}function jf(t){return s.jsx(mR,{className:"text-sm text-muted-foreground",...t})}const yR=Zj("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 He({className:t,variant:e,asChild:n=!1,...r}){const a=n?Qj:"span";return s.jsx(a,{className:$t(yR({variant:e}),t),...r})}var bR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vR=bR.reduce((t,e)=>{const n=Jj(`Primitive.${e}`),r=y.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),NR="Label",Bk=y.forwardRef((t,e)=>s.jsx(vR.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())}}));Bk.displayName=NR;var Vk=Bk;const ne=y.forwardRef(({className:t,...e},n)=>s.jsx(Vk,{ref:n,className:$t("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ne.displayName=Vk.displayName;function G0(t){const e=t+"CollectionProvider",[n,r]=Bo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:N,children:k}=w,T=sr.useRef(null),C=sr.useRef(new Map).current;return s.jsx(a,{scope:N,itemMap:C,collectionRef:T,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=cu(c),h=sr.forwardRef((w,N)=>{const{scope:k,children:T}=w,C=i(c,k),P=Zt(N,C.collectionRef);return s.jsx(u,{ref:P,children:T})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=cu(f),b=sr.forwardRef((w,N)=>{const{scope:k,children:T,...C}=w,P=sr.useRef(null),L=Zt(N,P),q=i(f,k);return sr.useEffect(()=>(q.itemMap.set(P,{ref:P,...C}),()=>void q.itemMap.delete(P))),s.jsx(x,{[m]:"",ref:L,children:T})});b.displayName=f;function v(w){const N=i(t+"CollectionConsumer",w);return sr.useCallback(()=>{const T=N.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${m}]`));return Array.from(N.itemMap.values()).sort((q,z)=>C.indexOf(q.ref.current)-C.indexOf(z.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},v,r]}var wR=y.createContext(void 0);function Sp(t){const e=y.useContext(wR);return t||e||"ltr"}var zx="rovingFocusGroup.onEntryFocus",jR={bubbles:!1,cancelable:!0},Cu="RovingFocusGroup",[Dg,Hk,kR]=G0(Cu),[SR,Uk]=Bo(Cu,[kR]),[CR,ER]=SR(Cu),Wk=y.forwardRef((t,e)=>s.jsx(Dg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Dg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(TR,{...t,ref:e})})}));Wk.displayName=Cu;var TR=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,x=y.useRef(null),b=Zt(e,x),v=Sp(i),[w,N]=Tl({prop:o,defaultProp:c??null,onChange:u,caller:Cu}),[k,T]=y.useState(!1),C=Ro(h),P=Hk(n),L=y.useRef(!1),[q,z]=y.useState(0);return y.useEffect(()=>{const H=x.current;if(H)return H.addEventListener(zx,C),()=>H.removeEventListener(zx,C)},[C]),s.jsx(CR,{scope:n,orientation:r,dir:v,loop:a,currentTabStopId:w,onItemFocus:y.useCallback(H=>N(H),[N]),onItemShiftTab:y.useCallback(()=>T(!0),[]),onFocusableItemAdd:y.useCallback(()=>z(H=>H+1),[]),onFocusableItemRemove:y.useCallback(()=>z(H=>H-1),[]),children:s.jsx(Rt.div,{tabIndex:k||q===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:Tt(t.onMouseDown,()=>{L.current=!0}),onFocus:Tt(t.onFocus,H=>{const R=!L.current;if(H.target===H.currentTarget&&R&&!k){const se=new CustomEvent(zx,jR);if(H.currentTarget.dispatchEvent(se),!se.defaultPrevented){const X=P().filter(I=>I.focusable),V=X.find(I=>I.active),ie=X.find(I=>I.id===w),he=[V,ie,...X].filter(Boolean).map(I=>I.ref.current);Gk(he,f)}}L.current=!1}),onBlur:Tt(t.onBlur,()=>T(!1))})})}),Kk="RovingFocusGroupItem",qk=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=To(),h=i||u,f=ER(Kk,n),m=f.currentTabStopId===h,x=Hk(n),{onFocusableItemAdd:b,onFocusableItemRemove:v,currentTabStopId:w}=f;return y.useEffect(()=>{if(r)return b(),()=>v()},[r,b,v]),s.jsx(Dg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Rt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:Tt(t.onMouseDown,N=>{r?f.onItemFocus(h):N.preventDefault()}),onFocus:Tt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Tt(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){f.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const k=IR(N,f.orientation,f.dir);if(k!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let C=x().filter(P=>P.focusable).map(P=>P.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const P=C.indexOf(N.currentTarget);C=f.loop?PR(C,P+1):C.slice(P+1)}setTimeout(()=>Gk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});qk.displayName=Kk;var MR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function AR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function IR(t,e,n){const r=AR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return MR[r]}function Gk(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function PR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var RR=Wk,LR=qk,Cp="Tabs",[OR]=Bo(Cp,[Uk]),Jk=Uk(),[DR,J0]=OR(Cp),Qk=y.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Sp(c),[m,x]=Tl({prop:r,onChange:a,defaultProp:i??"",caller:Cp});return s.jsx(DR,{scope:n,baseId:To(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Rt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Qk.displayName=Cp;var Yk="TabsList",Xk=y.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=J0(Yk,n),o=Jk(n);return s.jsx(RR,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Rt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});Xk.displayName=Yk;var Zk="TabsTrigger",e2=y.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=J0(Zk,n),c=Jk(n),u=s2(o.baseId,r),h=r2(o.baseId,r),f=r===o.value;return s.jsx(LR,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Rt.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:Tt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:Tt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:Tt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});e2.displayName=Zk;var t2="TabsContent",n2=y.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=J0(t2,n),u=s2(c.baseId,r),h=r2(c.baseId,r),f=r===c.value,m=y.useRef(f);return y.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(Su,{present:a||f,children:({present:x})=>s.jsx(Rt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});n2.displayName=t2;function s2(t,e){return`${t}-trigger-${e}`}function r2(t,e){return`${t}-content-${e}`}var _R=Qk,a2=Xk,i2=e2,o2=n2;const Vc=_R,Al=y.forwardRef(({className:t,...e},n)=>s.jsx(a2,{ref:n,className:$t("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Al.displayName=a2.displayName;const an=y.forwardRef(({className:t,...e},n)=>s.jsx(i2,{ref:n,className:$t("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}));an.displayName=i2.displayName;const on=y.forwardRef(({className:t,...e},n)=>s.jsx(o2,{ref:n,className:$t("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));on.displayName=o2.displayName;function Q0(t){const e=y.useRef({value:t,previous:t});return y.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]=y.useState(void 0);return Ws(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=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 r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Ep="Switch",[zR]=Bo(Ep),[$R,FR]=zR(Ep),l2=y.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[x,b]=y.useState(null),v=Zt(e,C=>b(C)),w=y.useRef(!1),N=x?f||!!x.closest("form"):!0,[k,T]=Tl({prop:a,defaultProp:i??!1,onChange:h,caller:Ep});return s.jsxs($R,{scope:n,checked:k,disabled:c,children:[s.jsx(Rt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":h2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:v,onClick:Tt(t.onClick,C=>{T(P=>!P),N&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),N&&s.jsx(u2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});l2.displayName=Ep;var c2="SwitchThumb",d2=y.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=FR(c2,n);return s.jsx(Rt.span,{"data-state":h2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});d2.displayName=c2;var BR="SwitchBubbleInput",u2=y.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=y.useRef(null),c=Zt(o,i),u=Q0(n),h=Y0(e);return y.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&b){const v=new Event("click",{bubbles:r});b.call(f,n),f.dispatchEvent(v)}},[u,n,r]),s.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}})});u2.displayName=BR;function h2(t){return t?"checked":"unchecked"}var f2=l2,VR=d2;const Gt=y.forwardRef(({className:t,...e},n)=>s.jsx(f2,{className:$t("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:s.jsx(VR,{className:$t("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")})}));Gt.displayName=f2.displayName;const HR={view_chapter:"浏览章节",purchase:"购买",match:"派对匹配",login:"登录",register:"注册",share:"分享",bind_phone:"绑定手机",bind_wechat:"绑定微信",fill_profile:"完善资料",fill_avatar:"设置头像",visit_page:"访问页面",first_pay:"首次付款",vip_activate:"开通会员",click_super:"点击超级个体",lead_submit:"提交留资",withdraw:"申请提现",referral_bind:"绑定推荐人",card_click:"点击名片",btn_click:"按钮点击",tab_click:"切换标签",nav_click:"导航点击",page_view:"页面浏览",search:"搜索"};function UR(t){return HR[t]||t||"行为"}function WR(t,e){const n=new Set,r=a=>(t[a]??0)>0;return(r("purchase")||r("first_pay")||r("vip_activate"))&&n.add("已付费"),(r("lead_submit")||r("click_super"))&&n.add("高意向"),r("view_chapter")&&n.add("想学习"),r("match")&&n.add("找合伙人"),r("withdraw")&&n.add("有提现行为"),r("referral_bind")&&n.add("推广参与"),(r("fill_profile")||r("fill_avatar")||r("bind_phone"))&&n.add("资料完善中"),e!=null&&e.hasFullBook&&n.add("全书读者"),e!=null&&e.isVip&&n.add("VIP会员"),e!=null&&e.mbti&&/^[EI][NS][FT][JP]$/i.test(e.mbti)&&n.add(String(e.mbti).toUpperCase()),Array.from(n)}function X0({open:t,onClose:e,userId:n,onUserUpdated:r}){var ra,Qs,ks,Ss,Ys,wn;const[a,i]=y.useState(null),[o,c]=y.useState([]),[u,h]=y.useState({}),[f,m]=y.useState([]),[x,b]=y.useState(null),[v,w]=y.useState(null),[N,k]=y.useState(!1),[T,C]=y.useState(!1),[P,L]=y.useState(!1),[q,z]=y.useState("info"),[H,R]=y.useState(""),[se,X]=y.useState(""),[V,ie]=y.useState(""),[le,he]=y.useState([]),[I,Q]=y.useState(""),[$,xe]=y.useState(""),[Z,F]=y.useState(""),[U,pe]=y.useState(!1),[fe,oe]=y.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[D,K]=y.useState([]),[_,Y]=y.useState(!1),[te,Ne]=y.useState(""),[Fe,We]=y.useState(""),[St,wt]=y.useState(!1),[Vt,_t]=y.useState(!1),[$n,Jt]=y.useState(null),[dn,yn]=y.useState(null),[bn,En]=y.useState(""),[vn,At]=y.useState(""),[Nn,Ft]=y.useState(""),[je,Te]=y.useState(!1),[Ue,it]=y.useState(null),[Dt,Ct]=y.useState(!1),[$e,mt]=y.useState({}),[es,is]=y.useState([]);y.useEffect(()=>{t&&n&&(Ct(!1),z("info"),Jt(null),yn(null),it(null),xe(""),F(""),Fn(),Oe("/api/db/vip-roles").then(re=>{re!=null&&re.success&&re.data&&K(re.data)}).catch(()=>{}))},[t,n]),y.useEffect(()=>{t&&Oe("/api/admin/mbti-avatars").then(re=>{re!=null&&re.avatars&&typeof re.avatars=="object"?mt(re.avatars):mt({})}).catch(()=>mt({}))},[t]);const Gn=(re,ve)=>{const Ye=(re||"").trim();if(Ye)return Ua(Ye);const ut=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ut)?($e[ut]||"").trim():""};async function Fn(){if(n){k(!0);try{const re=await Oe(`/api/db/users?id=${encodeURIComponent(n)}`);if(re!=null&&re.success&&re.user){const ve=re.user;i(ve),R(ve.phone||""),X(ve.wechatId||""),ie(ve.nickname||""),En(ve.phone||""),At(ve.wechatId||""),Ft(ve.openId||"");try{he(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{he([])}oe({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Oe(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Ye=ve.tracks||[];c(Ye.map(ut=>({...ut,actionLabel:ut.actionLabel||ut.action,timeAgo:ut.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Oe(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success?(m(ve.referrals||[]),b(ve.inboundSource||null)):(m([]),b(null))}catch{m([]),b(null)}try{const ve=await Oe(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Oe(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?is(ve.orders):is([])}catch{is([])}}catch(re){console.error("Load user detail error:",re)}finally{k(!1)}}}async function or(){if(!(a!=null&&a.phone)){G.info("用户未绑定手机号,无法同步");return}C(!0);try{const re=await jt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});re!=null&&re.success?(G.success("同步成功"),Fn()):G.error("同步失败: "+(re==null?void 0:re.error))}catch(re){console.error("Sync CKB error:",re),G.error("同步失败")}finally{C(!1)}}async function ls(){if(a){if(fe.isVip&&!fe.vipExpireDate.trim()){G.error("开启 VIP 请填写有效到期日");return}L(!0);try{const re={id:a.id,phone:H.trim()||void 0,wechatId:se.trim(),nickname:V||void 0,tags:JSON.stringify(le),isVip:fe.isVip,vipExpireDate:fe.isVip?fe.vipExpireDate:void 0,vipRole:fe.vipRole||void 0,vipName:fe.vipName||void 0,vipProject:fe.vipProject||void 0,vipContact:fe.vipContact||void 0,vipBio:fe.vipBio||void 0},ve=await tn("/api/db/users",re);ve!=null&&ve.success?(G.success("保存成功"),Fn(),r==null||r()):G.error("保存失败: "+(ve==null?void 0:ve.error))}catch(re){console.error("Save user error:",re),G.error("保存失败")}finally{L(!1)}}}const ws=()=>{I&&!le.includes(I)&&(he([...le,I]),Q(""))},kr=re=>he(le.filter(ve=>ve!==re));async function Pn(){if(a){if(!$){G.error("请输入新密码");return}if($!==Z){G.error("两次密码不一致");return}if($.length<6){G.error("密码至少 6 位");return}pe(!0);try{const re=await tn("/api/db/users",{id:a.id,password:$});re!=null&&re.success?(G.success("修改成功"),xe(""),F("")):G.error("修改失败: "+((re==null?void 0:re.error)||""))}catch{G.error("修改失败")}finally{pe(!1)}}}async function Js(){if(!a)return;const re=parseFloat(te);if(Number.isNaN(re)||re===0){G.error("请输入有效金额(正数增加、负数扣减)");return}wt(!0);try{const ve=await jt(`/api/admin/users/${a.id}/balance/adjust`,{amount:re,remark:Fe||void 0});ve!=null&&ve.success?(G.success("余额已调整"),Y(!1),Ne(""),We(""),Fn(),r==null||r()):G.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{G.error("调整失败")}finally{wt(!1)}}async function js(){if(!bn&&!Nn&&!vn){yn("请至少输入手机号、微信号或 OpenID 中的一项");return}_t(!0),yn(null),Jt(null);try{const re=new URLSearchParams;bn&&re.set("phone",bn),Nn&&re.set("openId",Nn),vn&&re.set("wechatId",vn);const ve=await Oe(`/api/admin/shensheshou/query?${re}`);ve!=null&&ve.success&&ve.data?(Jt(ve.data),a&&await Sr(ve.data)):yn((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(re){console.error("SSS query error:",re),yn("请求失败,请检查神射手接口配置")}finally{_t(!1)}}async function Sr(re){if(a)try{await jt("/api/admin/shensheshou/enrich",{userId:a.id,phone:bn||a.phone||"",openId:Nn||a.openId||"",wechatId:vn||a.wechatId||""}),Fn()}catch(ve){console.error("SSS enrich error:",ve)}}async function lr(){if(a){Te(!0),it(null);try{const re=Array.from(new Set(o.filter(zs=>zs.action==="view_chapter"||zs.action==="purchase"||zs.action==="first_pay").map(zs=>(zs.chapterTitle||zs.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Ye=re.length>0?`意向章节:${re.join("、")}`:"",ut={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:le,purchaseIntent:ve,purchaseIntentChapters:re,remark:Ye}]},Bn=await jt("/api/admin/shensheshou/ingest",ut);Bn!=null&&Bn.success&&Bn.data?it(Bn.data):it({error:(Bn==null?void 0:Bn.error)||"推送失败"})}catch(re){console.error("SSS ingest error:",re),it({error:"请求失败"})}finally{Te(!1)}}}const cs=re=>{const Ye={view_chapter:wr,purchase:Gd,match:Wn,login:Ci,register:Ci,share:Ba,bind_phone:S1,bind_wechat:SM,fill_profile:Jd,fill_avatar:Ci,visit_page:ya,first_pay:Gd,vip_activate:Oc,click_super:Wn,lead_submit:S1,withdraw:Ag,referral_bind:Ba,card_click:Ci,btn_click:Ri,tab_click:ya,nav_click:ya,page_view:ya,search:ya}[re]||Eg;return s.jsx(Ye,{className:"w-4 h-4"})};function Cr(re){const ve=String(re||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const cr=y.useMemo(()=>WR(u,a),[u,a]);function dr(){const re=[...le];for(const ve of cr)re.includes(ve)||re.push(ve);he(re),G.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Wt,{open:t,onOpenChange:()=>e(),children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[92vh] overflow-hidden flex flex-col p-4 sm:p-5",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ci,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),N?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?s.jsxs("div",{className:"flex flex-col min-h-0 flex-1 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[s.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:Gn(a.avatar,a.mbti)&&!Dt?s.jsx("img",{src:Gn(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>Ct(!0)}):((ra=a.nickname)==null?void 0:ra.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(He,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:V||a.nickname||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"手机号"}),s.jsx("p",{className:"text-white truncate",children:H||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"微信标识"}),s.jsx("p",{className:"text-white truncate",children:se||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"画像"}),s.jsx("p",{className:"text-[#38bdac] truncate",children:[a.region,a.industry,a.position,a.mbti?`MBTI ${a.mbti}`:""].filter(Boolean).join(" · ")||"未完善"})]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),s.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),s.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{Ne(""),We(""),Y(!0)},children:"调整"})]}),s.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((v==null?void 0:v.balance)??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),s.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),s.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),s.jsxs(Vc,{value:q,onValueChange:z,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Al,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[s.jsx(an,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),s.jsxs(an,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[s.jsx(ya,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(an,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),s.jsx(an,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),s.jsxs(on,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[s.jsxs("details",{className:"rounded-lg bg-[#0a1628] border border-gray-700/40 p-2 text-[11px] group",children:[s.jsxs("summary",{className:"cursor-pointer text-gray-400 select-none list-none flex items-center gap-1",children:[s.jsx("span",{className:"group-open:text-[#38bdac]",children:"技术标识"}),s.jsx("span",{className:"text-gray-600",children:"(用户ID / OpenID,默认折叠)"})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 text-gray-300 font-mono text-[10px] break-all border-t border-gray-700/30 pt-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"用户ID"})," ",a.id]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"OpenID"})," ",a.openId||"—"]}),s.jsx("p",{className:"text-gray-500 not-italic font-sans leading-snug",children:"OpenID 为微信用户标识;下方「微信标识」为微信号/wxid,供存客宝归属,与 OpenID 不同。"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:V,onChange:re=>ie(re.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:H,onChange:re=>R(re.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:se,onChange:re=>X(re.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[s.jsx(Kj,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Oc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Gt,{className:"scale-90",checked:fe.isVip,onCheckedChange:re=>oe(ve=>({...ve,isVip:re}))})]}),fe.isVip&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(ce,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:fe.vipExpireDate,onChange:re=>oe(ve=>({...ve,vipExpireDate:re.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:fe.vipRole,onChange:re=>oe(ve=>({...ve,vipRole:re.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),D.map(re=>s.jsx("option",{value:re.name,children:re.name},re.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:fe.vipName,onChange:re=>oe(ve=>({...ve,vipName:re.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:fe.vipProject,onChange:re=>oe(ve=>({...ve,vipProject:re.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:fe.vipContact,onChange:re=>oe(ve=>({...ve,vipContact:re.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:fe.vipBio,onChange:re=>oe(ve=>({...ve,vipBio:re.target.value}))})]})]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ri,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"外部资料 · 神射手 / 存客宝(与上方基础信息联动)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:bn,onChange:re=>En(re.target.value)}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:vn,onChange:re=>At(re.target.value)}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:Nn,onChange:re=>Ft(re.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(J,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:js,disabled:Vt,children:[Vt?s.jsx(Ve,{className:"w-3 h-3 animate-spin"}):s.jsx(va,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:lr,disabled:je||!a.phone,children:je?"推送…":"推神射手"}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:or,disabled:T||!a.phone,children:T?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),dn&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:dn}),$n&&s.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"RFM"})," ",s.jsx("span",{className:"text-[#38bdac] font-semibold",children:$n.rfm_score??"—"})]}),s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"等级"})," ",s.jsx("span",{className:"text-white font-semibold",children:$n.user_level??"—"})]})]}),Ue&&s.jsx("p",{className:"mt-1 text-[11px]",children:Ue.error?s.jsx("span",{className:"text-red-400",children:String(Ue.error)}):s.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ag,{className:"w-3.5 h-3.5 text-yellow-400"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[s.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:$,onChange:re=>xe(re.target.value)}),s.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:Z,onChange:re=>F(re.target.value)}),s.jsx(J,{size:"sm",className:"h-7 text-[11px] shrink-0 bg-yellow-500/20 text-yellow-300 border border-yellow-500/35 hover:bg-yellow-500/30",onClick:Pn,disabled:U||!$||!Z,children:U?"保存中":"确认修改"})]})]})]}),s.jsxs(on,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[es.length>0&&s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Gd,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",es.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:es.map((re,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-amber-300",children:re.productType==="fullbook"||re.productType==="vip"?"全书/VIP":`章节 ${re.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(re.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:re.createdAt?new Date(re.createdAt).toLocaleString("zh-CN"):""})]},re.orderSn||ve))})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[s.jsx(ya,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((re,ve)=>ve[1]-re[1]).map(([re,ve])=>s.jsxs(He,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[UR(re)," ×",ve]},re))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((re,ve)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:cs(re.action)}),ve0?((x==null?void 0:x.visits)||[]).map((re,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-white truncate",children:["第 ",re.seq||ve+1," 次 · ",re.referrerNickname||"微信用户",re.referrerId?`(${re.referrerId})`:""]}),re.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:re.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:re.visitedAt?new Date(re.visitedAt).toLocaleString():""})]},`${re.referrerId||"unknown"}_${ve}`)):s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"暂无来源点击记录"})})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ba,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((re,ve)=>{var ut;const Ye=re;return s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((ut=Ye.nickname)==null?void 0:ut.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Ye.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Ye.status==="vip"&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Ye.createdAt?new Date(Ye.createdAt).toLocaleDateString():""})]})]},Ye.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(on,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[s.jsx(Jd,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),s.jsxs("div",{className:"mb-2 p-2 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-start gap-2 text-[11px] text-gray-400",children:[s.jsx($j,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),s.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[s.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:cr.length===0,onClick:dr,children:"合并到已选"})]}),cr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:cr.map(re=>s.jsxs(He,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${le.includes(re)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[le.includes(re)?"✓ ":"",re]},re))}):s.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),s.jsx("div",{className:"mb-3 space-y-2",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(re=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:re.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:re.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{le.includes(ve)?kr(ve):he([...le,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${le.includes(ve)?"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:[le.includes(ve)?"✓ ":"",ve]},ve))})]},re.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[le.map((re,ve)=>s.jsxs(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[re,s.jsx("button",{type:"button",onClick:()=>kr(re),className:"ml-1 hover:text-red-400",children:s.jsx(rs,{className:"w-3 h-3"})})]},ve)),le.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:re=>Q(re.target.value),onKeyDown:re=>re.key==="Enter"&&ws()}),s.jsx(J,{onClick:ws,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const re=a.tags||a.ckbTags||"";let ve=[];try{const ut=typeof re=="string"?JSON.parse(re||"[]"):[];ve=Array.isArray(ut)?ut:typeof re=="string"?re.split(","):[]}catch{ve=typeof re=="string"?re.split(","):[]}const Ye=ve.map(ut=>String(ut).trim()).filter(Boolean);return Ye.length===0?null:s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(Jd,{className:"w-3.5 h-3.5 text-purple-400"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.map((ut,Bn)=>s.jsx(He,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:ut},Bn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(J,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(J,{onClick:ls,disabled:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),P?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Wt,{open:_,onOpenChange:Y,children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Kt,{children:s.jsx(qt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:te,onChange:re=>Ne(re.target.value)})]}),s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Fe,onChange:re=>We(re.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(J,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(J,{onClick:Js,disabled:St,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:St?"提交中...":"确认调整"})]})]})})]}):null}function KR(){const t=Ga(),[e,n]=y.useState(!0),[r,a]=y.useState(!0),[i,o]=y.useState(!0),[c,u]=y.useState([]),[h,f]=y.useState([]),[m,x]=y.useState(0),[b,v]=y.useState(0),[w,N]=y.useState(0),[k,T]=y.useState(0),[C,P]=y.useState(null),[L,q]=y.useState(null),[z,H]=y.useState(!1),[R,se]=y.useState(0),[X,V]=y.useState(!1),[ie,le]=y.useState(null),[he,I]=y.useState("overview"),[Q,$]=y.useState([]),[xe,Z]=y.useState(!1),[F,U]=y.useState("today"),[pe,fe]=y.useState(null),[oe,D]=y.useState(!1),[K,_]=y.useState(!0),[Y,te]=y.useState(null),[Ne,Fe]=y.useState(null),[We,St]=y.useState([]),wt=je=>{const Te=je;if((Te==null?void 0:Te.status)===401)P("登录已过期,请重新登录");else{if((Te==null?void 0:Te.name)==="AbortError")return;P("加载失败,请检查网络或联系管理员")}};async function Vt(je){var Dt,Ct;const Te=je?{signal:je}:void 0;n(!0),P(null);try{const $e=await Oe("/api/admin/dashboard/stats",Te);$e!=null&&$e.success&&(x($e.totalUsers??0),v($e.paidOrderCount??0),N($e.totalRevenue??0),T($e.conversionRate??0))}catch($e){if(($e==null?void 0:$e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",$e);try{const mt=await Oe("/api/admin/dashboard/overview",Te);mt!=null&&mt.success&&(x(mt.totalUsers??0),v(mt.paidOrderCount??0),N(mt.totalRevenue??0),T(mt.conversionRate??0))}catch(mt){wt(mt)}}}finally{n(!1)}try{const $e=await Oe("/api/admin/balance/summary",Te);$e!=null&&$e.success&&$e.data&&se($e.data.totalGifted??0)}catch{}try{const $e=await Oe("/api/db/ckb-plan-stats",Te);$e!=null&&$e.success&&$e.data?le({ckbTotal:$e.data.ckbTotal??0,withContact:$e.data.withContact??0}):le(null)}catch{le(null)}_(!0);try{const[$e,mt]=await Promise.allSettled([Oe("/api/db/match-records?stats=true",Te),Oe("/api/admin/distribution/overview",Te)]);$e.status==="fulfilled"&&((Dt=$e.value)!=null&&Dt.success)&&$e.value.data?te({totalMatches:$e.value.data.totalMatches??0,todayMatches:$e.value.data.todayMatches??0,uniqueUsers:$e.value.data.uniqueUsers??0,paidMatchCount:$e.value.data.paidMatchCount??0}):te(null),mt.status==="fulfilled"&&((Ct=mt.value)!=null&&Ct.success)&&mt.value.overview?Fe({todayClicks:mt.value.overview.todayClicks??0,todayBindings:mt.value.overview.todayBindings??0,todayConversions:mt.value.overview.todayConversions??0,monthClicks:mt.value.overview.monthClicks??0,monthBindings:mt.value.overview.monthBindings??0,monthConversions:mt.value.overview.monthConversions??0,totalClicks:mt.value.overview.totalClicks??0,totalBindings:mt.value.overview.totalBindings??0,totalConversions:mt.value.overview.totalConversions??0,conversionRate:mt.value.overview.conversionRate}):Fe(null)}catch{te(null),Fe(null)}finally{_(!1)}try{const $e=await Oe("/api/db/vip-members?limit=500",Te);$e!=null&&$e.success&&Array.isArray($e.data)?St($e.data):St([])}catch{St([])}a(!0),o(!0);const Ue=async()=>{try{const $e=await Oe("/api/admin/dashboard/recent-orders?limit=10",Te);if($e!=null&&$e.success&&$e.recentOrders)f($e.recentOrders);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const mt=await Oe("/api/admin/orders?page=1&pageSize=20&status=paid",Te),is=((mt==null?void 0:mt.orders)??[]).filter(Gn=>["paid","completed","success"].includes(Gn.status||""));f(is.slice(0,5))}catch{f([])}}finally{a(!1)}},it=async()=>{try{const $e=await Oe("/api/admin/dashboard/new-users",Te);if($e!=null&&$e.success&&$e.newUsers)u($e.newUsers);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const mt=await Oe("/api/db/users?page=1&pageSize=10",Te);u((mt==null?void 0:mt.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([Ue(),it()])}async function _t(je){const Te=je||F;D(!0);try{const Ue=await Oe(`/api/admin/track/stats?period=${Te}`);Ue!=null&&Ue.success&&fe({total:Ue.total??0,byModule:Ue.byModule??{}})}catch{fe(null)}finally{D(!1)}}const $n={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Jt={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},dn=je=>je?je.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",yn=je=>{if(!je)return"";const Te=je.trim().toLowerCase();if(!Te)return"";const Ue=We.find(Dt=>{const Ct=String(Dt.id||"").toLowerCase();return Ct===Te||Ct.includes(Te)||Te.includes(Ct)});if(Ue)return Ue.name||Ue.nickname||"";const it=We.find(Dt=>{const Ct=String(Dt.token||"").toLowerCase();return Ct&&(Ct===Te||Ct.includes(Te)||Te.includes(Ct))});return it&&(it.name||it.nickname)||""},bn=je=>{if(!je)return"未命名点击";const Te=je.trim(),Ue=Te.toLowerCase();if(/^链接头像[_-]/.test(Te)){const Dt=dn(Te.replace(/^链接头像[_-]/,""));return Dt?`头像:${Dt}`:"头像点击"}if(/^member[_-]?detail$/i.test(Ue)||Ue.includes("member detail"))return"成员详情";if(/^giftpay$/i.test(Ue)||Ue.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test(Ue))return`章节:${dn(Te)}`;if(Ue.includes("soulvip")||Ue.includes("super")){const Dt=Te.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),Ct=yn(Dt)||yn(dn(Dt));return Ct?`超级个体:${Ct}`:`超级个体:${dn(Dt)}`}if(Ue.includes("qgdtw")||Ue.includes("token")||Ue.includes("0000"))return`对象:${dn(Te)}`;const it={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return it[Te]?it[Te]:/^[a-z0-9_-]+$/i.test(Te)&&dn(Te)||Te},En=je=>{const Te=$n[je.module]||$n[je.page]||je.module||je.page||"其他",Ue=Jt[je.action]||je.action||"点击",it=bn(je.target);return`${Te} · ${Ue} · ${it}`};async function vn(){Z(!0);try{const je=await Oe("/api/admin/super-individual/stats");je!=null&&je.success&&Array.isArray(je.data)&&$(je.data)}catch{}finally{Z(!1)}}y.useEffect(()=>{const je=new AbortController;return Vt(je.signal),_t(),vn(),()=>{je.abort()}},[]);const At=m,Nn=je=>{const Te=je.productType||"",Ue=je.description||"";if(Te==="balance_recharge")return{title:`余额充值 ¥${typeof je.amount=="number"?je.amount.toFixed(2):parseFloat(String(je.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Te==="gift_pay")return{title:`代付 ¥${typeof je.amount=="number"?je.amount.toFixed(2):parseFloat(String(je.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Te==="gift_pay_batch"){const it=typeof je.amount=="number"?je.amount.toFixed(2):parseFloat(String(je.amount||"0")).toFixed(2);return{title:Ue||`代付分享 ¥${it}`,subtitle:"代付分享"}}if(Te==="section"&&Ue.includes("代付领取"))return{title:Ue.replace("代付领取 - ",""),subtitle:"代付领取"};if(Ue){if(Te==="section"&&Ue.includes("章节")){if(Ue.includes("-")){const it=Ue.split("-");if(it.length>=3)return{title:`第${it[1]}章 第${it[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:Ue,subtitle:"章节购买"}}return Te==="fullbook"||Ue.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Te==="vip"||Ue.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Te==="match"||Ue.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:Ue,subtitle:Te==="section"?"单章":Te==="fullbook"?"全书":"其他"}}return Te==="section"?{title:`章节 ${je.productId||""}`,subtitle:"单章购买"}:Te==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Te==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Te==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Te||"其他"}},Ft=[{title:"总用户数",value:e?null:At,sub:null,icon:Wn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:R>0?`含代付 ¥${R.toFixed(2)}`:null,icon:yf,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:Gd,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:wr,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ie?ie.ckbTotal??0:null,sub:(ie==null?void 0:ie.withContact)!=null?`含联系方式 ${ie.withContact} 人`:null,icon:jo,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:K?null:((Y==null?void 0:Y.totalMatches)??0)+((Ne==null?void 0:Ne.totalClicks)??0),sub:K?null:`找伙伴 ${(Y==null?void 0:Y.totalMatches)??0} / 推广 ${(Ne==null?void 0:Ne.totalClicks)??0}`,icon:Sc,color:"text-emerald-400",bg:"bg-emerald-500/20",link:"/find-partner"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),C&&s.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:[s.jsx("span",{children:C}),s.jsx("button",{type:"button",onClick:()=>Vt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"flex flex-nowrap gap-6 mb-8 overflow-x-auto pb-1",children:Ft.map((je,Te)=>s.jsxs(_e,{className:"min-w-[220px] flex-1 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>je.link&&t(je.link),children:[s.jsxs(ft,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(pt,{className:"text-sm font-medium text-gray-400",children:je.title}),s.jsx("div",{className:`p-2 rounded-lg ${je.bg}`,children:s.jsx(je.icon,{className:`w-4 h-4 ${je.color}`})})]}),s.jsx(ze,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:je.value!=null?je.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ve,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),je.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:je.sub})]}),s.jsx(ml,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Te))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>I("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${he==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),s.jsx("button",{type:"button",onClick:()=>I("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${he==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),s.jsx("button",{type:"button",onClick:()=>I("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${he==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),he==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{className:"flex flex-row items-center justify-between",children:[s.jsx(pt,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>Vt(),disabled:K,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 ${K?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(ze,{children:[K&&!Y&&!Ne?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4",children:[s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Y==null?void 0:Y.totalMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Y==null?void 0:Y.todayMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Y==null?void 0:Y.uniqueUsers)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Ne==null?void 0:Ne.totalClicks)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Ne==null?void 0:Ne.totalBindings)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Ne==null?void 0:Ne.totalConversions)??0})]})]}),(Ne==null?void 0:Ne.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",Ne.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{className:"flex flex-row items-center justify-between",children:[s.jsx(pt,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>Vt(),disabled:r||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||i?s.jsx(Ve,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ve,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(ze,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,X?10:4).map(je=>{var Ct;const Te=je.referrerId?c.find($e=>$e.id===je.referrerId):void 0,Ue=je.referralCode||(Te==null?void 0:Te.referralCode)||(Te==null?void 0:Te.nickname)||(je.referrerId?String(je.referrerId).slice(0,8):""),it=Nn(je),Dt=je.userNickname||((Ct=c.find($e=>$e.id===je.userId))==null?void 0:Ct.nickname)||"匿名用户";return s.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:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[je.userAvatar?s.jsx("img",{src:je.userAvatar,alt:Dt,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:$e=>{$e.currentTarget.style.display="none";const mt=$e.currentTarget.nextElementSibling;mt&&mt.classList.remove("hidden")}}):null,s.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] shrink-0 mt-0.5 ${je.userAvatar?"hidden":""}`,children:Dt.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{je.userId&&(q(je.userId),H(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Dt}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:it.title,children:it.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[it.subtitle&&it.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:it.subtitle}),s.jsx("span",{children:new Date(je.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),Ue&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",Ue]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(je.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:je.paymentMethod||"微信"})]})]},je.id)}),h.length>4&&!X&&s.jsx("button",{type:"button",onClick:()=>V(!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&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Gd,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(ft,{children:s.jsx(pt,{className:"text-white",children:"新注册用户"})}),s.jsx(ze,{children:s.jsx("div",{className:"space-y-3",children:i&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(je=>{var Te;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((Te=je.nickname)==null?void 0:Te.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{q(je.id),H(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:je.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:je.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:je.createdAt?new Date(je.createdAt).toLocaleDateString():"-"})]},je.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),he==="tags"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{className:"flex flex-row items-center justify-between",children:[s.jsxs(pt,{className:"text-white flex items-center gap-2",children:[s.jsx(Sc,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(je=>s.jsx("button",{type:"button",onClick:()=>{U(je),_t(je)},className:`px-3 py-1 text-xs rounded-full transition-colors ${F===je?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[je]},je))})]}),s.jsx(ze,{children:oe&&!pe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):pe&&Object.keys(pe.byModule).length>0?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",s.jsx("span",{className:"text-white font-bold text-lg",children:pe.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(pe.byModule).sort((je,Te)=>Te[1].reduce((Ue,it)=>Ue+it.count,0)-je[1].reduce((Ue,it)=>Ue+it.count,0)).slice(0,5).map(([je,Te])=>{const Ue=Te.reduce((it,Dt)=>it+Dt.count,0);return s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:$n[je]||je}),s.jsxs("span",{className:"text-xs text-gray-500",children:[Ue," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Te.sort((it,Dt)=>Dt.count-it.count).slice(0,8).map((it,Dt)=>{const Ct=En(it);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:Ct,children:Ct}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${Ue>0?it.count/Ue*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:it.count})]})]},Dt)})})]},je)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Sc,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),he==="super"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{className:"flex flex-row items-center justify-between",children:[s.jsxs(pt,{className:"text-white flex items-center gap-2",children:[s.jsx(Sc,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:vn,disabled:xe,children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(ze,{children:xe&&Q.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Q.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-400 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),s.jsx("tbody",{children:Q.map((je,Te)=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:Te+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[je.avatar?s.jsx("img",{src:je.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left text-sm truncate max-w-[160px]",onClick:()=>t(`/users?search=${encodeURIComponent(je.nickname||je.userId)}`),title:"点击跳转用户管理",children:je.nickname||je.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:je.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:je.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:je.uniqueClicks>0?(je.clicks/je.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof je.leadCount=="number"?je.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:je.phone||"-"})]},je.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Sc,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无超级个体点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序首页的超级个体被用户点击后,数据将展示在此"})]})})]}),s.jsx(X0,{open:z,onClose:()=>{H(!1),q(null)},userId:L,onUserUpdated:()=>Vt()})]})}const Ls=y.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:$t("w-full caption-bottom text-sm",t),...e})}));Ls.displayName="Table";const Os=y.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:$t("[&_tr]:border-b",t),...e}));Os.displayName="TableHeader";const Ds=y.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:$t("[&_tr:last-child]:border-0",t),...e}));Ds.displayName="TableBody";const Nt=y.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:$t("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));Nt.displayName="TableRow";const Ce=y.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:$t("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Ce.displayName="TableHead";const ke=y.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:$t("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ke.displayName="TableCell";function Lo(t,e){const[n,r]=y.useState(t);return y.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function rr({page:t,totalPages:e,total:n,pageSize:r,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),i&&s.jsx("select",{value:r,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=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:"首页"}),s.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:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.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:"下一页"}),s.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 qR(){const[t,e]=y.useState([]),[n,r]=y.useState([]),[a,i]=y.useState(0),[o,c]=y.useState(0),[u,h]=y.useState(0),[f,m]=y.useState(1),[x,b]=y.useState(10),[v,w]=y.useState(""),N=Lo(v,300),[k,T]=y.useState("all"),[C,P]=y.useState(!0),[L,q]=y.useState(null),[z,H]=y.useState(null),[R,se]=y.useState(""),[X,V]=y.useState(!1);async function ie(){P(!0),q(null);try{const Z=k==="all"?"":k==="completed"?"completed":k,F=new URLSearchParams({page:String(f),pageSize:String(x),...Z&&{status:Z},...N&&{search:N}}),[U,pe]=await Promise.all([Oe(`/api/admin/orders?${F}`),Oe("/api/db/users?page=1&pageSize=500")]);U!=null&&U.success&&(e(U.orders||[]),i(U.total??0),c(U.totalRevenue??0),h(U.todayRevenue??0)),pe!=null&&pe.success&&pe.users&&r(pe.users)}catch(Z){console.error("加载订单失败",Z),q("加载订单失败,请检查网络后重试")}finally{P(!1)}}y.useEffect(()=>{m(1)},[N,k]),y.useEffect(()=>{ie()},[f,x,N,k]);const le=Z=>{var F;return Z.userNickname||((F=n.find(U=>U.id===Z.userId))==null?void 0:F.nickname)||"匿名用户"},he=Z=>{var F;return((F=n.find(U=>U.id===Z))==null?void 0:F.phone)||"-"},I=Z=>{const F=Z.productType||Z.type||"",U=Z.description||"";if(F==="balance_recharge")return{name:`余额充值 ¥${Number(Z.amount||0).toFixed(2)}`,type:"余额充值"};if(U){if(F==="section"&&(U.includes("章节")||U.includes("代付领取"))){if(U.includes("代付领取"))return{name:U.replace("代付领取 - ",""),type:"代付领取"};if(U.includes("-")){const pe=U.split("-");if(pe.length>=3)return{name:`第${pe[1]}章 第${pe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:U,type:"章节购买"}}return F==="fullbook"||U.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:F==="vip"||U.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:F==="match"||U.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:U,type:"其他"}}return F==="section"?{name:`章节 ${Z.productId||Z.sectionId||""}`,type:"单章"}:F==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:F==="vip"?{name:"超级个体开通费用",type:"超级个体"}:F==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:F||"其他"}},Q=Math.ceil(a/x)||1;async function $(){var Z;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){V(!0),q(null);try{const F=await tn("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:R||void 0});F!=null&&F.success?(H(null),se(""),ie()):q((F==null?void 0:F.error)||"退款失败")}catch(F){const U=F;q(((Z=U==null?void 0:U.data)==null?void 0:Z.error)||"退款失败,请检查网络后重试")}finally{V(!1)}}}function xe(){if(t.length===0){G.info("暂无数据可导出");return}const Z=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],F=t.map(D=>{const K=I(D);return[D.orderSn||D.id||"",le(D),he(D.userId),K.name,Number(D.amount||0).toFixed(2),D.paymentMethod==="wechat"?"微信支付":D.paymentMethod==="balance"?"余额支付":D.paymentMethod==="alipay"?"支付宝":D.paymentMethod||"微信支付",D.status==="refunded"?"已退款":D.status==="paid"||D.status==="completed"?"已完成":D.status==="pending"||D.status==="created"?"待支付":"已失败",D.status==="refunded"&&D.refundReason?D.refundReason:"-",D.referrerEarnings?Number(D.referrerEarnings).toFixed(2):"-",D.createdAt?new Date(D.createdAt).toLocaleString("zh-CN"):""].join(",")}),U="\uFEFF"+[Z.join(","),...F].join(`
-`),pe=new Blob([U],{type:"text/csv;charset=utf-8"}),fe=URL.createObjectURL(pe),oe=document.createElement("a");oe.href=fe,oe.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,oe.click(),URL.revokeObjectURL(fe)}return s.jsxs("div",{className:"p-8 w-full",children:[L&&s.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:[s.jsx("span",{children:L}),s.jsx("button",{type:"button",onClick:()=>q(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(J,{variant:"outline",onClick:ie,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:v,onChange:Z=>w(Z.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Uj,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:Z=>T(Z.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(J,{variant:"outline",onClick:xe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(I5,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Ls,{children:[s.jsx(Os,{children:s.jsxs(Nt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ce,{className:"text-gray-400",children:"订单号"}),s.jsx(Ce,{className:"text-gray-400",children:"用户"}),s.jsx(Ce,{className:"text-gray-400",children:"商品"}),s.jsx(Ce,{className:"text-gray-400",children:"金额"}),s.jsx(Ce,{className:"text-gray-400",children:"支付方式"}),s.jsx(Ce,{className:"text-gray-400",children:"状态"}),s.jsx(Ce,{className:"text-gray-400",children:"退款原因"}),s.jsx(Ce,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Ce,{className:"text-gray-400",children:"下单时间"}),s.jsx(Ce,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(Ds,{children:[t.map(Z=>{const F=I(Z);return s.jsxs(Nt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(ke,{className:"font-mono text-xs text-gray-400",children:[(Z.orderSn||Z.id||"").slice(0,12),"..."]}),s.jsx(ke,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[le(Z),Z.paymentMethod==="gift_pay"&&s.jsx(He,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),Z.payerUserId&&Z.paymentMethod!=="gift_pay"&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:he(Z.userId)}),Z.payerUserId&&Z.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[Z.paymentMethod==="gift_pay"?"赠送人:":"代付人:",Z.payerNickname]})]})}),s.jsx(ke,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[F.name,(Z.productType||Z.type)==="vip"&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:F.type})]})}),s.jsxs(ke,{className:"text-[#38bdac] font-bold",children:["¥",Number(Z.amount||0).toFixed(2)]}),s.jsx(ke,{className:"text-gray-300",children:Z.paymentMethod==="wechat"?"微信支付":Z.paymentMethod==="balance"?"余额支付":Z.paymentMethod==="alipay"?"支付宝":Z.paymentMethod||"微信支付"}),s.jsx(ke,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Z.status==="refunded"?s.jsx(He,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):Z.status==="paid"||Z.status==="completed"?s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):Z.status==="pending"||Z.status==="created"?s.jsx(He,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(He,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(Z.status==="paid"||Z.status==="completed")&&(Z.webhookPushStatus==="sent"?s.jsx(He,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(He,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(ke,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:Z.refundReason,children:Z.status==="refunded"&&Z.refundReason?Z.refundReason:"-"}),s.jsx(ke,{className:"text-[#FFD700]",children:Z.referrerEarnings?`¥${Number(Z.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(ke,{className:"text-gray-400 text-sm",children:new Date(Z.createdAt).toLocaleString("zh-CN")}),s.jsx(ke,{children:(Z.status==="paid"||Z.status==="completed")&&Z.paymentMethod!=="balance"&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{H(Z),se("")},children:[s.jsx(qj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},Z.id)}),t.length===0&&s.jsx(Nt,{children:s.jsx(ke,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(rr,{page:f,totalPages:Q,total:a,pageSize:x,onPageChange:m,onPageSizeChange:Z=>{b(Z),m(1)}})]})})}),s.jsx(Wt,{open:!!z,onOpenChange:Z=>!Z&&H(null),children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-white",children:"订单退款"})}),z&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(z.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:R,onChange:Z=>se(Z.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Sn,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>H(null),disabled:X,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:$,disabled:X,children:X?"退款中...":"确认退款"})]})]})})]})}const Il=y.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:$t("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}));Il.displayName="Textarea";const J1=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],p2={INTJ:{title:"战略家",group:"NT",mood:"sharp"},INTP:{title:"逻辑学家",group:"NT",mood:"calm"},ENTJ:{title:"指挥官",group:"NT",mood:"sharp"},ENTP:{title:"辩论家",group:"NT",mood:"playful"},INFJ:{title:"提倡者",group:"NF",mood:"warm"},INFP:{title:"调停者",group:"NF",mood:"warm"},ENFJ:{title:"主人公",group:"NF",mood:"warm"},ENFP:{title:"竞选者",group:"NF",mood:"playful"},ISTJ:{title:"物流师",group:"SJ",mood:"calm"},ISFJ:{title:"守卫者",group:"SJ",mood:"warm"},ESTJ:{title:"总经理",group:"SJ",mood:"sharp"},ESFJ:{title:"执政官",group:"SJ",mood:"warm"},ISTP:{title:"鉴赏家",group:"SP",mood:"sharp"},ISFP:{title:"探险家",group:"SP",mood:"playful"},ESTP:{title:"企业家",group:"SP",mood:"playful"},ESFP:{title:"表演者",group:"SP",mood:"playful"}};function GR(t){switch(t){case"NT":return{bg:"#0d1424",body:"#c89a2c",accent:"#ffd66b",hair:"#6d540f",line:"#111827"};case"NF":return{bg:"#0a1721",body:"#2e9f7c",accent:"#84e9c9",hair:"#2d6a4f",line:"#11212a"};case"SJ":return{bg:"#101828",body:"#4f8cb8",accent:"#9bd4ff",hair:"#2e4a66",line:"#111f2d"};case"SP":return{bg:"#161225",body:"#8b6bc0",accent:"#ccb3ff",hair:"#574183",line:"#211832"};default:return{bg:"#0e1422",body:"#38bdac",accent:"#7ee7db",hair:"#1f6f66",line:"#10202d"}}}function JR(t){switch(t){case"sharp":return{eye:"M222 222 L242 220 M270 220 L290 222",brow:"M218 210 L244 202 M268 202 L294 210",mouth:"M234 256 Q256 246 278 256",tilt:-5};case"warm":return{eye:"M222 224 Q232 230 242 224 M270 224 Q280 230 290 224",brow:"M220 210 Q232 206 244 210 M268 210 Q280 206 292 210",mouth:"M232 254 Q256 272 280 254",tilt:2};case"playful":return{eye:"M222 224 Q232 236 242 224 M270 224 Q280 236 290 224",brow:"M220 210 Q234 200 246 208 M266 208 Q278 200 292 210",mouth:"M232 256 Q256 266 280 250",tilt:8};default:return{eye:"M222 224 Q232 220 242 224 M270 224 Q280 220 290 224",brow:"M220 210 Q232 208 244 210 M268 210 Q280 208 292 210",mouth:"M236 256 Q256 260 276 256",tilt:0}}}function QR(t){switch(t){case"sharp":return"M168 370 L206 300 L256 332 L306 300 L344 370 L306 392 L256 374 L206 392 Z";case"warm":return"M166 368 Q188 318 226 314 L256 340 L286 314 Q324 318 346 368 L314 392 Q286 404 256 396 Q226 404 198 392 Z";case"playful":return"M164 370 L198 304 L252 332 L318 300 L350 374 L316 394 L258 378 L196 396 Z";default:return"M166 370 L202 306 L256 336 L310 306 L346 370 L310 392 L256 380 L202 392 Z"}}function Q1(t){const e=p2[t],n=GR(e.group),r=JR(e.mood),a=QR(e.mood),i=`
-`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function YR(){const[t,e]=y.useState({}),[n,r]=y.useState(!0),[a,i]=y.useState(!1),[o,c]=y.useState(!1),u=y.useCallback(async()=>{r(!0);try{const x=await Oe("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{G.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);y.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await jt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){G.error((x==null?void 0:x.error)||"保存失败");return}G.success("已保存,后台与小程序默认头像同步生效"),u()}catch{G.error("保存失败")}finally{i(!1)}},f=x=>{const b=Q1(x);e(v=>({...v,[x]:b})),G.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};J1.forEach(b=>{x[b]=Q1(b)}),e(x),G.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Ve,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(ft,{className:"pb-2",children:[s.jsxs(pt,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(rA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(nn,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(ze,{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(EA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Ve,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(J,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(In,{className:"w-3.5 h-3.5 mr-1"}),a?"保存中…":"保存映射"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:J1.map(x=>{const b=t[x]??"",v=p2[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:v.title,children:v.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:b?s.jsx("img",{src:b,alt:x,className:"w-full h-full object-cover scale-110"}):s.jsx("span",{className:"text-gray-600 text-[10px]",children:"未配"})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:b,onChange:w=>e(N=>({...N,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const Y1=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",label:"绑定手机号",group:"用户状态"},{value:"update_avatar",label:"完善头像(非默认图,与昵称分开配置)",group:"用户状态"},{value:"update_nickname",label:"修改昵称(非默认微信昵称,与头像分开)",group:"用户状态"},{value:"fill_profile",label:"完善资料(MBTI/行业/职位,不含头像昵称)",group:"用户状态"},{value:"view_chapter",label:"浏览章节",group:"阅读行为"},{value:"browse_5_chapters",label:"累计浏览5个章节",group:"阅读行为"},{value:"purchase_section",label:"购买单章",group:"付费行为"},{value:"purchase_fullbook",label:"购买全书/VIP",group:"付费行为"},{value:"after_pay",label:"任意付款成功",group:"付费行为"},{value:"after_match",label:"完成派对匹配",group:"社交行为"},{value:"click_super_individual",label:"点击超级个体头像",group:"社交行为"},{value:"lead_submit",label:"提交留资/链接",group:"社交行为"},{value:"referral_bind",label:"被推荐人绑定",group:"分销行为"},{value:"share_action",label:"分享给好友/朋友圈",group:"分销行为"},{value:"withdraw_request",label:"申请提现",group:"分销行为"},{value:"add_wechat",label:"添加微信联系方式",group:"用户状态"}],X1=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function m2(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string")try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>typeof n=="string")}catch{try{const e=typeof atob=="function"?atob(t):"",n=JSON.parse(e);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}catch{}}return[]}function XR(t){return{...t,triggerConditions:m2(t.triggerConditions)}}const ZR=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"70–84",label:"优质"},{level:"B",range:"50–69",label:"中等"},{level:"C",range:"30–49",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],wc=[{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 Z1(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function e8(){var Yo,Pu,dd,Ru,Lu,Ou,Du;const[t,e]=_0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",[i,o]=y.useState([]),[c,u]=y.useState(0),[h,f]=y.useState(1),[m,x]=y.useState(10),[b,v]=y.useState(""),w=Lo(b,300),N=n==="vip"?"vip":n==="complete"?"complete":"all",[k,T]=y.useState(N),[C,P]=y.useState(!0),[L,q]=y.useState(!1),[z,H]=y.useState(null),[R,se]=y.useState(!1),[X,V]=y.useState(!1),[ie,le]=y.useState("desc");y.useEffect(()=>{n==="vip"?T("vip"):n==="complete"?T("complete"):n==="all"&&T("all")},[n]);const[he,I]=y.useState(!1),[Q,$]=y.useState(null),[xe,Z]=y.useState(!1),[F,U]=y.useState(!1),[pe,fe]=y.useState({referrals:[],stats:{}}),[oe,D]=y.useState(!1),[K,_]=y.useState(null),[Y,te]=y.useState(!1),[Ne,Fe]=y.useState(null),[We,St]=y.useState(!1),[wt,Vt]=y.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[_t,$n]=y.useState([]),[Jt,dn]=y.useState(!1),[yn,bn]=y.useState(!1),[En,vn]=y.useState(null),[At,Nn]=y.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ft,je]=y.useState([]),[Te,Ue]=y.useState(!1),[it,Dt]=y.useState(null),[Ct,$e]=y.useState(null),[mt,es]=y.useState({}),[is,Gn]=y.useState(!1),[Fn,or]=y.useState(null),[ls,ws]=y.useState([]),[kr,Pn]=y.useState(!1),[Js,js]=y.useState(null),[Sr,lr]=y.useState(""),[cs,Cr]=y.useState([]),[cr,dr]=y.useState(!1),[ra,Qs]=y.useState({}),[ks,Ss]=y.useState([]),[Ys,wn]=y.useState(0),[re,ve]=y.useState(1),[Ye]=y.useState(20),[ut,Bn]=y.useState(!1),[zs,Vr]=y.useState(null),[aa,Ca]=y.useState(""),ds=Lo(aa,300),[us,Ea]=y.useState(""),[zt,Ya]=y.useState(""),[O,Se]=y.useState({}),[Ze,It]=y.useState(null),[Et,ht]=y.useState(null),[xt,jn]=y.useState([]),[Ot,Er]=y.useState(!1),Xs=y.useRef(null),[Wl,Xa]=y.useState(!1),Cs=y.useCallback(async(M,de)=>{Bn(!0),Vr(null);try{const we=new URLSearchParams({mode:"contact",page:String(re),pageSize:String(Ye)}),Pe=M??ds;Pe&&we.set("search",Pe);const qe=de??us;qe&&we.set("source",qe),zt&&we.set("pushStatus",zt);const Qe=await Oe(`/api/db/ckb-leads?${we}`);if(Qe!=null&&Qe.success)Ss(Qe.records||[]),wn(Qe.total??0),Qe.stats&&Se(Qe.stats);else{const en=(Qe==null?void 0:Qe.error)||"加载获客列表失败";Vr(en),G.error(en),Ss([]),wn(0)}}catch(we){const Pe=we instanceof Error?we.message:"网络错误";Vr(Pe),G.error("加载获客列表失败: "+Pe),Ss([]),wn(0)}finally{Bn(!1)}},[re,Ye,ds,us,zt]);y.useEffect(()=>{jn([])},[ds,us,zt]);function ia(M,de){return{...M,...de.pushStatus!==void 0?{pushStatus:de.pushStatus}:{},...typeof de.retryCount=="number"?{retryCount:de.retryCount}:{},...de.ckbError!==void 0?{ckbError:de.ckbError}:{},...de.lastPushAt!==void 0?{lastPushAt:de.lastPushAt??void 0}:{},...de.nextRetryAt!==void 0?{nextRetryAt:de.nextRetryAt??void 0}:{}}}async function Za(M){if(M){It(M);try{const de=await jt("/api/db/ckb-leads/retry",{id:M});de!=null&&de.success?(G.success(de.pushed?"重推成功":"已发起重推,请刷新查看状态"),de.record&&Ss(we=>we.map(Pe=>Pe.id===M?ia(Pe,de.record):Pe))):G.error((de==null?void 0:de.error)||"重推失败")}catch(de){G.error(de instanceof Error?de.message:"重推请求失败")}finally{It(null)}}}async function od(M){if(M&&confirm("确定删除该条获客记录?删除后不可恢复。")){ht(M);try{const de=await jt("/api/db/ckb-leads/delete",{id:M});de!=null&&de.success?G.success("已删除"):G.error((de==null?void 0:de.error)||"删除失败")}catch(de){G.error(de instanceof Error?de.message:"删除请求失败")}finally{ht(null),Cs()}}}async function zi(){const M=be.filter(Pe=>Pe.pushStatus==="failed");if(M.length===0){G.info("当前页无失败记录");return}Xa(!0);let de=0;for(const Pe of M)try{const qe=await jt("/api/db/ckb-leads/retry",{id:Pe.id});if(qe!=null&&qe.success&&qe.pushed&&de++,qe!=null&&qe.success&&qe.record){const Qe=qe.record;Ss(en=>en.map(Ge=>Ge.id===Pe.id?ia(Ge,Qe):Ge))}}catch{}Xa(!1);const we=M.length;G.success(`批量重推完成:成功 ${de} / ${we}`)}function $i(){const M=be.filter(Ge=>Ge.pushStatus==="failed");if(M.length===0){G.info("当前筛选下无失败记录可导出");return}const de=Ge=>`"${String(Ge??"").replace(/"/g,'""')}"`,Pe=[["ID","昵称","手机号","微信号","对应@人","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const Ge of M)Pe.push([de(Ge.id),de(Ge.userNickname||Ge.name||""),de(Ge.phone||""),de(Ge.wechatId||""),de(Ge.personName||""),de(Ge.source||""),de(Ge.pushStatus||""),de(typeof Ge.retryCount=="number"?Ge.retryCount:""),de(Ge.ckbError||""),de(Ge.nextRetryAt?new Date(Ge.nextRetryAt).toLocaleString():""),de(Ge.createdAt?new Date(Ge.createdAt).toLocaleString():"")].join(","));const qe=new Blob(["\uFEFF"+Pe.join(`
-`)],{type:"text/csv;charset=utf-8;"}),Qe=URL.createObjectURL(qe),en=document.createElement("a");en.href=Qe,en.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(en),en.click(),document.body.removeChild(en),URL.revokeObjectURL(Qe),G.success(`已导出失败清单(${M.length} 条)`)}const Fi=y.useCallback(async()=>{try{const M=await Oe("/api/admin/mbti-avatars"),de=M!=null&&M.avatars&&typeof M.avatars=="object"?M.avatars:{};Qs(de)}catch{Qs({})}},[]);y.useEffect(()=>{t.get("tab")==="leads"&&Cs()},[t.get("tab"),re,Cs]),y.useEffect(()=>{if(a!=="leads")return;const M=window.setInterval(()=>{Cs()},3e4);return()=>window.clearInterval(M)},[a,Cs]),y.useEffect(()=>{Fi()},[Fi]);const Ta=y.useCallback((M,de)=>{const we=(M||"").trim();if(we)return we;const Pe=(de||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Pe)?(ra[Pe]||"").trim():""},[ra]),oa=y.useCallback(M=>{const de=!!M.hasFullBook,we=Number(M.purchasedSectionCount||0);return de?{tone:"vip",main:"已购全书",sub:we>0?`另购单章 ${we} 章`:"购买项:VIP / 全书"}:we>0?{tone:"paid",main:`已购 ${we} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[ei,ti]=y.useState(null),bt=y.useCallback(async()=>{try{const M=await Oe("/api/admin/users/online-stats");M!=null&&M.success&&typeof M.onlineCount=="number"?ti(M.onlineCount):ti(0)}catch{ti(null)}},[]);y.useEffect(()=>{bt();const M=setInterval(bt,1e4);return()=>clearInterval(M)},[bt]);async function Hr(M=!1){var de;P(!0),M&&q(!0),H(null);try{if(R){const we=new URLSearchParams({search:w,limit:String(m*5)}),Pe=await Oe(`/api/db/users/rfm?${we}`);if(Pe!=null&&Pe.success){let qe=Pe.users||[];ie==="asc"&&(qe=[...qe].reverse());const Qe=(h-1)*m;o(qe.slice(Qe,Qe+m)),u(((de=Pe.users)==null?void 0:de.length)??0),qe.length===0&&(se(!1),H("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else se(!1),H((Pe==null?void 0:Pe.error)||"RFM 加载失败,已切回普通模式")}else{const we=new URLSearchParams({page:String(h),pageSize:String(m),search:w,...k==="vip"&&{vip:"true"},...k==="complete"&&{pool:"complete"}}),Pe=await Oe(`/api/db/users?${we}`);Pe!=null&&Pe.success?(o(Pe.users||[]),u(Pe.total??0)):H((Pe==null?void 0:Pe.error)||"加载失败")}}catch(we){console.error("Load users error:",we),H("网络错误")}finally{P(!1),M&&q(!1)}}y.useEffect(()=>{f(1)},[w,k,R]),y.useEffect(()=>{Hr()},[h,m,w,k,R,ie]);const ni=Math.ceil(c/m)||1,Ma=()=>{R?ie==="desc"?le("asc"):(se(!1),le("desc")):(se(!0),le("desc"))},Bi=M=>({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"})[M||""]||"bg-gray-500/20 text-gray-400";async function hs(M){var de;if(!Z1("用户")){G.info("已取消删除");return}try{const we=await Ei(`/api/db/users?id=${encodeURIComponent(M)}`);we!=null&&we.success?(G.success("已删除"),Hr()):G.error("删除失败: "+((we==null?void 0:we.error)||"未知错误"))}catch(we){const Pe=we,qe=((de=Pe==null?void 0:Pe.data)==null?void 0:de.error)||(Pe==null?void 0:Pe.message)||"网络错误";G.error("删除失败: "+qe)}}const Kl=M=>{$(M),Vt({phone:M.phone||"",nickname:M.nickname||"",password:"",isAdmin:!!(M.isAdmin??!1),hasFullBook:!!(M.hasFullBook??!1)}),I(!0)},la=()=>{$(null),Vt({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),I(!0)};async function Vi(){if(!wt.phone||!wt.nickname){G.error("请填写手机号和昵称");return}Z(!0);try{if(Q){const M=await tn("/api/db/users",{id:Q.id,phone:wt.phone||void 0,nickname:wt.nickname,isAdmin:wt.isAdmin,hasFullBook:wt.hasFullBook,...wt.password&&{password:wt.password}});if(!(M!=null&&M.success)){G.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await jt("/api/db/users",{phone:wt.phone,nickname:wt.nickname,password:wt.password,isAdmin:wt.isAdmin});if(!(M!=null&&M.success)){G.error("创建失败: "+((M==null?void 0:M.error)||""));return}}I(!1),Hr()}catch{G.error("保存失败")}finally{Z(!1)}}async function Tr(M){_(M),U(!0),D(!0);try{const de=await Oe(`/api/db/users/referrals?userId=${encodeURIComponent(M.id)}`);de!=null&&de.success?fe({referrals:de.referrals||[],stats:de.stats||{}}):fe({referrals:[],stats:{}})}catch{fe({referrals:[],stats:{}})}finally{D(!1)}}const Es=y.useCallback(async()=>{dn(!0);try{const M=await Oe("/api/db/user-rules");M!=null&&M.success&&$n((M.rules||[]).map(de=>XR(de)))}catch{}finally{dn(!1)}},[]);async function Mr(){if(!At.title){G.error("请填写规则标题");return}Z(!0);try{if(En){const M=await tn("/api/db/user-rules",{id:En.id,...At});if(!(M!=null&&M.success)){G.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await jt("/api/db/user-rules",At);if(!(M!=null&&M.success)){G.error("创建失败: "+((M==null?void 0:M.error)||""));return}}bn(!1),Es()}catch{G.error("保存失败")}finally{Z(!1)}}async function si(M){if(!Z1("规则")){G.info("已取消删除");return}try{const de=await Ei(`/api/db/user-rules?id=${M}`);de!=null&&de.success&&Es()}catch{}}async function Aa(M){try{await tn("/api/db/user-rules",{id:M.id,enabled:!M.enabled}),Es()}catch{}}const sn=y.useCallback(async()=>{Ue(!0);try{const M=await Oe("/api/db/vip-members?limit=500");if(M!=null&&M.success&&M.data){const de=[...M.data].map((we,Pe)=>({...we,vipSort:typeof we.vipSort=="number"?we.vipSort:Pe+1}));de.sort((we,Pe)=>(we.vipSort??999999)-(Pe.vipSort??999999)),je(de)}else M&&M.error&&G.error(M.error)}catch{G.error("加载超级个体列表失败")}finally{Ue(!1)}},[]),[ld,Zs]=y.useState(!1),[ur,Hi]=y.useState(null),[Ar,hr]=y.useState(""),[Ia,ql]=y.useState(!1),[Ir,Ts]=y.useState(!1),[er,$s]=y.useState(null),[Gl,qo]=y.useState(""),[ri,Pa]=y.useState(!1),Ui=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],Jl=M=>{Hi(M),hr(M.vipRole||""),Zs(!0)},Pr=M=>{$s(M),qo((M.webhookUrl||"").trim()),Ts(!0)},ai=async M=>{const de=M.trim();if(ur){if(!de){G.error("请选择或输入标签");return}ql(!0);try{const we=await tn("/api/db/users",{id:ur.id,vipRole:de});if(!(we!=null&&we.success)){G.error((we==null?void 0:we.error)||"更新超级个体标签失败");return}G.success("已更新超级个体标签"),Zs(!1),Hi(null),await sn()}catch{G.error("更新超级个体标签失败")}finally{ql(!1)}}},Wi=async()=>{if(!er)return;const M=Gl.trim();if(M&&!/^https?:\/\//i.test(M)){G.error("Webhook 地址需以 http/https 开头");return}Pa(!0);try{const de=await tn("/api/db/vip-members/webhook",{userId:er.id,webhookUrl:M});if(!(de!=null&&de.success)){G.error((de==null?void 0:de.error)||"保存飞书群 Webhook 失败");return}G.success(M?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Ts(!1),$s(null),await sn()}catch{G.error("保存飞书群 Webhook 失败")}finally{Pa(!1)}},[Ql,ca]=y.useState(!1),[Ur,Ki]=y.useState(null),[fs,da]=y.useState(""),[qi,Ra]=y.useState(!1),cd=M=>{Ki(M),da(M.vipSort!=null?String(M.vipSort):""),ca(!0)},Go=async()=>{if(!Ur)return;const M=Number(fs);if(!Number.isFinite(M)){G.error("请输入有效的数字序号");return}Ra(!0);try{const de=await tn("/api/db/users",{id:Ur.id,vipSort:M});if(!(de!=null&&de.success)){G.error((de==null?void 0:de.error)||"更新排序序号失败");return}G.success("已更新排序序号"),ca(!1),Ki(null),await sn()}catch{G.error("更新排序序号失败")}finally{Ra(!1)}},Jo=(M,de)=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",de),Dt(de)},ii=(M,de)=>{M.preventDefault(),Ct!==de&&$e(de)},oi=()=>{Dt(null),$e(null)},Gi=async(M,de)=>{M.preventDefault();const we=M.dataTransfer.getData("text/plain")||it;if(Dt(null),$e(null),!we||we===de)return;const Pe=Ft.find(Ge=>Ge.id===we),qe=Ft.find(Ge=>Ge.id===de);if(!Pe||!qe)return;const Qe=Pe.vipSort??Ft.findIndex(Ge=>Ge.id===we)+1,en=qe.vipSort??Ft.findIndex(Ge=>Ge.id===de)+1;je(Ge=>{const Qt=[...Ge],fr=Qt.findIndex(ud=>ud.id===we),Rr=Qt.findIndex(ud=>ud.id===de);if(fr===-1||Rr===-1)return Ge;const Wr=[...Qt],[Xp,Zp]=[Wr[fr],Wr[Rr]];return Wr[fr]={...Zp,vipSort:Qe},Wr[Rr]={...Xp,vipSort:en},Wr});try{const[Ge,Qt]=await Promise.all([tn("/api/db/users",{id:we,vipSort:en}),tn("/api/db/users",{id:de,vipSort:Qe})]);if(!(Ge!=null&&Ge.success)||!(Qt!=null&&Qt.success)){G.error((Ge==null?void 0:Ge.error)||(Qt==null?void 0:Qt.error)||"更新排序失败"),await sn();return}G.success("已更新排序"),await sn()}catch{G.error("更新排序失败"),await sn()}},Qo=y.useCallback(async()=>{Gn(!0);try{const M=await Oe("/api/db/users/journey-stats");M!=null&&M.success&&M.stats&&es(M.stats)}catch{}finally{Gn(!1)}},[]),Yl=y.useCallback(async M=>{or(M),Pn(!0);try{const de=await Oe(`/api/db/users/journey-users?stage=${M}&limit=50`);de!=null&&de.success&&de.users&&ws(de.users)}catch{}finally{Pn(!1)}},[]),Xl=y.useCallback(async(M,de)=>{js(M),lr(de),dr(!0);try{const we=await Oe(`/api/db/users/tracks?userId=${M}&limit=50`);we!=null&&we.success&&we.tracks&&Cr(we.tracks)}catch{}finally{dr(!1)}},[]),[li,E]=y.useState(!1),B=async()=>{E(!0);try{const M=await jt("/api/admin/shensheshou/batch-enrich",{limit:20});M!=null&&M.success?(G.success(`批量补全完成:${M.enriched} 人已补全,${M.skipped} 人跳过`),Hr()):G.error((M==null?void 0:M.error)||"批量补全失败")}catch{G.error("批量补全请求失败")}finally{E(!1)}},ue=M=>{const de=[M.phone,M.nickname,M.avatar,M.wechatId,M.mbti,M.industry,M.region,M.position],we=de.filter(Pe=>Pe!=null&&Pe!=="").length;return Math.round(we/de.length*100)},{leadsRows:be,leadsRawCount:Ke,leadsDeduped:yt}=y.useMemo(()=>{const M=Ge=>(Ge||"").replace(/\D/g,"")||"",de=Ge=>{const Qt=M(Ge.phone);if(Qt)return`phone:${Qt}`;const fr=(Ge.userId||"").trim();if(fr)return`user:${fr}`;const Rr=(Ge.wechatId||"").trim();return Rr?`wechat:${Rr}`:`row:${Ge.id}`},we=ds.trim().toLowerCase();let Pe=ks;we&&(Pe=ks.filter(Ge=>[Ge.userNickname,Ge.name,Ge.phone,Ge.wechatId,Ge.personName,Ge.source,String(Ge.ckbPlanId??"")].filter(Boolean).join(" ").toLowerCase().includes(we)));const qe=[...Pe].sort((Ge,Qt)=>{const fr=Ge.createdAt?new Date(Ge.createdAt).getTime():0;return(Qt.createdAt?new Date(Qt.createdAt).getTime():0)-fr}),Qe=new Set,en=[];for(const Ge of qe){const Qt=de(Ge);Qe.has(Qt)||(Qe.add(Qt),en.push(Ge))}return{leadsRows:en,leadsRawCount:Pe.length,leadsDeduped:Pe.length-en.length}},[ks,ds]);y.useEffect(()=>{const M=be.map(Pe=>Pe.id),de=M.filter(Pe=>xt.includes(Pe)).length,we=Xs.current;we&&(we.indeterminate=de>0&&dewe.id),de=M.length>0&&M.every(we=>xt.includes(we));jn(de?we=>we.filter(Pe=>!M.includes(Pe)):we=>[...new Set([...we,...M])])}function Vn(M){jn(de=>de.includes(M)?de.filter(we=>we!==M):[...de,M])}async function ps(){if(xt.length===0){G.info("请先勾选要删除的记录");return}const M=xt.length;if(!confirm(`确定批量删除选中的 ${M} 条获客记录?删除后不可恢复。`))return;const de=500;Er(!0);try{let we=0;for(let Pe=0;PeM==="success"?s.jsx(He,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"成功"}):M==="failed"?s.jsx(He,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):s.jsx(He,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}),ms=y.useMemo(()=>{const M=new Map;for(const de of be){if(de.pushStatus!=="failed")continue;const we=(de.ckbError||"未知错误").trim()||"未知错误";M.set(we,(M.get(we)||0)+1)}return Array.from(M.entries()).map(([de,we])=>({reason:de,count:we})).sort((de,we)=>we.count-de.count)},[be]);async function Jn(){const M=be.filter(Qe=>Qe.pushStatus==="failed");if(M.length===0){G.info("当前页无失败记录");return}const de=ms.slice(0,8).map(Qe=>`- ${Qe.reason}:${Qe.count} 条`).join(`
-`),we=M.slice(0,30).map(Qe=>Qe.id).join(", "),Pe=M.slice(0,20).map(Qe=>`#${Qe.id} | ${Qe.userNickname||Qe.name||"-"} | 手机:${Qe.phone||"-"} | 来源:${Qe.source||"-"} | 重试:${Qe.retryCount??0} | 错误:${Qe.ckbError||"-"}`).join(`
-`),qe=["【获客失败排障信息】",`时间:${new Date().toLocaleString()}`,`当前页失败总数:${M.length}`,"主要失败原因:",de||"- 无",`最近失败记录ID(最多30条):${we||"无"}`,"","失败记录明细(最多20条):",Pe||"无"].join(`
-`);try{await navigator.clipboard.writeText(qe),G.success("已复制排障信息")}catch{G.error("复制失败,请检查浏览器剪贴板权限")}}return s.jsxs("div",{className:"p-8 w-full",children:[z&&s.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:[s.jsx("span",{children:z}),s.jsx("button",{type:"button",onClick:()=>H(null),children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",c," 位注册用户",ei!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",ei," 人"]}),R&&" · RFM 排序中"]})]}),s.jsx(_e,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(ze,{className:"p-3 sm:p-4 space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>V(M=>!M),className:"flex items-center gap-2 min-w-0 flex-1 text-left rounded-lg px-1 py-0.5 hover:bg-white/5 transition-colors","aria-expanded":X,children:[s.jsx(yf,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),s.jsx("div",{className:"text-xs text-gray-500 truncate",children:X?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),X?s.jsx(Cg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Sl,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:Ma,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:R?ie==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),X&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0–100(六维度):最近消费 R(25%)+ 订单频次 F(20%)+ 累计金额 M(20%)+ 推荐人数(15%)+ 行为轨迹(10%)+ 资料完善(10%)。各维度在全量用户中归一化,与后端"," ",s.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ZR.map(({level:M,range:de,label:we})=>s.jsxs(He,{variant:"outline",className:`text-[10px] border-0 ${Bi(M)}`,children:[M," ",de," · ",we]},M))})]})]})})]}),s.jsxs(Vc,{value:a,onValueChange:M=>{const de=new URLSearchParams(t);M==="users"?de.delete("tab"):de.set("tab",M),e(de)},className:"w-full",children:[s.jsxs(Al,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(an,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Wn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(an,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Cs(),children:[s.jsx(jo,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(an,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Qo,children:[s.jsx(ya,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(an,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Es,children:[s.jsx(wo,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(an,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:sn,children:[s.jsx(Oc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(on,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(J,{variant:"outline",onClick:B,disabled:li,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[li?s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ri,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(J,{variant:"outline",onClick:()=>Hr(!0),disabled:L,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${L?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:k,onChange:M=>{const de=M.target.value;T(de),f(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:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:b,onChange:M=>v(M.target.value)})]}),s.jsxs(J,{onClick:la,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(jo,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Ls,{children:[s.jsx(Os,{children:s.jsxs(Nt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ce,{className:"text-gray-400",children:"用户信息"}),s.jsx(Ce,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Ce,{className:"text-gray-400",children:"购买状态"}),s.jsx(Ce,{className:"text-gray-400",children:"分销收益"}),s.jsxs(Ce,{className:"text-gray-400 cursor-pointer select-none",onClick:Ma,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(yf,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),R?ie==="desc"?s.jsx(Sl,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Cg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Sx,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),R&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Ce,{className:"text-gray-400",children:"资料完善"}),s.jsx(Ce,{className:"text-gray-400",children:"注册时间"}),s.jsx(Ce,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(Ds,{children:[i.map(M=>{var de,we,Pe;return s.jsxs(Nt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(ke,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var en;const qe=Ta(M.avatar,M.mbti),Qe=((en=M.nickname)==null?void 0:en.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>St(!0),className:"w-10 h-10 shrink-0 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden ring-1 ring-transparent hover:ring-[#38bdac]/60 transition",children:qe?s.jsx("img",{src:qe,className:"w-full h-full rounded-full object-cover",alt:"",onError:Ge=>{var Rr;const Qt=Ge.target;if(Qt.style.display="none",Qt.nextElementSibling)return;const fr=document.createElement("span");fr.textContent=Qe,(Rr=Qt.parentElement)==null||Rr.appendChild(fr)}}):Qe})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{Fe(M.id),te(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:M.nickname}),M.isAdmin&&s.jsx(He,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),M.openId&&!((de=M.id)!=null&&de.startsWith("user_"))&&s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:M.id,children:[(we=M.id)==null?void 0:we.slice(0,16),(((Pe=M.id)==null?void 0:Pe.length)??0)>16?"…":""]})]})]})}),s.jsx(ke,{children:s.jsxs("div",{className:"space-y-1",children:[M.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:M.phone})]}),M.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:M.wechatId})]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(ke,{children:(()=>{const qe=oa(M);return qe.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(He,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:qe.main}),qe.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:qe.sub})]}):qe.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(He,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:qe.main}),qe.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:qe.sub})]}):s.jsx(He,{variant:"outline",className:"text-gray-500 border-gray-600",children:qe.main})})()}),s.jsx(ke,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(M.earnings||0)).toFixed(2)]}),parseFloat(String(M.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(M.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Tr(M),role:"button",tabIndex:0,onKeyDown:qe=>qe.key==="Enter"&&Tr(M),children:[s.jsx(Wn,{className:"w-3 h-3"})," 绑定",M.referralCount||0,"人"]})]})}),s.jsx(ke,{children:M.rfmScore!=null&&M.rfmScore!==void 0?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:M.rfmScore}),s.jsx(He,{className:`border-0 text-xs ${Bi(M.rfmLevel)}`,children:M.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(ke,{children:(()=>{const qe=ue(M),Qe=qe>=75?"text-green-400":qe>=50?"text-yellow-400":"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${qe>=75?"bg-green-500":qe>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${qe}%`}})}),s.jsxs("span",{className:`text-xs ${Qe}`,children:[qe,"%"]})]})})()}),s.jsx(ke,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleDateString():"-"}),s.jsx(ke,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{Fe(M.id),te(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(gf,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Kl(M),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(rn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>hs(M.id),title:"删除",children:s.jsx(Yn,{className:"w-4 h-4"})})]})})]},M.id)}),i.length===0&&s.jsx(Nt,{children:s.jsx(ke,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(rr,{page:h,totalPages:ni,total:c,pageSize:m,onPageChange:f,onPageSizeChange:M=>{x(M),f(1)}})]})})})]}),s.jsxs(on,{value:"leads",children:[zs&&s.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:[s.jsx("span",{children:zs}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Vr(null),"aria-label":"关闭",children:"×"})]}),!ut&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"总留资条数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:Ys})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId)"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:O.uniqueUsers??0})]}),(O.sourceStats&&O.sourceStats.length>0?O.sourceStats.slice(0,2):[]).map(M=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",M.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:M.cnt})]},M.source))]}),!ut&&ms.length>0&&s.jsx(_e,{className:"bg-[#3a1010]/35 border-red-900/60 shadow-lg mb-4",children:s.jsxs(ze,{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-red-200 font-medium",children:"失败原因聚合"}),s.jsx("p",{className:"text-red-300/70 text-xs",children:"基于当前页筛选结果,按失败原因聚合统计"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:Jn,className:"border-red-600/70 text-red-200 hover:bg-red-500/10 bg-transparent",children:"一键复制排障信息"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:ms.slice(0,8).map(M=>s.jsxs(He,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[M.reason," · ",M.count]},M.reason))})]})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{placeholder:"搜索昵称/手机/微信/@人/来源…",value:aa,onChange:M=>Ca(M.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),O.sourceStats&&O.sourceStats.length>0&&s.jsxs("select",{value:us,onChange:M=>{Ea(M.target.value),ve(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),O.sourceStats.map(M=>s.jsxs("option",{value:M.source,children:[M.source,"(",M.cnt,")"]},M.source))]}),s.jsxs("select",{value:zt,onChange:M=>{Ya(M.target.value),ve(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"推送成功"}),s.jsx("option",{value:"failed",children:"推送失败"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:()=>{Ya("failed"),ve(1)},className:"border-red-600/60 text-red-300 hover:bg-red-500/10 bg-transparent text-xs h-9",children:"只看失败"}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",Ke," 条",yt>0?` · 已合并 ${yt} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(J,{variant:"outline",onClick:$i,disabled:ut,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(J,{variant:"outline",onClick:zi,disabled:Wl||Ot||ut,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Wl?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(J,{variant:"outline",onClick:()=>void ps(),disabled:Ot||xt.length===0||ut,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Yn,{className:`w-4 h-4 mr-2 ${Ot?"animate-pulse":""}`}),Ot?"删除中…":`批量删除(${xt.length})`]}),s.jsxs(J,{variant:"outline",onClick:()=>Cs(),disabled:ut,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ut?"animate-spin":""}`})," 刷新"]})]})]}),!ut&&be.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:xt.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",xt.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>jn([]),children:"清空"})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:ut?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Ls,{children:[s.jsx(Os,{children:s.jsxs(Nt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ce,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:Xs,type:"checkbox",checked:be.length>0&&be.every(M=>xt.includes(M.id)),onChange:kt,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(Ce,{className:"text-gray-400",children:"昵称"}),s.jsx(Ce,{className:"text-gray-400",children:"手机号"}),s.jsx(Ce,{className:"text-gray-400",children:"微信号"}),s.jsx(Ce,{className:"text-gray-400",children:"对应 @人"}),s.jsx(Ce,{className:"text-gray-400",children:"获客计划"}),s.jsx(Ce,{className:"text-gray-400",children:"来源"}),s.jsx(Ce,{className:"text-gray-400",children:"推送状态"}),s.jsx(Ce,{className:"text-gray-400",children:"重试"}),s.jsx(Ce,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(Ds,{children:[be.map(M=>s.jsxs(Nt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(ke,{className:"text-center align-middle w-10",children:s.jsx("input",{type:"checkbox",checked:xt.includes(M.id),onChange:()=>Vn(M.id),disabled:Ot,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx(ke,{className:"text-gray-300",children:M.userNickname||M.name||"-"}),s.jsx(ke,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(ke,{className:"text-gray-300",children:M.wechatId||"-"}),s.jsx(ke,{className:"text-[#38bdac]",children:M.personName||"-"}),s.jsx(ke,{className:"text-gray-400",children:M.ckbPlanId?`#${M.ckbPlanId}`:"-"}),s.jsx(ke,{children:s.jsx(He,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:M.source||"未知"})}),s.jsx(ke,{children:s.jsxs("div",{className:"space-y-1",children:[Tn(M.pushStatus),!!M.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:M.ckbError,children:M.ckbError})]})}),s.jsx(ke,{className:"text-gray-400 text-xs",children:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:typeof M.retryCount=="number"?`第 ${M.retryCount} 次`:"-"}),s.jsxs(J,{size:"sm",variant:"outline",disabled:Ot||Ze===M.id||Et===M.id,onClick:()=>Za(M.id),className:"h-7 px-2 text-[11px] border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-3 h-3 mr-1 ${Ze===M.id?"animate-spin":""}`}),"重推"]}),s.jsxs(J,{size:"sm",variant:"outline",disabled:Ot||Et===M.id||Ze===M.id,onClick:()=>od(M.id),className:"h-7 px-2 text-[11px] border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Yn,{className:`w-3 h-3 mr-1 ${Et===M.id?"animate-pulse":""}`}),"删除"]})]})}),s.jsx(ke,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleString():"-"})]},M.id)),be.length===0&&s.jsx(Nt,{children:s.jsx(ke,{colSpan:10,className:"p-0 align-top",children:s.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[s.jsx(jo,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),s.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:ds.trim()||us?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>Cs(),disabled:ut,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ut?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(rr,{page:re,totalPages:Math.ceil(Ys/Ye)||1,total:Ys,pageSize:Ye,onPageChange:ve,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(on,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(J,{variant:"outline",onClick:Qo,disabled:is,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${is?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.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"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:wc.map((M,de)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${M.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${Fn===M.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>Yl(M.id),title:`点击查看「${M.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:M.icon}),s.jsx("div",{className:`text-xs font-medium ${M.color.split(" ").find(we=>we.startsWith("text-"))}`,children:M.label}),mt[M.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:mt[M.id]})," 人"]}),s.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:de+1})]}),des.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:M.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:M.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",M.next]})]})]},M.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(wr,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),is?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(mt).length>0?s.jsx("div",{className:"space-y-2",children:wc.map(M=>{const de=mt[M.id]||0,we=Math.max(...wc.map(qe=>mt[qe.id]||0),1),Pe=Math.round(de/we*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[M.icon," ",M.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${Pe}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:de})]},M.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),Fn&&s.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(Yo=wc.find(M=>M.id===Fn))==null?void 0:Yo.icon," ",(Pu=wc.find(M=>M.id===Fn))==null?void 0:Pu.label," 阶段用户"]}),s.jsxs(He,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[ls.length," 人"]})]}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>or(null),className:"text-gray-400 hover:text-white",children:s.jsx(rs,{className:"w-4 h-4"})})]}),kr?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):ls.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(Ls,{children:[s.jsx(Os,{children:s.jsxs(Nt,{className:"border-gray-700",children:[s.jsx(Ce,{className:"text-gray-400",children:"昵称"}),s.jsx(Ce,{className:"text-gray-400",children:"手机号"}),s.jsx(Ce,{className:"text-gray-400",children:"注册时间"}),s.jsx(Ce,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(Ds,{children:ls.map(M=>s.jsxs(Nt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(ke,{className:"text-white",children:M.nickname||"微信用户"}),s.jsx(ke,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(ke,{className:"text-gray-400 text-xs",children:M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(ke,{className:"text-right",children:s.jsxs(J,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>Xl(M.id,M.nickname||"微信用户"),children:[s.jsx(gf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},M.id))})]})]}),s.jsx(Wt,{open:!!Js,onOpenChange:M=>{M||js(null)},children:s.jsxs(Ut,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(ya,{className:"w-5 h-5 text-[#38bdac]"}),Sr," 的行为轨迹"]})}),cr?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):cs.length===0?s.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):s.jsxs("div",{className:"relative pl-6 space-y-0",children:[s.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),cs.map((M,de)=>s.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[s.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-white text-sm font-medium",children:M.actionLabel}),M.module&&s.jsx(He,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:M.module})]}),(M.chapterTitle||M.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:M.chapterTitle||M.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[M.timeAgo," · ",M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):""]})]})]},M.id||de))]})]})})]}),s.jsxs(on,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程触达规则:各行为节点的触发条件与展示文案(偏利他说明,少用命令式)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(J,{variant:"outline",onClick:Es,disabled:Jt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Jt?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:()=>{vn(null),Nn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),bn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Un,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),Jt?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):_t.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(wr,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(J,{onClick:Es,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ve,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:_t.map(M=>{var we;const de=m2(M.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${M.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",M.sort]}),s.jsx(rn,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:M.title}),M.trigger&&s.jsx(He,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:M.trigger}),de.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[de.slice(0,3).map(Pe=>{const qe=Y1.find(Qe=>Qe.value===Pe);return s.jsx(He,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(qe==null?void 0:qe.label)||Pe},Pe)}),de.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",de.length-3]})]}),M.actionType&&M.actionType!=="popup"&&s.jsx(He,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((we=X1.find(Pe=>Pe.value===M.actionType))==null?void 0:we.label)||M.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Gt,{checked:M.enabled,onCheckedChange:()=>Aa(M)}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{vn(M),Nn({title:M.title,description:M.description,trigger:M.trigger,triggerConditions:de,actionType:M.actionType||"popup",sort:M.sort,enabled:M.enabled}),bn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>si(M.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]}),M.description&&s.jsxs("details",{className:"ml-[52px] mt-1",children:[s.jsxs("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:["查看完整描述",s.jsxs("span",{className:"text-gray-600 ml-1",children:["(",M.description.length," 字,默认折叠)"]})]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700 whitespace-pre-wrap",children:M.description})]})]},M.id)})})]}),s.jsxs(on,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(J,{variant:"outline",onClick:sn,disabled:Te,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Te?"animate-spin":""}`})," ","刷新"]})})]}),Te?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Ft.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Oc,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:s.jsxs(Ls,{children:[s.jsx(Os,{children:s.jsxs(Nt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ce,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(Ce,{className:"text-gray-400",children:"成员"}),s.jsx(Ce,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(Ce,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(Ce,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(Ce,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(Ce,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(Ce,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(Ds,{children:Ft.map((M,de)=>{var qe;const we=it===M.id,Pe=Ct===M.id;return s.jsxs(Nt,{draggable:!0,onDragStart:Qe=>Jo(Qe,M.id),onDragOver:Qe=>ii(Qe,M.id),onDrop:Qe=>Gi(Qe,M.id),onDragEnd:oi,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${we?"opacity-60":""} ${Pe?"bg-[#38bdac]/10":""}`,children:[s.jsx(ke,{className:"text-gray-300",children:de+1}),s.jsx(ke,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Ta(M.avatar,M.mbti)?s.jsx("img",{src:Ta(M.avatar,M.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Qe=>{var Ge,Qt;Qe.target.style.display="none";const en=document.createElement("div");en.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",en.textContent=((Ge=M.name)==null?void 0:Ge[0])||"创",(Qt=Qe.target.parentElement)==null||Qt.appendChild(en)}}):s.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:((qe=M.name)==null?void 0:qe[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:M.name})})]})}),s.jsx(ke,{className:"text-gray-300 whitespace-nowrap",children:M.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(ke,{className:"text-center text-blue-400 text-xs font-mono",children:M.clickCount!=null?String(M.clickCount):"-"}),s.jsx(ke,{className:"text-center text-green-400 text-xs font-mono",children:M.leadCount!=null?String(M.leadCount):"-"}),s.jsx(ke,{className:"text-gray-300",children:M.vipSort??de+1}),s.jsx(ke,{className:"text-xs",children:M.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:M.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),s.jsx(ke,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>Jl(M),title:"设置超级个体标签",children:s.jsx(Jd,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>Pr(M),title:"编辑飞书群Webhook",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>cd(M),title:"设置排序序号",children:s.jsx(Sx,{className:"w-3.5 h-3.5"})})]})})]},M.id)})})]})})})]})]}),s.jsx(Wt,{open:We,onOpenChange:St,children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(YR,{})]})}),s.jsx(Wt,{open:Ql,onOpenChange:M=>{ca(M),M||Ki(null)},children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(Sx,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",Ur==null?void 0:Ur.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:fs,onChange:M=>da(M.target.value)})]}),s.jsxs(Sn,{children:[s.jsxs(J,{variant:"outline",onClick:()=>ca(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Go,disabled:qi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),qi?"保存中...":"保存"]})]})]})}),s.jsx(Wt,{open:ld,onOpenChange:M=>{Zs(M),M||Hi(null)},children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(Oc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",ur==null?void 0:ur.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Ui.map(M=>s.jsx(J,{variant:Ar===M?"default":"outline",size:"sm",className:Ar===M?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>hr(M),children:M},M))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Ar,onChange:M=>hr(M.target.value)})]})]}),s.jsxs(Sn,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Zs(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:()=>ai(Ar),disabled:Ia,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),Ia?"保存中...":"保存"]})]})]})}),s.jsx(Wt,{open:Ir,onOpenChange:M=>{Ts(M),M||$s(null)},children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",er==null?void 0:er.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:Gl,onChange:M=>qo(M.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(Sn,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Ts(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Wi,disabled:ri,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),ri?"保存中...":"保存"]})]})]})}),s.jsx(Wt,{open:he,onOpenChange:I,children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[Q?s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(jo,{className:"w-5 h-5 text-[#38bdac]"}),Q?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"手机号"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:wt.phone,onChange:M=>Vt({...wt,phone:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"昵称"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:wt.nickname,onChange:M=>Vt({...wt,nickname:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:Q?"新密码 (留空则不修改)":"密码"}),s.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:Q?"留空则不修改":"请输入密码",value:wt.password,onChange:M=>Vt({...wt,password:M.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Gt,{checked:wt.isAdmin,onCheckedChange:M=>Vt({...wt,isAdmin:M})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"已购全书"}),s.jsx(Gt,{checked:wt.hasFullBook,onCheckedChange:M=>Vt({...wt,hasFullBook:M})})]})]}),s.jsxs(Sn,{children:[s.jsxs(J,{variant:"outline",onClick:()=>I(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Vi,disabled:xe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),xe?"保存中...":"保存"]})]})]})}),s.jsx(Wt,{open:yn,onOpenChange:bn,children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}),En?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:At.title,onChange:M=>Nn({...At,title:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则描述"}),s.jsx(Il,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:At.description,onChange:M=>Nn({...At,description:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(M=>{const de=Y1.filter(we=>we.group===M);return de.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:M}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:de.map(we=>{const Pe=(At.triggerConditions||[]).includes(we.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${Pe?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const qe=At.triggerConditions||[],Qe=Pe?qe.filter(en=>en!==we.value):[...qe,we.value];Nn({...At,triggerConditions:Qe})},children:we.label},we.value)})})]},M)})}),(At.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(At.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:At.trigger,onChange:M=>Nn({...At,trigger:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:X1.map(M=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${At.actionType===M.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>Nn({...At,actionType:M.value}),children:[s.jsx("span",{className:`text-xs font-medium ${At.actionType===M.value?"text-[#38bdac]":"text-gray-300"}`,children:M.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:M.desc})]},M.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(ne,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Gt,{checked:At.enabled,onCheckedChange:M=>Nn({...At,enabled:M})})]})]}),s.jsxs(Sn,{children:[s.jsxs(J,{variant:"outline",onClick:()=>bn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Mr,disabled:xe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),xe?"保存中...":"保存"]})]})]})}),s.jsx(Wt,{open:F,onOpenChange:U,children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-white flex items-center gap-2",children:[s.jsx(Wn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",K==null?void 0:K.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((dd=pe.stats)==null?void 0:dd.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Ru=pe.stats)==null?void 0:Ru.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((Lu=pe.stats)==null?void 0:Lu.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Ou=pe.stats)==null?void 0:Ou.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),oe?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Du=pe.referrals)==null?void 0:Du.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(pe.referrals??[]).map((M,de)=>{var Pe;const we=M;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((Pe=we.nickname)==null?void 0:Pe.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:we.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:we.phone||(we.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[we.status==="vip"&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),we.status==="paid"&&s.jsxs(He,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",we.purchasedSections,"章"]}),we.status==="free"&&s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:we.createdAt?new Date(we.createdAt).toLocaleDateString():""})]})]},we.id||de)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(Sn,{children:s.jsx(J,{variant:"outline",onClick:()=>U(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(X0,{open:Y,onClose:()=>te(!1),userId:Ne,onUserUpdated:Hr})]})}function kf(t,[e,n]){return Math.min(n,Math.max(e,t))}var x2=["PageUp","PageDown"],g2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],y2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},nd="Slider",[_g,t8,n8]=G0(nd),[b2]=Bo(nd,[n8]),[s8,Tp]=b2(nd),v2=y.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:x=()=>{},inverted:b=!1,form:v,...w}=t,N=y.useRef(new Set),k=y.useRef(0),C=o==="horizontal"?r8:a8,[P=[],L]=Tl({prop:f,defaultProp:h,onChange:X=>{var ie;(ie=[...N.current][k.current])==null||ie.focus(),m(X)}}),q=y.useRef(P);function z(X){const V=d8(P,X);se(X,V)}function H(X){se(X,k.current)}function R(){const X=q.current[k.current];P[k.current]!==X&&x(P)}function se(X,V,{commit:ie}={commit:!1}){const le=p8(i),he=m8(Math.round((X-r)/i)*i+r,le),I=kf(he,[r,a]);L((Q=[])=>{const $=l8(Q,I,V);if(f8($,u*i)){k.current=$.indexOf(I);const xe=String($)!==String(Q);return xe&&ie&&x($),xe?$:Q}else return Q})}return s.jsx(s8,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:N.current,values:P,orientation:o,form:v,children:s.jsx(_g.Provider,{scope:t.__scopeSlider,children:s.jsx(_g.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:Tt(w.onPointerDown,()=>{c||(q.current=P)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:z,onSlideMove:c?void 0:H,onSlideEnd:c?void 0:R,onHomeKeyDown:()=>!c&&se(r,0,{commit:!0}),onEndKeyDown:()=>!c&&se(a,P.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:V})=>{if(!c){const he=x2.includes(X.key)||X.shiftKey&&g2.includes(X.key)?10:1,I=k.current,Q=P[I],$=i*he*V;se(Q+$,I,{commit:!0})}}})})})})});v2.displayName=nd;var[N2,w2]=b2(nd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),r8=y.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=y.useState(null),b=Zt(e,C=>x(C)),v=y.useRef(void 0),w=Sp(a),N=w==="ltr",k=N&&!i||!N&&i;function T(C){const P=v.current||m.getBoundingClientRect(),L=[0,P.width],z=Z0(L,k?[n,r]:[r,n]);return v.current=P,z(C-P.left)}return s.jsx(N2,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx(j2,{dir:w,"data-orientation":"horizontal",...f,ref:b,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const P=T(C.clientX);o==null||o(P)},onSlideMove:C=>{const P=T(C.clientX);c==null||c(P)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:C=>{const L=y2[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:L?-1:1})}})})}),a8=y.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=y.useRef(null),m=Zt(e,f),x=y.useRef(void 0),b=!a;function v(w){const N=x.current||f.current.getBoundingClientRect(),k=[0,N.height],C=Z0(k,b?[r,n]:[n,r]);return x.current=N,C(w-N.top)}return s.jsx(N2,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:s.jsx(j2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const N=v(w.clientY);i==null||i(N)},onSlideMove:w=>{const N=v(w.clientY);o==null||o(N)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=y2[b?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),j2=y.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Tp(nd,n);return s.jsx(Rt.span,{...h,ref:e,onKeyDown:Tt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):x2.concat(g2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:Tt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:Tt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:Tt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),k2="SliderTrack",S2=y.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Tp(k2,n);return s.jsx(Rt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});S2.displayName=k2;var zg="SliderRange",C2=y.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Tp(zg,n),i=w2(zg,n),o=y.useRef(null),c=Zt(e,o),u=a.values.length,h=a.values.map(x=>M2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Rt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});C2.displayName=zg;var $g="SliderThumb",E2=y.forwardRef((t,e)=>{const n=t8(t.__scopeSlider),[r,a]=y.useState(null),i=Zt(e,c=>a(c)),o=y.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(i8,{...t,ref:i,index:o})}),i8=y.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Tp($g,n),c=w2($g,n),[u,h]=y.useState(null),f=Zt(e,T=>h(T)),m=u?o.form||!!u.closest("form"):!0,x=Y0(u),b=o.values[r],v=b===void 0?0:M2(b,o.min,o.max),w=c8(r,o.values.length),N=x==null?void 0:x[c.size],k=N?u8(N,v,c.direction):0;return y.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${v}% + ${k}px)`},children:[s.jsx(_g.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Rt.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":b,"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:b===void 0?{display:"none"}:t.style,onFocus:Tt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(T2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});E2.displayName=$g;var o8="RadioBubbleInput",T2=y.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=y.useRef(null),i=Zt(a,r),o=Q0(e);return y.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]),s.jsx(Rt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});T2.displayName=o8;function l8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function M2(t,e,n){const i=100/(n-e)*(t-e);return kf(i,[0,100])}function c8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function d8(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function u8(t,e,n){const r=t/2,i=Z0([0,50],[0,r]);return(r-i(e)*n)*n}function h8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function f8(t,e){if(e>0){const n=h8(t);return Math.min(...n)>=e}return!0}function Z0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function p8(t){return(String(t).split(".")[1]||"").length}function m8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var x8=v2,g8=S2,y8=C2,b8=E2;function v8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=y.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(x8,{defaultValue:e,value:n,min:r,max:a,className:$t("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(g8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(y8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(b8,{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 N8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function A2(t){const e=!!(t!=null&&t.embedded),[n,r]=y.useState(N8),[a,i]=y.useState(!0),[o,c]=y.useState(!1);y.useEffect(()=>{Oe("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&r({distributorShare:m.distributorShare??90,minWithdrawAmount:m.minWithdrawAmount??10,bindingDays:m.bindingDays??30,userDiscount:m.userDiscount??5,withdrawFee:m.withdrawFee??5,enableAutoWithdraw:m.enableAutoWithdraw??!1,vipOrderShareVip:m.vipOrderShareVip??20,vipOrderShareNonVip:m.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>i(!1))},[]);const u=async()=>{c(!0);try{const f={distributorShare:Number(n.distributorShare)||0,minWithdrawAmount:Number(n.minWithdrawAmount)||0,bindingDays:Number(n.bindingDays)||0,userDiscount:Number(n.userDiscount)||0,withdrawFee:Number(n.withdrawFee)??5,enableAutoWithdraw:!!n.enableAutoWithdraw,vipOrderShareVip:Number(n.vipOrderShareVip)||20,vipOrderShareNonVip:Number(n.vipOrderShareNonVip)||10},m=await jt("/api/admin/referral-settings",f);if(!m||m.success===!1){G.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}G.success(`✅ 分销配置已保存成功!
-
-• 小程序与网站的推广规则会一起生效
-• 绑定关系会使用新的天数配置
-• 佣金比例会立即应用到新订单
-
-如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),G.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(b=>({...b,[f]:isNaN(x)?0:x}))};return a?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:e?"p-4 w-full":"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Bc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(Fc,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(J,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(In,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{children:[s.jsxs(pt,{className:"flex items-center gap-2 text-white",children:[s.jsx(DM,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(nn,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(ze,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Ph,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Wn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(v8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(ce,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:n.distributorShare,onChange:h("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Ph,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Ph,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Wn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(ce,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(ft,{children:[s.jsxs(pt,{className:"flex items-center gap-2 text-white",children:[s.jsx(Bc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(nn,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(ze,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(ce,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(ce,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),s.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(He,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Gt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(ft,{children:s.jsxs(pt,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Ph,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(ze,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function w8(){const[t]=_0(),[e,n]=y.useState("overview"),[r,a]=y.useState("orders"),[i,o]=y.useState([]),[c,u]=y.useState(null),[h,f]=y.useState([]),[m,x]=y.useState([]),[b,v]=y.useState([]),[w,N]=y.useState(!0),[k,T]=y.useState(null),[C,P]=y.useState(""),[L,q]=y.useState("all"),[z,H]=y.useState(1),[R,se]=y.useState(10),[X,V]=y.useState(0),[ie,le]=y.useState(new Set),[he,I]=y.useState(null),[Q,$]=y.useState(""),[xe,Z]=y.useState(!1),[F,U]=y.useState(null),[pe,fe]=y.useState(""),[oe,D]=y.useState(!1),[K,_]=y.useState(!1),[Y,te]=y.useState(!1),[Ne,Fe]=y.useState([]),[We,St]=y.useState(1),[wt,Vt]=y.useState(0),[_t,$n]=y.useState(""),[Jt,dn]=y.useState([]),[yn,bn]=y.useState(0),[En,vn]=y.useState(1),[At,Nn]=y.useState(10),[Ft,je]=y.useState(!1),[Te,Ue]=y.useState(null),[it,Dt]=y.useState(""),Ct=Lo(it,300),[$e,mt]=y.useState(""),[es,is]=y.useState(""),[Gn,Fn]=y.useState({}),[or,ls]=y.useState(null),[ws,kr]=y.useState(null),[Pn,Js]=y.useState([]),[js,Sr]=y.useState(!1),lr=y.useRef(null),cs=y.useCallback(async()=>{je(!0),Ue(null);try{const O=new URLSearchParams({mode:"contact",page:String(En),pageSize:String(At)});Ct.trim()&&O.set("search",Ct.trim()),$e&&O.set("source",$e),es&&O.set("pushStatus",es);const Se=await Oe(`/api/db/ckb-leads?${O}`);if(Se!=null&&Se.success)dn(Se.records||[]),bn(Se.total??0),Se.stats&&Fn(Se.stats);else{const Ze=(Se==null?void 0:Se.error)||"加载获客情况失败";Ue(Ze),G.error(Ze),dn([]),bn(0)}}catch(O){const Se=O instanceof Error?O.message:"网络错误";Ue(Se),G.error("加载获客情况失败: "+Se),dn([]),bn(0)}finally{je(!1)}},[En,At,Ct,$e,es]);y.useEffect(()=>{Js([])},[Ct,$e,es]),y.useEffect(()=>{const O=Jt.map(It=>It.id),Se=O.filter(It=>Pn.includes(It)).length,Ze=lr.current;Ze&&(Ze.indeterminate=Se>0&&SeZe.id),Se=O.length>0&&O.every(Ze=>Pn.includes(Ze));Js(Se?Ze=>Ze.filter(It=>!O.includes(It)):Ze=>[...new Set([...Ze,...O])])}function cr(O){Js(Se=>Se.includes(O)?Se.filter(Ze=>Ze!==O):[...Se,O])}async function dr(){if(Pn.length===0){G.info("请先勾选要删除的记录");return}const O=Pn.length;if(!confirm(`确定批量删除选中的 ${O} 条获客记录?删除后不可恢复。`))return;const Se=500;Sr(!0);try{let Ze=0;for(let It=0;ItZe.map(It=>It.id===O?ra(It,Se.record):It))):G.error((Se==null?void 0:Se.error)||"重推失败")}catch(Se){G.error(Se instanceof Error?Se.message:"重推请求失败")}finally{ls(null)}}}async function ks(O){if(O&&confirm("确定删除该条获客记录?删除后不可恢复,用户可再次提交留资。")){kr(O);try{const Se=await jt("/api/db/ckb-leads/delete",{id:O});Se!=null&&Se.success?G.success("已删除"):G.error((Se==null?void 0:Se.error)||"删除失败")}catch(Se){G.error(Se instanceof Error?Se.message:"删除请求失败")}finally{kr(null),cs()}}}function Ss(O){return O==="success"?s.jsx(He,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"成功"}):O==="failed"?s.jsx(He,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):s.jsx(He,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})}y.useEffect(()=>{Ys()},[]),y.useEffect(()=>{const O=t.get("tab");(O==="overview"||O==="orders"||O==="bindings"||O==="withdrawals"||O==="settings"||O==="leads")&&n(O)},[t]),y.useEffect(()=>{H(1)},[e,L]),y.useEffect(()=>{if(e==="leads"){N(!1);return}wn(e)},[e]),y.useEffect(()=>{if(e==="orders"&&r==="giftpay"){wn("giftPay",!0);return}["orders","bindings","withdrawals"].includes(e)&&wn(e,!0),e==="leads"&&cs()},[z,R,L,C,e,r,We,_t,En,At,cs]),y.useEffect(()=>{e==="withdrawals"&&Bn()},[e]);async function Ys(){T(null);try{const O=await Oe("/api/admin/distribution/overview");O!=null&&O.success&&O.overview&&u(O.overview)}catch(O){console.error("[Admin] 概览接口异常:",O),T("加载概览失败")}try{const O=await Oe("/api/db/users");v((O==null?void 0:O.users)||[])}catch(O){console.error("[Admin] 用户数据加载失败:",O)}}async function wn(O,Se=!1){var Ze;if(!(!Se&&ie.has(O))){N(!0);try{const It=b;switch(O){case"overview":break;case"orders":{try{const Et=new URLSearchParams({page:String(z),pageSize:String(R),...L!=="all"&&{status:L},...C&&{search:C}}),ht=await Oe(`/api/admin/orders?${Et}`);if(ht!=null&&ht.success&&ht.orders){const xt=ht.orders.map(jn=>{const Ot=It.find(Xs=>Xs.id===jn.userId),Er=jn.referrerId?It.find(Xs=>Xs.id===jn.referrerId):null;return{...jn,amount:parseFloat(String(jn.amount))||0,userNickname:(Ot==null?void 0:Ot.nickname)||jn.userNickname||"未知用户",userPhone:(Ot==null?void 0:Ot.phone)||jn.userPhone||"-",referrerNickname:(Er==null?void 0:Er.nickname)||null,referrerCode:(Er==null?void 0:Er.referralCode)??null,type:jn.productType||jn.type}});o(xt),V(ht.total??xt.length)}else o([]),V(0)}catch(Et){console.error(Et),T("加载订单失败"),o([])}break}case"bindings":{try{const Et=new URLSearchParams({page:String(z),pageSize:String(R),...L!=="all"&&{status:L}}),ht=await Oe(`/api/db/distribution?${Et}`);f((ht==null?void 0:ht.bindings)||[]),V((ht==null?void 0:ht.total)??((Ze=ht==null?void 0:ht.bindings)==null?void 0:Ze.length)??0)}catch(Et){console.error(Et),T("加载绑定数据失败"),f([])}break}case"withdrawals":{try{const Et=L==="completed"?"success":L==="rejected"?"failed":L,ht=new URLSearchParams({...Et&&Et!=="all"&&{status:Et},page:String(z),pageSize:String(R)}),xt=await Oe(`/api/admin/withdrawals?${ht}`);if(xt!=null&&xt.success&&xt.withdrawals){const jn=xt.withdrawals.map(Ot=>({...Ot,account:Ot.account??"未绑定微信号",status:Ot.status==="success"?"completed":Ot.status==="failed"?"rejected":Ot.status}));x(jn),V((xt==null?void 0:xt.total)??jn.length)}else xt!=null&&xt.success||T(`获取提现记录失败: ${(xt==null?void 0:xt.error)||"未知错误"}`),x([])}catch(Et){console.error(Et),T("加载提现数据失败"),x([])}break}case"giftPay":{try{const Et=new URLSearchParams({page:String(We),pageSize:"20",..._t&&{status:_t}}),ht=await Oe(`/api/admin/gift-pay-requests?${Et}`);ht!=null&&ht.success&&ht.data?(Fe(ht.data),Vt(ht.total??ht.data.length)):(Fe([]),Vt(0))}catch(Et){console.error(Et),T("加载代付请求失败"),Fe([])}break}case"leads":break}le(Et=>new Set(Et).add(O))}catch(It){console.error(It)}finally{N(!1)}}}async function re(){if(T(null),e==="leads"){await cs();return}le(O=>{const Se=new Set(O);return Se.delete(e),e==="orders"&&r==="giftpay"&&Se.delete("giftPay"),Se}),e==="overview"&&Ys(),e==="orders"&&r==="giftpay"?await wn("giftPay",!0):await wn(e,!0)}async function ve(O){if(confirm("确认审核通过并打款?"))try{const Se=await tn("/api/admin/withdrawals",{id:O,action:"approve"});if(!(Se!=null&&Se.success)){const Ze=(Se==null?void 0:Se.message)||(Se==null?void 0:Se.error)||"操作失败";G.error(Ze);return}await re()}catch(Se){console.error(Se),G.error("操作失败")}}function Ye(O){U(O),fe("")}async function ut(){const O=F;if(!O)return;const Se=pe.trim();if(!Se){G.error("请填写拒绝原因");return}D(!0);try{const Ze=await tn("/api/admin/withdrawals",{id:O,action:"reject",errorMessage:Se});if(!(Ze!=null&&Ze.success)){G.error((Ze==null?void 0:Ze.error)||"操作失败");return}G.success("已拒绝该提现申请"),U(null),fe(""),await re()}catch(Ze){console.error(Ze),G.error("操作失败")}finally{D(!1)}}async function Bn(){try{const O=await Oe("/api/admin/withdrawals/auto-approve");O!=null&&O.success&&typeof O.enableAutoApprove=="boolean"&&_(O.enableAutoApprove)}catch{}}async function zs(O){te(!0);try{const Se=await tn("/api/admin/withdrawals/auto-approve",{enableAutoApprove:O});Se!=null&&Se.success?(_(O),G.success(O?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):G.error("更新失败: "+((Se==null?void 0:Se.error)??""))}catch{G.error("更新失败")}finally{te(!1)}}function Vr(){F&&G.info("已取消操作"),U(null),fe("")}async function aa(){var O;if(!(!(he!=null&&he.orderSn)&&!(he!=null&&he.id))){Z(!0),T(null);try{const Se=await tn("/api/admin/orders/refund",{orderSn:he.orderSn||he.id,reason:Q||void 0});Se!=null&&Se.success?(I(null),$(""),await wn("orders",!0)):T((Se==null?void 0:Se.error)||"退款失败")}catch(Se){const Ze=Se;T(((O=Ze==null?void 0:Ze.data)==null?void 0:O.error)||"退款失败,请检查网络后重试")}finally{Z(!1)}}}function Ca(O){const Se={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"},Ze={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(He,{className:`${Se[O]||"bg-gray-500/20 text-gray-400"} border-0`,children:Ze[O]||O})}const ds=Math.ceil(X/R)||1,us=Math.ceil(yn/At)||1,Ea=i,zt=h.filter(O=>{var Ze,It,Et,ht;if(!C)return!0;const Se=C.toLowerCase();return((Ze=O.refereeNickname)==null?void 0:Ze.toLowerCase().includes(Se))||((It=O.refereePhone)==null?void 0:It.includes(Se))||((Et=O.referrerName)==null?void 0:Et.toLowerCase().includes(Se))||((ht=O.referrerCode)==null?void 0:ht.toLowerCase().includes(Se))}),Ya=m.filter(O=>{var Ze;if(!C)return!0;const Se=C.toLowerCase();return((Ze=O.userName)==null?void 0:Ze.toLowerCase().includes(Se))||O.account&&O.account.toLowerCase().includes(Se)});return s.jsxs("div",{className:"p-8 w-full",children:[k&&s.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:[s.jsx("span",{children:k}),s.jsx("button",{type:"button",onClick:()=>T(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(J,{onClick:re,disabled:w||e==="leads"&&Ft,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1.5 ${w||e==="leads"&&Ft?"animate-spin":""}`}),"刷新"]})]}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:yf},{key:"orders",label:"订单与代付",icon:xf},{key:"bindings",label:"绑定管理",icon:Ba},{key:"withdrawals",label:"提现审核",icon:Bc},{key:"settings",label:"推广设置",icon:wo},{key:"leads",label:"获客情况",icon:jo}].map(O=>s.jsxs("button",{type:"button",onClick:()=>{n(O.key),q("all"),P(""),O.key!=="orders"&&a("orders"),O.key==="leads"&&vn(1)},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${e===O.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(O.icon,{className:"w-3.5 h-3.5"}),O.label]},O.key))}),w?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[e==="overview"&&c&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[s.jsx(Ri,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",onClick:()=>void re(),disabled:w,className:"text-gray-400 h-7",children:s.jsx(Ve,{className:`w-3.5 h-3.5 ${w?"animate-spin":""}`})})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-gray-500 text-xs border-b border-gray-700/50",children:[s.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),s.jsxs("tbody",{className:"text-white",children:[s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(gf,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.totalClicks})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Ba,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.totalBindings})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Cx,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(xf,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(c.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.totalEarnings??0).toFixed(0)]})]})]})]})}),c.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",c.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(_e,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Eg,{className:"w-5 h-5 text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[c.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(_e,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Bc,{className:"w-5 h-5 text-blue-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[c.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(c.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(J,{onClick:()=>n("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Wn,{className:"w-5 h-5 text-gray-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-white",children:c.totalDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Cx,{className:"w-5 h-5 text-green-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-green-400",children:c.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),e==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>a("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r==="giftpay"?"bg-amber-500/20 text-amber-400 border border-amber-500/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>{a("giftpay"),wn("giftPay",!0)},children:[s.jsx(Tg,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),r==="orders"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:C,onChange:O=>P(O.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:L,onChange:O=>q(O.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void re(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[i.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Ea.map(O=>{var Se,Ze;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Se=O.id)==null?void 0:Se.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:O.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:O.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const It=O.productType||O.type,Et=O.description||"",ht=String(O.productId||O.sectionId||""),xt=It==="vip"||Et.includes("VIP")||Et.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return It==="balance_recharge"?`余额充值 ¥${typeof O.amount=="number"?O.amount.toFixed(2):parseFloat(String(O.amount||"0")).toFixed(2)}`:xt?"超级个体开通费用":It==="fullbook"?`${O.bookName||"《底层逻辑》"} - 全本`:It==="match"?"匹配次数购买":`${O.bookName||"《底层逻辑》"} - ${O.sectionTitle||O.chapterTitle||`章节${O.productId||O.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const It=O.productType||O.type,Et=O.description||"",ht=String(O.productId||O.sectionId||""),xt=It==="vip"||Et.includes("VIP")||Et.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return It==="balance_recharge"?"余额充值":xt?"超级个体":It==="fullbook"?"全书解锁":It==="match"?"功能权益":O.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof O.amount=="number"?O.amount.toFixed(2):parseFloat(String(O.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:O.paymentMethod==="wechat"?"微信支付":O.paymentMethod==="balance"?"余额支付":O.paymentMethod==="alipay"?"支付宝":O.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:O.status==="refunded"?s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):O.status==="completed"||O.status==="paid"?s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):O.status==="pending"||O.status==="created"?s.jsx(He,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(He,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:O.refundReason,children:O.status==="refunded"&&O.refundReason?O.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:O.referrerId||O.referralCode?s.jsxs("span",{title:O.referralCode||O.referrerCode||O.referrerId||"",children:[O.referrerNickname||O.referralCode||O.referrerCode||((Ze=O.referrerId)==null?void 0:Ze.slice(0,8)),(O.referralCode||O.referrerCode)&&` (${O.referralCode||O.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:O.referrerEarnings?`¥${(typeof O.referrerEarnings=="number"?O.referrerEarnings:parseFloat(String(O.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:O.createdAt?new Date(O.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(O.status==="paid"||O.status==="completed")&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{I(O),$("")},children:[s.jsx(qj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},O.id)})})]})}),e==="orders"&&s.jsx(rr,{page:z,totalPages:ds,total:X,pageSize:R,onPageChange:H,onPageSizeChange:O=>{se(O),H(1)}})]})})]}),r==="giftpay"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(ft,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(pt,{className:"text-white text-base",children:"代付请求列表"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:_t,onChange:O=>{$n(O.target.value),St(1)},children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待支付(旧)"}),s.jsx("option",{value:"pending_pay",children:"待发起人支付"}),s.jsx("option",{value:"paid",children:"已支付"}),s.jsx("option",{value:"refunded",children:"已退款"}),s.jsx("option",{value:"cancelled",children:"已取消"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>void wn("giftPay",!0),disabled:w,className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${w?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(ze,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Ne.map(O=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:O.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:O.initiatorNick||O.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[O.productType," · ¥",O.amount.toFixed(2)]}),O.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:O.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(O.quantity??1)>1?`${O.quantity}份 / 已领${O.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:O.payerNick||(O.payerUserId?O.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(He,{className:O.status==="paid"?"bg-green-500/20 text-green-400 border-0":O.status==="pending"||O.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":O.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:O.status==="paid"?"已支付":O.status==="pending"||O.status==="pending_pay"?"待支付":O.status==="refunded"?"已退款":O.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:O.createdAt?new Date(O.createdAt).toLocaleString("zh-CN"):"-"})]},O.id))})]})}),Ne.length===0&&!w&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),wt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(rr,{page:We,totalPages:Math.ceil(wt/20),total:wt,pageSize:20,onPageChange:St,onPageSizeChange:()=>{}})})]})]})]}),e==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:C,onChange:O=>P(O.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:L,onChange:O=>q(O.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void re(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[zt.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:zt.map(O=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:O.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:O.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:O.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:O.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:O.boundAt?new Date(O.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:O.expiresAt?new Date(O.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Ca(O.status)}),s.jsx("td",{className:"p-4",children:O.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",O.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},O.id))})]})}),e==="bindings"&&s.jsx(rr,{page:z,totalPages:ds,total:X,pageSize:R,onPageChange:H,onPageSizeChange:O=>{se(O),H(1)}})]})})]}),e==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:C,onChange:O=>P(O.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:L,onChange:O=>q(O.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[s.jsx(Ri,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Gt,{checked:K,onCheckedChange:zs,disabled:Y,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void re(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[Ya.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Ya.map(O=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[O.userAvatar?s.jsx("img",{src:O.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(O.userName||O.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:O.userName||O.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",O.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(He,{className:O.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:O.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:O.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:O.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:O.createdAt?new Date(O.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Ca(O.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${O.status==="rejected"||O.status==="failed"?"text-red-400":"text-gray-400"}`,title:O.remark,children:O.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:O.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(J,{size:"sm",onClick:()=>ve(O.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Cx,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>Ye(O.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Bj,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},O.id))})]})}),e==="withdrawals"&&s.jsx(rr,{page:z,totalPages:ds,total:X,pageSize:R,onPageChange:H,onPageSizeChange:O=>{se(O),H(1)}})]})})]}),e==="leads"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-500 text-sm",children:["展示用户通过文章 @、首页等入口留下的线索,以及转发存客宝接口的推送状态与失败原因(数据来自"," ",s.jsx("code",{className:"text-gray-400",children:"ckb_lead_records"}),")。"]}),Te&&s.jsxs("div",{className:"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:[s.jsx("span",{children:Te}),s.jsx("button",{type:"button",className:"shrink-0 ml-2 hover:text-red-300",onClick:()=>Ue(null),children:"×"})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"总留资条数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:yn})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",children:Gn.uniqueUsers??0})]}),(Gn.sourceStats||[]).slice(0,2).map(O=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",O.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:O.cnt})]},O.source))]}),s.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:it,onChange:O=>{Dt(O.target.value),vn(1)},placeholder:"搜索昵称 / 手机 / 微信 / 姓名…",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),Gn.sourceStats&&Gn.sourceStats.length>0&&s.jsxs("select",{value:$e,onChange:O=>{mt(O.target.value),vn(1)},className:"px-3 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white text-sm shrink-0",children:[s.jsx("option",{value:"",children:"全部来源"}),Gn.sourceStats.map(O=>s.jsxs("option",{value:O.source,children:[O.source,"(",O.cnt,")"]},O.source))]}),s.jsxs("select",{value:es,onChange:O=>{is(O.target.value),vn(1)},className:"px-3 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white text-sm shrink-0",children:[s.jsx("option",{value:"",children:"推送状态:全部"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"成功"}),s.jsx("option",{value:"failed",children:"失败"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void cs(),disabled:Ft,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Ft?"animate-spin":""}`}),"刷新列表"]})]}),Jt.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-1 py-2 rounded-lg bg-[#0a1628]/80 border border-gray-700/40",children:[s.jsxs("span",{className:"text-sm text-gray-400",children:["已选 ",s.jsx("span",{className:"text-[#38bdac] font-medium",children:Pn.length})," 条(可翻页继续勾选;改搜索或来源/状态筛选会清空)"]}),s.jsxs(J,{type:"button",variant:"outline",size:"sm",disabled:js||Pn.length===0,onClick:()=>void dr(),className:"border-red-500/50 text-red-400 hover:bg-red-500/15 bg-transparent",children:[s.jsx(Yn,{className:`w-3.5 h-3.5 mr-1.5 ${js?"animate-pulse":""}`}),js?"删除中…":"批量删除选中"]}),Pn.length>0&&s.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-gray-500 hover:text-gray-300",onClick:()=>Js([]),children:"清空选择"})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:Jt.length===0&&!Ft?s.jsxs("div",{className:"py-16 text-center text-gray-500",children:[s.jsx(jo,{className:"w-12 h-12 mx-auto mb-3 text-[#38bdac]/30"}),s.jsx("p",{children:"暂无记录,或当前筛选无匹配"})]}):Jt.length===0&&Ft?s.jsxs("div",{className:"flex items-center justify-center py-16",children:[s.jsx(Ve,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载获客情况…"})]}):s.jsxs("div",{className:"relative min-h-[200px]",children:[s.jsxs("div",{className:Ft?"pointer-events-none select-none opacity-50":"",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-3 w-10 text-center font-medium",children:s.jsx("input",{ref:lr,type:"checkbox",checked:Jt.length>0&&Jt.every(O=>Pn.includes(O.id)),onChange:Cr,disabled:Ft,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页"})}),s.jsx("th",{className:"p-4 text-left font-medium",children:"点击用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"@ 目标人物"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"联系方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"来源"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"存客宝推送"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"最后推送"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"创建时间"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Jt.map(O=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-3 w-10 text-center align-middle",children:s.jsx("input",{type:"checkbox",checked:Pn.includes(O.id),onChange:()=>cr(O.id),disabled:js||Ft,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2 min-w-[10rem]",children:[O.userAvatar?s.jsx("img",{src:O.userAvatar,alt:"",className:"w-9 h-9 rounded-full object-cover shrink-0"}):s.jsx("div",{className:"w-9 h-9 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm shrink-0",children:(O.userNickname||O.name||"?").slice(0,1)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:O.userNickname||O.name||"-"}),O.userId&&s.jsx("p",{className:"text-gray-500 text-xs font-mono truncate max-w-[8rem]",children:O.userId})]})]})}),s.jsx("td",{className:"p-4 text-[#38bdac]",children:O.personName||"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{children:O.phone||"-"}),s.jsx("p",{className:"text-xs",children:O.wechatId||"-"})]})}),s.jsx("td",{className:"p-4",children:s.jsx(He,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:O.source||"未知"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"space-y-1 max-w-[14rem]",children:[Ss(O.pushStatus),O.ckbError?s.jsx("p",{className:"text-xs text-red-300 break-words",title:O.ckbError,children:O.ckbError}):s.jsx("p",{className:"text-xs text-gray-500",children:"—"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["重试 ",typeof O.retryCount=="number"?O.retryCount:0," 次"]})]})}),s.jsx("td",{className:"p-4 text-gray-400 text-xs",children:O.lastPushAt?new Date(O.lastPushAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-xs",children:O.createdAt?new Date(O.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-right",children:s.jsxs("div",{className:"flex flex-wrap gap-2 justify-end",children:[s.jsxs(J,{size:"sm",variant:"outline",disabled:Ft||js||or===O.id||ws===O.id,onClick:()=>Qs(O.id),className:"border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent h-8",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${or===O.id?"animate-spin":""}`}),"重推"]}),s.jsxs(J,{size:"sm",variant:"outline",disabled:Ft||js||ws===O.id||or===O.id,onClick:()=>ks(O.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/15 bg-transparent h-8",children:[s.jsx(Yn,{className:`w-3.5 h-3.5 mr-1 ${ws===O.id?"animate-pulse":""}`}),"删除"]})]})})]},O.id))})]})}),s.jsx(rr,{page:En,totalPages:us,total:yn,pageSize:At,onPageChange:vn,onPageSizeChange:O=>{Nn(O),vn(1)}})]}),Ft&&s.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center rounded-b-lg bg-[#0f2137]/85 backdrop-blur-[2px]","aria-busy":"true","aria-label":"加载中",children:[s.jsx(Ve,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"mt-2 text-sm text-gray-400",children:"加载中…"})]})]})})})]})]}),s.jsx(Wt,{open:!!he,onOpenChange:O=>!O&&I(null),children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-white",children:"订单退款"})}),he&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",he.orderSn||he.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof he.amount=="number"?he.amount.toFixed(2):parseFloat(String(he.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:Q,onChange:O=>$(O.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Sn,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>I(null),disabled:xe,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:aa,disabled:xe,children:xe?"退款中...":"确认退款"})]})]})}),s.jsx(Wt,{open:!!F,onOpenChange:O=>!O&&Vr(),children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:pe,onChange:O=>fe(O.target.value)})})]})]}),s.jsxs(Sn,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Vr,disabled:oe,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ut,disabled:oe||!pe.trim(),children:oe?"提交中...":"确认拒绝"})]})]})}),e==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(A2,{embedded:!0})})]})}function j8(){const[t,e]=y.useState([]),[n,r]=y.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=y.useState(!0),[o,c]=y.useState(null),[u,h]=y.useState("all"),[f,m]=y.useState(1),[x,b]=y.useState(10),[v,w]=y.useState(0),[N,k]=y.useState(null),[T,C]=y.useState(null),[P,L]=y.useState(""),[q,z]=y.useState(!1);async function H(){var I,Q,$,xe,Z,F,U;i(!0),c(null);try{const pe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),fe=await Oe(`/api/admin/withdrawals?${pe}`);if(fe!=null&&fe.success){const oe=fe.withdrawals||[];e(oe),w(fe.total??((I=fe.stats)==null?void 0:I.total)??oe.length),r({total:((Q=fe.stats)==null?void 0:Q.total)??fe.total??oe.length,pendingCount:(($=fe.stats)==null?void 0:$.pendingCount)??0,pendingAmount:((xe=fe.stats)==null?void 0:xe.pendingAmount)??0,successCount:((Z=fe.stats)==null?void 0:Z.successCount)??0,successAmount:((F=fe.stats)==null?void 0:F.successAmount)??0,failedCount:((U=fe.stats)==null?void 0:U.failedCount)??0})}else c("加载提现记录失败")}catch(pe){console.error("Load withdrawals error:",pe),c("加载失败,请检查网络后重试")}finally{i(!1)}}y.useEffect(()=>{m(1)},[u]),y.useEffect(()=>{H()},[u,f,x]);const R=Math.ceil(v/x)||1;async function se(I){const Q=t.find($=>$.id===I);if(Q!=null&&Q.userCommissionInfo&&Q.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Q.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
-
-确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const $=await tn("/api/admin/withdrawals",{id:I,action:"approve"});$!=null&&$.success?H():G.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{G.error("操作失败")}finally{k(null)}}async function X(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Q=await jt("/api/admin/withdrawals/cancel",{id:I});Q!=null&&Q.success?(G.success("已撤回打款"),H()):G.error("撤回失败: "+((Q==null?void 0:Q.error)??"未知错误"))}catch{G.error("撤回失败")}finally{k(null)}}}function V(I){C(I),L("")}async function ie(){const I=T;if(!I)return;const Q=P.trim();if(!Q){G.error("请填写拒绝原因");return}z(!0);try{const $=await tn("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Q});$!=null&&$.success?(G.success("已拒绝该提现申请"),C(null),L(""),H()):G.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{G.error("操作失败")}finally{z(!1)}}function le(){T&&G.info("已取消操作"),C(null),L("")}function he(I){switch(I){case"pending":return s.jsx(He,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(He,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(He,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(He,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.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:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(J,{variant:"outline",onClick:H,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(xf,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","processing","pending_confirm","success","failed"].map(I=>s.jsx(J,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="processing"?"处理中":I==="pending_confirm"?"待确认收款":I==="success"?"已完成":"已拒绝"},I))}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Bc,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:Ua(I.userAvatar),alt:I.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",I.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",I.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",I.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:he(I.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${I.status==="rejected"||I.status==="failed"?"text-red-400":"text-gray-400"}`,title:I.remark,children:I.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(J,{size:"sm",onClick:()=>se(I.id),disabled:N===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(Np,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>V(I.id),disabled:N===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(rs,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="processing"||I.status==="pending_confirm")&&s.jsx("div",{className:"mt-2 flex items-center justify-end gap-2",children:s.jsx(J,{size:"sm",variant:"outline",onClick:()=>X(I.id),disabled:N===I.id,className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:"撤回打款"})}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(rr,{page:f,totalPages:R,total:v,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Wt,{open:!!T,onOpenChange:I=>!I&&le(),children:s.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:P,onChange:I=>L(I.target.value)})})]})]}),s.jsxs(Sn,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:le,disabled:q,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ie,disabled:q||!P.trim(),children:q?"提交中...":"确认拒绝"})]})]})})]})}var $x={exports:{}},Fx={};/**
- * @license React
- * use-sync-external-store-shim.production.js
- *
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */var eN;function k8(){if(eN)return Fx;eN=1;var t=ju();function e(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,x){var b=x(),v=r({inst:{value:b,getSnapshot:x}}),w=v[0].inst,N=v[1];return i(function(){w.value=b,w.getSnapshot=x,u(w)&&N({inst:w})},[m,b,x]),a(function(){return u(w)&&N({inst:w}),m(function(){u(w)&&N({inst:w})})},[m]),o(b),b}function u(m){var x=m.getSnapshot;m=m.value;try{var b=x();return!n(m,b)}catch{return!0}}function h(m,x){return x()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Fx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Fx}var tN;function I2(){return tN||(tN=1,$x.exports=k8()),$x.exports}var P2=I2();function Is(t){this.content=t}Is.prototype={constructor:Is,find:function(t){for(var e=0;e>1}};Is.from=function(t){if(t instanceof Is)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Is(e)};function R2(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(r),i=e.child(r);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=R2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function L2(t,e,n,r){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:r};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&r(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),r,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,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)&&r&&(o?o=!1:i+=r),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.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))),r.push(c),a+=c.nodeSize),o=u}return new Ee(r,a)}cutByIndex(e,n){return e==n?Ee.empty:e==0&&n==this.content.length?this:new Ee(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return a[e]=n,new Ee(a,i)}addToStart(e){return new Ee([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ee(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,r=0;;n++){let a=this.child(n),i=r+a.nodeSize;if(i>=e)return i==e?Bh(n+1,i):Bh(n,r);r=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 Ee.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ee(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ee.empty;let n,r=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-a.type.rank),n}};cn.none=[];class Cf extends Error{}class Be{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=D2(this.content,e+this.openStart,n);return r&&new Be(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Be(O2(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 Be.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Be(Ee.fromJSON(e,n.content),r,a)}static maxOpen(e,n=!0){let r=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Be(e,r,a)}}Be.empty=new Be(Ee.empty,0,0);function O2(t,e,n){let{index:r,offset:a}=t.findIndex(e),i=t.maybeChild(r),{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(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(O2(i.content,e-a-1,n-a-1)))}function D2(t,e,n,r){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return r&&!r.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=D2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function S8(t,e,n){if(n.openStart>t.depth)throw new Cf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Cf("Inconsistent open depths");return _2(t,e,n,0)}function _2(t,e,n,r){let a=t.index(r),i=t.node(r);if(a==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Qd(t,e,n,r){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&&(vl(t.nodeAfter,r),i++));for(let c=i;ca&&Bg(t,e,a+1),o=r.depth>a&&Bg(n,r,a+1),c=[];return Qd(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(z2(i,o),vl(Nl(i,$2(t,e,n,r,a+1)),c)):(i&&vl(Nl(i,Ef(t,e,a+1)),c),Qd(e,n,a,c),o&&vl(Nl(o,Ef(n,r,a+1)),c)),Qd(r,null,a,c),new Ee(c)}function Ef(t,e,n){let r=[];if(Qd(null,t,n,r),t.depth>n){let a=Bg(t,e,n+1);vl(Nl(a,Ef(t,e,n+1)),r)}return Qd(e,null,n,r),new Ee(r)}function C8(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(Ee.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class du{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],a=e.child(n);return r?e.child(n).cut(r):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 r=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;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Tf(this,e,r);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 r=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(r.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new du(n,r,i)}static resolveCached(e,n){let r=nN.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.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()+")"),F2(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,r=Ee.empty,a=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,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 r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let a=Ee.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};Mi.prototype.text=void 0;class Mf extends Mi{constructor(e,n,r,a){if(super(e,n,null,a),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):F2(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 Mf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Mf(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 F2(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new A8(e,n);if(r.next==null)return Pl.empty;let a=B2(r);r.next&&r.err("Unexpected trailing text");let i=_8(D8(a));return z8(i,r),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(r){e.push(r);for(let a=0;a{let i=a+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return i}).join(`
-`)}}Pl.empty=new Pl(!0);class A8{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 B2(t){let e=[];do e.push(I8(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function I8(t){let e=[];do e.push(P8(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function P8(t){let e=O8(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=R8(t,e);else break;return e}function sN(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function R8(t,e){let n=sN(t),r=n;return t.eat(",")&&(t.next!="}"?r=sN(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function L8(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];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 O8(t){if(t.eat("(")){let e=B2(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=L8(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 D8(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function r(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 r(c,u),a(i(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(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[r.join(",")]=new Pl(r.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:U2(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mi(this,this.computeAttrs(e),Ee.from(n),cn.setFrom(r))}createChecked(e=null,n,r){return n=Ee.from(n),this.checkContent(n),new Mi(this,this.computeAttrs(e),n,cn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ee.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(Ee.empty,!0);return i?new Mi(this,e,n.append(i),cn.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new q2(i,n,o));let a=n.spec.topNode||"doc";if(!r[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function $8(t,e,n){let r=n.split("|");return a=>{let i=a===null?"null":typeof a;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class F8{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?$8(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Mp{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=K2(e,a.attrs),this.excluded=null;let i=H2(this.attrs);this.instance=i?new cn(this,i):null}create(e=null){return!e&&this.instance?this.instance:new cn(this,U2(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Mp(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class G2{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=Is.from(e.nodes),n.marks=Is.from(e.marks||{}),this.nodes=aN.compile(this.spec.nodes,this),this.marks=Mp.compile(this.spec.marks,this);let r=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=r[o]||(r[o]=Pl.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?iN(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==""?[]:iN(this,o.split(" "))}this.nodeFromJSON=a=>Mi.fromJSON(this,a),this.markFromJSON=a=>cn.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof aN){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,r,a)}text(e,n){let r=this.nodes.text;return new Mf(r,r.defaultAttrs,e,cn.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 iN(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function B8(t){return t.tag!=null}function V8(t){return t.style!=null}class Mo{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(B8(a))this.tags.push(a);else if(V8(a)){let i=/[^=]*/.exec(a.style)[0];r.indexOf(i)<0&&r.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 r=new lN(this,n,!1);return r.addAll(e,cn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new lN(this,n,!0);return r.addAll(e,cn.none,n.from,n.to),Be.maxOpen(r.finish())}matchTag(e,n,r){for(let a=r?this.tags.indexOf(r)+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 r(a){let i=a.priority==null?50:a.priority,o=0;for(;o{r(o=cN(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=>{r(o=cN(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Mo(e,Mo.schemaRules(e)))}}const J2={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},H8={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Q2={ol:!0,ul:!0},uu=1,Hg=2,Yd=4;function oN(t,e,n){return e!=null?(e?uu:0)|(e==="full"?Hg:0):t&&t.whitespace=="pre"?uu|Hg:n&~Yd}class Vh{constructor(e,n,r,a,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=a,this.options=o,this.content=[],this.activeMarks=cn.none,this.match=i||(o&Yd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ee.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(e.type))?(this.match=r,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&uu)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.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=Ee.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ee.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&&!J2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class lN{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=oN(null,n.preserveWhitespace,0)|(r?Yd:0);a?i=new Vh(a.type,a.attrs,cn.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new Vh(null,null,cn.none,!0,null,o):i=new Vh(e.schema.topNodeType,null,cn.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 r=e.nodeValue,a=this.top,i=a.options&Hg?"full":this.localPreserveWS||(a.options&uu)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
-`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.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,r,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,r,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!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,r),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,a){let i=r||0;for(let o=r?e.childNodes[r]: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,r){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(r)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):dN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Vh(e,n,u,a,null,c)),this.open++,r}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|=uu)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)e+=r[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.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:r&&u>=i?r.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 r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function U8(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Q2.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function W8(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cN(t){let e={};for(let n in t)e[n]=t[n];return e}function dN(t,e){let n=e.schema.nodes;for(let r in n){let a=n[r];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(r),r=i.dom)}return r}serializeMark(e,n,r={}){let a=this.marks[e.type.name];return a&&of(Vx(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return of(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=uN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return uN(e.marks)}}function uN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Vx(t){return t.document||window.document}const hN=new WeakMap;function K8(t){let e=hN.get(t);return e===void 0&&hN.set(t,e=q8(t)),e}function q8(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);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 x=m.indexOf(" ");x>0?u.setAttributeNS(m.slice(0,x),m.slice(x+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:b,contentDOM:v}=of(t,x,n,r);if(u.appendChild(b),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const Y2=65535,X2=Math.pow(2,16);function G8(t,e){return t+e*X2}function fN(t){return t&Y2}function J8(t){return(t-(t&Y2))/X2}const Z2=1,eS=2,lf=4,tS=8;class Ug{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&tS)>0}get deletedBefore(){return(this.delInfo&(Z2|lf))>0}get deletedAfter(){return(this.delInfo&(eS|lf))>0}get deletedAcross(){return(this.delInfo&lf)>0}}class zr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&zr.empty)return zr.empty}recover(e){let n=0,r=fN(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 x=h?e==u?-1:e==m?1:n:n,b=u+a+(x<0?0:f);if(r)return b;let v=e==(n<0?u:m)?null:G8(c/3,e-u),w=e==u?eS:e==m?Z2:lf;return(n<0?e!=u:e!=m)&&(w|=tS),new Ug(b,w,v)}a+=f-h}return r?e+a:new Ug(e+a,0,null)}touches(e,n){let r=0,a=fN(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;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=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?r-a-1:void 0)}}invert(){let e=new hu;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return Xn.fromReplace(e,this.from,this.to,i)}invert(){return new Na(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ko(n.pos,r.pos,this.mark)}merge(e){return e instanceof ko&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ko(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 ko(n.from,n.to,e.markFromJSON(n.mark))}}Gs.jsonID("addMark",ko);class Na extends Gs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Be(ey(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Xn.fromReplace(e,this.from,this.to,r)}invert(){return new ko(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Na(n.pos,r.pos,this.mark)}merge(e){return e instanceof Na&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Na(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 Na(n.from,n.to,e.markFromJSON(n.mark))}}Gs.jsonID("removeMark",Na);class So extends Gs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Xn.fromReplace(e,this.pos,this.pos+1,new Be(Ee.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;ar.pos?null:new vs(n.pos,r.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 vs(n.from,n.to,n.gapFrom,n.gapTo,Be.fromJSON(e,n.slice),n.insert,!!n.structure)}}Gs.jsonID("replaceAround",vs);function Wg(t,e,n){let r=t.resolve(e),a=n-e,i=r.depth;for(;a>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,a--;if(a>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function Q8(t,e,n,r){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let x=Math.max(h,e),b=Math.min(h+u.nodeSize,n),v=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function Y8(t,e,n,r){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof Mp){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new Na(o.from,o.to,o.style)))}function ty(t,e,n,r=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 X8(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function sd(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,a=0,i=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+a,u=t.$to.indexAfter(r)-i;if(rn;v--)w||r.index(v)>0?(w=!0,f=Ee.from(r.node(v).copy(f)),m++):u--;let x=Ee.empty,b=0;for(let v=i,w=!1;v>n;v--)w||a.after(v+1)=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ee.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new vs(a,i,a,i,new Be(r,0,0),n.length,!0))}function sL(t,e,n,r,a){if(!r.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(r,u)&&rL(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!v?h=!1:!b&&v&&(h=!0)}h===!1&&sS(t,o,c,i),ty(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),x=f.map(c+o.nodeSize,1);return t.step(new vs(m,x,m+1,x-1,new Be(Ee.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&nS(t,o,c,i),!1}})}function nS(t,e,n,r){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(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function sS(t,e,n,r){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
-`))}})}function rL(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function aL(t,e,n,r,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(r,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 vs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Be(Ee.from(o),0,0),1,!0))}function Ai(t,e,n=1,r){let a=t.resolve(e),i=a.depth-n,o=r&&r[r.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),x=a.index(h);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(x,m.childCount),v=r&&r[f+1];v&&(b=b.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(b))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function iL(t,e,n=1,r){let a=t.doc.resolve(e),i=Ee.empty,o=Ee.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ee.from(a.node(c).copy(i));let f=r&&r[h];o=Ee.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new bs(e,e,new Be(i.append(o),n,n),!0))}function Vo(t,e){let n=t.resolve(e),r=n.index();return rS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function oL(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let a=0;a0?(i=r.node(a+1),c++,o=r.node(a).maybeChild(c)):(i=r.node(a).maybeChild(c-1),o=r.node(a+1)),i&&!i.isTextblock&&rS(i,o)&&r.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?r.before(a):r.after(a)}}function lL(t,e,n){let r=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?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);sS(t,f.node(),f.before(),c)}o.inlineContent&&ty(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new bs(h,u.map(e+n,-1),Be.empty,!0)),r===!0){let f=t.doc.resolve(h);nS(t,f.node(),f.before(),t.steps.length)}return t}function cL(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let a=r.depth-1;a>=0;a--){let i=r.index(a);if(r.node(a).canReplaceWith(i,i,n))return r.before(a+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let a=r.depth-1;a>=0;a--){let i=r.indexAfter(a);if(r.node(a).canReplaceWith(i,i,n))return r.after(a+1);if(i=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.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?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function Ip(t,e,n=e,r=Be.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return iS(a,i,r)?new bs(e,n,r):new dL(a,i,r).fit()}function iS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dL{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ee.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=Ee.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,r=this.$from,a=this.close(e<0?this.$to:r.doc.resolve(e));if(!a)return null;let i=this.placed,o=r.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new Be(i,o,c);return e>-1?new vs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new bs(r.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,a=this.unplaced.openEnd;r1&&(a=0),i.type.spec.isolating&&a<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let a,i=null;r?(i=Ux(this.unplaced.content,r-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(Ee.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=Ux(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Be(e,n+1,Math.max(r,a.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=Ux(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Be(Bd(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Be(Bd(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w1||u==0||w.content.size)&&(m=N,f.push(oS(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?b:-1)))}let v=h==c.childCount;v||(b=-1),this.placed=Vd(this.placed,n,Ee.from(f)),this.frontier[n].match=m,v&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,N=c;w1&&a==this.$to.end(--r);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=Wx(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=Vd(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let a=e.node(r),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(r));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,r){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=Vd(this.placed,this.depth,Ee.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ee.empty,!0);n.childCount&&(this.placed=Vd(this.placed,this.frontier.length,n))}}function Bd(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Bd(t.firstChild.content,e-1,n)))}function Vd(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Vd(t.lastChild.content,e-1,n)))}function Ux(t,e){for(let n=0;n1&&(r=r.replaceChild(0,oS(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Ee.empty,!0)))),t.copy(r)}function Wx(t,e,n,r,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=r.fillBefore(i.content,!0,o);return c&&!uL(n,i.content,o)?c:null}function uL(t,e,n){for(let r=n;r0;x--,b--){let v=a.node(x).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==b&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,b=0;;b++){let v=x.firstChild;if(h.push(v),b==r.openStart)break;x=v.content}for(let x=f-1;x>=0;x--){let b=h[x],v=hL(b.type);if(v&&!b.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(v||!b.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let b=(x+f+1)%(r.openStart+1),v=h[b];if(v)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let b=o[x];b<0||(e=a.before(b),n=i.after(b))}}function lS(t,e,n,r,a){if(er){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ee.empty,!0))}return t}function pL(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=cL(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Be(Ee.from(r),0,0))}function mL(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=cS(r,a);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),a.indexAfter(c-1))))return t.delete(r.before(c),a.after(c))}for(let o=1;o<=r.depth&&o<=a.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&a.end(o)-n!=a.depth-o&&r.start(o-1)==a.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),a.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function cS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let a=r;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 _c extends Gs{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return Xn.fromReplace(e,this.pos,this.pos+1,new Be(Ee.from(a),0,n.isLeaf?0:1))}getMap(){return zr.empty}invert(e){return new _c(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 _c(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 _c(n.pos,n.attr,n.value)}}Gs.jsonID("attr",_c);class fu extends Gs{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 r=e.type.create(n,e.content,e.marks);return Xn.ok(r)}getMap(){return zr.empty}invert(e){return new fu(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 fu(n.attr,n.value)}}Gs.jsonID("docAttr",fu);let Hc=class extends Error{};Hc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Hc.prototype=Object.create(Error.prototype);Hc.prototype.constructor=Hc;Hc.prototype.name="TransformError";class sy{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new hu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Hc(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 r=0;r{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,r=Be.empty){let a=Ip(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new Be(Ee.from(r),0,0))}delete(e,n){return this.replace(e,n,Be.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return fL(this,e,n,r),this}replaceRangeWith(e,n,r){return pL(this,e,n,r),this}deleteRange(e,n){return mL(this,e,n),this}lift(e,n){return Z8(this,e,n),this}join(e,n=1){return lL(this,e,n),this}wrap(e,n){return nL(this,e,n),this}setBlockType(e,n=e,r,a=null){return sL(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return aL(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new _c(e,n,r)),this}setDocAttribute(e,n){return this.step(new fu(e,n)),this}addNodeMark(e,n){return this.step(new So(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof cn)n.isInSet(r.marks)&&this.step(new Rl(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new Rl(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,r){return iL(this,e,n,r),this}addMark(e,n,r){return Q8(this,e,n,r),this}removeMark(e,n,r){return Y8(this,e,n,r),this}clearIncompatible(e,n,r){return ty(this,e,n,r),this}}const Kx=Object.create(null);class gt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new dS(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?Cc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Cc(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Fr(e.node(0))}static atStart(e){return Cc(e,e,0,0,1)||new Fr(e)}static atEnd(e){return Cc(e,e,e.content.size,e.childCount,-1)||new Fr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kx[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Kx)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kx[e]=n,n.prototype.jsonID=e,n}getBookmark(){return lt.between(this.$anchor,this.$head).getBookmark()}}gt.prototype.visible=!0;class dS{constructor(e,n){this.$from=e,this.$to=n}}let mN=!1;function xN(t){!mN&&!t.parent.inlineContent&&(mN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class lt extends gt{constructor(e,n=e){xN(e),xN(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return gt.near(r);let a=e.resolve(n.map(this.anchor));return new lt(a.parent.inlineContent?a:r,r)}replace(e,n=Be.empty){if(super.replace(e,n),n==Be.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof lt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Pp(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 lt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let a=e.resolve(n);return new this(a,r==n?a:e.resolve(r))}static between(e,n,r){let a=e.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let i=gt.findFrom(n,r,!0)||gt.findFrom(n,-r,!0);if(i)n=i.$head;else return gt.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(gt.findFrom(e,-r,!0)||gt.findFrom(e,r,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&ot.isSelectable(c))return ot.create(t,n-(a<0?c.nodeSize:0))}else{let u=Cc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function gN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(gt.near(t.doc.resolve(o),n))}const yN=1,Hh=2,bN=4;class gL extends sy{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|=Hh,this}ensureMarks(e){return cn.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&Hh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Hh,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||cn.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(gt.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|=bN,this}get scrolledIntoView(){return(this.updated&bN)>0}}function vN(t,e){return!e||!t?t:t.bind(e)}class Hd{constructor(e,n,r){this.name=e,this.init=vN(n.init,r),this.apply=vN(n.apply,r)}}const yL=[new Hd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hd("selection",{init(t,e){return t.selection||gt.atStart(e.doc)},apply(t){return t.selection}}),new Hd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class qx{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yL.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Hd(r.key,r.spec.state,r))})}}class Lc{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[r],i=a.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new qx(e.schema,e.plugins),i=new Lc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Mi.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=gt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[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 uS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=uS(a,e,{})),n[r]=a}return n}class pn{constructor(e){this.spec=e,this.props={},e.props&&uS(e.props,this,this.props),this.key=e.key?e.key.key:hS("plugin")}getState(e){return e[this.key]}}const Gx=Object.create(null);function hS(t){return t in Gx?t+"$"+ ++Gx[t]:(Gx[t]=0,t+"$")}class Cn{constructor(e="key"){this.key=hS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ay=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function fS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const pS=(t,e,n)=>{let r=fS(t,n);if(!r)return!1;let a=iy(r);if(!a){let o=r.blockRange(),c=o&&sd(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(jS(t,a,e,-1))return!0;if(r.parent.content.size==0&&(Uc(i,"end")||ot.isSelectable(i)))for(let o=r.depth;;o--){let c=Ip(t.doc,r.before(o),r.after(o),Be.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==r.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},bL=(t,e,n)=>{let r=fS(t,n);if(!r)return!1;let a=iy(r);return a?mS(t,a,e):!1},vL=(t,e,n)=>{let r=gS(t,n);if(!r)return!1;let a=oy(r);return a?mS(t,a,e):!1};function mS(t,e,n){let r=e.nodeBefore,a=r,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=Ip(t.doc,i,u,Be.empty);if(!h||h.from!=i||h instanceof bs&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(lt.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Uc(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const xS=(t,e,n)=>{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=iy(r)}let o=i&&i.nodeBefore;return!o||!ot.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ot.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function iy(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 gS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=gS(t,n);if(!r)return!1;let a=oy(r);if(!a)return!1;let i=a.nodeAfter;if(jS(t,a,e,1))return!0;if(r.parent.content.size==0&&(Uc(i,"start")||ot.isSelectable(i))){let o=Ip(t.doc,r.before(),r.after(),Be.empty);if(o&&o.slice.size{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof ot,a;if(r){if(n.node.isTextblock||!Vo(t.doc,n.from))return!1;a=n.from}else if(a=Ap(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(ot.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},wL=(t,e)=>{let n=t.selection,r;if(n instanceof ot){if(n.node.isTextblock||!Vo(t.doc,n.to))return!1;r=n.to}else if(r=Ap(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},jL=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&sd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},vS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
-`).scrollIntoView()),!0)};function ly(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=ly(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(gt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},NS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof Fr||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=ly(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.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(Ai(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&sd(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function SL(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof ot&&e.selection.node.isBlock)return!r.parentOffset||!Ai(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),h=r.start(b)==r.pos-(r.depth-b),c=ly(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),o=b;break}else{if(b==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof lt||e.selection instanceof Fr)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=Ai(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=Ai(f.doc,m,i.length,i)),!x)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let b=f.mapping.map(r.before(o)),v=f.doc.resolve(b);c&&r.node(o-1).canReplaceWith(v.index(),v.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const CL=SL(),EL=(t,e)=>{let{$from:n,to:r}=t.selection,a,i=n.sharedDepth(r);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(ot.create(t.doc,a))),!0)};function TL(t,e,n){let r=e.nodeBefore,a=e.nodeAfter,i=e.index();return!r||!a||!r.type.compatibleContent(a.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||Vo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function jS(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&TL(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 b=e.pos+i.nodeSize,v=Ee.empty;for(let k=o.length-1;k>=0;k--)v=Ee.from(o[k].create(null,v));v=Ee.from(a.copy(v));let w=t.tr.step(new vs(e.pos-1,b,e.pos,b,new Be(v,1,0),o.length,!0)),N=w.doc.resolve(b+2*o.length);N.nodeAfter&&N.nodeAfter.type==a.type&&Vo(w.doc,N.pos)&&w.join(N.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:gt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&sd(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&Uc(i,"start",!0)&&Uc(a,"end")){let b=a,v=[];for(;v.push(b),!b.isTextblock;)b=b.lastChild;let w=i,N=1;for(;!w.isTextblock;w=w.firstChild)N++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let k=Ee.empty;for(let C=v.length-1;C>=0;C--)k=Ee.from(v[C].copy(k));let T=t.tr.step(new vs(e.pos-v.length,e.pos+i.nodeSize,e.pos+N,e.pos+i.nodeSize-N,new Be(k,v.length,0),0,!0));n(T.scrollIntoView())}return!0}}return!1}function kS(t){return function(e,n){let r=e.selection,a=t<0?r.$from:r.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(lt.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const ML=kS(-1),AL=kS(1);function IL(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&ny(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function NN(t,e=null){return function(n,r){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(r){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 Tf(u,u,e.depth),e.endIndex=0;f--)i=Ee.from(n[f].type.create(n[f].attrs,i));t.step(new vs(e.start-(r?2:0),e.end,e.start,e.end,new Be(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?DL(e,n,t,i):_L(e,n,i):!0:!1}}function DL(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;v--)b-=a.child(v).nodeSize,r.delete(b-1,b+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.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?Ee.empty:Ee.from(a))))return!1;let m=i.pos,x=m+o.nodeSize;return r.step(new vs(m-(c?1:0),x+(u?1:0),m+1,x-1,new Be((c?Ee.empty:Ee.from(a.copy(Ee.empty))).append(u?Ee.empty:Ee.from(a.copy(Ee.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function zL(t){return function(e,n){let{$from:r,$to:a}=e.selection,i=r.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=Ee.from(h?t.create():null),m=new Be(Ee.from(t.create(null,Ee.from(c.type.create(null,f)))),h?3:1,0),x=i.start,b=i.end;n(e.tr.step(new vs(x-(h?3:1),b,x,b,m,1,!0)).scrollIntoView())}return!0}}const Ps=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Wc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kg=null;const ki=function(t,e,n){let r=Kg||(Kg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},$L=function(){Kg=null},Ll=function(t,e,n,r){return n&&(wN(t,e,n,r,-1)||wN(t,e,n,r,1))},FL=/^(img|br|input|textarea|hr)$/i;function wN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:ta(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Eu(t)||FL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ps(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?ta(t):0}else return!1}}function ta(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function BL(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=ta(t)}else if(t.parentNode&&!Eu(t))e=Ps(t),t=t.parentNode;else return null}}function VL(t,e){for(;;){if(t.nodeType==3&&e2),ea=Kc||(Wa?/Mac/.test(Wa.platform):!1),ES=Wa?/Win/.test(Wa.platform):!1,Ti=/Android \d/.test(Ho),Tu=!!jN&&"webkitFontSmoothing"in jN.documentElement.style,KL=Tu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function qL(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 bi(t,e){return typeof t=="number"?t:t[e]}function GL(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function kN(t,e,n){let r=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=Wc(o);continue}let c=o,u=c==i.body,h=u?qL(i):GL(c),f=0,m=0;if(e.toph.bottom-bi(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+bi(a,"top")-h.top:e.bottom-h.bottom+bi(a,"bottom")),e.lefth.right-bi(r,"right")&&(f=e.right-h.right+bi(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let b=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-b,N=c.scrollTop-v;e={left:e.left-w,top:e.top-N,right:e.right-w,bottom:e.bottom-N}}let x=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(x))break;o=x=="absolute"?o.offsetParent:Wc(o)}}function JL(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){r=c,a=u.top;break}}return{refDOM:r,refTop:a,stack:TS(t.dom)}}function TS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Wc(r));return e}function QL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;MS(n,r==0?0:r-e)}function MS(t,e){for(let n=0;n=c){o=Math.max(v.bottom,o),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=f,h={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?XL(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:AS(n,a)}function XL(t,e){let n=t.nodeValue.length,r=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return r.detach(),a||{node:t,offset:0}}function dy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ZL(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(r,a,i)}function t6(t,e,n,r){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>r.left||u.top>r.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function IS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Tu&&a&&r.nodeType==1&&(h=r.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,r==t.dom&&a==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||r.nodeType!=1||r.childNodes[a-1].nodeName!="BR")&&(c=t6(t,r,a,e))}c==null&&(c=e6(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function SN(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,_d(po(ki(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==ta(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return Jx(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==ta(r))){let u=r.childNodes[a-1],h=u.nodeType==3?ki(u,ta(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return _d(po(h,1),!1)}if(i==null&&a=0)}function _d(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 Jx(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 RS(t,e,n){let r=t.state,a=t.root.activeElement;r!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),a!=t.dom&&a&&a.focus()}}function r6(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return RS(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=PS(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=ki(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 a6=/[\u0590-\u08ac]/;function i6(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let a=r.parentOffset,i=!a,o=a==r.parent.content.size,c=t.domSelection();return c?!a6.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:RS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),x=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:w}=t.domSelectionRange(),N=v&&!b.contains(v.nodeType==1?v:v.parentNode)||u==v&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return x!=null&&(c.caretBidiLevel=x),N}):r.pos==r.start()||r.pos==r.end()}let CN=null,EN=null,TN=!1;function o6(t,e,n){return CN==e&&EN==n?TN:(CN=e,EN=n,TN=n=="up"||n=="down"?r6(t,e,n):i6(t,e,n))}const sa=0,MN=1,xl=2,Ka=3;class Mu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=sa,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nPs(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??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof OS){a=e-i;break}i=c}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof LS&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Ps(i.dom)+1:0}}else{let i,o=!0;for(;i=r=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 x=this.children[m-1];if(x.size&&x.dom.parentNode==this.contentDOM&&!x.emptyChildAt(1)){a=Ps(x.dom)+1;break}e-=x.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fv&&on){let v=c;c=u,u=v}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(b)}}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 r=0,a=0;a=r:er){let c=r+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?xl:MN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ka:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?xl:Ka}r=o}this.dirty=xl}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xl:MN;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==sa&&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 l6 extends Mu{constructor(e,n,r,a){super(e,[],n,null),this.textDOM=r,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 Ol extends Mu{constructor(e,n,r,a,i){super(e,[],r,a),this.mark=n,this.spec=i}static create(e,n,r,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,r);return(!o||!o.dom)&&(o=Vl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ol(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ka||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ka&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=sa){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Yg(i,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,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}=Vl.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 x=f;return f=zS(f,r,n),h?u=new c6(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new Lp(e,n,r,a,f,x,i):new Io(e,n,r,a,f,m||null,x,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 r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ee.empty)}return e}matchesNode(e,n,r){return this.dirty==sa&&e.eq(this.node)&&Af(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=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 u6(this,o&&o.node,e);p6(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,r,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?cn.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,x)=>{u.syncToMarks(h.marks,r,e,x);let b;u.findNodeMatch(h,f,m,x)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,b,e)||u.updateNextNode(h,f,m,e,x,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==xl)&&(o&&this.protectLocalComposition(e,o),DS(this.contentDOM,this.children,e),Kc&&m6(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof lt)||rn+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=x6(this.node.content,o,r-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:r,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 l6(this,i,n,a);e.input.compositionNodes.push(o),this.children=Yg(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==Ka||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,a),!0)}updateInner(e,n,r,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=sa}updateOuterDeco(e){if(Af(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=_S(this.dom,this.nodeDOM,Qg(this.outerDeco,this.node,n),Qg(e,this.node,n)),this.dom!=r&&(r.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 AN(t,e,n,r,a){zS(r,e,t);let i=new Io(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Lp extends Io{constructor(e,n,r,a,i,o,c){super(e,n,r,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,r,a){return this.dirty==Ka||this.dirty!=sa&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=sa||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=sa,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Lp(this.parent,a,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ka)}get domAtom(){return!1}isText(e){return this.node.text==e}}class OS extends Mu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==sa&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class c6 extends Io{constructor(e,n,r,a,i,o,c,u,h,f){super(e,n,r,a,i,o,c,h,f),this.spec=u}update(e,n,r,a){if(this.dirty==Ka)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,a){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,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 DS(t,e,n){let r=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=Ol.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,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,r))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(r){let h=n.children[r-1];if(h instanceof Ol)n=h,r=h.children.length;else{c=h,r--;break}}else{if(n==e)break e;r=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 f6(t,e){return t.type.side-e.type.side}function p6(t,e,n,r){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let v=i+x.nodeSize;if(x.isText){let N=v;o!N.inline):c.slice();r(x,w,e.forChild(i,x),b),i=v}}function m6(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 x6(t,e,n,r){for(let a=0,i=0;a=n){if(i>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Yg(t,e,n,r,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,r)))}return i}function uy(t,e=null){let n=t.domSelectionRange(),r=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=r.resolve(o),u,h;if(Rp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&ot.isSelectable(m)&&a.parent&&!(m.isInline&&HL(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new ot(o==x?c:r.resolve(x))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,x=o;for(let b=0;b{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!$S(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function y6(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ps(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&jr&&Ao<=11&&(n.disabled=!0,n.disabled=!1)}function FS(t,e){if(e instanceof ot){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ON(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ON(t)}function ON(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function hy(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||lt.between(e,n,r)}function DN(t){return t.editable&&!t.hasFocus()?!1:BS(t)}function BS(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 b6(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ll(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Xg(t,e){let{$anchor:n,$head:r}=t.selection,a=e>0?n.max(r):n.min(r),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&>.findFrom(i,e)}function mo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function _N(t,e,n){let r=t.state.selection;if(r instanceof lt)if(n.indexOf("s")>-1){let{$head:a}=r,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 mo(t,new lt(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=Xg(t.state,e);return a&&a instanceof ot?mo(t,a):!1}else if(!(ea&&n.indexOf("m")>-1)){let a=r.$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?ot.isSelectable(i)?mo(t,new ot(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Tu?mo(t,new lt(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ot&&r.node.isInline)return mo(t,new lt(e>0?r.$to:r.$from));{let a=Xg(t.state,e);return a?mo(t,a):!1}}}function If(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Zd(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function kc(t,e){return e<0?v6(t):N6(t)}function v6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(na&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Zd(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(VS(n))break;{let c=n.previousSibling;for(;c&&Zd(c,-1);)a=n.parentNode,i=Ps(c),c=c.previousSibling;if(c)n=c,r=If(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Zg(t,n,r):a&&Zg(t,a,i)}function N6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=If(n),i,o;for(;;)if(r{t.state==a&&Ii(t)},50)}function zN(t,e){let n=t.state.doc.resolve(e);if(!(_s||ES)&&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 $N(t,e,n){let r=t.state.selection;if(r instanceof lt&&!r.empty||n.indexOf("s")>-1||ea&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Xg(t.state,e);if(o&&o instanceof ot)return mo(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof Fr?gt.near(o,e):gt.findFrom(o,e);return c?mo(t,c):!1}return!1}function FN(t,e){if(!(t.state.selection instanceof lt))return!0;let{$head:n,$anchor:r,empty:a}=t.state.selection;if(!n.sameParent(r))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 BN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function k6(t){if(!Ks||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 r=e.firstChild;BN(t,r,"true"),setTimeout(()=>BN(t,r,"false"),20)}return!1}function S6(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function C6(t,e){let n=e.keyCode,r=S6(e);if(n==8||ea&&n==72&&r=="c")return FN(t,-1)||kc(t,-1);if(n==46&&!e.shiftKey||ea&&n==68&&r=="c")return FN(t,1)||kc(t,1);if(n==13||n==27)return!0;if(n==37||ea&&n==66&&r=="c"){let a=n==37?zN(t,t.state.selection.from)=="ltr"?-1:1:-1;return _N(t,a,r)||kc(t,a)}else if(n==39||ea&&n==70&&r=="c"){let a=n==39?zN(t,t.state.selection.from)=="ltr"?1:-1:1;return _N(t,a,r)||kc(t,a)}else{if(n==38||ea&&n==80&&r=="c")return $N(t,-1,r)||kc(t,-1);if(n==40||ea&&n==78&&r=="c")return k6(t)||$N(t,1,r)||kc(t,1);if(r==(ea?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function fy(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,i--;let b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||Vl.fromSchema(t.state.schema),c=GS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=qS[h.nodeName.toLowerCase()]);){for(let b=f.length-1;b>=0;b--){let v=c.createElement(f[b]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let x=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
-
-`);return{dom:u,text:x,slice:e}}function HS(t,e,n,r,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",x=>{e=x(e,i||r,t)}),i)return c=new Be(Ee.from(t.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0),t.someProp("transformPasted",x=>{c=x(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",x=>x(e,a,r,t));if(m)c=m;else{let x=a.marks(),{schema:b}=t.state,v=Vl.fromSchema(b);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let N=o.appendChild(document.createElement("p"));w&&N.appendChild(v.serializeNode(b.text(w,x)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=A6(n),Tu&&I6(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let x=o.firstChild;for(;x&&x.nodeType!=1;)x=x.nextSibling;if(!x)break;o=x}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Mo.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!E6.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=P6(VN(c,+f[1],+f[2]),f[4]);else if(c=Be.maxOpen(T6(c.content,a),!0),c.openStart||c.openEnd){let m=0,x=0;for(let b=c.content.firstChild;m{c=m(c,t,u)}),c}const E6=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function T6(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let a=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(c=>{if(!o)return;let u=a.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&i.length&&WS(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=KS(o[o.length-1],i.length));let f=US(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ee.from(o)}return t}function US(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ee.from(t));return t}function WS(t,e,n,r,a){if(a1&&(i=0),a=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=a).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(Ee.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function VN(t,e,n){return en})),Yx.createHTML(t)):t}function A6(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=GS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&qS[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>""+i+">").reverse().join("")),n.innerHTML=M6(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Ee.from(u.create(r[c+1],a)),i++,o++}return new Be(a,i,o)}const ar={},ir={},R6={touchstart:!0,touchmove:!0};class L6{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function O6(t){for(let e in ar){let n=ar[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{_6(t,r)&&!py(t,r)&&(t.editable||!(r.type in ir))&&n(t,r)},R6[e]?{passive:!0}:void 0)}Ks&&t.dom.addEventListener("input",()=>null),t0(t)}function Co(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function D6(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function t0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>py(t,r))})}function py(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function _6(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function z6(t,e){!py(t,e)&&ar[e.type]&&(t.editable||!(e.type in ir))&&ar[e.type](t,e)}ir.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!QS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ti&&_s&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Kc&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",a=>a(t,hl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||C6(t,n)?n.preventDefault():Co(t,"key")};ir.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ir.keypress=(t,e)=>{let n=e;if(QS(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ea&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof lt)||!r.$from.sameParent(r.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function Op(t){return{left:t.clientX,top:t.clientY}}function $6(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function my(t,e,n,r,a){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),a,!0):c(t,n,i.node(o),i.before(o),a,!1)))return!0;return!1}function zc(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function F6(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ot.isSelectable(r)?(zc(t,new ot(n)),!0):!1}function B6(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof ot&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(ot.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?a=i.before(n.$from.depth):a=i.before(o);break}}return a!=null?(zc(t,ot.create(t.state.doc,a)),!0):!1}function V6(t,e,n,r,a){return my(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?B6(t,n):F6(t,n))}function H6(t,e,n,r){return my(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function U6(t,e,n,r){return my(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||W6(t,n,r)}function W6(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(zc(t,lt.create(r,0,r.content.size)),!0):!1;let a=r.resolve(e);for(let i=a.depth+1;i>0;i--){let o=i>a.depth?a.nodeAfter:a.node(i),c=a.before(i);if(o.inlineContent)zc(t,lt.create(r,c+1,c+1+o.content.size));else if(ot.isSelectable(o))zc(t,ot.create(r,c));else continue;return!0}}function xy(t){return Pf(t)}const JS=ea?"metaKey":"ctrlKey";ar.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=xy(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&$6(n,t.input.lastClick)&&!n[JS]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:a,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(Op(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new K6(t,o,n,!!r)):(i=="doubleClick"?H6:U6)(t,o.pos,o.inside,n)?n.preventDefault():Co(t,"pointer"))};class K6{constructor(e,n,r,a){this.view=e,this.pos=n,this.event=r,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[JS],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}const c=a?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof ot&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&na&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Co(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ii(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Op(e))),this.updateAllowDefault(e),this.allowDefault||!n?Co(this.view,"pointer"):V6(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ks&&this.mightDrag&&!this.mightDrag.node.isAtom||_s&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(zc(this.view,gt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Co(this.view,"pointer")}move(e){this.updateAllowDefault(e),Co(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ar.touchstart=t=>{t.input.lastTouch=Date.now(),xy(t),Co(t,"pointer")};ar.touchmove=t=>{t.input.lastTouch=Date.now(),Co(t,"pointer")};ar.contextmenu=t=>xy(t);function QS(t,e){return t.composing?!0:Ks&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const q6=Ti?5e3:-1;ir.compositionstart=ir.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof lt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||_s&&ES&&G6(t)))t.markCursor=t.state.storedMarks||n.marks(),Pf(t,!0),t.markCursor=null;else if(Pf(t,!e.selection.empty),na&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let a=r.focusNode,i=r.focusOffset;a&&a.nodeType==1&&i!=0;){let o=i<0?a.lastChild:a.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else a=o,i=-1}}t.input.composing=!0}YS(t,q6)};function G6(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}ir.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,YS(t,20))};function YS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Pf(t),e))}function XS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Q6());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function J6(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=BL(e.focusNode,e.focusOffset),r=VL(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let a=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!a||!a.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Q6(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Pf(t,e=!1){if(!(Ti&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),XS(t),e||t.docView&&t.docView.dirty){let n=uy(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Y6(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const pu=jr&&Ao<15||Kc&&KL<604;ar.copy=ir.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=pu?null:n.clipboardData,o=r.content(),{dom:c,text:u}=fy(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):Y6(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function X6(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Z6(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?mu(t,r.value,null,a,e):mu(t,r.textContent,r.innerHTML,a,e)},50)}function mu(t,e,n,r,a){let i=HS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Be.empty)))return!0;if(!i)return!1;let o=X6(i),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ZS(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ir.paste=(t,e)=>{let n=e;if(t.composing&&!Ti)return;let r=pu?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&mu(t,ZS(r),r.getData("text/html"),a,n)?n.preventDefault():Z6(t,n)};class eC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const eO=ea?"altKey":"ctrlKey";function tC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[eO]}ar.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(Op(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof ot?a.to-1:a.to))){if(r&&r.mightDrag)o=ot.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=ot.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=fy(t,c);(!n.dataTransfer.files.length||!_s||CS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(pu?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",pu||n.dataTransfer.setData("text/plain",h),t.dragging=new eC(f,tC(t,n),o)};ar.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ir.dragover=ir.dragenter=(t,e)=>e.preventDefault();ir.drop=(t,e)=>{try{tO(t,e,t.dragging)}finally{t.dragging=null}};function tO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Op(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=HS(t,ZS(e.dataTransfer),pu?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&tC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Be.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?aS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let x=u.doc.resolve(h);if(f&&ot.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new ot(x));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,N,k)=>b=k),u.setSelection(hy(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}ar.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ii(t)},20))};ar.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ar.beforeinput=(t,e)=>{if(_s&&Ti&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,hl(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in ir)ar[t]=ir[t];function xu(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Rf{constructor(e,n){this.toDOM=e,this.spec=n||wl,this.side=this.spec.side||0}map(e,n,r,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new as(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Rf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&xu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Po{constructor(e,n){this.attrs=e,this.spec=n||wl}map(e,n,r,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new as(i,o,this)}valid(e,n){return n.from=e&&(!i||i(c.spec))&&r.push(c.copy(c.from+a,c.to+a))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,a+c,i)}}map(e,n,r){return this==Us||e.maps.length==0?this:this.mapInner(e,n,0,0,r||wl)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=sC(n,c,h)){for(a||(a=this.children.slice());ic&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;ci&&u.type instanceof Po){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,wl));return yo.from(r)}forChild(e,n){if(n.isLeaf)return ln.empty;let r=[];for(let a=0;an instanceof ln)?e:e.reduce((n,r)=>n.concat(r instanceof ln?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let N=w-v-(b-x);for(let k=0;kT+f-m)continue;let C=c[k]+f-m;b>=C?c[k+1]=x<=C?-2:-1:x>=f&&N&&(c[k]+=N,c[k+1]+=N)}m+=N}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let x=n.map(t[h+1]+i,-1),b=x-a,{index:v,offset:w}=r.content.findIndex(m),N=r.maybeChild(v);if(N&&w==m&&w+N.nodeSize==b){let k=c[h+2].mapInner(n,N,f+1,t[h]+i+1,o);k!=Us?(c[h]=m,c[h+1]=b,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=sO(c,t,e,n,a,i,o),f=Lf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=sC(t,c,u+n);if(h){i=!0;let f=Lf(h,c,n+u+1,r);f!=Us&&a.push(u,u+c.nodeSize,f)}});let o=nC(i?rC(t):t,-n).sort(jl);for(let c=0;c0;)e++;t.splice(e,0,n)}function Xx(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Us&&e.push(r)}),t.cursorWrapper&&e.push(ln.create(t.state.doc,[t.cursorWrapper.deco])),yo.from(e)}const rO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},aO=jr&&Ao<=11;class iO{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class oO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new iO,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():Ks&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),aO&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,rO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(DN(this.view)){if(this.suppressingSelectionUpdates)return Ii(this.view);if(jr&&Ao<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ll(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Wc(i))n.add(i);for(let i=e.anchorNode;i;i=Wc(i))if(n.has(i)){r=i;break}let a=r&&this.view.docView.nearestDesc(r);if(a&&a.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&DN(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;ff.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let m=f.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&f.parentNode.removeChild(f)}}else if(na&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,x]=f;m.parentNode&&m.parentNode.parentNode==x.parentNode?x.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let x of f){let b=x.parentNode;b&&b.nodeName=="LI"&&(!m||dO(e,m)!=b)&&x.remove()}}}let h=null;i<0&&a&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||a)&&(i>-1&&(e.docView.markDirty(i,o),lO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,uO(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ii(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fa;N--){let k=r.childNodes[N-1],T=k.pmViewDesc;if(k.nodeName=="BR"&&!T){i=N;break}if(!T||T.size)break}let m=t.state.doc,x=t.someProp("domParser")||Mo.fromSchema(t.state.schema),b=m.resolve(o),v=null,w=x.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:i,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:fO,context:b});if(h&&h[0].pos!=null){let N=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=N),v={anchor:N+o,head:k+o}}return{doc:w,sel:v,from:o,to:c}}function fO(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ks&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Ks&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const pO=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function mO(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let z=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,H=uy(t,z);if(H&&!t.state.selection.eq(H)){if(_s&&Ti&&t.input.lastKeyCode===13&&Date.now()-100se(t,hl(13,"Enter"))))return;let R=t.state.tr.setSelection(H);z=="pointer"?R.setMeta("pointer",!0):z=="key"&&R.scrollIntoView(),i&&R.setMeta("composition",i),t.dispatch(R)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=hO(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),x,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Ti)&&a.some(z=>z.nodeType==1&&!pO.test(z.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",z=>z(t,hl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof lt&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let z=GN(t,t.state.doc,h.sel);if(z&&!z.eq(t.state.selection)){let H=t.state.tr.setSelection(z);i&&H.setMeta("composition",i),t.dispatch(H)}}return}t.state.selection.fromt.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?v.start=t.state.selection.from:v.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),jr&&Ao<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>h.from&&h.doc.textBetween(v.start-h.from-1,v.start-h.from+1)==" "&&(v.start--,v.endA--,v.endB--);let w=h.doc.resolveNoCache(v.start-h.from),N=h.doc.resolveNoCache(v.endB-h.from),k=f.resolve(v.start),T=w.sameParent(N)&&w.parent.inlineContent&&k.end()>=v.endA;if((Kc&&t.input.lastIOSEnter>Date.now()-225&&(!T||a.some(z=>z.nodeName=="DIV"||z.nodeName=="P"))||!T&&w.posz(t,hl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&gO(f,v.start,v.endA,w,N)&&t.someProp("handleKeyDown",z=>z(t,hl(8,"Backspace")))){Ti&&_s&&t.domObserver.suppressSelectionUpdates();return}_s&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),Ti&&!T&&w.start()!=N.start()&&N.parentOffset==0&&w.depth==N.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,N=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(z){return z(t,hl(13,"Enter"))})},20));let C=v.start,P=v.endA,L=z=>{let H=z||t.state.tr.replace(C,P,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let R=GN(t,H.doc,h.sel);R&&!(_s&&t.composing&&R.empty&&(v.start!=v.endB||t.input.lastChromeDeleteIi(t),20));let z=L(t.state.tr.delete(C,P)),H=f.resolve(v.start).marksAcross(f.resolve(v.endA));H&&z.ensureMarks(H),t.dispatch(z)}else if(v.endA==v.endB&&(q=xO(w.parent.content.cut(w.parentOffset,N.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start())))){let z=L(t.state.tr);q.type=="add"?z.addMark(C,P,q.mark):z.removeMark(C,P,q.mark),t.dispatch(z)}else if(w.parent.child(w.index()).isText&&w.index()==N.index()-(N.textOffset?0:1)){let z=w.parent.textBetween(w.parentOffset,N.parentOffset),H=()=>L(t.state.tr.insertText(z,C,P));t.someProp("handleTextInput",R=>R(t,C,P,z,H))||t.dispatch(H())}else t.dispatch(L());else t.dispatch(L())}function GN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:hy(t,e.resolve(n.anchor),e.resolve(n.head))}function xO(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,a=n,i=r,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(a.length==0&&i.length==1)c=i[0],o="remove",u=f=>f.mark(c.removeFromSet(f.marks));else return null;let h=[];for(let f=0;fn||Zx(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,a++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,a++}return a}function yO(t,e,n,r,a){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(a=="end"){let u=Math.max(0,i-Math.min(o,c));r-=o+u-i}if(o=o?i-r:0;i-=u,i&&i=c?i-r:0;i-=u,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}class aC{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new L6,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(ew),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=XN(this),YN(this),this.nodeViews=ZN(this),this.docView=AN(this.state.doc,QN(this),Xx(this),this.dom,this),this.domObserver=new oO(this,(r,a,i,o)=>mO(this,r,a,i,o)),this.domObserver.start(),O6(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&t0(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ew),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let a=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(XS(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=ZN(this);vO(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&t0(this),this.editable=XN(this),YN(this);let u=Xx(this),h=QN(this),f=a.plugins!=e.plugins&&!a.doc.eq(e.doc)?"reset":e.scrollToSelection>a.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(a.selection))&&(o=!0);let x=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&JL(this);if(o){this.domObserver.stop();let b=m&&(jr||_s)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&bO(a.selection,e.selection);if(m){let v=_s?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=J6(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=AN(e.doc,h,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&b6(this))?Ii(this,b):(FS(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((r=this.dragging)===null||r===void 0)&&r.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():x&&QL(x)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ot){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&kN(this,n.getBoundingClientRect(),e)}else kN(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(i))==r.node&&(a=i)}this.dragging=new eC(e.slice,e.move,a<0?void 0:ot.create(this.state.doc,a))}someProp(e,n){let r=this._props&&this._props[e],a;if(r!=null&&(a=n?n(r):r))return a;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return n6(this,e)}coordsAtPos(e,n=1){return PS(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let a=this.docView.posFromDOM(e,n,r);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(e,n){return o6(this,n||this.state,e)}pasteHTML(e,n){return mu(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return mu(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return fy(this,e)}destroy(){this.docView&&(D6(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xx(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$L())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return z6(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ks&&this.root.nodeType===11&&UL(this.dom.ownerDocument)==this.dom&&cO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}aC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function QN(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[as.node(0,t.state.doc.content.size,e)]}function YN(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:as.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function XN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function bO(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ZN(t){let e=Object.create(null);function n(r){for(let a in r)Object.prototype.hasOwnProperty.call(e,a)||(e[a]=r[a])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function vO(t,e){let n=0,r=0;for(let a in t){if(t[a]!=e[a])return!0;n++}for(let a in e)r++;return n!=r}function ew(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Oo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Of={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},NO=typeof navigator<"u"&&/Mac/.test(navigator.platform),wO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Rs=0;Rs<10;Rs++)Oo[48+Rs]=Oo[96+Rs]=String(Rs);for(var Rs=1;Rs<=24;Rs++)Oo[Rs+111]="F"+Rs;for(var Rs=65;Rs<=90;Rs++)Oo[Rs]=String.fromCharCode(Rs+32),Of[Rs]=String.fromCharCode(Rs);for(var eg in Oo)Of.hasOwnProperty(eg)||(Of[eg]=Oo[eg]);function jO(t){var e=NO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||wO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Of:Oo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const kO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),SO=typeof navigator<"u"&&/Win/.test(navigator.platform);function CO(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,a,i,o;for(let c=0;c{for(var n in e)MO(t,n,{get:e[n],enumerable:!0})};function Dp(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:a}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return a},get tr(){return r=n.selection,a=n.doc,i=n.storedMarks,n}}}var _p=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:a}=n,i=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(i);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:a}=this,{view:i}=r,o=[],c=!!t,u=t||a.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,x])=>[m,(...v)=>{const w=this.buildProps(u,e),N=x(...v)(w);return o.push(N),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,a=t||n.tr,i=this.buildProps(a,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...i,dispatch:void 0})])),chain:()=>this.createChain(a,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:a}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:Dp({state:a,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...h)=>u(...h)(o)]))}};return o}},iC={};vy(iC,{blur:()=>AO,clearContent:()=>IO,clearNodes:()=>PO,command:()=>RO,createParagraphNear:()=>LO,cut:()=>OO,deleteCurrentNode:()=>DO,deleteNode:()=>_O,deleteRange:()=>zO,deleteSelection:()=>$O,enter:()=>FO,exitCode:()=>BO,extendMarkRange:()=>VO,first:()=>HO,focus:()=>WO,forEach:()=>KO,insertContent:()=>qO,insertContentAt:()=>QO,joinBackward:()=>ZO,joinDown:()=>XO,joinForward:()=>eD,joinItemBackward:()=>tD,joinItemForward:()=>nD,joinTextblockBackward:()=>sD,joinTextblockForward:()=>rD,joinUp:()=>YO,keyboardShortcut:()=>iD,lift:()=>oD,liftEmptyBlock:()=>lD,liftListItem:()=>cD,newlineInCode:()=>dD,resetAttributes:()=>uD,scrollIntoView:()=>hD,selectAll:()=>fD,selectNodeBackward:()=>pD,selectNodeForward:()=>mD,selectParentNode:()=>xD,selectTextblockEnd:()=>gD,selectTextblockStart:()=>yD,setContent:()=>bD,setMark:()=>$D,setMeta:()=>FD,setNode:()=>BD,setNodeSelection:()=>VD,setTextDirection:()=>HD,setTextSelection:()=>UD,sinkListItem:()=>WD,splitBlock:()=>KD,splitListItem:()=>qD,toggleList:()=>GD,toggleMark:()=>JD,toggleNode:()=>QD,toggleWrap:()=>YD,undoInputRule:()=>XD,unsetAllMarks:()=>ZD,unsetMark:()=>e_,unsetTextDirection:()=>t_,updateAttributes:()=>n_,wrapIn:()=>s_,wrapInList:()=>r_});var AO=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),IO=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),PO=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:a}=r;return n&&a.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),x=h.resolve(f.map(u+c.nodeSize)),b=m.blockRange(x);if(!b)return;const v=sd(b);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,w)}(v||v===0)&&e.lift(b,v)})}),!0},RO=t=>e=>t(e),LO=()=>({state:t,dispatch:e})=>NS(t,e),OO=(t,e)=>({editor:n,tr:r})=>{const{state:a}=n,i=a.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new lt(r.doc.resolve(Math.max(o-1,0)))),!0},DO=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const a=t.selection.$anchor;for(let i=a.depth;i>0;i-=1)if(a.node(i).type===r.type){if(e){const c=a.before(i),u=a.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function Zn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var _O=t=>({tr:e,state:n,dispatch:r})=>{const a=Zn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===a){if(r){const u=i.before(o),h=i.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},zO=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},$O=()=>({state:t,dispatch:e})=>ay(t,e),FO=()=>({commands:t})=>t.keyboardShortcut("Enter"),BO=()=>({state:t,dispatch:e})=>kL(t,e);function Ny(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Df(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:Ny(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function oC(t,e,n={}){return t.find(r=>r.type===e&&Df(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function tw(t,e,n={}){return!!oC(t,e,n)}function wy(t,e,n){var r;if(!t||!e)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===e))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===e)||(n=n||((r=a.node.marks[0])==null?void 0:r.attrs),!oC([...a.node.marks],e,n)))return;let o=a.index,c=t.start()+a.offset,u=o+1,h=c+a.node.nodeSize;for(;o>0&&tw([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:r,dispatch:a})=>{const i=_i(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=wy(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=lt.create(o,m.from,m.to);n.setSelection(x)}}return!0},HO=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:a,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(_f()||nw())&&r.dom.focus(),UO()&&!_f()&&!nw()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!lC(n.state.selection))return o(),!0;const c=cC(a.doc,t)||n.state.selection,u=n.state.selection.eq(c);return i&&(u||a.setSelection(c),u&&a.storedMarks&&a.setStoredMarks(a.storedMarks),o()),!0},KO=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),qO=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),dC=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&dC(r)}return t};function Uh(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return dC(n)}function gu(t,e,n){if(t instanceof Mi||t instanceof Ee)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,a=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return Ee.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),gu("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new G2({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:h=>(o=!0,c=typeof h=="string"?h:h.outerHTML,null)}]}})});if(n.slice?Mo.fromSchema(u).parseSlice(Uh(t),n.parseOptions):Mo.fromSchema(u).parse(Uh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Mo.fromSchema(e);return n.slice?i.parseSlice(Uh(t),n.parseOptions).content:i.parse(Uh(t),n.parseOptions)}return gu("",e,n)}function GO(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(gt.near(t.doc.resolve(o),n))}var JO=t=>!("type"in t),QO=(t,e,n)=>({tr:r,dispatch:a,editor:i})=>{var o;if(a){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=N=>{i.emit("contentError",{editor:i,error:N,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{gu(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(N){u(N)}try{c=gu(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(N){return u(N),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},x=!0,b=!0;if((JO(c)?c:[c]).forEach(N=>{N.check(),x=x?N.isText&&N.marks.length===0:!1,b=b?N.isBlock:!1}),f===m&&b){const{parent:N}=r.doc.resolve(f);N.isTextblock&&!N.type.spec.code&&!N.childCount&&(f-=1,m+=1)}let w;if(x){if(Array.isArray(e))w=e.map(N=>N.text||"").join("");else if(e instanceof Ee){let N="";e.forEach(k=>{k.text&&(N+=k.text)}),w=N}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const N=r.doc.resolve(f),k=N.node(),T=N.parentOffset===0,C=k.isText||k.isTextblock,P=k.content.size>0;T&&C&&P&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&GO(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:f,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:f,text:w})}return!0},YO=()=>({state:t,dispatch:e})=>NL(t,e),XO=()=>({state:t,dispatch:e})=>wL(t,e),ZO=()=>({state:t,dispatch:e})=>pS(t,e),eD=()=>({state:t,dispatch:e})=>yS(t,e),tD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ap(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ap(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},sD=()=>({state:t,dispatch:e})=>bL(t,e),rD=()=>({state:t,dispatch:e})=>vL(t,e);function uC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function aD(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,a,i,o;for(let c=0;c({editor:e,view:n,tr:r,dispatch:a})=>{const i=aD(t).split(/-(?!$)/),o=i.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",h=>h(n,c))});return u==null||u.steps.forEach(h=>{const f=h.map(r.mapping);f&&a&&r.maybeStep(f)}),!0};function Do(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Zn(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,x)=>{if(m.isText)return;const b=Math.max(r,x),v=Math.min(a,x+m.nodeSize);c.push({node:m,from:b,to:v})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Df(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var oD=(t,e={})=>({state:n,dispatch:r})=>{const a=Zn(t,n.schema);return Do(n,a,e)?jL(n,r):!1},lD=()=>({state:t,dispatch:e})=>wS(t,e),cD=t=>({state:e,dispatch:n})=>{const r=Zn(t,e.schema);return OL(r)(e,n)},dD=()=>({state:t,dispatch:e})=>vS(t,e);function zp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function sw(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,a)=>(n.includes(a)||(r[a]=t[a]),r),{})}var uD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=zp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Zn(t,r.schema)),c==="mark"&&(o=_i(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{r.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{i&&i===f.type&&(u=!0,a&&n.setNodeMarkup(m,void 0,sw(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(x=>{o===x.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(sw(x.attrs,e))))})})}),u},hD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fD=()=>({tr:t,dispatch:e})=>{if(e){const n=new Fr(t.doc);t.setSelection(n)}return!0},pD=()=>({state:t,dispatch:e})=>xS(t,e),mD=()=>({state:t,dispatch:e})=>bS(t,e),xD=()=>({state:t,dispatch:e})=>EL(t,e),gD=()=>({state:t,dispatch:e})=>AL(t,e),yD=()=>({state:t,dispatch:e})=>ML(t,e);function n0(t,e,n={},r={}){return gu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var bD=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const h=n0(t,a.schema,r,{errorOnInvalidContent:e??a.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??a.options.enableContentCheck})};function hC(t,e){const n=_i(e,t.schema),{from:r,to:a,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,a,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function fC(t,e){const n=new sy(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function vD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function pC(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function $p(t){return e=>pC(e.$from,t)}function at(t,e,n){return t.config[e]===void 0&&t.parent?at(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?at(t.parent,e,n):null}):t.config[e]}function jy(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=at(e,"addExtensions",n);return r?[e,...jy(r())]:e}).flat(10)}function ky(t,e){const n=Vl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function mC(t){return typeof t=="function"}function Yt(t,e=void 0,...n){return mC(t)?e?t.bind(e)(...n):t(...n):t}function wD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function qc(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),r=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function xC(t){const e=[],{nodeExtensions:n,markExtensions:r}=qc(t),a=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(h=>h.name!=="text").map(h=>h.name),c=r.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:a},m=at(h,"addGlobalAttributes",f);if(!m)return;m().forEach(b=>{let v;Array.isArray(b.types)?v=b.types:b.types==="*"?v=u:b.types==="nodes"?v=o:b.types==="marks"?v=c:v=[],v.forEach(w=>{Object.entries(b.attributes).forEach(([N,k])=>{e.push({type:w,name:N,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=at(h,"addAttributes",f);if(!m)return;const x=m();Object.entries(x).forEach(([b,v])=>{const w={...i,...v};typeof(w==null?void 0:w.default)=="function"&&(w.default=w.default()),w!=null&&w.isRequired&&(w==null?void 0:w.default)===void 0&&delete w.default,e.push({type:h.name,name:b,attribute:w})})}),e}function jD(t){const e=[];let n="",r=!1,a=!1,i=0;const o=t.length;for(let c=0;c0){i-=1,n+=u;continue}if(u===";"&&i===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function rw(t){const e=[],n=jD(t||""),r=n.length;for(let a=0;a!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([a,i])=>{if(!r[a]){r[a]=i;return}if(a==="class"){const c=i?String(i).split(" "):[],u=r[a]?r[a].split(" "):[],h=c.filter(f=>!u.includes(f));r[a]=[...u,...h].join(" ")}else if(a==="style"){const c=new Map([...rw(r[a]),...rw(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function yu(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Xt(n,r),{})}function kD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function aw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const a=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):kD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function iw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&wD(n)?!1:n!=null))}function ow(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function SD(t,e){var n;const r=xC(t),{nodeExtensions:a,markExtensions:i}=qc(t),o=(n=a.find(h=>at(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=r.filter(k=>k.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((k,T)=>{const C=at(T,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),b=iw({...x,content:Yt(at(h,"content",m)),marks:Yt(at(h,"marks",m)),group:Yt(at(h,"group",m)),inline:Yt(at(h,"inline",m)),atom:Yt(at(h,"atom",m)),selectable:Yt(at(h,"selectable",m)),draggable:Yt(at(h,"draggable",m)),code:Yt(at(h,"code",m)),whitespace:Yt(at(h,"whitespace",m)),linebreakReplacement:Yt(at(h,"linebreakReplacement",m)),defining:Yt(at(h,"defining",m)),isolating:Yt(at(h,"isolating",m)),attrs:Object.fromEntries(f.map(ow))}),v=Yt(at(h,"parseHTML",m));v&&(b.parseDOM=v.map(k=>aw(k,f)));const w=at(h,"renderHTML",m);w&&(b.toDOM=k=>w({node:k,HTMLAttributes:yu(k,f)}));const N=at(h,"renderText",m);return N&&(b.toText=N),[h.name,b]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((N,k)=>{const T=at(k,"extendMarkSchema",m);return{...N,...T?T(h):{}}},{}),b=iw({...x,inclusive:Yt(at(h,"inclusive",m)),excludes:Yt(at(h,"excludes",m)),group:Yt(at(h,"group",m)),spanning:Yt(at(h,"spanning",m)),code:Yt(at(h,"code",m)),attrs:Object.fromEntries(f.map(ow))}),v=Yt(at(h,"parseHTML",m));v&&(b.parseDOM=v.map(N=>aw(N,f)));const w=at(h,"renderHTML",m);return w&&(b.toDOM=N=>w({mark:N,HTMLAttributes:yu(N,f)})),[h.name,b]}));return new G2({topNode:o,nodes:c,marks:u})}function CD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function eu(t){return t.sort((n,r)=>{const a=at(n,"priority")||100,i=at(r,"priority")||100;return a>i?-1:ar.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function yC(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=`
-
-`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,a,(u,h,f,m)=>{var x;u.isBlock&&h>r&&(c+=i);const b=o==null?void 0:o[u.type.name];if(b)return f&&(c+=b({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(x=u==null?void 0:u.text)==null?void 0:x.slice(Math.max(r,h)-h,a-h))}),c}function ED(t,e){const n={from:0,to:t.content.size};return yC(t,n,e)}function bC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function TD(t,e){const n=Zn(e,t.schema),{from:r,to:a}=t.selection,i=[];t.doc.nodesBetween(r,a,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function vC(t,e){const n=zp(typeof e=="string"?e:e.name,t.schema);return n==="node"?TD(t,e):n==="mark"?hC(t,e):{}}function MD(t,e=JSON.stringify){const n={};return t.filter(r=>{const a=e(r);return Object.prototype.hasOwnProperty.call(n,a)?!1:n[a]=!0})}function AD(t){const e=MD(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function NC(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((a,i)=>{const o=[];if(a.ranges.length)a.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(i).map(c,-1),f=e.slice(i).map(u),m=e.invert().map(h,-1),x=e.invert().map(f);r.push({oldRange:{from:m,to:x},newRange:{from:h,to:f}})})}),AD(r)}function Sy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=wy(i,a.type);o&&r.push({mark:a,...o})}):n.nodesBetween(t,e,(a,i)=>{!a||(a==null?void 0:a.nodeSize)===void 0||r.push(...a.marks.map(o=>({from:i,to:i+a.nodeSize,mark:o})))}),r}var ID=(t,e,n,r=20)=>{const a=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const c=a.node(i);(c==null?void 0:c.type.name)===e?o=c:i-=1}return[o,i]};function zd(t,e){return e.nodes[t]||e.marks[t]||null}function cf(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const a=t.find(i=>i.type===e&&i.name===r);return a?a.attribute.keepOnSplit:!1}))}var PD=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(a,i,o,c)=>{var u,h;const f=((h=(u=a.type.spec).toText)==null?void 0:h.call(u,{node:a,pos:i,parent:o,index:c}))||a.textContent||"%leaf%";n+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,r-i))}),n};function s0(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?_i(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Df(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:x})=>{const b=m.pos,v=x.pos;t.doc.nodesBetween(b,v,(w,N)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(b,N),T=Math.min(v,N+w.nodeSize),C=T-k;o+=C,c.push(...w.marks.map(P=>({mark:P,from:k,to:T})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Df(m.mark.attrs,n,{strict:!1})).reduce((m,x)=>m+x.to-x.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,x)=>m+x.to-x.from,0);return(u>0?u+h:u)>=o}function RD(t,e,n={}){if(!e)return Do(t,null,n)||s0(t,null,n);const r=zp(e,t.schema);return r==="node"?Do(t,e,n):r==="mark"?s0(t,e,n):!1}var LD=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=$p(c=>c.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return a.pos+1===o.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function lw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function cw(t,e){const{nodeExtensions:n}=qc(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Yt(at(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function Fp(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let a=!0;return t.content.forEach(i=>{a!==!1&&(Fp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function wC(t){return t instanceof ot}var jC=class kC{constructor(e){this.position=e}static fromJSON(e){return new kC(e.position)}toJSON(){return{position:this.position}}};function DD(t,e){const n=e.mapping.mapResult(t.position);return{position:new jC(n.pos),mapResult:n}}function _D(t){return new jC(t)}function zD(t,e,n){var r;const{selection:a}=e;let i=null;if(lC(a)&&(i=a.$cursor),i){const c=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=a;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,x)=>{if(h)return!1;if(f.isInline){const b=!x||x.type.allowsMarkType(n),v=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=b&&v}return!h}),h})}var $D=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=_i(t,r.schema);if(a)if(o){const h=hC(r,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;r.doc.nodesBetween(f,m,(x,b)=>{const v=Math.max(b,f),w=Math.min(b+x.nodeSize,m);x.marks.find(k=>k.type===u)?x.marks.forEach(k=>{u===k.type&&n.addMark(v,w,u.create({...k.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return zD(r,n,u)},FD=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),BD=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Zn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?a().command(({commands:c})=>NN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>NN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},VD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=yl(t,0,r.content.size),i=ot.create(r,a);e.setSelection(i)}return!0},HD=(t,e)=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=r;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=i.from,c=i.to),a&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},UD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=lt.atStart(r).from,c=lt.atEnd(r).to,u=yl(a,o,c),h=yl(i,o,c),f=lt.create(r,u,h);e.setSelection(f)}return!0},WD=t=>({state:e,dispatch:n})=>{const r=Zn(t,e.schema);return zL(r)(e,n)};function dw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(a=>e==null?void 0:e.includes(a.type.name));t.tr.ensureMarks(r)}}var KD=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:a})=>{const{selection:i,doc:o}=e,{$from:c,$to:u}=i,h=a.extensionManager.attributes,f=cf(h,c.node().type.name,c.node().attrs);if(i instanceof ot&&i.node.isBlock)return!c.parentOffset||!Ai(o,c.pos)?!1:(r&&(t&&dw(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,x=c.depth===0?void 0:vD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&x?[{type:x,attrs:f}]:void 0,v=Ai(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!v&&Ai(e.doc,e.mapping.map(c.pos),1,x?[{type:x}]:void 0)&&(v=!0,b=x?[{type:x,attrs:f}]:void 0),r){if(v&&(i instanceof lt&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),x&&!m&&!c.parentOffset&&c.parent.type!==x)){const w=e.mapping.map(c.before()),N=e.doc.resolve(w);c.node(-1).canReplaceWith(N.index(),N.index()+1,x)&&e.setNodeMarkup(e.mapping.map(c.before()),x)}t&&dw(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return v},qD=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Zn(t,r.schema),{$from:u,$to:h}=r.selection,f=r.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const x=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){let k=Ee.empty;const T=u.index(-1)?1:u.index(-2)?2:3;for(let H=u.depth-T;H>=u.depth-3;H-=1)k=Ee.from(u.node(H).copy(k));const C=u.indexAfter(-1){if(z>-1)return!1;H.isTextblock&&H.content.size===0&&(z=R+1)}),z>-1&&n.setSelection(lt.near(n.doc.resolve(z))),n.scrollIntoView()}return!0}const b=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...cf(x,m.type.name,m.attrs),...e},w={...cf(x,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const N=b?[{type:c,attrs:v},{type:b,attrs:w}]:[{type:c,attrs:v}];if(!Ai(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:T}=r,{splittableMarks:C}=i.extensionManager,P=T||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,N).scrollIntoView(),!P||!a)return!0;const L=P.filter(q=>C.includes(q.type.name));n.ensureMarks(L)}return!0},ng=(t,e)=>{const n=$p(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&Vo(t.doc,n.pos)&&t.join(n.pos),!0},sg=(t,e)=>{const n=$p(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&Vo(t.doc,r)&&t.join(r),!0},GD=(t,e,n,r={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:x}=a.extensionManager,b=Zn(t,o.schema),v=Zn(e,o.schema),{selection:w,storedMarks:N}=o,{$from:k,$to:T}=w,C=k.blockRange(T),P=N||w.$to.parentOffset&&w.$from.marks();if(!C)return!1;const L=$p(q=>cw(q.type.name,m))(w);if(C.depth>=1&&L&&C.depth-L.depth<=1){if(L.node.type===b)return h.liftListItem(v);if(cw(L.node.type.name,m)&&b.validContent(L.node.content)&&c)return u().command(()=>(i.setNodeMarkup(L.pos,b),!0)).command(()=>ng(i,b)).command(()=>sg(i,b)).run()}return!n||!P||!c?u().command(()=>f().wrapInList(b,r)?!0:h.clearNodes()).wrapInList(b,r).command(()=>ng(i,b)).command(()=>sg(i,b)).run():u().command(()=>{const q=f().wrapInList(b,r),z=P.filter(H=>x.includes(H.type.name));return i.ensureMarks(z),q?!0:h.clearNodes()}).wrapInList(b,r).command(()=>ng(i,b)).command(()=>sg(i,b)).run()},JD=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=_i(t,r.schema);return s0(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},QD=(t,e,n={})=>({state:r,commands:a})=>{const i=Zn(t,r.schema),o=Zn(e,r.schema),c=Do(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?a.setNode(o,u):a.setNode(i,{...u,...n})},YD=(t,e={})=>({state:n,commands:r})=>{const a=Zn(t,n.schema);return Do(n,a,e)?r.lift(a):r.wrapIn(a,e)},XD=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;u-=1)o.step(c.steps[u].invert(c.docs[u]));if(i.text){const u=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else o.delete(i.from,i.to)}return!0}}return!1},ZD=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:a}=n;return r||e&&a.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},e_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=_i(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:x,to:b}=c;const v=(i=h.marks().find(N=>N.type===u))==null?void 0:i.attrs,w=wy(h,u,v);w&&(x=w.from,b=w.to),n.removeMark(x,b,u)}else m.forEach(x=>{n.removeMark(x.$from.pos,x.$to.pos,u)});return n.removeStoredMark(u),!0},t_=t=>({tr:e,state:n,dispatch:r})=>{const{selection:a}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=a.from,o=a.to),r&&e.doc.nodesBetween(i,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},n_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=zp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Zn(t,r.schema)),c==="mark"&&(o=_i(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let x,b,v,w;n.selection.empty?r.doc.nodesBetween(f,m,(N,k)=>{i&&i===N.type&&(u=!0,v=Math.max(k,f),w=Math.min(k+N.nodeSize,m),x=k,b=N)}):r.doc.nodesBetween(f,m,(N,k)=>{k=f&&k<=m&&(i&&i===N.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...N.attrs,...e})),o&&N.marks.length&&N.marks.forEach(T=>{if(o===T.type&&(u=!0,a)){const C=Math.max(k,f),P=Math.min(k+N.nodeSize,m);n.addMark(C,P,o.create({...T.attrs,...e}))}}))}),b&&(x!==void 0&&a&&n.setNodeMarkup(x,void 0,{...b.attrs,...e}),o&&b.marks.length&&b.marks.forEach(N=>{o===N.type&&a&&n.addMark(v,w,o.create({...N.attrs,...e}))}))}),u},s_=(t,e={})=>({state:n,dispatch:r})=>{const a=Zn(t,n.schema);return IL(a,e)(n,r)},r_=(t,e={})=>({state:n,dispatch:r})=>{const a=Zn(t,n.schema);return PL(a,e)(n,r)},a_=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Bp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},i_=(t,e)=>{if(Ny(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Wh(t){var e;const{editor:n,from:r,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(r);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(x=>x.type.spec.code))return!1;let f=!1;const m=PD(h)+i;return o.forEach(x=>{if(f)return;const b=i_(m,x.find);if(!b)return;const v=u.state.tr,w=Dp({state:u.state,transaction:v}),N={from:r-(b[0].length-i.length),to:a},{commands:k,chain:T,can:C}=new _p({editor:n,state:w});x.handler({state:w,range:N,match:b,commands:k,chain:T,can:C})===null||!v.steps.length||(x.undoable&&v.setMeta(c,{transform:v,from:r,to:a,text:i}),u.dispatch(v),f=!0)}),f}function o_(t){const{editor:e,rules:n}=t,r=new pn({state:{init(){return null},apply(a,i,o){const c=a.getMeta(r);if(c)return c;const u=a.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=ky(Ee.from(f),o.schema);const{from:m}=u,x=m+f.length;Wh({editor:e,from:m,to:x,text:f,rules:n,plugin:r})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return Wh({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&Wh({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(a,i){if(i.key!=="Enter")return!1;const{$cursor:o}=a.state.selection;return o?Wh({editor:e,from:o.pos,to:o.pos,text:`
-`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function l_(t){return Object.prototype.toString.call(t).slice(8,-1)}function Kh(t){return l_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function SC(t,e){const n={...t};return Kh(t)&&Kh(e)&&Object.keys(e).forEach(r=>{Kh(e[r])&&Kh(t[r])?n[r]=SC(t[r],e[r]):n[r]=e[r]}),n}var Cy=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Yt(at(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Yt(at(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>SC(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Hl=class CC extends Cy{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new CC(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,a=e.state.selection.$from;if(a.pos===a.end()){const o=a.marks();if(!!!o.find(h=>(h==null?void 0:h.type.name)===n.name))return!1;const u=o.find(h=>(h==null?void 0:h.type.name)===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",a.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function c_(t){return typeof t=="number"}var d_=class{constructor(t){this.find=t.find,this.handler=t.handler}},u_=(t,e,n)=>{if(Ny(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(a=>{const i=[a.text];return i.index=a.index,i.input=t,i.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(a.replaceWith)),i}):[]};function h_(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new _p({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(b,v)=>{var w,N,k,T,C;if((N=(w=b.type)==null?void 0:w.spec)!=null&&N.code||!(b.isText||b.isTextblock||b.isInline))return;const P=(C=(T=(k=b.content)==null?void 0:k.size)!=null?T:b.nodeSize)!=null?C:0,L=Math.max(r,v),q=Math.min(a,v+P);if(L>=q)return;const z=b.isText?b.text||"":b.textBetween(L-v,q-v,void 0,"");u_(z,i.find,o).forEach(R=>{if(R.index===void 0)return;const se=L+R.index+1,X=se+R[0].length,V={from:n.tr.mapping.map(se),to:n.tr.mapping.map(X)},ie=i.handler({state:n,range:V,match:R,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ie)})}),m.every(b=>b!==null)}var qh=null,f_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function p_(t){const{editor:e,rules:n}=t;let r=null,a=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:x,rule:b,pasteEvt:v})=>{const w=f.tr,N=Dp({state:f,transaction:w});if(!(!h_({editor:e,state:N,from:Math.max(m-1,0),to:x.b-1,rule:b,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(f=>new pn({view(m){const x=v=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,r&&(qh=e)},b=()=>{qh&&(qh=null)};return window.addEventListener("dragstart",x),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",x),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,x)=>{if(i=r===m.dom.parentElement,c=x,!i){const b=qh;b!=null&&b.isEditable&&setTimeout(()=>{const v=b.state.selection;v&&b.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,x)=>{var b;const v=(b=x.clipboardData)==null?void 0:b.getData("text/html");return o=x,a=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,x,b)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!a,N=v.getMeta("uiEvent")==="drop"&&!i,k=v.getMeta("applyPasteRules"),T=!!k;if(!w&&!N&&!T)return;if(T){let{text:L}=k;typeof L=="string"?L=L:L=ky(Ee.from(L),b.schema);const{from:q}=k,z=q+L.length,H=f_(L);return u({rule:f,state:b,from:q,to:{b:z},pasteEvt:H})}const C=x.doc.content.findDiffStart(b.doc.content),P=x.doc.content.findDiffEnd(b.doc.content);if(!(!c_(C)||!P||C===P.b))return u({rule:f,state:b,from:C,to:P,pasteEvt:o})}}))}var Vp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=gC(t),this.schema=SD(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zd(e.name,this.schema)},r=at(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return eu([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:zd(r.name,this.schema)},i=[],o=at(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&at(r,"exitable",a)&&(c.ArrowRight=()=>Hl.handleExit({editor:t,mark:r})),o){const x=Object.fromEntries(Object.entries(o()).map(([b,v])=>[b,()=>v({editor:t})]));c={...c,...x}}const u=TO(c);i.push(u);const h=at(r,"addInputRules",a);if(lw(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const b=o_({editor:t,rules:x}),v=Array.isArray(b)?b:[b];i.push(...v)}}const f=at(r,"addPasteRules",a);if(lw(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const b=p_({editor:t,rules:x});i.push(...b)}}const m=at(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return xC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=qc(this.extensions);return Object.fromEntries(e.filter(n=>!!at(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Zn(n.name,this.schema)},i=at(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const b=yu(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:x,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return eu([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:zd(a.name,this.schema)},o=at(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return eu([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:zd(a.name,this.schema)},o=at(a,"transformPastedHTML",i);return o?(c,u)=>{const h=r(c,u);return o.call(i,h)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=qc(this.extensions);return Object.fromEntries(e.filter(n=>!!at(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:_i(n.name,this.schema)},i=at(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=yu(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{M_(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zd(e.name,this.schema)};e.type==="mark"&&((n=Yt(at(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=at(e,"onBeforeCreate",r),i=at(e,"onCreate",r),o=at(e,"onUpdate",r),c=at(e,"onSelectionUpdate",r),u=at(e,"onTransaction",r),h=at(e,"onFocus",r),f=at(e,"onBlur",r),m=at(e,"onDestroy",r);a&&this.editor.on("beforeCreate",a),i&&this.editor.on("create",i),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),m&&this.editor.on("destroy",m)})}};Vp.resolve=gC;Vp.sort=eu;Vp.flatten=jy;var m_={};vy(m_,{ClipboardTextSerializer:()=>TC,Commands:()=>MC,Delete:()=>AC,Drop:()=>IC,Editable:()=>PC,FocusEvents:()=>LC,Keymap:()=>OC,Paste:()=>DC,Tabindex:()=>_C,TextDirection:()=>zC,focusEventsPluginKey:()=>RC});var zn=class EC extends Cy{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new EC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},TC=zn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new pn({key:new Cn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:a}=e,{ranges:i}=a,o=Math.min(...i.map(f=>f.$from.pos)),c=Math.max(...i.map(f=>f.$to.pos)),u=bC(n);return yC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),MC=zn.create({name:"commands",addCommands(){return{...iC}}}),AC=zn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=fC(t.before,[t,...e]);NC(f).forEach(b=>{f.mapping.mapResult(b.oldRange.from).deletedAfter&&f.mapping.mapResult(b.oldRange.to).deletedBefore&&f.before.nodesBetween(b.oldRange.from,b.oldRange.to,(v,w)=>{const N=w+v.nodeSize-2,k=b.oldRange.from<=w&&N<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:N,newFrom:f.mapping.map(w),newTo:f.mapping.map(N),deletedRange:b.oldRange,newRange:b.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const x=f.mapping;f.steps.forEach((b,v)=>{var w,N;if(b instanceof Na){const k=x.slice(v).map(b.from,-1),T=x.slice(v).map(b.to),C=x.invert().map(k,-1),P=x.invert().map(T),L=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(z=>z.eq(b.mark)),q=(N=f.doc.nodeAt(T))==null?void 0:N.marks.some(z=>z.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:C,to:P},newRange:{from:k,to:T},partial:!!(q||L),editor:this.editor,transaction:t,combinedTransform:f})}})};(a=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||a?setTimeout(i,0):i()}}),IC=zn.create({name:"drop",addProseMirrorPlugins(){return[new pn({key:new Cn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),PC=zn.create({name:"editable",addProseMirrorPlugins(){return[new pn({key:new Cn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),RC=new Cn("focusEvents"),LC=zn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new pn({key:RC,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),OC=zn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:x,parent:b}=m,v=m.parent.isTextblock&&x>0?c.doc.resolve(x-1):m,w=v.parent.type.spec.isolating,N=m.pos-m.parentOffset,k=w&&v.parent.childCount===1?N===m.pos:gt.atStart(h).from===x;return!f||!b.type.isTextblock||b.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},a={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return _f()||uC()?i:a},addProseMirrorPlugins(){return[new pn({key:new Cn("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!r||a)return;const{empty:i,from:o,to:c}=e.selection,u=gt.atStart(e.doc).from,h=gt.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!Fp(n.doc))return;const x=n.tr,b=Dp({state:n,transaction:x}),{commands:v}=new _p({editor:this.editor,state:b});if(v.clearNodes(),!!x.steps.length)return x}})]}}),DC=zn.create({name:"paste",addProseMirrorPlugins(){return[new pn({key:new Cn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),_C=zn.create({name:"tabindex",addProseMirrorPlugins(){return[new pn({key:new Cn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),zC=zn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=qc(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new pn({key:new Cn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),x_=class Ud{constructor(e,n,r=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=a}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Ud(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ud(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ud(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const a=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+r+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!a&&!o&&u.depth<=this.depth)return;const h=new Ud(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,a=this.parent;for(;a&&!r;){if(a.node.type.name===e)if(Object.keys(n).length>0){const i=a.node.attrs,o=Object.keys(n);for(let c=0;c{r&&a.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&a.push(o),!(r&&a.length>0)&&(a=a.concat(o.querySelectorAll(e,n,r))))}),a}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},g_=`.ProseMirror {
- position: relative;
-}
-
-.ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
-}
-
-.ProseMirror [contenteditable="false"] {
- white-space: normal;
-}
-
-.ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
-}
-
-.ProseMirror pre {
- white-space: pre-wrap;
-}
-
-img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
-}
-
-.ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
-}
-
-.ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
-}
-
-@keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
-}
-
-.ProseMirror-hideselection *::selection {
- background: transparent;
-}
-
-.ProseMirror-hideselection *::-moz-selection {
- background: transparent;
-}
-
-.ProseMirror-hideselection * {
- caret-color: transparent;
-}
-
-.ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
-}`;function y_(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const a=document.createElement("style");return e&&a.setAttribute("nonce",e),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}var b_=class extends a_{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:DD,createMappablePosition:_D},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:a,moved:i})=>this.options.onDrop(r,a,i)),this.on("paste",({event:r,slice:a})=>this.options.onPaste(r,a)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=cC(e,this.options.autofocus);this.editorState=Lc.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=y_(g_,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=mC(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(a=>{const i=typeof a=="string"?`${a}$`:a.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[PC,TC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),MC,LC,OC,_C,IC,DC,AC,zC.configure({direction:this.options.textDirection})].filter(a=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[a.name]!==!1:!0):[],...this.options.extensions].filter(a=>["extension","node","mark"].includes(a==null?void 0:a.type));this.extensionManager=new Vp(r,this)}createCommandManager(){this.commandManager=new _p({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=n0(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=n0(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),a=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new aC(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:a,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const u=this.view.dom;u.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(h=>{var f;return(f=this.capturedTransaction)==null?void 0:f.step(h)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),a=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!a)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),c=o==null?void 0:o.getMeta("focus"),u=o==null?void 0:o.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(h=>h.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return vC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return RD(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ky(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
-
-`,textSerializers:n={}}=t||{};return ED(this.state.doc,{blockSeparator:e,textSerializers:{...bC(this.schema),...n}})}get isEmpty(){return Fp(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new x_(e,this)}get $doc(){return this.$pos(0)}};function Gc(t){return new Bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Yt(t.getAttributes,void 0,r);if(a===!1||a===null)return null;const{tr:i}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(Sy(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>h).length)return null;fn.from&&i.delete(n.from+u,h);const x=n.from+u+o.length;i.addMark(n.from+u,x,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function $C(t){return new Bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Yt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(f,c,u)}else if(r[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function r0(t){return new Bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Yt(t.getAttributes,void 0,r)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Jc(t){return new Bp({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Yt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&ny(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:x}=e,{splittableMarks:b}=t.editor.extensionManager,v=x||m.$to.parentOffset&&m.$from.marks();if(v){const w=v.filter(N=>b.includes(N.type.name));o.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Vo(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var v_=t=>"touches"in t,N_=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,h=c.clientY-this.startY;this.handleResize(u,h)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const h=u.clientX-this.startX,f=u.clientY-this.startY;this.handleResize(h,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,a,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(a=t.options)!=null&&a.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),a=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),a&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,v_(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:a}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,a,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,a=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),c?a=this.startHeight+n:u&&(a=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(a=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,a,t):{width:r,height:a}}applyConstraints(t,e,n){var r,a,i,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(h=Math.min(this.maxSize.width,h)),(a=this.maxSize)!=null&&a.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return cthis.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",a=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:a?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function w_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ot){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let a=r.depth;for(;a>=0;){const i=r.index(a);if(r.node(a).contentMatchAt(i).matchType(e))return!0;a-=1}return!1}function j_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var k_={};vy(k_,{createAtomBlockMarkdownSpec:()=>S_,createBlockMarkdownSpec:()=>C_,createInlineMarkdownSpec:()=>FC,parseAttributes:()=>Ey,parseIndentedBlocks:()=>a0,renderNestedMarkdownContent:()=>My,serializeAttributes:()=>Ty});function Ey(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,h,f])=>{var m;const x=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[x];b&&(e[h]=b.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function Ty(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function S_(t){const{nodeName:e,name:n,parseAttributes:r=Ey,serializeAttributes:a=Ty,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(x=>{x in f&&(m[x]=f[x])}),m};return{parseMarkdown:(f,m)=>{const x={...i,...f.attributes};return m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const x=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=f.match(x))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,x){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=f.match(b);if(!v)return;const w=v[1]||"",N=r(w);if(!o.find(T=>!(T in N)))return{type:e,raw:v[0],attributes:N}}},renderMarkdown:f=>{const m=h(f.attrs||{}),x=a(m),b=x?` {${x}}`:"";return`:::${u}${b} :::`}}}function C_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=Ey,serializeAttributes:i=Ty,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const x={};return u.forEach(b=>{b in m&&(x[b]=m[b])}),x};return{parseMarkdown:(m,x)=>{let b;if(r){const w=r(m);b=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?b=x.parseChildren(m.tokens||[]):b=x.parseInline(m.tokens||[]);const v={...o,...m.attributes};return x.createNode(e,v,b)},markdownTokenizer:{name:e,level:"block",start(m){var x;const b=new RegExp(`^:::${h}`,"m"),v=(x=m.match(b))==null?void 0:x.index;return v!==void 0?v:-1},tokenize(m,x,b){var v;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),N=m.match(w);if(!N)return;const[k,T=""]=N,C=a(T);let P=1;const L=k.length;let q="";const z=/^:::([\w-]*)(\s.*)?/gm,H=m.slice(L);for(z.lastIndex=0;;){const R=z.exec(H);if(R===null)break;const se=R.index,X=R[1];if(!((v=R[2])!=null&&v.endsWith(":::"))){if(X)P+=1;else if(P-=1,P===0){const V=H.slice(0,se);q=V.trim();const ie=m.slice(0,L+se+R[0].length);let le=[];if(q)if(c==="block")for(le=b.blockTokens(V),le.forEach(he=>{he.text&&(!he.tokens||he.tokens.length===0)&&(he.tokens=b.inlineTokens(he.text))});le.length>0;){const he=le[le.length-1];if(he.type==="paragraph"&&(!he.text||he.text.trim()===""))le.pop();else break}else le=b.inlineTokens(q);return{type:e,raw:ie,attributes:C,content:q,tokens:le}}}}}},renderMarkdown:(m,x)=>{const b=f(m.attrs||{}),v=i(b),w=v?` {${v}}`:"",N=x.renderChildren(m.content||[],`
-
-`);return`:::${h}${w}
-
-${N}
-
-:::`}}}function E_(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,a,i,o]=r;e[a]=i||o,r=n.exec(t)}return e}function T_(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function FC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=E_,serializeAttributes:i=T_,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=x=>{if(!u)return x;const b={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,N=typeof v=="string"?void 0:v.skipIfDefault;if(w in x){const k=x[w];if(N!==void 0&&k===N)return;b[w]=k}}),b},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(x,b)=>{const v={...o,...x.attributes};if(c)return b.createNode(e,v);const w=r?r(x):x.content||"";return w?b.createNode(e,v,[b.createTextNode(w)]):b.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(x){const b=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=x.match(b),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(x,b,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),N=x.match(w);if(!N)return;let k="",T="";if(c){const[,P]=N;T=P}else{const[,P,L]=N;T=P,k=L||""}const C=a(T.trim());return{type:e,raw:N[0],content:k.trim(),attributes:C}}},renderMarkdown:x=>{let b="";r?b=r(x):x.content&&x.content.length>0&&(b=x.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const v=f(x.attrs||{}),w=i(v),N=w?` ${w}`:"";return c?`[${h}${N}]`:`[${h}${N}]${b}[/${h}]`}}}function a0(t,e,n){var r,a,i,o;const c=t.split(`
-`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(x.trim()===""){f+=1,h=`${h}${x}
-`;continue}else return}const v=e.extractItemData(b),{indentLevel:w,mainContent:N}=v;h=`${h}${x}
-`;const k=[N];for(f+=1;fse.trim()!=="");if(z===-1)break;if((((a=(r=c[f+1+z].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:a.length)||0)>w){k.push(L),h=`${h}${L}
-`,f+=1;continue}else break}if((((o=(i=L.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>w)k.push(L),h=`${h}${L}
-`,f+=1;else break}let T;const C=k.slice(1);if(C.length>0){const L=C.map(q=>q.slice(w+m)).join(`
-`);L.trim()&&(e.customNestedParser?T=e.customNestedParser(L):T=n.blockTokens(L))}const P=e.createToken(v,T);u.push(P)}if(u.length!==0)return{items:u,raw:h}}function My(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const a=typeof n=="function"?n(r):n,[i,...o]=t.content,c=e.renderChildren([i]),u=[`${a}${c}`];return o&&o.length>0&&o.forEach(h=>{const f=e.renderChildren([h]);if(f){const m=f.split(`
-`).map(x=>x?e.indent(x):"").join(`
-`);u.push(m)}}),u.join(`
-`)}function M_(t,e,n={}){const{state:r}=e,{doc:a,tr:i}=r,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(b=>{if(b!==o)return!1;m=b}),!m)return;let x=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(x=!0)}),x){const b=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,b)}}),i.docChanged&&e.view.dispatch(i)}var qn=class BC extends Cy{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Dl(t){return new d_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=Yt(t.getAttributes,void 0,r,a);if(i===!1||i===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),x=m+c.length;if(Sy(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(N=>N===t.type&&N!==v.mark.type)).filter(v=>v.to>m).length)return null;x