@whispering233/ai-editor-server 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ function qN(n,o){for(var r=0;r<o.length;r++){const l=o[r];if(typeof l!="string"&&!Array.isArray(l)){for(const c in l)if(c!=="default"&&!(c in n)){const d=Object.getOwnPropertyDescriptor(l,c);d&&Object.defineProperty(n,c,d.get?d:{enumerable:!0,get:()=>l[c]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&l(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(c){if(c.ep)return;c.ep=!0;const d=r(c);fetch(c.href,d)}})();function Gv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Rf={exports:{}},yl={};var Ub;function $N(){if(Ub)return yl;Ub=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(l,c,d){var m=null;if(d!==void 0&&(m=""+d),c.key!==void 0&&(m=""+c.key),"key"in c){d={};for(var g in c)g!=="key"&&(d[g]=c[g])}else d=c;return c=d.ref,{$$typeof:n,type:l,key:m,ref:c!==void 0?c:null,props:d}}return yl.Fragment=o,yl.jsx=r,yl.jsxs=r,yl}var Hb;function XN(){return Hb||(Hb=1,Rf.exports=$N()),Rf.exports}var i=XN(),Of={exports:{}},rt={};var Pb;function KN(){if(Pb)return rt;Pb=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),S=Symbol.iterator;function j(z){return z===null||typeof z!="object"?null:(z=S&&z[S]||z["@@iterator"],typeof z=="function"?z:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,O={};function N(z,Z,F){this.props=z,this.context=Z,this.refs=O,this.updater=F||E}N.prototype.isReactComponent={},N.prototype.setState=function(z,Z){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,Z,"setState")},N.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function T(){}T.prototype=N.prototype;function k(z,Z,F){this.props=z,this.context=Z,this.refs=O,this.updater=F||E}var C=k.prototype=new T;C.constructor=k,_(C,N.prototype),C.isPureReactComponent=!0;var H=Array.isArray;function M(){}var L={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function J(z,Z,F){var Y=F.ref;return{$$typeof:n,type:z,key:Z,ref:Y!==void 0?Y:null,props:F}}function oe(z,Z){return J(z.type,Z,z.props)}function ie(z){return typeof z=="object"&&z!==null&&z.$$typeof===n}function te(z){var Z={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(F){return Z[F]})}var Q=/\/+/g;function G(z,Z){return typeof z=="object"&&z!==null&&z.key!=null?te(""+z.key):Z.toString(36)}function K(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(M,M):(z.status="pending",z.then(function(Z){z.status==="pending"&&(z.status="fulfilled",z.value=Z)},function(Z){z.status==="pending"&&(z.status="rejected",z.reason=Z)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function A(z,Z,F,Y,q){var P=typeof z;(P==="undefined"||P==="boolean")&&(z=null);var me=!1;if(z===null)me=!0;else switch(P){case"bigint":case"string":case"number":me=!0;break;case"object":switch(z.$$typeof){case n:case o:me=!0;break;case v:return me=z._init,A(me(z._payload),Z,F,Y,q)}}if(me)return q=q(z),me=Y===""?"."+G(z,0):Y,H(q)?(F="",me!=null&&(F=me.replace(Q,"$&/")+"/"),A(q,Z,F,"",function(Le){return Le})):q!=null&&(ie(q)&&(q=oe(q,F+(q.key==null||z&&z.key===q.key?"":(""+q.key).replace(Q,"$&/")+"/")+me)),Z.push(q)),1;me=0;var re=Y===""?".":Y+":";if(H(z))for(var de=0;de<z.length;de++)Y=z[de],P=re+G(Y,de),me+=A(Y,Z,F,P,q);else if(de=j(z),typeof de=="function")for(z=de.call(z),de=0;!(Y=z.next()).done;)Y=Y.value,P=re+G(Y,de++),me+=A(Y,Z,F,P,q);else if(P==="object"){if(typeof z.then=="function")return A(K(z),Z,F,Y,q);throw Z=String(z),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return me}function D(z,Z,F){if(z==null)return z;var Y=[],q=0;return A(z,Y,"","",function(P){return Z.call(F,P,q++)}),Y}function B(z){if(z._status===-1){var Z=z._result;Z=Z(),Z.then(function(F){(z._status===0||z._status===-1)&&(z._status=1,z._result=F)},function(F){(z._status===0||z._status===-1)&&(z._status=2,z._result=F)}),z._status===-1&&(z._status=0,z._result=Z)}if(z._status===1)return z._result.default;throw z._result}var I=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},V={map:D,forEach:function(z,Z,F){D(z,function(){Z.apply(this,arguments)},F)},count:function(z){var Z=0;return D(z,function(){Z++}),Z},toArray:function(z){return D(z,function(Z){return Z})||[]},only:function(z){if(!ie(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return rt.Activity=x,rt.Children=V,rt.Component=N,rt.Fragment=r,rt.Profiler=c,rt.PureComponent=k,rt.StrictMode=l,rt.Suspense=b,rt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,rt.__COMPILER_RUNTIME={__proto__:null,c:function(z){return L.H.useMemoCache(z)}},rt.cache=function(z){return function(){return z.apply(null,arguments)}},rt.cacheSignal=function(){return null},rt.cloneElement=function(z,Z,F){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var Y=_({},z.props),q=z.key;if(Z!=null)for(P in Z.key!==void 0&&(q=""+Z.key),Z)!w.call(Z,P)||P==="key"||P==="__self"||P==="__source"||P==="ref"&&Z.ref===void 0||(Y[P]=Z[P]);var P=arguments.length-2;if(P===1)Y.children=F;else if(1<P){for(var me=Array(P),re=0;re<P;re++)me[re]=arguments[re+2];Y.children=me}return J(z.type,q,Y)},rt.createContext=function(z){return z={$$typeof:m,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:d,_context:z},z},rt.createElement=function(z,Z,F){var Y,q={},P=null;if(Z!=null)for(Y in Z.key!==void 0&&(P=""+Z.key),Z)w.call(Z,Y)&&Y!=="key"&&Y!=="__self"&&Y!=="__source"&&(q[Y]=Z[Y]);var me=arguments.length-2;if(me===1)q.children=F;else if(1<me){for(var re=Array(me),de=0;de<me;de++)re[de]=arguments[de+2];q.children=re}if(z&&z.defaultProps)for(Y in me=z.defaultProps,me)q[Y]===void 0&&(q[Y]=me[Y]);return J(z,P,q)},rt.createRef=function(){return{current:null}},rt.forwardRef=function(z){return{$$typeof:g,render:z}},rt.isValidElement=ie,rt.lazy=function(z){return{$$typeof:v,_payload:{_status:-1,_result:z},_init:B}},rt.memo=function(z,Z){return{$$typeof:p,type:z,compare:Z===void 0?null:Z}},rt.startTransition=function(z){var Z=L.T,F={};L.T=F;try{var Y=z(),q=L.S;q!==null&&q(F,Y),typeof Y=="object"&&Y!==null&&typeof Y.then=="function"&&Y.then(M,I)}catch(P){I(P)}finally{Z!==null&&F.types!==null&&(Z.types=F.types),L.T=Z}},rt.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},rt.use=function(z){return L.H.use(z)},rt.useActionState=function(z,Z,F){return L.H.useActionState(z,Z,F)},rt.useCallback=function(z,Z){return L.H.useCallback(z,Z)},rt.useContext=function(z){return L.H.useContext(z)},rt.useDebugValue=function(){},rt.useDeferredValue=function(z,Z){return L.H.useDeferredValue(z,Z)},rt.useEffect=function(z,Z){return L.H.useEffect(z,Z)},rt.useEffectEvent=function(z){return L.H.useEffectEvent(z)},rt.useId=function(){return L.H.useId()},rt.useImperativeHandle=function(z,Z,F){return L.H.useImperativeHandle(z,Z,F)},rt.useInsertionEffect=function(z,Z){return L.H.useInsertionEffect(z,Z)},rt.useLayoutEffect=function(z,Z){return L.H.useLayoutEffect(z,Z)},rt.useMemo=function(z,Z){return L.H.useMemo(z,Z)},rt.useOptimistic=function(z,Z){return L.H.useOptimistic(z,Z)},rt.useReducer=function(z,Z,F){return L.H.useReducer(z,Z,F)},rt.useRef=function(z){return L.H.useRef(z)},rt.useState=function(z){return L.H.useState(z)},rt.useSyncExternalStore=function(z,Z,F){return L.H.useSyncExternalStore(z,Z,F)},rt.useTransition=function(){return L.H.useTransition()},rt.version="19.2.8",rt}var Yb;function Xl(){return Yb||(Yb=1,Of.exports=KN()),Of.exports}var h=Xl();const Me=Gv(h),QN=qN({__proto__:null,default:Me},[h]);var kf={exports:{}},vl={},_f={exports:{}},Mf={};var Vb;function ZN(){return Vb||(Vb=1,(function(n){function o(A,D){var B=A.length;A.push(D);e:for(;0<B;){var I=B-1>>>1,V=A[I];if(0<c(V,D))A[I]=D,A[B]=V,B=I;else break e}}function r(A){return A.length===0?null:A[0]}function l(A){if(A.length===0)return null;var D=A[0],B=A.pop();if(B!==D){A[0]=B;e:for(var I=0,V=A.length,z=V>>>1;I<z;){var Z=2*(I+1)-1,F=A[Z],Y=Z+1,q=A[Y];if(0>c(F,B))Y<V&&0>c(q,F)?(A[I]=q,A[Y]=B,I=Y):(A[I]=F,A[Z]=B,I=Z);else if(Y<V&&0>c(q,B))A[I]=q,A[Y]=B,I=Y;else break e}}return D}function c(A,D){var B=A.sortIndex-D.sortIndex;return B!==0?B:A.id-D.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var m=Date,g=m.now();n.unstable_now=function(){return m.now()-g}}var b=[],p=[],v=1,x=null,S=3,j=!1,E=!1,_=!1,O=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function C(A){for(var D=r(p);D!==null;){if(D.callback===null)l(p);else if(D.startTime<=A)l(p),D.sortIndex=D.expirationTime,o(b,D);else break;D=r(p)}}function H(A){if(_=!1,C(A),!E)if(r(b)!==null)E=!0,M||(M=!0,te());else{var D=r(p);D!==null&&K(H,D.startTime-A)}}var M=!1,L=-1,w=5,J=-1;function oe(){return O?!0:!(n.unstable_now()-J<w)}function ie(){if(O=!1,M){var A=n.unstable_now();J=A;var D=!0;try{e:{E=!1,_&&(_=!1,T(L),L=-1),j=!0;var B=S;try{t:{for(C(A),x=r(b);x!==null&&!(x.expirationTime>A&&oe());){var I=x.callback;if(typeof I=="function"){x.callback=null,S=x.priorityLevel;var V=I(x.expirationTime<=A);if(A=n.unstable_now(),typeof V=="function"){x.callback=V,C(A),D=!0;break t}x===r(b)&&l(b),C(A)}else l(b);x=r(b)}if(x!==null)D=!0;else{var z=r(p);z!==null&&K(H,z.startTime-A),D=!1}}break e}finally{x=null,S=B,j=!1}D=void 0}}finally{D?te():M=!1}}}var te;if(typeof k=="function")te=function(){k(ie)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,G=Q.port2;Q.port1.onmessage=ie,te=function(){G.postMessage(null)}}else te=function(){N(ie,0)};function K(A,D){L=N(function(){A(n.unstable_now())},D)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(A){A.callback=null},n.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):w=0<A?Math.floor(1e3/A):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(A){switch(S){case 1:case 2:case 3:var D=3;break;default:D=S}var B=S;S=D;try{return A()}finally{S=B}},n.unstable_requestPaint=function(){O=!0},n.unstable_runWithPriority=function(A,D){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var B=S;S=A;try{return D()}finally{S=B}},n.unstable_scheduleCallback=function(A,D,B){var I=n.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?I+B:I):B=I,A){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=B+V,A={id:v++,callback:D,priorityLevel:A,startTime:B,expirationTime:V,sortIndex:-1},B>I?(A.sortIndex=B,o(p,A),r(b)===null&&A===r(p)&&(_?(T(L),L=-1):_=!0,K(H,B-I))):(A.sortIndex=V,o(b,A),E||j||(E=!0,M||(M=!0,te()))),A},n.unstable_shouldYield=oe,n.unstable_wrapCallback=function(A){var D=S;return function(){var B=S;S=D;try{return A.apply(this,arguments)}finally{S=B}}}})(Mf)),Mf}var Fb;function JN(){return Fb||(Fb=1,_f.exports=ZN()),_f.exports}var Af={exports:{}},vn={};var Gb;function WN(){if(Gb)return vn;Gb=1;var n=Xl();function o(b){var p="https://react.dev/errors/"+b;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)p+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+b+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var l={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},c=Symbol.for("react.portal");function d(b,p,v){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:x==null?null:""+x,children:b,containerInfo:p,implementation:v}}var m=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function g(b,p){if(b==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return vn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,vn.createPortal=function(b,p){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(o(299));return d(b,p,null,v)},vn.flushSync=function(b){var p=m.T,v=l.p;try{if(m.T=null,l.p=2,b)return b()}finally{m.T=p,l.p=v,l.d.f()}},vn.preconnect=function(b,p){typeof b=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,l.d.C(b,p))},vn.prefetchDNS=function(b){typeof b=="string"&&l.d.D(b)},vn.preinit=function(b,p){if(typeof b=="string"&&p&&typeof p.as=="string"){var v=p.as,x=g(v,p.crossOrigin),S=typeof p.integrity=="string"?p.integrity:void 0,j=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;v==="style"?l.d.S(b,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:x,integrity:S,fetchPriority:j}):v==="script"&&l.d.X(b,{crossOrigin:x,integrity:S,fetchPriority:j,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},vn.preinitModule=function(b,p){if(typeof b=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var v=g(p.as,p.crossOrigin);l.d.M(b,{crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&l.d.M(b)},vn.preload=function(b,p){if(typeof b=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var v=p.as,x=g(v,p.crossOrigin);l.d.L(b,v,{crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},vn.preloadModule=function(b,p){if(typeof b=="string")if(p){var v=g(p.as,p.crossOrigin);l.d.m(b,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else l.d.m(b)},vn.requestFormReset=function(b){l.d.r(b)},vn.unstable_batchedUpdates=function(b,p){return b(p)},vn.useFormState=function(b,p,v){return m.H.useFormState(b,p,v)},vn.useFormStatus=function(){return m.H.useHostTransitionStatus()},vn.version="19.2.8",vn}var qb;function qv(){if(qb)return Af.exports;qb=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(o){console.error(o)}}return n(),Af.exports=WN(),Af.exports}var $b;function ej(){if($b)return vl;$b=1;var n=JN(),o=Xl(),r=qv();function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function m(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function b(e){if(d(e)!==e)throw Error(l(188))}function p(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(l(188));return t!==e?null:e}for(var s=e,a=t;;){var u=s.return;if(u===null)break;var f=u.alternate;if(f===null){if(a=u.return,a!==null){s=a;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===s)return b(u),e;if(f===a)return b(u),t;f=f.sibling}throw Error(l(188))}if(s.return!==a.return)s=u,a=f;else{for(var y=!1,R=u.child;R;){if(R===s){y=!0,s=u,a=f;break}if(R===a){y=!0,a=u,s=f;break}R=R.sibling}if(!y){for(R=f.child;R;){if(R===s){y=!0,s=f,a=u;break}if(R===a){y=!0,a=f,s=u;break}R=R.sibling}if(!y)throw Error(l(189))}}if(s.alternate!==a)throw Error(l(190))}if(s.tag!==3)throw Error(l(188));return s.stateNode.current===s?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var x=Object.assign,S=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),k=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),oe=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=ie&&e[ie]||e["@@iterator"],typeof e=="function"?e:null)}var Q=Symbol.for("react.client.reference");function G(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case N:return"Profiler";case O:return"StrictMode";case H:return"Suspense";case M:return"SuspenseList";case J:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case k:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case C:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:G(e.type)||"Memo";case w:t=e._payload,e=e._init;try{return G(e(t))}catch{}}return null}var K=Array.isArray,A=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},I=[],V=-1;function z(e){return{current:e}}function Z(e){0>V||(e.current=I[V],I[V]=null,V--)}function F(e,t){V++,I[V]=e.current,e.current=t}var Y=z(null),q=z(null),P=z(null),me=z(null);function re(e,t){switch(F(P,t),F(q,e),F(Y,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ib(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=ib(t),e=cb(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Z(Y),F(Y,e)}function de(){Z(Y),Z(q),Z(P)}function Le(e){e.memoizedState!==null&&F(me,e);var t=Y.current,s=cb(t,e.type);t!==s&&(F(q,e),F(Y,s))}function De(e){q.current===e&&(Z(Y),Z(q)),me.current===e&&(Z(me),hl._currentValue=B)}var we,Be;function ge(e){if(we===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||"",Be=-1<s.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+we+e+Be}var le=!1;function Ye(e,t){if(!e||le)return"";le=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(he){var fe=he}Reflect.construct(e,[],Ne)}else{try{Ne.call()}catch(he){fe=he}e.call(Ne.prototype)}}else{try{throw Error()}catch(he){fe=he}(Ne=e())&&typeof Ne.catch=="function"&&Ne.catch(function(){})}}catch(he){if(he&&fe&&typeof he.stack=="string")return[he.stack,fe.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=a.DetermineComponentFrameRoot(),y=f[0],R=f[1];if(y&&R){var X=y.split(`
4
+ `),ue=R.split(`
5
+ `);for(u=a=0;a<X.length&&!X[a].includes("DetermineComponentFrameRoot");)a++;for(;u<ue.length&&!ue[u].includes("DetermineComponentFrameRoot");)u++;if(a===X.length||u===ue.length)for(a=X.length-1,u=ue.length-1;1<=a&&0<=u&&X[a]!==ue[u];)u--;for(;1<=a&&0<=u;a--,u--)if(X[a]!==ue[u]){if(a!==1||u!==1)do if(a--,u--,0>u||X[a]!==ue[u]){var ye=`
6
+ `+X[a].replace(" at new "," at ");return e.displayName&&ye.includes("<anonymous>")&&(ye=ye.replace("<anonymous>",e.displayName)),ye}while(1<=a&&0<=u);break}}}finally{le=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?ge(s):""}function ke(e,t){switch(e.tag){case 26:case 27:case 5:return ge(e.type);case 16:return ge("Lazy");case 13:return e.child!==t&&t!==null?ge("Suspense Fallback"):ge("Suspense");case 19:return ge("SuspenseList");case 0:case 15:return Ye(e.type,!1);case 11:return Ye(e.type.render,!1);case 1:return Ye(e.type,!0);case 31:return ge("Activity");default:return""}}function Ae(e){try{var t="",s=null;do t+=ke(e,s),s=e,e=e.return;while(e);return t}catch(a){return`
7
+ Error generating stack: `+a.message+`
8
+ `+a.stack}}var ve=Object.prototype.hasOwnProperty,Ue=n.unstable_scheduleCallback,Pe=n.unstable_cancelCallback,Ie=n.unstable_shouldYield,ee=n.unstable_requestPaint,U=n.unstable_now,$=n.unstable_getCurrentPriorityLevel,je=n.unstable_ImmediatePriority,xe=n.unstable_UserBlockingPriority,ae=n.unstable_NormalPriority,Re=n.unstable_LowPriority,He=n.unstable_IdlePriority,We=n.log,pt=n.unstable_setDisableYieldValue,_t=null,mt=null;function Tt(e){if(typeof We=="function"&&pt(e),mt&&typeof mt.setStrictMode=="function")try{mt.setStrictMode(_t,e)}catch{}}var Rt=Math.clz32?Math.clz32:Se,zt=Math.log,Te=Math.LN2;function Se(e){return e>>>=0,e===0?32:31-(zt(e)/Te|0)|0}var Fe=256,Ot=262144,Pt=4194304;function ne(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function be(e,t,s){var a=e.pendingLanes;if(a===0)return 0;var u=0,f=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var R=a&134217727;return R!==0?(a=R&~f,a!==0?u=ne(a):(y&=R,y!==0?u=ne(y):s||(s=R&~e,s!==0&&(u=ne(s))))):(R=a&~f,R!==0?u=ne(R):y!==0?u=ne(y):s||(s=a&~e,s!==0&&(u=ne(s)))),u===0?0:t!==0&&t!==u&&(t&f)===0&&(f=u&-u,s=t&-t,f>=s||f===32&&(s&4194048)!==0)?t:u}function Oe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ze(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function nt(){var e=Pt;return Pt<<=1,(Pt&62914560)===0&&(Pt=4194304),e}function at(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function ot(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qt(e,t,s,a,u,f){var y=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var R=e.entanglements,X=e.expirationTimes,ue=e.hiddenUpdates;for(s=y&~s;0<s;){var ye=31-Rt(s),Ne=1<<ye;R[ye]=0,X[ye]=-1;var fe=ue[ye];if(fe!==null)for(ue[ye]=null,ye=0;ye<fe.length;ye++){var he=fe[ye];he!==null&&(he.lane&=-536870913)}s&=~Ne}a!==0&&$n(e,a,0),f!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=f&~(y&~t))}function $n(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-Rt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|s&261930}function Zt(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var a=31-Rt(s),u=1<<a;u&t|e[a]&t&&(e[a]|=t),s&=~u}}function pn(e,t){var s=t&-t;return s=(s&42)!==0?1:uo(s),(s&(e.suspendedLanes|t))!==0?0:s}function uo(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ln(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function As(){var e=D.p;return e!==0?e:(e=window.event,e===void 0?32:Mb(e.type))}function ni(e,t){var s=D.p;try{return D.p=e,t()}finally{D.p=s}}var ps=Math.random().toString(36).slice(2),on="__reactFiber$"+ps,wn="__reactProps$"+ps,kr="__reactContainer$"+ps,bu="__reactEvents$"+ps,zS="__reactListeners$"+ps,LS="__reactHandles$"+ps,Kp="__reactResources$"+ps,ka="__reactMarker$"+ps;function yu(e){delete e[on],delete e[wn],delete e[bu],delete e[zS],delete e[LS]}function _r(e){var t=e[on];if(t)return t;for(var s=e.parentNode;s;){if(t=s[kr]||s[on]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=gb(e);e!==null;){if(s=e[on])return s;e=gb(e)}return t}e=s,s=e.parentNode}return null}function Mr(e){if(e=e[on]||e[kr]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function _a(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function Ar(e){var t=e[Kp];return t||(t=e[Kp]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function cn(e){e[ka]=!0}var Qp=new Set,Zp={};function Go(e,t){Dr(e,t),Dr(e+"Capture",t)}function Dr(e,t){for(Zp[e]=t,e=0;e<t.length;e++)Qp.add(t[e])}var IS=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Jp={},Wp={};function BS(e){return ve.call(Wp,e)?!0:ve.call(Jp,e)?!1:IS.test(e)?Wp[e]=!0:(Jp[e]=!0,!1)}function si(e,t,s){if(BS(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var a=t.toLowerCase().slice(0,5);if(a!=="data-"&&a!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function oi(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Ds(e,t,s,a){if(a===null)e.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+a)}}function Xn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function eh(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function US(e,t,s){var a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var u=a.get,f=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(y){s=""+y,f.call(this,y)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return s},setValue:function(y){s=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function vu(e){if(!e._valueTracker){var t=eh(e)?"checked":"value";e._valueTracker=US(e,t,""+e[t])}}function th(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),a="";return e&&(a=eh(e)?e.checked?"true":"false":e.value),e=a,e!==s?(t.setValue(e),!0):!1}function ri(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var HS=/[\n"\\]/g;function Kn(e){return e.replace(HS,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Su(e,t,s,a,u,f,y,R){e.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.type=y:e.removeAttribute("type"),t!=null?y==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Xn(t)):e.value!==""+Xn(t)&&(e.value=""+Xn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?Eu(e,y,Xn(t)):s!=null?Eu(e,y,Xn(s)):a!=null&&e.removeAttribute("value"),u==null&&f!=null&&(e.defaultChecked=!!f),u!=null&&(e.checked=u&&typeof u!="function"&&typeof u!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Xn(R):e.removeAttribute("name")}function nh(e,t,s,a,u,f,y,R){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(e.type=f),t!=null||s!=null){if(!(f!=="submit"&&f!=="reset"||t!=null)){vu(e);return}s=s!=null?""+Xn(s):"",t=t!=null?""+Xn(t):s,R||t===e.value||(e.value=t),e.defaultValue=t}a=a??u,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=R?e.checked:!!a,e.defaultChecked=!!a,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),vu(e)}function Eu(e,t,s){t==="number"&&ri(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function zr(e,t,s,a){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&a&&(e[s].defaultSelected=!0)}else{for(s=""+Xn(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,a&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function sh(e,t,s){if(t!=null&&(t=""+Xn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+Xn(s):""}function oh(e,t,s,a){if(t==null){if(a!=null){if(s!=null)throw Error(l(92));if(K(a)){if(1<a.length)throw Error(l(93));a=a[0]}s=a}s==null&&(s=""),t=s}s=Xn(t),e.defaultValue=s,a=e.textContent,a===s&&a!==""&&a!==null&&(e.value=a),vu(e)}function Lr(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var PS=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function rh(e,t,s){var a=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?a?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":a?e.setProperty(t,s):typeof s!="number"||s===0||PS.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function ah(e,t,s){if(t!=null&&typeof t!="object")throw Error(l(62));if(e=e.style,s!=null){for(var a in s)!s.hasOwnProperty(a)||t!=null&&t.hasOwnProperty(a)||(a.indexOf("--")===0?e.setProperty(a,""):a==="float"?e.cssFloat="":e[a]="");for(var u in t)a=t[u],t.hasOwnProperty(u)&&s[u]!==a&&rh(e,u,a)}else for(var f in t)t.hasOwnProperty(f)&&rh(e,f,t[f])}function Nu(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var YS=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),VS=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ai(e){return VS.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function zs(){}var ju=null;function Tu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ir=null,Br=null;function lh(e){var t=Mr(e);if(t&&(e=t.stateNode)){var s=e[wn]||null;e:switch(e=t.stateNode,t.type){case"input":if(Su(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+Kn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var a=s[t];if(a!==e&&a.form===e.form){var u=a[wn]||null;if(!u)throw Error(l(90));Su(a,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(t=0;t<s.length;t++)a=s[t],a.form===e.form&&th(a)}break e;case"textarea":sh(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&zr(e,!!s.multiple,t,!1)}}}var wu=!1;function ih(e,t,s){if(wu)return e(t,s);wu=!0;try{var a=e(t);return a}finally{if(wu=!1,(Ir!==null||Br!==null)&&($i(),Ir&&(t=Ir,e=Br,Br=Ir=null,lh(t),e)))for(t=0;t<e.length;t++)lh(e[t])}}function Ma(e,t){var s=e.stateNode;if(s===null)return null;var a=s[wn]||null;if(a===null)return null;s=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(l(231,t,typeof s));return s}var Ls=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cu=!1;if(Ls)try{var Aa={};Object.defineProperty(Aa,"passive",{get:function(){Cu=!0}}),window.addEventListener("test",Aa,Aa),window.removeEventListener("test",Aa,Aa)}catch{Cu=!1}var fo=null,Ru=null,li=null;function ch(){if(li)return li;var e,t=Ru,s=t.length,a,u="value"in fo?fo.value:fo.textContent,f=u.length;for(e=0;e<s&&t[e]===u[e];e++);var y=s-e;for(a=1;a<=y&&t[s-a]===u[f-a];a++);return li=u.slice(e,1<a?1-a:void 0)}function ii(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ci(){return!0}function uh(){return!1}function Cn(e){function t(s,a,u,f,y){this._reactName=s,this._targetInst=u,this.type=a,this.nativeEvent=f,this.target=y,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(s=e[R],this[R]=s?s(f):f[R]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?ci:uh,this.isPropagationStopped=uh,this}return x(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=ci)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=ci)},persist:function(){},isPersistent:ci}),t}var qo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ui=Cn(qo),Da=x({},qo,{view:0,detail:0}),FS=Cn(Da),Ou,ku,za,di=x({},Da,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mu,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==za&&(za&&e.type==="mousemove"?(Ou=e.screenX-za.screenX,ku=e.screenY-za.screenY):ku=Ou=0,za=e),Ou)},movementY:function(e){return"movementY"in e?e.movementY:ku}}),dh=Cn(di),GS=x({},di,{dataTransfer:0}),qS=Cn(GS),$S=x({},Da,{relatedTarget:0}),_u=Cn($S),XS=x({},qo,{animationName:0,elapsedTime:0,pseudoElement:0}),KS=Cn(XS),QS=x({},qo,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ZS=Cn(QS),JS=x({},qo,{data:0}),fh=Cn(JS),WS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},eE={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},tE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nE(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tE[e])?!!t[e]:!1}function Mu(){return nE}var sE=x({},Da,{key:function(e){if(e.key){var t=WS[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ii(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?eE[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mu,charCode:function(e){return e.type==="keypress"?ii(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ii(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),oE=Cn(sE),rE=x({},di,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mh=Cn(rE),aE=x({},Da,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mu}),lE=Cn(aE),iE=x({},qo,{propertyName:0,elapsedTime:0,pseudoElement:0}),cE=Cn(iE),uE=x({},di,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),dE=Cn(uE),fE=x({},qo,{newState:0,oldState:0}),mE=Cn(fE),pE=[9,13,27,32],Au=Ls&&"CompositionEvent"in window,La=null;Ls&&"documentMode"in document&&(La=document.documentMode);var hE=Ls&&"TextEvent"in window&&!La,ph=Ls&&(!Au||La&&8<La&&11>=La),hh=" ",gh=!1;function xh(e,t){switch(e){case"keyup":return pE.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ur=!1;function gE(e,t){switch(e){case"compositionend":return bh(t);case"keypress":return t.which!==32?null:(gh=!0,hh);case"textInput":return e=t.data,e===hh&&gh?null:e;default:return null}}function xE(e,t){if(Ur)return e==="compositionend"||!Au&&xh(e,t)?(e=ch(),li=Ru=fo=null,Ur=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return ph&&t.locale!=="ko"?null:t.data;default:return null}}var bE={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function yh(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!bE[e.type]:t==="textarea"}function vh(e,t,s,a){Ir?Br?Br.push(a):Br=[a]:Ir=a,t=ec(t,"onChange"),0<t.length&&(s=new ui("onChange","change",null,s,a),e.push({event:s,listeners:t}))}var Ia=null,Ba=null;function yE(e){nb(e,0)}function fi(e){var t=_a(e);if(th(t))return e}function Sh(e,t){if(e==="change")return t}var Eh=!1;if(Ls){var Du;if(Ls){var zu="oninput"in document;if(!zu){var Nh=document.createElement("div");Nh.setAttribute("oninput","return;"),zu=typeof Nh.oninput=="function"}Du=zu}else Du=!1;Eh=Du&&(!document.documentMode||9<document.documentMode)}function jh(){Ia&&(Ia.detachEvent("onpropertychange",Th),Ba=Ia=null)}function Th(e){if(e.propertyName==="value"&&fi(Ba)){var t=[];vh(t,Ba,e,Tu(e)),ih(yE,t)}}function vE(e,t,s){e==="focusin"?(jh(),Ia=t,Ba=s,Ia.attachEvent("onpropertychange",Th)):e==="focusout"&&jh()}function SE(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return fi(Ba)}function EE(e,t){if(e==="click")return fi(t)}function NE(e,t){if(e==="input"||e==="change")return fi(t)}function jE(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var In=typeof Object.is=="function"?Object.is:jE;function Ua(e,t){if(In(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(a=0;a<s.length;a++){var u=s[a];if(!ve.call(t,u)||!In(e[u],t[u]))return!1}return!0}function wh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ch(e,t){var s=wh(e);e=0;for(var a;s;){if(s.nodeType===3){if(a=e+s.textContent.length,e<=t&&a>=t)return{node:s,offset:t-e};e=a}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=wh(s)}}function Rh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Rh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Oh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ri(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=ri(e.document)}return t}function Lu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var TE=Ls&&"documentMode"in document&&11>=document.documentMode,Hr=null,Iu=null,Ha=null,Bu=!1;function kh(e,t,s){var a=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Bu||Hr==null||Hr!==ri(a)||(a=Hr,"selectionStart"in a&&Lu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Ha&&Ua(Ha,a)||(Ha=a,a=ec(Iu,"onSelect"),0<a.length&&(t=new ui("onSelect","select",null,t,s),e.push({event:t,listeners:a}),t.target=Hr)))}function $o(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Pr={animationend:$o("Animation","AnimationEnd"),animationiteration:$o("Animation","AnimationIteration"),animationstart:$o("Animation","AnimationStart"),transitionrun:$o("Transition","TransitionRun"),transitionstart:$o("Transition","TransitionStart"),transitioncancel:$o("Transition","TransitionCancel"),transitionend:$o("Transition","TransitionEnd")},Uu={},_h={};Ls&&(_h=document.createElement("div").style,"AnimationEvent"in window||(delete Pr.animationend.animation,delete Pr.animationiteration.animation,delete Pr.animationstart.animation),"TransitionEvent"in window||delete Pr.transitionend.transition);function Xo(e){if(Uu[e])return Uu[e];if(!Pr[e])return e;var t=Pr[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in _h)return Uu[e]=t[s];return e}var Mh=Xo("animationend"),Ah=Xo("animationiteration"),Dh=Xo("animationstart"),wE=Xo("transitionrun"),CE=Xo("transitionstart"),RE=Xo("transitioncancel"),zh=Xo("transitionend"),Lh=new Map,Hu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Hu.push("scrollEnd");function cs(e,t){Lh.set(e,t),Go(t,[e])}var mi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Qn=[],Yr=0,Pu=0;function pi(){for(var e=Yr,t=Pu=Yr=0;t<e;){var s=Qn[t];Qn[t++]=null;var a=Qn[t];Qn[t++]=null;var u=Qn[t];Qn[t++]=null;var f=Qn[t];if(Qn[t++]=null,a!==null&&u!==null){var y=a.pending;y===null?u.next=u:(u.next=y.next,y.next=u),a.pending=u}f!==0&&Ih(s,u,f)}}function hi(e,t,s,a){Qn[Yr++]=e,Qn[Yr++]=t,Qn[Yr++]=s,Qn[Yr++]=a,Pu|=a,e.lanes|=a,e=e.alternate,e!==null&&(e.lanes|=a)}function Yu(e,t,s,a){return hi(e,t,s,a),gi(e)}function Ko(e,t){return hi(e,null,null,t),gi(e)}function Ih(e,t,s){e.lanes|=s;var a=e.alternate;a!==null&&(a.lanes|=s);for(var u=!1,f=e.return;f!==null;)f.childLanes|=s,a=f.alternate,a!==null&&(a.childLanes|=s),f.tag===22&&(e=f.stateNode,e===null||e._visibility&1||(u=!0)),e=f,f=f.return;return e.tag===3?(f=e.stateNode,u&&t!==null&&(u=31-Rt(s),e=f.hiddenUpdates,a=e[u],a===null?e[u]=[t]:a.push(t),t.lane=s|536870912),f):null}function gi(e){if(50<il)throw il=0,Zd=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Vr={};function OE(e,t,s,a){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bn(e,t,s,a){return new OE(e,t,s,a)}function Vu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Is(e,t){var s=e.alternate;return s===null?(s=Bn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function Bh(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function xi(e,t,s,a,u,f){var y=0;if(a=e,typeof e=="function")Vu(e)&&(y=1);else if(typeof e=="string")y=DN(e,s,Y.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case J:return e=Bn(31,s,t,u),e.elementType=J,e.lanes=f,e;case _:return Qo(s.children,u,f,t);case O:y=8,u|=24;break;case N:return e=Bn(12,s,t,u|2),e.elementType=N,e.lanes=f,e;case H:return e=Bn(13,s,t,u),e.elementType=H,e.lanes=f,e;case M:return e=Bn(19,s,t,u),e.elementType=M,e.lanes=f,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case k:y=10;break e;case T:y=9;break e;case C:y=11;break e;case L:y=14;break e;case w:y=16,a=null;break e}y=29,s=Error(l(130,e===null?"null":typeof e,"")),a=null}return t=Bn(y,s,t,u),t.elementType=e,t.type=a,t.lanes=f,t}function Qo(e,t,s,a){return e=Bn(7,e,a,t),e.lanes=s,e}function Fu(e,t,s){return e=Bn(6,e,null,t),e.lanes=s,e}function Uh(e){var t=Bn(18,null,null,0);return t.stateNode=e,t}function Gu(e,t,s){return t=Bn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Hh=new WeakMap;function Zn(e,t){if(typeof e=="object"&&e!==null){var s=Hh.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Ae(t)},Hh.set(e,t),t)}return{value:e,source:t,stack:Ae(t)}}var Fr=[],Gr=0,bi=null,Pa=0,Jn=[],Wn=0,mo=null,hs=1,gs="";function Bs(e,t){Fr[Gr++]=Pa,Fr[Gr++]=bi,bi=e,Pa=t}function Ph(e,t,s){Jn[Wn++]=hs,Jn[Wn++]=gs,Jn[Wn++]=mo,mo=e;var a=hs;e=gs;var u=32-Rt(a)-1;a&=~(1<<u),s+=1;var f=32-Rt(t)+u;if(30<f){var y=u-u%5;f=(a&(1<<y)-1).toString(32),a>>=y,u-=y,hs=1<<32-Rt(t)+u|s<<u|a,gs=f+e}else hs=1<<f|s<<u|a,gs=e}function qu(e){e.return!==null&&(Bs(e,1),Ph(e,1,0))}function $u(e){for(;e===bi;)bi=Fr[--Gr],Fr[Gr]=null,Pa=Fr[--Gr],Fr[Gr]=null;for(;e===mo;)mo=Jn[--Wn],Jn[Wn]=null,gs=Jn[--Wn],Jn[Wn]=null,hs=Jn[--Wn],Jn[Wn]=null}function Yh(e,t){Jn[Wn++]=hs,Jn[Wn++]=gs,Jn[Wn++]=mo,hs=t.id,gs=t.overflow,mo=e}var hn=null,Ft=null,Et=!1,po=null,es=!1,Xu=Error(l(519));function ho(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ya(Zn(t,e)),Xu}function Vh(e){var t=e.stateNode,s=e.type,a=e.memoizedProps;switch(t[on]=e,t[wn]=a,s){case"dialog":gt("cancel",t),gt("close",t);break;case"iframe":case"object":case"embed":gt("load",t);break;case"video":case"audio":for(s=0;s<ul.length;s++)gt(ul[s],t);break;case"source":gt("error",t);break;case"img":case"image":case"link":gt("error",t),gt("load",t);break;case"details":gt("toggle",t);break;case"input":gt("invalid",t),nh(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":gt("invalid",t);break;case"textarea":gt("invalid",t),oh(t,a.value,a.defaultValue,a.children)}s=a.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||a.suppressHydrationWarning===!0||ab(t.textContent,s)?(a.popover!=null&&(gt("beforetoggle",t),gt("toggle",t)),a.onScroll!=null&&gt("scroll",t),a.onScrollEnd!=null&&gt("scrollend",t),a.onClick!=null&&(t.onclick=zs),t=!0):t=!1,t||ho(e,!0)}function Fh(e){for(hn=e.return;hn;)switch(hn.tag){case 5:case 31:case 13:es=!1;return;case 27:case 3:es=!0;return;default:hn=hn.return}}function qr(e){if(e!==hn)return!1;if(!Et)return Fh(e),Et=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||mf(e.type,e.memoizedProps)),s=!s),s&&Ft&&ho(e),Fh(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ft=hb(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ft=hb(e)}else t===27?(t=Ft,Oo(e.type)?(e=bf,bf=null,Ft=e):Ft=t):Ft=hn?ns(e.stateNode.nextSibling):null;return!0}function Zo(){Ft=hn=null,Et=!1}function Ku(){var e=po;return e!==null&&(_n===null?_n=e:_n.push.apply(_n,e),po=null),e}function Ya(e){po===null?po=[e]:po.push(e)}var Qu=z(null),Jo=null,Us=null;function go(e,t,s){F(Qu,t._currentValue),t._currentValue=s}function Hs(e){e._currentValue=Qu.current,Z(Qu)}function Zu(e,t,s){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===s)break;e=e.return}}function Ju(e,t,s,a){var u=e.child;for(u!==null&&(u.return=e);u!==null;){var f=u.dependencies;if(f!==null){var y=u.child;f=f.firstContext;e:for(;f!==null;){var R=f;f=u;for(var X=0;X<t.length;X++)if(R.context===t[X]){f.lanes|=s,R=f.alternate,R!==null&&(R.lanes|=s),Zu(f.return,s,e),a||(y=null);break e}f=R.next}}else if(u.tag===18){if(y=u.return,y===null)throw Error(l(341));y.lanes|=s,f=y.alternate,f!==null&&(f.lanes|=s),Zu(y,s,e),y=null}else y=u.child;if(y!==null)y.return=u;else for(y=u;y!==null;){if(y===e){y=null;break}if(u=y.sibling,u!==null){u.return=y.return,y=u;break}y=y.return}u=y}}function $r(e,t,s,a){e=null;for(var u=t,f=!1;u!==null;){if(!f){if((u.flags&524288)!==0)f=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var y=u.alternate;if(y===null)throw Error(l(387));if(y=y.memoizedProps,y!==null){var R=u.type;In(u.pendingProps.value,y.value)||(e!==null?e.push(R):e=[R])}}else if(u===me.current){if(y=u.alternate,y===null)throw Error(l(387));y.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(hl):e=[hl])}u=u.return}e!==null&&Ju(t,e,s,a),t.flags|=262144}function yi(e){for(e=e.firstContext;e!==null;){if(!In(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wo(e){Jo=e,Us=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function gn(e){return Gh(Jo,e)}function vi(e,t){return Jo===null&&Wo(e),Gh(e,t)}function Gh(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Us===null){if(e===null)throw Error(l(308));Us=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Us=Us.next=t;return s}var kE=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,a){e.push(a)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},_E=n.unstable_scheduleCallback,ME=n.unstable_NormalPriority,en={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wu(){return{controller:new kE,data:new Map,refCount:0}}function Va(e){e.refCount--,e.refCount===0&&_E(ME,function(){e.controller.abort()})}var Fa=null,ed=0,Xr=0,Kr=null;function AE(e,t){if(Fa===null){var s=Fa=[];ed=0,Xr=sf(),Kr={status:"pending",value:void 0,then:function(a){s.push(a)}}}return ed++,t.then(qh,qh),t}function qh(){if(--ed===0&&Fa!==null){Kr!==null&&(Kr.status="fulfilled");var e=Fa;Fa=null,Xr=0,Kr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function DE(e,t){var s=[],a={status:"pending",value:null,reason:null,then:function(u){s.push(u)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var u=0;u<s.length;u++)(0,s[u])(t)},function(u){for(a.status="rejected",a.reason=u,u=0;u<s.length;u++)(0,s[u])(void 0)}),a}var $h=A.S;A.S=function(e,t){kx=U(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&AE(e,t),$h!==null&&$h(e,t)};var er=z(null);function td(){var e=er.current;return e!==null?e:Ht.pooledCache}function Si(e,t){t===null?F(er,er.current):F(er,t.pool)}function Xh(){var e=td();return e===null?null:{parent:en._currentValue,pool:e}}var Qr=Error(l(460)),nd=Error(l(474)),Ei=Error(l(542)),Ni={then:function(){}};function Kh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Qh(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(zs,zs),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Jh(e),e;default:if(typeof t.status=="string")t.then(zs,zs);else{if(e=Ht,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=t,e.status="pending",e.then(function(a){if(t.status==="pending"){var u=t;u.status="fulfilled",u.value=a}},function(a){if(t.status==="pending"){var u=t;u.status="rejected",u.reason=a}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Jh(e),e}throw nr=t,Qr}}function tr(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(nr=s,Qr):s}}var nr=null;function Zh(){if(nr===null)throw Error(l(459));var e=nr;return nr=null,e}function Jh(e){if(e===Qr||e===Ei)throw Error(l(483))}var Zr=null,Ga=0;function ji(e){var t=Ga;return Ga+=1,Zr===null&&(Zr=[]),Qh(Zr,e,t)}function qa(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ti(e,t){throw t.$$typeof===S?Error(l(525)):(e=Object.prototype.toString.call(t),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Wh(e){function t(se,W){if(e){var ce=se.deletions;ce===null?(se.deletions=[W],se.flags|=16):ce.push(W)}}function s(se,W){if(!e)return null;for(;W!==null;)t(se,W),W=W.sibling;return null}function a(se){for(var W=new Map;se!==null;)se.key!==null?W.set(se.key,se):W.set(se.index,se),se=se.sibling;return W}function u(se,W){return se=Is(se,W),se.index=0,se.sibling=null,se}function f(se,W,ce){return se.index=ce,e?(ce=se.alternate,ce!==null?(ce=ce.index,ce<W?(se.flags|=67108866,W):ce):(se.flags|=67108866,W)):(se.flags|=1048576,W)}function y(se){return e&&se.alternate===null&&(se.flags|=67108866),se}function R(se,W,ce,Ee){return W===null||W.tag!==6?(W=Fu(ce,se.mode,Ee),W.return=se,W):(W=u(W,ce),W.return=se,W)}function X(se,W,ce,Ee){var Je=ce.type;return Je===_?ye(se,W,ce.props.children,Ee,ce.key):W!==null&&(W.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===w&&tr(Je)===W.type)?(W=u(W,ce.props),qa(W,ce),W.return=se,W):(W=xi(ce.type,ce.key,ce.props,null,se.mode,Ee),qa(W,ce),W.return=se,W)}function ue(se,W,ce,Ee){return W===null||W.tag!==4||W.stateNode.containerInfo!==ce.containerInfo||W.stateNode.implementation!==ce.implementation?(W=Gu(ce,se.mode,Ee),W.return=se,W):(W=u(W,ce.children||[]),W.return=se,W)}function ye(se,W,ce,Ee,Je){return W===null||W.tag!==7?(W=Qo(ce,se.mode,Ee,Je),W.return=se,W):(W=u(W,ce),W.return=se,W)}function Ne(se,W,ce){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Fu(""+W,se.mode,ce),W.return=se,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case j:return ce=xi(W.type,W.key,W.props,null,se.mode,ce),qa(ce,W),ce.return=se,ce;case E:return W=Gu(W,se.mode,ce),W.return=se,W;case w:return W=tr(W),Ne(se,W,ce)}if(K(W)||te(W))return W=Qo(W,se.mode,ce,null),W.return=se,W;if(typeof W.then=="function")return Ne(se,ji(W),ce);if(W.$$typeof===k)return Ne(se,vi(se,W),ce);Ti(se,W)}return null}function fe(se,W,ce,Ee){var Je=W!==null?W.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return Je!==null?null:R(se,W,""+ce,Ee);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case j:return ce.key===Je?X(se,W,ce,Ee):null;case E:return ce.key===Je?ue(se,W,ce,Ee):null;case w:return ce=tr(ce),fe(se,W,ce,Ee)}if(K(ce)||te(ce))return Je!==null?null:ye(se,W,ce,Ee,null);if(typeof ce.then=="function")return fe(se,W,ji(ce),Ee);if(ce.$$typeof===k)return fe(se,W,vi(se,ce),Ee);Ti(se,ce)}return null}function he(se,W,ce,Ee,Je){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return se=se.get(ce)||null,R(W,se,""+Ee,Je);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case j:return se=se.get(Ee.key===null?ce:Ee.key)||null,X(W,se,Ee,Je);case E:return se=se.get(Ee.key===null?ce:Ee.key)||null,ue(W,se,Ee,Je);case w:return Ee=tr(Ee),he(se,W,ce,Ee,Je)}if(K(Ee)||te(Ee))return se=se.get(ce)||null,ye(W,se,Ee,Je,null);if(typeof Ee.then=="function")return he(se,W,ce,ji(Ee),Je);if(Ee.$$typeof===k)return he(se,W,ce,vi(W,Ee),Je);Ti(W,Ee)}return null}function $e(se,W,ce,Ee){for(var Je=null,wt=null,Xe=W,dt=W=0,yt=null;Xe!==null&&dt<ce.length;dt++){Xe.index>dt?(yt=Xe,Xe=null):yt=Xe.sibling;var Ct=fe(se,Xe,ce[dt],Ee);if(Ct===null){Xe===null&&(Xe=yt);break}e&&Xe&&Ct.alternate===null&&t(se,Xe),W=f(Ct,W,dt),wt===null?Je=Ct:wt.sibling=Ct,wt=Ct,Xe=yt}if(dt===ce.length)return s(se,Xe),Et&&Bs(se,dt),Je;if(Xe===null){for(;dt<ce.length;dt++)Xe=Ne(se,ce[dt],Ee),Xe!==null&&(W=f(Xe,W,dt),wt===null?Je=Xe:wt.sibling=Xe,wt=Xe);return Et&&Bs(se,dt),Je}for(Xe=a(Xe);dt<ce.length;dt++)yt=he(Xe,se,dt,ce[dt],Ee),yt!==null&&(e&&yt.alternate!==null&&Xe.delete(yt.key===null?dt:yt.key),W=f(yt,W,dt),wt===null?Je=yt:wt.sibling=yt,wt=yt);return e&&Xe.forEach(function(Do){return t(se,Do)}),Et&&Bs(se,dt),Je}function et(se,W,ce,Ee){if(ce==null)throw Error(l(151));for(var Je=null,wt=null,Xe=W,dt=W=0,yt=null,Ct=ce.next();Xe!==null&&!Ct.done;dt++,Ct=ce.next()){Xe.index>dt?(yt=Xe,Xe=null):yt=Xe.sibling;var Do=fe(se,Xe,Ct.value,Ee);if(Do===null){Xe===null&&(Xe=yt);break}e&&Xe&&Do.alternate===null&&t(se,Xe),W=f(Do,W,dt),wt===null?Je=Do:wt.sibling=Do,wt=Do,Xe=yt}if(Ct.done)return s(se,Xe),Et&&Bs(se,dt),Je;if(Xe===null){for(;!Ct.done;dt++,Ct=ce.next())Ct=Ne(se,Ct.value,Ee),Ct!==null&&(W=f(Ct,W,dt),wt===null?Je=Ct:wt.sibling=Ct,wt=Ct);return Et&&Bs(se,dt),Je}for(Xe=a(Xe);!Ct.done;dt++,Ct=ce.next())Ct=he(Xe,se,dt,Ct.value,Ee),Ct!==null&&(e&&Ct.alternate!==null&&Xe.delete(Ct.key===null?dt:Ct.key),W=f(Ct,W,dt),wt===null?Je=Ct:wt.sibling=Ct,wt=Ct);return e&&Xe.forEach(function(GN){return t(se,GN)}),Et&&Bs(se,dt),Je}function Bt(se,W,ce,Ee){if(typeof ce=="object"&&ce!==null&&ce.type===_&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case j:e:{for(var Je=ce.key;W!==null;){if(W.key===Je){if(Je=ce.type,Je===_){if(W.tag===7){s(se,W.sibling),Ee=u(W,ce.props.children),Ee.return=se,se=Ee;break e}}else if(W.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===w&&tr(Je)===W.type){s(se,W.sibling),Ee=u(W,ce.props),qa(Ee,ce),Ee.return=se,se=Ee;break e}s(se,W);break}else t(se,W);W=W.sibling}ce.type===_?(Ee=Qo(ce.props.children,se.mode,Ee,ce.key),Ee.return=se,se=Ee):(Ee=xi(ce.type,ce.key,ce.props,null,se.mode,Ee),qa(Ee,ce),Ee.return=se,se=Ee)}return y(se);case E:e:{for(Je=ce.key;W!==null;){if(W.key===Je)if(W.tag===4&&W.stateNode.containerInfo===ce.containerInfo&&W.stateNode.implementation===ce.implementation){s(se,W.sibling),Ee=u(W,ce.children||[]),Ee.return=se,se=Ee;break e}else{s(se,W);break}else t(se,W);W=W.sibling}Ee=Gu(ce,se.mode,Ee),Ee.return=se,se=Ee}return y(se);case w:return ce=tr(ce),Bt(se,W,ce,Ee)}if(K(ce))return $e(se,W,ce,Ee);if(te(ce)){if(Je=te(ce),typeof Je!="function")throw Error(l(150));return ce=Je.call(ce),et(se,W,ce,Ee)}if(typeof ce.then=="function")return Bt(se,W,ji(ce),Ee);if(ce.$$typeof===k)return Bt(se,W,vi(se,ce),Ee);Ti(se,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,W!==null&&W.tag===6?(s(se,W.sibling),Ee=u(W,ce),Ee.return=se,se=Ee):(s(se,W),Ee=Fu(ce,se.mode,Ee),Ee.return=se,se=Ee),y(se)):s(se,W)}return function(se,W,ce,Ee){try{Ga=0;var Je=Bt(se,W,ce,Ee);return Zr=null,Je}catch(Xe){if(Xe===Qr||Xe===Ei)throw Xe;var wt=Bn(29,Xe,null,se.mode);return wt.lanes=Ee,wt.return=se,wt}}}var sr=Wh(!0),eg=Wh(!1),xo=!1;function sd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function od(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function yo(e,t,s){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(kt&2)!==0){var u=a.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),a.pending=t,t=gi(e),Ih(e,null,s),t}return hi(e,a,t,s),gi(e)}function $a(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,s|=a,t.lanes=s,Zt(e,s)}}function rd(e,t){var s=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,s===a)){var u=null,f=null;if(s=s.firstBaseUpdate,s!==null){do{var y={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};f===null?u=f=y:f=f.next=y,s=s.next}while(s!==null);f===null?u=f=t:f=f.next=t}else u=f=t;s={baseState:a.baseState,firstBaseUpdate:u,lastBaseUpdate:f,shared:a.shared,callbacks:a.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var ad=!1;function Xa(){if(ad){var e=Kr;if(e!==null)throw e}}function Ka(e,t,s,a){ad=!1;var u=e.updateQueue;xo=!1;var f=u.firstBaseUpdate,y=u.lastBaseUpdate,R=u.shared.pending;if(R!==null){u.shared.pending=null;var X=R,ue=X.next;X.next=null,y===null?f=ue:y.next=ue,y=X;var ye=e.alternate;ye!==null&&(ye=ye.updateQueue,R=ye.lastBaseUpdate,R!==y&&(R===null?ye.firstBaseUpdate=ue:R.next=ue,ye.lastBaseUpdate=X))}if(f!==null){var Ne=u.baseState;y=0,ye=ue=X=null,R=f;do{var fe=R.lane&-536870913,he=fe!==R.lane;if(he?(bt&fe)===fe:(a&fe)===fe){fe!==0&&fe===Xr&&(ad=!0),ye!==null&&(ye=ye.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var $e=e,et=R;fe=t;var Bt=s;switch(et.tag){case 1:if($e=et.payload,typeof $e=="function"){Ne=$e.call(Bt,Ne,fe);break e}Ne=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=et.payload,fe=typeof $e=="function"?$e.call(Bt,Ne,fe):$e,fe==null)break e;Ne=x({},Ne,fe);break e;case 2:xo=!0}}fe=R.callback,fe!==null&&(e.flags|=64,he&&(e.flags|=8192),he=u.callbacks,he===null?u.callbacks=[fe]:he.push(fe))}else he={lane:fe,tag:R.tag,payload:R.payload,callback:R.callback,next:null},ye===null?(ue=ye=he,X=Ne):ye=ye.next=he,y|=fe;if(R=R.next,R===null){if(R=u.shared.pending,R===null)break;he=R,R=he.next,he.next=null,u.lastBaseUpdate=he,u.shared.pending=null}}while(!0);ye===null&&(X=Ne),u.baseState=X,u.firstBaseUpdate=ue,u.lastBaseUpdate=ye,f===null&&(u.shared.lanes=0),jo|=y,e.lanes=y,e.memoizedState=Ne}}function tg(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function ng(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)tg(s[e],t)}var Jr=z(null),wi=z(0);function sg(e,t){e=Ks,F(wi,e),F(Jr,t),Ks=e|t.baseLanes}function ld(){F(wi,Ks),F(Jr,Jr.current)}function id(){Ks=wi.current,Z(Jr),Z(wi)}var Un=z(null),ts=null;function vo(e){var t=e.alternate;F(Jt,Jt.current&1),F(Un,e),ts===null&&(t===null||Jr.current!==null||t.memoizedState!==null)&&(ts=e)}function cd(e){F(Jt,Jt.current),F(Un,e),ts===null&&(ts=e)}function og(e){e.tag===22?(F(Jt,Jt.current),F(Un,e),ts===null&&(ts=e)):So()}function So(){F(Jt,Jt.current),F(Un,Un.current)}function Hn(e){Z(Un),ts===e&&(ts=null),Z(Jt)}var Jt=z(0);function Ci(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||gf(s)||xf(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ps=0,ct=null,Lt=null,tn=null,Ri=!1,Wr=!1,or=!1,Oi=0,Qa=0,ea=null,zE=0;function Xt(){throw Error(l(321))}function ud(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!In(e[s],t[s]))return!1;return!0}function dd(e,t,s,a,u,f){return Ps=f,ct=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,A.H=e===null||e.memoizedState===null?Pg:wd,or=!1,f=s(a,u),or=!1,Wr&&(f=ag(t,s,a,u)),rg(e),f}function rg(e){A.H=Wa;var t=Lt!==null&&Lt.next!==null;if(Ps=0,tn=Lt=ct=null,Ri=!1,Qa=0,ea=null,t)throw Error(l(300));e===null||nn||(e=e.dependencies,e!==null&&yi(e)&&(nn=!0))}function ag(e,t,s,a){ct=e;var u=0;do{if(Wr&&(ea=null),Qa=0,Wr=!1,25<=u)throw Error(l(301));if(u+=1,tn=Lt=null,e.updateQueue!=null){var f=e.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}A.H=Yg,f=t(s,a)}while(Wr);return f}function LE(){var e=A.H,t=e.useState()[0];return t=typeof t.then=="function"?Za(t):t,e=e.useState()[0],(Lt!==null?Lt.memoizedState:null)!==e&&(ct.flags|=1024),t}function fd(){var e=Oi!==0;return Oi=0,e}function md(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function pd(e){if(Ri){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ri=!1}Ps=0,tn=Lt=ct=null,Wr=!1,Qa=Oi=0,ea=null}function Nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?ct.memoizedState=tn=e:tn=tn.next=e,tn}function Wt(){if(Lt===null){var e=ct.alternate;e=e!==null?e.memoizedState:null}else e=Lt.next;var t=tn===null?ct.memoizedState:tn.next;if(t!==null)tn=t,Lt=e;else{if(e===null)throw ct.alternate===null?Error(l(467)):Error(l(310));Lt=e,e={memoizedState:Lt.memoizedState,baseState:Lt.baseState,baseQueue:Lt.baseQueue,queue:Lt.queue,next:null},tn===null?ct.memoizedState=tn=e:tn=tn.next=e}return tn}function ki(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Za(e){var t=Qa;return Qa+=1,ea===null&&(ea=[]),e=Qh(ea,e,t),t=ct,(tn===null?t.memoizedState:tn.next)===null&&(t=t.alternate,A.H=t===null||t.memoizedState===null?Pg:wd),e}function _i(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Za(e);if(e.$$typeof===k)return gn(e)}throw Error(l(438,String(e)))}function hd(e){var t=null,s=ct.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var a=ct.alternate;a!==null&&(a=a.updateQueue,a!==null&&(a=a.memoCache,a!=null&&(t={data:a.data.map(function(u){return u.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=ki(),ct.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),a=0;a<e;a++)s[a]=oe;return t.index++,s}function Ys(e,t){return typeof t=="function"?t(e):t}function Mi(e){var t=Wt();return gd(t,Lt,e)}function gd(e,t,s){var a=e.queue;if(a===null)throw Error(l(311));a.lastRenderedReducer=s;var u=e.baseQueue,f=a.pending;if(f!==null){if(u!==null){var y=u.next;u.next=f.next,f.next=y}t.baseQueue=u=f,a.pending=null}if(f=e.baseState,u===null)e.memoizedState=f;else{t=u.next;var R=y=null,X=null,ue=t,ye=!1;do{var Ne=ue.lane&-536870913;if(Ne!==ue.lane?(bt&Ne)===Ne:(Ps&Ne)===Ne){var fe=ue.revertLane;if(fe===0)X!==null&&(X=X.next={lane:0,revertLane:0,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),Ne===Xr&&(ye=!0);else if((Ps&fe)===fe){ue=ue.next,fe===Xr&&(ye=!0);continue}else Ne={lane:0,revertLane:ue.revertLane,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},X===null?(R=X=Ne,y=f):X=X.next=Ne,ct.lanes|=fe,jo|=fe;Ne=ue.action,or&&s(f,Ne),f=ue.hasEagerState?ue.eagerState:s(f,Ne)}else fe={lane:Ne,revertLane:ue.revertLane,gesture:ue.gesture,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},X===null?(R=X=fe,y=f):X=X.next=fe,ct.lanes|=Ne,jo|=Ne;ue=ue.next}while(ue!==null&&ue!==t);if(X===null?y=f:X.next=R,!In(f,e.memoizedState)&&(nn=!0,ye&&(s=Kr,s!==null)))throw s;e.memoizedState=f,e.baseState=y,e.baseQueue=X,a.lastRenderedState=f}return u===null&&(a.lanes=0),[e.memoizedState,a.dispatch]}function xd(e){var t=Wt(),s=t.queue;if(s===null)throw Error(l(311));s.lastRenderedReducer=e;var a=s.dispatch,u=s.pending,f=t.memoizedState;if(u!==null){s.pending=null;var y=u=u.next;do f=e(f,y.action),y=y.next;while(y!==u);In(f,t.memoizedState)||(nn=!0),t.memoizedState=f,t.baseQueue===null&&(t.baseState=f),s.lastRenderedState=f}return[f,a]}function lg(e,t,s){var a=ct,u=Wt(),f=Et;if(f){if(s===void 0)throw Error(l(407));s=s()}else s=t();var y=!In((Lt||u).memoizedState,s);if(y&&(u.memoizedState=s,nn=!0),u=u.queue,vd(ug.bind(null,a,u,e),[e]),u.getSnapshot!==t||y||tn!==null&&tn.memoizedState.tag&1){if(a.flags|=2048,ta(9,{destroy:void 0},cg.bind(null,a,u,s,t),null),Ht===null)throw Error(l(349));f||(Ps&127)!==0||ig(a,t,s)}return s}function ig(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=ct.updateQueue,t===null?(t=ki(),ct.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function cg(e,t,s,a){t.value=s,t.getSnapshot=a,dg(t)&&fg(e)}function ug(e,t,s){return s(function(){dg(t)&&fg(e)})}function dg(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!In(e,s)}catch{return!0}}function fg(e){var t=Ko(e,2);t!==null&&Mn(t,e,2)}function bd(e){var t=Nn();if(typeof e=="function"){var s=e;if(e=s(),or){Tt(!0);try{s()}finally{Tt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:e},t}function mg(e,t,s,a){return e.baseState=s,gd(e,Lt,typeof a=="function"?a:Ys)}function IE(e,t,s,a,u){if(zi(e))throw Error(l(485));if(e=t.action,e!==null){var f={payload:u,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){f.listeners.push(y)}};A.T!==null?s(!0):f.isTransition=!1,a(f),s=t.pending,s===null?(f.next=t.pending=f,pg(t,f)):(f.next=s.next,t.pending=s.next=f)}}function pg(e,t){var s=t.action,a=t.payload,u=e.state;if(t.isTransition){var f=A.T,y={};A.T=y;try{var R=s(u,a),X=A.S;X!==null&&X(y,R),hg(e,t,R)}catch(ue){yd(e,t,ue)}finally{f!==null&&y.types!==null&&(f.types=y.types),A.T=f}}else try{f=s(u,a),hg(e,t,f)}catch(ue){yd(e,t,ue)}}function hg(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(a){gg(e,t,a)},function(a){return yd(e,t,a)}):gg(e,t,s)}function gg(e,t,s){t.status="fulfilled",t.value=s,xg(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,pg(e,s)))}function yd(e,t,s){var a=e.pending;if(e.pending=null,a!==null){a=a.next;do t.status="rejected",t.reason=s,xg(t),t=t.next;while(t!==a)}e.action=null}function xg(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function bg(e,t){return t}function yg(e,t){if(Et){var s=Ht.formState;if(s!==null){e:{var a=ct;if(Et){if(Ft){t:{for(var u=Ft,f=es;u.nodeType!==8;){if(!f){u=null;break t}if(u=ns(u.nextSibling),u===null){u=null;break t}}f=u.data,u=f==="F!"||f==="F"?u:null}if(u){Ft=ns(u.nextSibling),a=u.data==="F!";break e}}ho(a)}a=!1}a&&(t=s[0])}}return s=Nn(),s.memoizedState=s.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bg,lastRenderedState:t},s.queue=a,s=Bg.bind(null,ct,a),a.dispatch=s,a=bd(!1),f=Td.bind(null,ct,!1,a.queue),a=Nn(),u={state:t,dispatch:null,action:e,pending:null},a.queue=u,s=IE.bind(null,ct,u,f,s),u.dispatch=s,a.memoizedState=e,[t,s,!1]}function vg(e){var t=Wt();return Sg(t,Lt,e)}function Sg(e,t,s){if(t=gd(e,t,bg)[0],e=Mi(Ys)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var a=Za(t)}catch(y){throw y===Qr?Ei:y}else a=t;t=Wt();var u=t.queue,f=u.dispatch;return s!==t.memoizedState&&(ct.flags|=2048,ta(9,{destroy:void 0},BE.bind(null,u,s),null)),[a,f,e]}function BE(e,t){e.action=t}function Eg(e){var t=Wt(),s=Lt;if(s!==null)return Sg(t,s,e);Wt(),t=t.memoizedState,s=Wt();var a=s.queue.dispatch;return s.memoizedState=e,[t,a,!1]}function ta(e,t,s,a){return e={tag:e,create:s,deps:a,inst:t,next:null},t=ct.updateQueue,t===null&&(t=ki(),ct.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(a=s.next,s.next=e,e.next=a,t.lastEffect=e),e}function Ng(){return Wt().memoizedState}function Ai(e,t,s,a){var u=Nn();ct.flags|=e,u.memoizedState=ta(1|t,{destroy:void 0},s,a===void 0?null:a)}function Di(e,t,s,a){var u=Wt();a=a===void 0?null:a;var f=u.memoizedState.inst;Lt!==null&&a!==null&&ud(a,Lt.memoizedState.deps)?u.memoizedState=ta(t,f,s,a):(ct.flags|=e,u.memoizedState=ta(1|t,f,s,a))}function jg(e,t){Ai(8390656,8,e,t)}function vd(e,t){Di(2048,8,e,t)}function UE(e){ct.flags|=4;var t=ct.updateQueue;if(t===null)t=ki(),ct.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function Tg(e){var t=Wt().memoizedState;return UE({ref:t,nextImpl:e}),function(){if((kt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function wg(e,t){return Di(4,2,e,t)}function Cg(e,t){return Di(4,4,e,t)}function Rg(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Og(e,t,s){s=s!=null?s.concat([e]):null,Di(4,4,Rg.bind(null,t,e),s)}function Sd(){}function kg(e,t){var s=Wt();t=t===void 0?null:t;var a=s.memoizedState;return t!==null&&ud(t,a[1])?a[0]:(s.memoizedState=[e,t],e)}function _g(e,t){var s=Wt();t=t===void 0?null:t;var a=s.memoizedState;if(t!==null&&ud(t,a[1]))return a[0];if(a=e(),or){Tt(!0);try{e()}finally{Tt(!1)}}return s.memoizedState=[a,t],a}function Ed(e,t,s){return s===void 0||(Ps&1073741824)!==0&&(bt&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=Mx(),ct.lanes|=e,jo|=e,s)}function Mg(e,t,s,a){return In(s,t)?s:Jr.current!==null?(e=Ed(e,s,a),In(e,t)||(nn=!0),e):(Ps&42)===0||(Ps&1073741824)!==0&&(bt&261930)===0?(nn=!0,e.memoizedState=s):(e=Mx(),ct.lanes|=e,jo|=e,t)}function Ag(e,t,s,a,u){var f=D.p;D.p=f!==0&&8>f?f:8;var y=A.T,R={};A.T=R,Td(e,!1,t,s);try{var X=u(),ue=A.S;if(ue!==null&&ue(R,X),X!==null&&typeof X=="object"&&typeof X.then=="function"){var ye=DE(X,a);Ja(e,t,ye,Vn(e))}else Ja(e,t,a,Vn(e))}catch(Ne){Ja(e,t,{then:function(){},status:"rejected",reason:Ne},Vn())}finally{D.p=f,y!==null&&R.types!==null&&(y.types=R.types),A.T=y}}function HE(){}function Nd(e,t,s,a){if(e.tag!==5)throw Error(l(476));var u=Dg(e).queue;Ag(e,u,t,B,s===null?HE:function(){return zg(e),s(a)})}function Dg(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:B},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function zg(e){var t=Dg(e);t.next===null&&(t=e.alternate.memoizedState),Ja(e,t.next.queue,{},Vn())}function jd(){return gn(hl)}function Lg(){return Wt().memoizedState}function Ig(){return Wt().memoizedState}function PE(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Vn();e=bo(s);var a=yo(t,e,s);a!==null&&(Mn(a,t,s),$a(a,t,s)),t={cache:Wu()},e.payload=t;return}t=t.return}}function YE(e,t,s){var a=Vn();s={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},zi(e)?Ug(t,s):(s=Yu(e,t,s,a),s!==null&&(Mn(s,e,a),Hg(s,t,a)))}function Bg(e,t,s){var a=Vn();Ja(e,t,s,a)}function Ja(e,t,s,a){var u={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(zi(e))Ug(t,u);else{var f=e.alternate;if(e.lanes===0&&(f===null||f.lanes===0)&&(f=t.lastRenderedReducer,f!==null))try{var y=t.lastRenderedState,R=f(y,s);if(u.hasEagerState=!0,u.eagerState=R,In(R,y))return hi(e,t,u,0),Ht===null&&pi(),!1}catch{}if(s=Yu(e,t,u,a),s!==null)return Mn(s,e,a),Hg(s,t,a),!0}return!1}function Td(e,t,s,a){if(a={lane:2,revertLane:sf(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},zi(e)){if(t)throw Error(l(479))}else t=Yu(e,s,a,2),t!==null&&Mn(t,e,2)}function zi(e){var t=e.alternate;return e===ct||t!==null&&t===ct}function Ug(e,t){Wr=Ri=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Hg(e,t,s){if((s&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,s|=a,t.lanes=s,Zt(e,s)}}var Wa={readContext:gn,use:_i,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useLayoutEffect:Xt,useInsertionEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useSyncExternalStore:Xt,useId:Xt,useHostTransitionStatus:Xt,useFormState:Xt,useActionState:Xt,useOptimistic:Xt,useMemoCache:Xt,useCacheRefresh:Xt};Wa.useEffectEvent=Xt;var Pg={readContext:gn,use:_i,useCallback:function(e,t){return Nn().memoizedState=[e,t===void 0?null:t],e},useContext:gn,useEffect:jg,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,Ai(4194308,4,Rg.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Ai(4194308,4,e,t)},useInsertionEffect:function(e,t){Ai(4,2,e,t)},useMemo:function(e,t){var s=Nn();t=t===void 0?null:t;var a=e();if(or){Tt(!0);try{e()}finally{Tt(!1)}}return s.memoizedState=[a,t],a},useReducer:function(e,t,s){var a=Nn();if(s!==void 0){var u=s(t);if(or){Tt(!0);try{s(t)}finally{Tt(!1)}}}else u=t;return a.memoizedState=a.baseState=u,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:u},a.queue=e,e=e.dispatch=YE.bind(null,ct,e),[a.memoizedState,e]},useRef:function(e){var t=Nn();return e={current:e},t.memoizedState=e},useState:function(e){e=bd(e);var t=e.queue,s=Bg.bind(null,ct,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:Sd,useDeferredValue:function(e,t){var s=Nn();return Ed(s,e,t)},useTransition:function(){var e=bd(!1);return e=Ag.bind(null,ct,e.queue,!0,!1),Nn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var a=ct,u=Nn();if(Et){if(s===void 0)throw Error(l(407));s=s()}else{if(s=t(),Ht===null)throw Error(l(349));(bt&127)!==0||ig(a,t,s)}u.memoizedState=s;var f={value:s,getSnapshot:t};return u.queue=f,jg(ug.bind(null,a,f,e),[e]),a.flags|=2048,ta(9,{destroy:void 0},cg.bind(null,a,f,s,t),null),s},useId:function(){var e=Nn(),t=Ht.identifierPrefix;if(Et){var s=gs,a=hs;s=(a&~(1<<32-Rt(a)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Oi++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=zE++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:jd,useFormState:yg,useActionState:yg,useOptimistic:function(e){var t=Nn();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=Td.bind(null,ct,!0,s),s.dispatch=t,[e,t]},useMemoCache:hd,useCacheRefresh:function(){return Nn().memoizedState=PE.bind(null,ct)},useEffectEvent:function(e){var t=Nn(),s={impl:e};return t.memoizedState=s,function(){if((kt&2)!==0)throw Error(l(440));return s.impl.apply(void 0,arguments)}}},wd={readContext:gn,use:_i,useCallback:kg,useContext:gn,useEffect:vd,useImperativeHandle:Og,useInsertionEffect:wg,useLayoutEffect:Cg,useMemo:_g,useReducer:Mi,useRef:Ng,useState:function(){return Mi(Ys)},useDebugValue:Sd,useDeferredValue:function(e,t){var s=Wt();return Mg(s,Lt.memoizedState,e,t)},useTransition:function(){var e=Mi(Ys)[0],t=Wt().memoizedState;return[typeof e=="boolean"?e:Za(e),t]},useSyncExternalStore:lg,useId:Lg,useHostTransitionStatus:jd,useFormState:vg,useActionState:vg,useOptimistic:function(e,t){var s=Wt();return mg(s,Lt,e,t)},useMemoCache:hd,useCacheRefresh:Ig};wd.useEffectEvent=Tg;var Yg={readContext:gn,use:_i,useCallback:kg,useContext:gn,useEffect:vd,useImperativeHandle:Og,useInsertionEffect:wg,useLayoutEffect:Cg,useMemo:_g,useReducer:xd,useRef:Ng,useState:function(){return xd(Ys)},useDebugValue:Sd,useDeferredValue:function(e,t){var s=Wt();return Lt===null?Ed(s,e,t):Mg(s,Lt.memoizedState,e,t)},useTransition:function(){var e=xd(Ys)[0],t=Wt().memoizedState;return[typeof e=="boolean"?e:Za(e),t]},useSyncExternalStore:lg,useId:Lg,useHostTransitionStatus:jd,useFormState:Eg,useActionState:Eg,useOptimistic:function(e,t){var s=Wt();return Lt!==null?mg(s,Lt,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:hd,useCacheRefresh:Ig};Yg.useEffectEvent=Tg;function Cd(e,t,s,a){t=e.memoizedState,s=s(a,t),s=s==null?t:x({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Rd={enqueueSetState:function(e,t,s){e=e._reactInternals;var a=Vn(),u=bo(a);u.payload=t,s!=null&&(u.callback=s),t=yo(e,u,a),t!==null&&(Mn(t,e,a),$a(t,e,a))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var a=Vn(),u=bo(a);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=yo(e,u,a),t!==null&&(Mn(t,e,a),$a(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Vn(),a=bo(s);a.tag=2,t!=null&&(a.callback=t),t=yo(e,a,s),t!==null&&(Mn(t,e,s),$a(t,e,s))}};function Vg(e,t,s,a,u,f,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,f,y):t.prototype&&t.prototype.isPureReactComponent?!Ua(s,a)||!Ua(u,f):!0}function Fg(e,t,s,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,a),t.state!==e&&Rd.enqueueReplaceState(t,t.state,null)}function rr(e,t){var s=t;if("ref"in t){s={};for(var a in t)a!=="ref"&&(s[a]=t[a])}if(e=e.defaultProps){s===t&&(s=x({},s));for(var u in e)s[u]===void 0&&(s[u]=e[u])}return s}function Gg(e){mi(e)}function qg(e){console.error(e)}function $g(e){mi(e)}function Li(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(a){setTimeout(function(){throw a})}}function Xg(e,t,s){try{var a=e.onCaughtError;a(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Od(e,t,s){return s=bo(s),s.tag=3,s.payload={element:null},s.callback=function(){Li(e,t)},s}function Kg(e){return e=bo(e),e.tag=3,e}function Qg(e,t,s,a){var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var f=a.value;e.payload=function(){return u(f)},e.callback=function(){Xg(t,s,a)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Xg(t,s,a),typeof u!="function"&&(To===null?To=new Set([this]):To.add(this));var R=a.stack;this.componentDidCatch(a.value,{componentStack:R!==null?R:""})})}function VE(e,t,s,a,u){if(s.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){if(t=s.alternate,t!==null&&$r(t,s,u,!0),s=Un.current,s!==null){switch(s.tag){case 31:case 13:return ts===null?Xi():s.alternate===null&&Kt===0&&(Kt=3),s.flags&=-257,s.flags|=65536,s.lanes=u,a===Ni?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([a]):t.add(a),ef(e,a,u)),!1;case 22:return s.flags|=65536,a===Ni?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([a]):s.add(a)),ef(e,a,u)),!1}throw Error(l(435,s.tag))}return ef(e,a,u),Xi(),!1}if(Et)return t=Un.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,a!==Xu&&(e=Error(l(422),{cause:a}),Ya(Zn(e,s)))):(a!==Xu&&(t=Error(l(423),{cause:a}),Ya(Zn(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,a=Zn(a,s),u=Od(e.stateNode,a,u),rd(e,u),Kt!==4&&(Kt=2)),!1;var f=Error(l(520),{cause:a});if(f=Zn(f,s),ll===null?ll=[f]:ll.push(f),Kt!==4&&(Kt=2),t===null)return!0;a=Zn(a,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=u&-u,s.lanes|=e,e=Od(s.stateNode,a,e),rd(s,e),!1;case 1:if(t=s.type,f=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(To===null||!To.has(f))))return s.flags|=65536,u&=-u,s.lanes|=u,u=Kg(u),Qg(u,e,s,a),rd(s,u),!1}s=s.return}while(s!==null);return!1}var kd=Error(l(461)),nn=!1;function xn(e,t,s,a){t.child=e===null?eg(t,null,s,a):sr(t,e.child,s,a)}function Zg(e,t,s,a,u){s=s.render;var f=t.ref;if("ref"in a){var y={};for(var R in a)R!=="ref"&&(y[R]=a[R])}else y=a;return Wo(t),a=dd(e,t,s,y,f,u),R=fd(),e!==null&&!nn?(md(e,t,u),Vs(e,t,u)):(Et&&R&&qu(t),t.flags|=1,xn(e,t,a,u),t.child)}function Jg(e,t,s,a,u){if(e===null){var f=s.type;return typeof f=="function"&&!Vu(f)&&f.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=f,Wg(e,t,f,a,u)):(e=xi(s.type,null,a,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(f=e.child,!Bd(e,u)){var y=f.memoizedProps;if(s=s.compare,s=s!==null?s:Ua,s(y,a)&&e.ref===t.ref)return Vs(e,t,u)}return t.flags|=1,e=Is(f,a),e.ref=t.ref,e.return=t,t.child=e}function Wg(e,t,s,a,u){if(e!==null){var f=e.memoizedProps;if(Ua(f,a)&&e.ref===t.ref)if(nn=!1,t.pendingProps=a=f,Bd(e,u))(e.flags&131072)!==0&&(nn=!0);else return t.lanes=e.lanes,Vs(e,t,u)}return _d(e,t,s,a,u)}function ex(e,t,s,a){var u=a.children,f=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.mode==="hidden"){if((t.flags&128)!==0){if(f=f!==null?f.baseLanes|s:s,e!==null){for(a=t.child=e.child,u=0;a!==null;)u=u|a.lanes|a.childLanes,a=a.sibling;a=u&~f}else a=0,t.child=null;return tx(e,t,f,s,a)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Si(t,f!==null?f.cachePool:null),f!==null?sg(t,f):ld(),og(t);else return a=t.lanes=536870912,tx(e,t,f!==null?f.baseLanes|s:s,s,a)}else f!==null?(Si(t,f.cachePool),sg(t,f),So(),t.memoizedState=null):(e!==null&&Si(t,null),ld(),So());return xn(e,t,u,s),t.child}function el(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function tx(e,t,s,a,u){var f=td();return f=f===null?null:{parent:en._currentValue,pool:f},t.memoizedState={baseLanes:s,cachePool:f},e!==null&&Si(t,null),ld(),og(t),e!==null&&$r(e,t,a,!0),t.childLanes=u,null}function Ii(e,t){return t=Ui({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function nx(e,t,s){return sr(t,e.child,null,s),e=Ii(t,t.pendingProps),e.flags|=2,Hn(t),t.memoizedState=null,e}function FE(e,t,s){var a=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Et){if(a.mode==="hidden")return e=Ii(t,a),t.lanes=536870912,el(null,e);if(cd(t),(e=Ft)?(e=pb(e,es),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mo!==null?{id:hs,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},s=Uh(e),s.return=t,t.child=s,hn=t,Ft=null)):e=null,e===null)throw ho(t);return t.lanes=536870912,null}return Ii(t,a)}var f=e.memoizedState;if(f!==null){var y=f.dehydrated;if(cd(t),u)if(t.flags&256)t.flags&=-257,t=nx(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(nn||$r(e,t,s,!1),u=(s&e.childLanes)!==0,nn||u){if(a=Ht,a!==null&&(y=pn(a,s),y!==0&&y!==f.retryLane))throw f.retryLane=y,Ko(e,y),Mn(a,e,y),kd;Xi(),t=nx(e,t,s)}else e=f.treeContext,Ft=ns(y.nextSibling),hn=t,Et=!0,po=null,es=!1,e!==null&&Yh(t,e),t=Ii(t,a),t.flags|=4096;return t}return e=Is(e.child,{mode:a.mode,children:a.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Bi(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(l(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function _d(e,t,s,a,u){return Wo(t),s=dd(e,t,s,a,void 0,u),a=fd(),e!==null&&!nn?(md(e,t,u),Vs(e,t,u)):(Et&&a&&qu(t),t.flags|=1,xn(e,t,s,u),t.child)}function sx(e,t,s,a,u,f){return Wo(t),t.updateQueue=null,s=ag(t,a,s,u),rg(e),a=fd(),e!==null&&!nn?(md(e,t,f),Vs(e,t,f)):(Et&&a&&qu(t),t.flags|=1,xn(e,t,s,f),t.child)}function ox(e,t,s,a,u){if(Wo(t),t.stateNode===null){var f=Vr,y=s.contextType;typeof y=="object"&&y!==null&&(f=gn(y)),f=new s(a,f),t.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=Rd,t.stateNode=f,f._reactInternals=t,f=t.stateNode,f.props=a,f.state=t.memoizedState,f.refs={},sd(t),y=s.contextType,f.context=typeof y=="object"&&y!==null?gn(y):Vr,f.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Cd(t,s,y,a),f.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(y=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),y!==f.state&&Rd.enqueueReplaceState(f,f.state,null),Ka(t,a,f,u),Xa(),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!0}else if(e===null){f=t.stateNode;var R=t.memoizedProps,X=rr(s,R);f.props=X;var ue=f.context,ye=s.contextType;y=Vr,typeof ye=="object"&&ye!==null&&(y=gn(ye));var Ne=s.getDerivedStateFromProps;ye=typeof Ne=="function"||typeof f.getSnapshotBeforeUpdate=="function",R=t.pendingProps!==R,ye||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(R||ue!==y)&&Fg(t,f,a,y),xo=!1;var fe=t.memoizedState;f.state=fe,Ka(t,a,f,u),Xa(),ue=t.memoizedState,R||fe!==ue||xo?(typeof Ne=="function"&&(Cd(t,s,Ne,a),ue=t.memoizedState),(X=xo||Vg(t,s,X,a,fe,ue,y))?(ye||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(t.flags|=4194308)):(typeof f.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=ue),f.props=a,f.state=ue,f.context=y,a=X):(typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{f=t.stateNode,od(e,t),y=t.memoizedProps,ye=rr(s,y),f.props=ye,Ne=t.pendingProps,fe=f.context,ue=s.contextType,X=Vr,typeof ue=="object"&&ue!==null&&(X=gn(ue)),R=s.getDerivedStateFromProps,(ue=typeof R=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(y!==Ne||fe!==X)&&Fg(t,f,a,X),xo=!1,fe=t.memoizedState,f.state=fe,Ka(t,a,f,u),Xa();var he=t.memoizedState;y!==Ne||fe!==he||xo||e!==null&&e.dependencies!==null&&yi(e.dependencies)?(typeof R=="function"&&(Cd(t,s,R,a),he=t.memoizedState),(ye=xo||Vg(t,s,ye,a,fe,he,X)||e!==null&&e.dependencies!==null&&yi(e.dependencies))?(ue||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(a,he,X),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(a,he,X)),typeof f.componentDidUpdate=="function"&&(t.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof f.componentDidUpdate!="function"||y===e.memoizedProps&&fe===e.memoizedState||(t.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&fe===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=he),f.props=a,f.state=he,f.context=X,a=ye):(typeof f.componentDidUpdate!="function"||y===e.memoizedProps&&fe===e.memoizedState||(t.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&fe===e.memoizedState||(t.flags|=1024),a=!1)}return f=a,Bi(e,t),a=(t.flags&128)!==0,f||a?(f=t.stateNode,s=a&&typeof s.getDerivedStateFromError!="function"?null:f.render(),t.flags|=1,e!==null&&a?(t.child=sr(t,e.child,null,u),t.child=sr(t,null,s,u)):xn(e,t,s,u),t.memoizedState=f.state,e=t.child):e=Vs(e,t,u),e}function rx(e,t,s,a){return Zo(),t.flags|=256,xn(e,t,s,a),t.child}var Md={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ad(e){return{baseLanes:e,cachePool:Xh()}}function Dd(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Yn),e}function ax(e,t,s){var a=t.pendingProps,u=!1,f=(t.flags&128)!==0,y;if((y=f)||(y=e!==null&&e.memoizedState===null?!1:(Jt.current&2)!==0),y&&(u=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(Et){if(u?vo(t):So(),(e=Ft)?(e=pb(e,es),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mo!==null?{id:hs,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},s=Uh(e),s.return=t,t.child=s,hn=t,Ft=null)):e=null,e===null)throw ho(t);return xf(e)?t.lanes=32:t.lanes=536870912,null}var R=a.children;return a=a.fallback,u?(So(),u=t.mode,R=Ui({mode:"hidden",children:R},u),a=Qo(a,u,s,null),R.return=t,a.return=t,R.sibling=a,t.child=R,a=t.child,a.memoizedState=Ad(s),a.childLanes=Dd(e,y,s),t.memoizedState=Md,el(null,a)):(vo(t),zd(t,R))}var X=e.memoizedState;if(X!==null&&(R=X.dehydrated,R!==null)){if(f)t.flags&256?(vo(t),t.flags&=-257,t=Ld(e,t,s)):t.memoizedState!==null?(So(),t.child=e.child,t.flags|=128,t=null):(So(),R=a.fallback,u=t.mode,a=Ui({mode:"visible",children:a.children},u),R=Qo(R,u,s,null),R.flags|=2,a.return=t,R.return=t,a.sibling=R,t.child=a,sr(t,e.child,null,s),a=t.child,a.memoizedState=Ad(s),a.childLanes=Dd(e,y,s),t.memoizedState=Md,t=el(null,a));else if(vo(t),xf(R)){if(y=R.nextSibling&&R.nextSibling.dataset,y)var ue=y.dgst;y=ue,a=Error(l(419)),a.stack="",a.digest=y,Ya({value:a,source:null,stack:null}),t=Ld(e,t,s)}else if(nn||$r(e,t,s,!1),y=(s&e.childLanes)!==0,nn||y){if(y=Ht,y!==null&&(a=pn(y,s),a!==0&&a!==X.retryLane))throw X.retryLane=a,Ko(e,a),Mn(y,e,a),kd;gf(R)||Xi(),t=Ld(e,t,s)}else gf(R)?(t.flags|=192,t.child=e.child,t=null):(e=X.treeContext,Ft=ns(R.nextSibling),hn=t,Et=!0,po=null,es=!1,e!==null&&Yh(t,e),t=zd(t,a.children),t.flags|=4096);return t}return u?(So(),R=a.fallback,u=t.mode,X=e.child,ue=X.sibling,a=Is(X,{mode:"hidden",children:a.children}),a.subtreeFlags=X.subtreeFlags&65011712,ue!==null?R=Is(ue,R):(R=Qo(R,u,s,null),R.flags|=2),R.return=t,a.return=t,a.sibling=R,t.child=a,el(null,a),a=t.child,R=e.child.memoizedState,R===null?R=Ad(s):(u=R.cachePool,u!==null?(X=en._currentValue,u=u.parent!==X?{parent:X,pool:X}:u):u=Xh(),R={baseLanes:R.baseLanes|s,cachePool:u}),a.memoizedState=R,a.childLanes=Dd(e,y,s),t.memoizedState=Md,el(e.child,a)):(vo(t),s=e.child,e=s.sibling,s=Is(s,{mode:"visible",children:a.children}),s.return=t,s.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=s,t.memoizedState=null,s)}function zd(e,t){return t=Ui({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ui(e,t){return e=Bn(22,e,null,t),e.lanes=0,e}function Ld(e,t,s){return sr(t,e.child,null,s),e=zd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function lx(e,t,s){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Zu(e.return,t,s)}function Id(e,t,s,a,u,f){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:s,tailMode:u,treeForkCount:f}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=a,y.tail=s,y.tailMode=u,y.treeForkCount=f)}function ix(e,t,s){var a=t.pendingProps,u=a.revealOrder,f=a.tail;a=a.children;var y=Jt.current,R=(y&2)!==0;if(R?(y=y&1|2,t.flags|=128):y&=1,F(Jt,y),xn(e,t,a,s),a=Et?Pa:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&lx(e,s,t);else if(e.tag===19)lx(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&Ci(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),Id(t,!1,u,s,f,a);break;case"backwards":case"unstable_legacy-backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Ci(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}Id(t,!0,s,null,f,a);break;case"together":Id(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function Vs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),jo|=t.lanes,(s&t.childLanes)===0)if(e!==null){if($r(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(l(153));if(t.child!==null){for(e=t.child,s=Is(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Is(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Bd(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&yi(e)))}function GE(e,t,s){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),go(t,en,e.memoizedState.cache),Zo();break;case 27:case 5:Le(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:go(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,cd(t),null;break;case 13:var a=t.memoizedState;if(a!==null)return a.dehydrated!==null?(vo(t),t.flags|=128,null):(s&t.child.childLanes)!==0?ax(e,t,s):(vo(t),e=Vs(e,t,s),e!==null?e.sibling:null);vo(t);break;case 19:var u=(e.flags&128)!==0;if(a=(s&t.childLanes)!==0,a||($r(e,t,s,!1),a=(s&t.childLanes)!==0),u){if(a)return ix(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),F(Jt,Jt.current),a)break;return null;case 22:return t.lanes=0,ex(e,t,s,t.pendingProps);case 24:go(t,en,e.memoizedState.cache)}return Vs(e,t,s)}function cx(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)nn=!0;else{if(!Bd(e,s)&&(t.flags&128)===0)return nn=!1,GE(e,t,s);nn=(e.flags&131072)!==0}else nn=!1,Et&&(t.flags&1048576)!==0&&Ph(t,Pa,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=tr(t.elementType),t.type=e,typeof e=="function")Vu(e)?(a=rr(e,a),t.tag=1,t=ox(null,t,e,a,s)):(t.tag=0,t=_d(null,t,e,a,s));else{if(e!=null){var u=e.$$typeof;if(u===C){t.tag=11,t=Zg(null,t,e,a,s);break e}else if(u===L){t.tag=14,t=Jg(null,t,e,a,s);break e}}throw t=G(e)||e,Error(l(306,t,""))}}return t;case 0:return _d(e,t,t.type,t.pendingProps,s);case 1:return a=t.type,u=rr(a,t.pendingProps),ox(e,t,a,u,s);case 3:e:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(l(387));a=t.pendingProps;var f=t.memoizedState;u=f.element,od(e,t),Ka(t,a,null,s);var y=t.memoizedState;if(a=y.cache,go(t,en,a),a!==f.cache&&Ju(t,[en],s,!0),Xa(),a=y.element,f.isDehydrated)if(f={element:a,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=f,t.memoizedState=f,t.flags&256){t=rx(e,t,a,s);break e}else if(a!==u){u=Zn(Error(l(424)),t),Ya(u),t=rx(e,t,a,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Ft=ns(e.firstChild),hn=t,Et=!0,po=null,es=!0,s=eg(t,null,a,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Zo(),a===u){t=Vs(e,t,s);break e}xn(e,t,a,s)}t=t.child}return t;case 26:return Bi(e,t),e===null?(s=vb(t.type,null,t.pendingProps,null))?t.memoizedState=s:Et||(s=t.type,e=t.pendingProps,a=tc(P.current).createElement(s),a[on]=t,a[wn]=e,bn(a,s,e),cn(a),t.stateNode=a):t.memoizedState=vb(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Le(t),e===null&&Et&&(a=t.stateNode=xb(t.type,t.pendingProps,P.current),hn=t,es=!0,u=Ft,Oo(t.type)?(bf=u,Ft=ns(a.firstChild)):Ft=u),xn(e,t,t.pendingProps.children,s),Bi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Et&&((u=a=Ft)&&(a=SN(a,t.type,t.pendingProps,es),a!==null?(t.stateNode=a,hn=t,Ft=ns(a.firstChild),es=!1,u=!0):u=!1),u||ho(t)),Le(t),u=t.type,f=t.pendingProps,y=e!==null?e.memoizedProps:null,a=f.children,mf(u,f)?a=null:y!==null&&mf(u,y)&&(t.flags|=32),t.memoizedState!==null&&(u=dd(e,t,LE,null,null,s),hl._currentValue=u),Bi(e,t),xn(e,t,a,s),t.child;case 6:return e===null&&Et&&((e=s=Ft)&&(s=EN(s,t.pendingProps,es),s!==null?(t.stateNode=s,hn=t,Ft=null,e=!0):e=!1),e||ho(t)),null;case 13:return ax(e,t,s);case 4:return re(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=sr(t,null,a,s):xn(e,t,a,s),t.child;case 11:return Zg(e,t,t.type,t.pendingProps,s);case 7:return xn(e,t,t.pendingProps,s),t.child;case 8:return xn(e,t,t.pendingProps.children,s),t.child;case 12:return xn(e,t,t.pendingProps.children,s),t.child;case 10:return a=t.pendingProps,go(t,t.type,a.value),xn(e,t,a.children,s),t.child;case 9:return u=t.type._context,a=t.pendingProps.children,Wo(t),u=gn(u),a=a(u),t.flags|=1,xn(e,t,a,s),t.child;case 14:return Jg(e,t,t.type,t.pendingProps,s);case 15:return Wg(e,t,t.type,t.pendingProps,s);case 19:return ix(e,t,s);case 31:return FE(e,t,s);case 22:return ex(e,t,s,t.pendingProps);case 24:return Wo(t),a=gn(en),e===null?(u=td(),u===null&&(u=Ht,f=Wu(),u.pooledCache=f,f.refCount++,f!==null&&(u.pooledCacheLanes|=s),u=f),t.memoizedState={parent:a,cache:u},sd(t),go(t,en,u)):((e.lanes&s)!==0&&(od(e,t),Ka(t,null,null,s),Xa()),u=e.memoizedState,f=t.memoizedState,u.parent!==a?(u={parent:a,cache:a},t.memoizedState=u,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=u),go(t,en,a)):(a=f.cache,go(t,en,a),a!==u.cache&&Ju(t,[en],s,!0))),xn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function Fs(e){e.flags|=4}function Ud(e,t,s,a,u){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(u&335544128)===u)if(e.stateNode.complete)e.flags|=8192;else if(Lx())e.flags|=8192;else throw nr=Ni,nd}else e.flags&=-16777217}function ux(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Tb(t))if(Lx())e.flags|=8192;else throw nr=Ni,nd}function Hi(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?nt():536870912,e.lanes|=t,ra|=t)}function tl(e,t){if(!Et)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Gt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,a=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,a|=u.subtreeFlags&65011712,a|=u.flags&65011712,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,a|=u.subtreeFlags,a|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=a,e.childLanes=s,t}function qE(e,t,s){var a=t.pendingProps;switch($u(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(t),null;case 1:return Gt(t),null;case 3:return s=t.stateNode,a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Hs(en),de(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(qr(t)?Fs(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Ku())),Gt(t),null;case 26:var u=t.type,f=t.memoizedState;return e===null?(Fs(t),f!==null?(Gt(t),ux(t,f)):(Gt(t),Ud(t,u,null,a,s))):f?f!==e.memoizedState?(Fs(t),Gt(t),ux(t,f)):(Gt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==a&&Fs(t),Gt(t),Ud(t,u,e,a,s)),null;case 27:if(De(t),s=P.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Fs(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Gt(t),null}e=Y.current,qr(t)?Vh(t):(e=xb(u,a,s),t.stateNode=e,Fs(t))}return Gt(t),null;case 5:if(De(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Fs(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Gt(t),null}if(f=Y.current,qr(t))Vh(t);else{var y=tc(P.current);switch(f){case 1:f=y.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:f=y.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":f=y.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":f=y.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":f=y.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof a.is=="string"?y.createElement("select",{is:a.is}):y.createElement("select"),a.multiple?f.multiple=!0:a.size&&(f.size=a.size);break;default:f=typeof a.is=="string"?y.createElement(u,{is:a.is}):y.createElement(u)}}f[on]=t,f[wn]=a;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)f.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===t)break e;for(;y.sibling===null;){if(y.return===null||y.return===t)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}t.stateNode=f;e:switch(bn(f,u,a),u){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Fs(t)}}return Gt(t),Ud(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Fs(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(l(166));if(e=P.current,qr(t)){if(e=t.stateNode,s=t.memoizedProps,a=null,u=hn,u!==null)switch(u.tag){case 27:case 5:a=u.memoizedProps}e[on]=t,e=!!(e.nodeValue===s||a!==null&&a.suppressHydrationWarning===!0||ab(e.nodeValue,s)),e||ho(t,!0)}else e=tc(e).createTextNode(a),e[on]=t,t.stateNode=e}return Gt(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(a=qr(t),s!==null){if(e===null){if(!a)throw Error(l(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[on]=t}else Zo(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Gt(t),e=!1}else s=Ku(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Hn(t),t):(Hn(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Gt(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=qr(t),a!==null&&a.dehydrated!==null){if(e===null){if(!u)throw Error(l(318));if(u=t.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(l(317));u[on]=t}else Zo(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Gt(t),u=!1}else u=Ku(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=u),u=!0;if(!u)return t.flags&256?(Hn(t),t):(Hn(t),null)}return Hn(t),(t.flags&128)!==0?(t.lanes=s,t):(s=a!==null,e=e!==null&&e.memoizedState!==null,s&&(a=t.child,u=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(u=a.alternate.memoizedState.cachePool.pool),f=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),f!==u&&(a.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),Hi(t,t.updateQueue),Gt(t),null);case 4:return de(),e===null&&lf(t.stateNode.containerInfo),Gt(t),null;case 10:return Hs(t.type),Gt(t),null;case 19:if(Z(Jt),a=t.memoizedState,a===null)return Gt(t),null;if(u=(t.flags&128)!==0,f=a.rendering,f===null)if(u)tl(a,!1);else{if(Kt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(f=Ci(e),f!==null){for(t.flags|=128,tl(a,!1),e=f.updateQueue,t.updateQueue=e,Hi(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)Bh(s,e),s=s.sibling;return F(Jt,Jt.current&1|2),Et&&Bs(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&U()>Gi&&(t.flags|=128,u=!0,tl(a,!1),t.lanes=4194304)}else{if(!u)if(e=Ci(f),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,Hi(t,e),tl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!f.alternate&&!Et)return Gt(t),null}else 2*U()-a.renderingStartTime>Gi&&s!==536870912&&(t.flags|=128,u=!0,tl(a,!1),t.lanes=4194304);a.isBackwards?(f.sibling=t.child,t.child=f):(e=a.last,e!==null?e.sibling=f:t.child=f,a.last=f)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=U(),e.sibling=null,s=Jt.current,F(Jt,u?s&1|2:s&1),Et&&Bs(t,a.treeForkCount),e):(Gt(t),null);case 22:case 23:return Hn(t),id(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(s&536870912)!==0&&(t.flags&128)===0&&(Gt(t),t.subtreeFlags&6&&(t.flags|=8192)):Gt(t),s=t.updateQueue,s!==null&&Hi(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==s&&(t.flags|=2048),e!==null&&Z(er),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Hs(en),Gt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function $E(e,t){switch($u(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Hs(en),de(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return De(t),null;case 31:if(t.memoizedState!==null){if(Hn(t),t.alternate===null)throw Error(l(340));Zo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Hn(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));Zo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Z(Jt),null;case 4:return de(),null;case 10:return Hs(t.type),null;case 22:case 23:return Hn(t),id(),e!==null&&Z(er),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Hs(en),null;case 25:return null;default:return null}}function dx(e,t){switch($u(t),t.tag){case 3:Hs(en),de();break;case 26:case 27:case 5:De(t);break;case 4:de();break;case 31:t.memoizedState!==null&&Hn(t);break;case 13:Hn(t);break;case 19:Z(Jt);break;case 10:Hs(t.type);break;case 22:case 23:Hn(t),id(),e!==null&&Z(er);break;case 24:Hs(en)}}function nl(e,t){try{var s=t.updateQueue,a=s!==null?s.lastEffect:null;if(a!==null){var u=a.next;s=u;do{if((s.tag&e)===e){a=void 0;var f=s.create,y=s.inst;a=f(),y.destroy=a}s=s.next}while(s!==u)}}catch(R){At(t,t.return,R)}}function Eo(e,t,s){try{var a=t.updateQueue,u=a!==null?a.lastEffect:null;if(u!==null){var f=u.next;a=f;do{if((a.tag&e)===e){var y=a.inst,R=y.destroy;if(R!==void 0){y.destroy=void 0,u=t;var X=s,ue=R;try{ue()}catch(ye){At(u,X,ye)}}}a=a.next}while(a!==f)}}catch(ye){At(t,t.return,ye)}}function fx(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{ng(t,s)}catch(a){At(e,e.return,a)}}}function mx(e,t,s){s.props=rr(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(a){At(e,t,a)}}function sl(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof s=="function"?e.refCleanup=s(a):s.current=a}}catch(u){At(e,t,u)}}function xs(e,t){var s=e.ref,a=e.refCleanup;if(s!==null)if(typeof a=="function")try{a()}catch(u){At(e,t,u)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(u){At(e,t,u)}else s.current=null}function px(e){var t=e.type,s=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&a.focus();break e;case"img":s.src?a.src=s.src:s.srcSet&&(a.srcset=s.srcSet)}}catch(u){At(e,e.return,u)}}function Hd(e,t,s){try{var a=e.stateNode;hN(a,e.type,s,t),a[wn]=t}catch(u){At(e,e.return,u)}}function hx(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Oo(e.type)||e.tag===4}function Pd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||hx(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Oo(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Yd(e,t,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=zs));else if(a!==4&&(a===27&&Oo(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Yd(e,t,s),e=e.sibling;e!==null;)Yd(e,t,s),e=e.sibling}function Pi(e,t,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(a!==4&&(a===27&&Oo(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(Pi(e,t,s),e=e.sibling;e!==null;)Pi(e,t,s),e=e.sibling}function gx(e){var t=e.stateNode,s=e.memoizedProps;try{for(var a=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);bn(t,a,s),t[on]=e,t[wn]=s}catch(f){At(e,e.return,f)}}var Gs=!1,sn=!1,Vd=!1,xx=typeof WeakSet=="function"?WeakSet:Set,un=null;function XE(e,t){if(e=e.containerInfo,df=ic,e=Oh(e),Lu(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var a=s.getSelection&&s.getSelection();if(a&&a.rangeCount!==0){s=a.anchorNode;var u=a.anchorOffset,f=a.focusNode;a=a.focusOffset;try{s.nodeType,f.nodeType}catch{s=null;break e}var y=0,R=-1,X=-1,ue=0,ye=0,Ne=e,fe=null;t:for(;;){for(var he;Ne!==s||u!==0&&Ne.nodeType!==3||(R=y+u),Ne!==f||a!==0&&Ne.nodeType!==3||(X=y+a),Ne.nodeType===3&&(y+=Ne.nodeValue.length),(he=Ne.firstChild)!==null;)fe=Ne,Ne=he;for(;;){if(Ne===e)break t;if(fe===s&&++ue===u&&(R=y),fe===f&&++ye===a&&(X=y),(he=Ne.nextSibling)!==null)break;Ne=fe,fe=Ne.parentNode}Ne=he}s=R===-1||X===-1?null:{start:R,end:X}}else s=null}s=s||{start:0,end:0}}else s=null;for(ff={focusedElem:e,selectionRange:s},ic=!1,un=t;un!==null;)if(t=un,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,un=e;else for(;un!==null;){switch(t=un,f=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)u=e[s],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&f!==null){e=void 0,s=t,u=f.memoizedProps,f=f.memoizedState,a=s.stateNode;try{var $e=rr(s.type,u);e=a.getSnapshotBeforeUpdate($e,f),a.__reactInternalSnapshotBeforeUpdate=e}catch(et){At(s,s.return,et)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)hf(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":hf(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(l(163))}if(e=t.sibling,e!==null){e.return=t.return,un=e;break}un=t.return}}function bx(e,t,s){var a=s.flags;switch(s.tag){case 0:case 11:case 15:$s(e,s),a&4&&nl(5,s);break;case 1:if($s(e,s),a&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){At(s,s.return,y)}else{var u=rr(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){At(s,s.return,y)}}a&64&&fx(s),a&512&&sl(s,s.return);break;case 3:if($s(e,s),a&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{ng(e,t)}catch(y){At(s,s.return,y)}}break;case 27:t===null&&a&4&&gx(s);case 26:case 5:$s(e,s),t===null&&a&4&&px(s),a&512&&sl(s,s.return);break;case 12:$s(e,s);break;case 31:$s(e,s),a&4&&Sx(e,s);break;case 13:$s(e,s),a&4&&Ex(e,s),a&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=sN.bind(null,s),NN(e,s))));break;case 22:if(a=s.memoizedState!==null||Gs,!a){t=t!==null&&t.memoizedState!==null||sn,u=Gs;var f=sn;Gs=a,(sn=t)&&!f?Xs(e,s,(s.subtreeFlags&8772)!==0):$s(e,s),Gs=u,sn=f}break;case 30:break;default:$s(e,s)}}function yx(e){var t=e.alternate;t!==null&&(e.alternate=null,yx(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&yu(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var $t=null,Rn=!1;function qs(e,t,s){for(s=s.child;s!==null;)vx(e,t,s),s=s.sibling}function vx(e,t,s){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(_t,s)}catch{}switch(s.tag){case 26:sn||xs(s,t),qs(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:sn||xs(s,t);var a=$t,u=Rn;Oo(s.type)&&($t=s.stateNode,Rn=!1),qs(e,t,s),fl(s.stateNode),$t=a,Rn=u;break;case 5:sn||xs(s,t);case 6:if(a=$t,u=Rn,$t=null,qs(e,t,s),$t=a,Rn=u,$t!==null)if(Rn)try{($t.nodeType===9?$t.body:$t.nodeName==="HTML"?$t.ownerDocument.body:$t).removeChild(s.stateNode)}catch(f){At(s,t,f)}else try{$t.removeChild(s.stateNode)}catch(f){At(s,t,f)}break;case 18:$t!==null&&(Rn?(e=$t,fb(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),ma(e)):fb($t,s.stateNode));break;case 4:a=$t,u=Rn,$t=s.stateNode.containerInfo,Rn=!0,qs(e,t,s),$t=a,Rn=u;break;case 0:case 11:case 14:case 15:Eo(2,s,t),sn||Eo(4,s,t),qs(e,t,s);break;case 1:sn||(xs(s,t),a=s.stateNode,typeof a.componentWillUnmount=="function"&&mx(s,t,a)),qs(e,t,s);break;case 21:qs(e,t,s);break;case 22:sn=(a=sn)||s.memoizedState!==null,qs(e,t,s),sn=a;break;default:qs(e,t,s)}}function Sx(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ma(e)}catch(s){At(t,t.return,s)}}}function Ex(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ma(e)}catch(s){At(t,t.return,s)}}function KE(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new xx),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new xx),t;default:throw Error(l(435,e.tag))}}function Yi(e,t){var s=KE(e);t.forEach(function(a){if(!s.has(a)){s.add(a);var u=oN.bind(null,e,a);a.then(u,u)}})}function On(e,t){var s=t.deletions;if(s!==null)for(var a=0;a<s.length;a++){var u=s[a],f=e,y=t,R=y;e:for(;R!==null;){switch(R.tag){case 27:if(Oo(R.type)){$t=R.stateNode,Rn=!1;break e}break;case 5:$t=R.stateNode,Rn=!1;break e;case 3:case 4:$t=R.stateNode.containerInfo,Rn=!0;break e}R=R.return}if($t===null)throw Error(l(160));vx(f,y,u),$t=null,Rn=!1,f=u.alternate,f!==null&&(f.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Nx(t,e),t=t.sibling}var us=null;function Nx(e,t){var s=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:On(t,e),kn(e),a&4&&(Eo(3,e,e.return),nl(3,e),Eo(5,e,e.return));break;case 1:On(t,e),kn(e),a&512&&(sn||s===null||xs(s,s.return)),a&64&&Gs&&(e=e.updateQueue,e!==null&&(a=e.callbacks,a!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?a:s.concat(a))));break;case 26:var u=us;if(On(t,e),kn(e),a&512&&(sn||s===null||xs(s,s.return)),a&4){var f=s!==null?s.memoizedState:null;if(a=e.memoizedState,s===null)if(a===null)if(e.stateNode===null){e:{a=e.type,s=e.memoizedProps,u=u.ownerDocument||u;t:switch(a){case"title":f=u.getElementsByTagName("title")[0],(!f||f[ka]||f[on]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=u.createElement(a),u.head.insertBefore(f,u.querySelector("head > title"))),bn(f,a,s),f[on]=e,cn(f),a=f;break e;case"link":var y=Nb("link","href",u).get(a+(s.href||""));if(y){for(var R=0;R<y.length;R++)if(f=y[R],f.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&f.getAttribute("rel")===(s.rel==null?null:s.rel)&&f.getAttribute("title")===(s.title==null?null:s.title)&&f.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){y.splice(R,1);break t}}f=u.createElement(a),bn(f,a,s),u.head.appendChild(f);break;case"meta":if(y=Nb("meta","content",u).get(a+(s.content||""))){for(R=0;R<y.length;R++)if(f=y[R],f.getAttribute("content")===(s.content==null?null:""+s.content)&&f.getAttribute("name")===(s.name==null?null:s.name)&&f.getAttribute("property")===(s.property==null?null:s.property)&&f.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&f.getAttribute("charset")===(s.charSet==null?null:s.charSet)){y.splice(R,1);break t}}f=u.createElement(a),bn(f,a,s),u.head.appendChild(f);break;default:throw Error(l(468,a))}f[on]=e,cn(f),a=f}e.stateNode=a}else jb(u,e.type,e.stateNode);else e.stateNode=Eb(u,a,e.memoizedProps);else f!==a?(f===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):f.count--,a===null?jb(u,e.type,e.stateNode):Eb(u,a,e.memoizedProps)):a===null&&e.stateNode!==null&&Hd(e,e.memoizedProps,s.memoizedProps)}break;case 27:On(t,e),kn(e),a&512&&(sn||s===null||xs(s,s.return)),s!==null&&a&4&&Hd(e,e.memoizedProps,s.memoizedProps);break;case 5:if(On(t,e),kn(e),a&512&&(sn||s===null||xs(s,s.return)),e.flags&32){u=e.stateNode;try{Lr(u,"")}catch($e){At(e,e.return,$e)}}a&4&&e.stateNode!=null&&(u=e.memoizedProps,Hd(e,u,s!==null?s.memoizedProps:u)),a&1024&&(Vd=!0);break;case 6:if(On(t,e),kn(e),a&4){if(e.stateNode===null)throw Error(l(162));a=e.memoizedProps,s=e.stateNode;try{s.nodeValue=a}catch($e){At(e,e.return,$e)}}break;case 3:if(oc=null,u=us,us=nc(t.containerInfo),On(t,e),us=u,kn(e),a&4&&s!==null&&s.memoizedState.isDehydrated)try{ma(t.containerInfo)}catch($e){At(e,e.return,$e)}Vd&&(Vd=!1,jx(e));break;case 4:a=us,us=nc(e.stateNode.containerInfo),On(t,e),kn(e),us=a;break;case 12:On(t,e),kn(e);break;case 31:On(t,e),kn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Yi(e,a)));break;case 13:On(t,e),kn(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Fi=U()),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Yi(e,a)));break;case 22:u=e.memoizedState!==null;var X=s!==null&&s.memoizedState!==null,ue=Gs,ye=sn;if(Gs=ue||u,sn=ye||X,On(t,e),sn=ye,Gs=ue,kn(e),a&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||X||Gs||sn||ar(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){X=s=t;try{if(f=X.stateNode,u)y=f.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{R=X.stateNode;var Ne=X.memoizedProps.style,fe=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null;R.style.display=fe==null||typeof fe=="boolean"?"":(""+fe).trim()}}catch($e){At(X,X.return,$e)}}}else if(t.tag===6){if(s===null){X=t;try{X.stateNode.nodeValue=u?"":X.memoizedProps}catch($e){At(X,X.return,$e)}}}else if(t.tag===18){if(s===null){X=t;try{var he=X.stateNode;u?mb(he,!0):mb(X.stateNode,!1)}catch($e){At(X,X.return,$e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}a&4&&(a=e.updateQueue,a!==null&&(s=a.retryQueue,s!==null&&(a.retryQueue=null,Yi(e,s))));break;case 19:On(t,e),kn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Yi(e,a)));break;case 30:break;case 21:break;default:On(t,e),kn(e)}}function kn(e){var t=e.flags;if(t&2){try{for(var s,a=e.return;a!==null;){if(hx(a)){s=a;break}a=a.return}if(s==null)throw Error(l(160));switch(s.tag){case 27:var u=s.stateNode,f=Pd(e);Pi(e,f,u);break;case 5:var y=s.stateNode;s.flags&32&&(Lr(y,""),s.flags&=-33);var R=Pd(e);Pi(e,R,y);break;case 3:case 4:var X=s.stateNode.containerInfo,ue=Pd(e);Yd(e,ue,X);break;default:throw Error(l(161))}}catch(ye){At(e,e.return,ye)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function jx(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;jx(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function $s(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)bx(e,t.alternate,t),t=t.sibling}function ar(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Eo(4,t,t.return),ar(t);break;case 1:xs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&mx(t,t.return,s),ar(t);break;case 27:fl(t.stateNode);case 26:case 5:xs(t,t.return),ar(t);break;case 22:t.memoizedState===null&&ar(t);break;case 30:ar(t);break;default:ar(t)}e=e.sibling}}function Xs(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var a=t.alternate,u=e,f=t,y=f.flags;switch(f.tag){case 0:case 11:case 15:Xs(u,f,s),nl(4,f);break;case 1:if(Xs(u,f,s),a=f,u=a.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(ue){At(a,a.return,ue)}if(a=f,u=a.updateQueue,u!==null){var R=a.stateNode;try{var X=u.shared.hiddenCallbacks;if(X!==null)for(u.shared.hiddenCallbacks=null,u=0;u<X.length;u++)tg(X[u],R)}catch(ue){At(a,a.return,ue)}}s&&y&64&&fx(f),sl(f,f.return);break;case 27:gx(f);case 26:case 5:Xs(u,f,s),s&&a===null&&y&4&&px(f),sl(f,f.return);break;case 12:Xs(u,f,s);break;case 31:Xs(u,f,s),s&&y&4&&Sx(u,f);break;case 13:Xs(u,f,s),s&&y&4&&Ex(u,f);break;case 22:f.memoizedState===null&&Xs(u,f,s),sl(f,f.return);break;case 30:break;default:Xs(u,f,s)}t=t.sibling}}function Fd(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Va(s))}function Gd(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Va(e))}function ds(e,t,s,a){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Tx(e,t,s,a),t=t.sibling}function Tx(e,t,s,a){var u=t.flags;switch(t.tag){case 0:case 11:case 15:ds(e,t,s,a),u&2048&&nl(9,t);break;case 1:ds(e,t,s,a);break;case 3:ds(e,t,s,a),u&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Va(e)));break;case 12:if(u&2048){ds(e,t,s,a),e=t.stateNode;try{var f=t.memoizedProps,y=f.id,R=f.onPostCommit;typeof R=="function"&&R(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(X){At(t,t.return,X)}}else ds(e,t,s,a);break;case 31:ds(e,t,s,a);break;case 13:ds(e,t,s,a);break;case 23:break;case 22:f=t.stateNode,y=t.alternate,t.memoizedState!==null?f._visibility&2?ds(e,t,s,a):ol(e,t):f._visibility&2?ds(e,t,s,a):(f._visibility|=2,na(e,t,s,a,(t.subtreeFlags&10256)!==0||!1)),u&2048&&Fd(y,t);break;case 24:ds(e,t,s,a),u&2048&&Gd(t.alternate,t);break;default:ds(e,t,s,a)}}function na(e,t,s,a,u){for(u=u&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var f=e,y=t,R=s,X=a,ue=y.flags;switch(y.tag){case 0:case 11:case 15:na(f,y,R,X,u),nl(8,y);break;case 23:break;case 22:var ye=y.stateNode;y.memoizedState!==null?ye._visibility&2?na(f,y,R,X,u):ol(f,y):(ye._visibility|=2,na(f,y,R,X,u)),u&&ue&2048&&Fd(y.alternate,y);break;case 24:na(f,y,R,X,u),u&&ue&2048&&Gd(y.alternate,y);break;default:na(f,y,R,X,u)}t=t.sibling}}function ol(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,a=t,u=a.flags;switch(a.tag){case 22:ol(s,a),u&2048&&Fd(a.alternate,a);break;case 24:ol(s,a),u&2048&&Gd(a.alternate,a);break;default:ol(s,a)}t=t.sibling}}var rl=8192;function sa(e,t,s){if(e.subtreeFlags&rl)for(e=e.child;e!==null;)wx(e,t,s),e=e.sibling}function wx(e,t,s){switch(e.tag){case 26:sa(e,t,s),e.flags&rl&&e.memoizedState!==null&&zN(s,us,e.memoizedState,e.memoizedProps);break;case 5:sa(e,t,s);break;case 3:case 4:var a=us;us=nc(e.stateNode.containerInfo),sa(e,t,s),us=a;break;case 22:e.memoizedState===null&&(a=e.alternate,a!==null&&a.memoizedState!==null?(a=rl,rl=16777216,sa(e,t,s),rl=a):sa(e,t,s));break;default:sa(e,t,s)}}function Cx(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function al(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var a=t[s];un=a,Ox(a,e)}Cx(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Rx(e),e=e.sibling}function Rx(e){switch(e.tag){case 0:case 11:case 15:al(e),e.flags&2048&&Eo(9,e,e.return);break;case 3:al(e);break;case 12:al(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Vi(e)):al(e);break;default:al(e)}}function Vi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var a=t[s];un=a,Ox(a,e)}Cx(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Eo(8,t,t.return),Vi(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,Vi(t));break;default:Vi(t)}e=e.sibling}}function Ox(e,t){for(;un!==null;){var s=un;switch(s.tag){case 0:case 11:case 15:Eo(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var a=s.memoizedState.cachePool.pool;a!=null&&a.refCount++}break;case 24:Va(s.memoizedState.cache)}if(a=s.child,a!==null)a.return=s,un=a;else e:for(s=e;un!==null;){a=un;var u=a.sibling,f=a.return;if(yx(a),a===s){un=null;break e}if(u!==null){u.return=f,un=u;break e}un=f}}}var QE={getCacheForType:function(e){var t=gn(en),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return gn(en).controller.signal}},ZE=typeof WeakMap=="function"?WeakMap:Map,kt=0,Ht=null,ht=null,bt=0,Mt=0,Pn=null,No=!1,oa=!1,qd=!1,Ks=0,Kt=0,jo=0,lr=0,$d=0,Yn=0,ra=0,ll=null,_n=null,Xd=!1,Fi=0,kx=0,Gi=1/0,qi=null,To=null,rn=0,wo=null,aa=null,Qs=0,Kd=0,Qd=null,_x=null,il=0,Zd=null;function Vn(){return(kt&2)!==0&&bt!==0?bt&-bt:A.T!==null?sf():As()}function Mx(){if(Yn===0)if((bt&536870912)===0||Et){var e=Ot;Ot<<=1,(Ot&3932160)===0&&(Ot=262144),Yn=e}else Yn=536870912;return e=Un.current,e!==null&&(e.flags|=32),Yn}function Mn(e,t,s){(e===Ht&&(Mt===2||Mt===9)||e.cancelPendingCommit!==null)&&(la(e,0),Co(e,bt,Yn,!1)),ot(e,s),((kt&2)===0||e!==Ht)&&(e===Ht&&((kt&2)===0&&(lr|=s),Kt===4&&Co(e,bt,Yn,!1)),bs(e))}function Ax(e,t,s){if((kt&6)!==0)throw Error(l(327));var a=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Oe(e,t),u=a?eN(e,t):Wd(e,t,!0),f=a;do{if(u===0){oa&&!a&&Co(e,t,0,!1);break}else{if(s=e.current.alternate,f&&!JE(s)){u=Wd(e,t,!1),f=!1;continue}if(u===2){if(f=t,e.errorRecoveryDisabledLanes&f)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var R=e;u=ll;var X=R.current.memoizedState.isDehydrated;if(X&&(la(R,y).flags|=256),y=Wd(R,y,!1),y!==2){if(qd&&!X){R.errorRecoveryDisabledLanes|=f,lr|=f,u=4;break e}f=_n,_n=u,f!==null&&(_n===null?_n=f:_n.push.apply(_n,f))}u=y}if(f=!1,u!==2)continue}}if(u===1){la(e,0),Co(e,t,0,!0);break}e:{switch(a=e,f=u,f){case 0:case 1:throw Error(l(345));case 4:if((t&4194048)!==t)break;case 6:Co(a,t,Yn,!No);break e;case 2:_n=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(u=Fi+300-U(),10<u)){if(Co(a,t,Yn,!No),be(a,0,!0)!==0)break e;Qs=t,a.timeoutHandle=ub(Dx.bind(null,a,s,_n,qi,Xd,t,Yn,lr,ra,No,f,"Throttled",-0,0),u);break e}Dx(a,s,_n,qi,Xd,t,Yn,lr,ra,No,f,null,-0,0)}}break}while(!0);bs(e)}function Dx(e,t,s,a,u,f,y,R,X,ue,ye,Ne,fe,he){if(e.timeoutHandle=-1,Ne=t.subtreeFlags,Ne&8192||(Ne&16785408)===16785408){Ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zs},wx(t,f,Ne);var $e=(f&62914560)===f?Fi-U():(f&4194048)===f?kx-U():0;if($e=LN(Ne,$e),$e!==null){Qs=f,e.cancelPendingCommit=$e(Yx.bind(null,e,t,f,s,a,u,y,R,X,ye,Ne,null,fe,he)),Co(e,f,y,!ue);return}}Yx(e,t,f,s,a,u,y,R,X)}function JE(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var a=0;a<s.length;a++){var u=s[a],f=u.getSnapshot;u=u.value;try{if(!In(f(),u))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Co(e,t,s,a){t&=~$d,t&=~lr,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var u=t;0<u;){var f=31-Rt(u),y=1<<f;a[f]=-1,u&=~y}s!==0&&$n(e,s,t)}function $i(){return(kt&6)===0?(cl(0),!1):!0}function Jd(){if(ht!==null){if(Mt===0)var e=ht.return;else e=ht,Us=Jo=null,pd(e),Zr=null,Ga=0,e=ht;for(;e!==null;)dx(e.alternate,e),e=e.return;ht=null}}function la(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,bN(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Qs=0,Jd(),Ht=e,ht=s=Is(e.current,null),bt=t,Mt=0,Pn=null,No=!1,oa=Oe(e,t),qd=!1,ra=Yn=$d=lr=jo=Kt=0,_n=ll=null,Xd=!1,(t&8)!==0&&(t|=t&32);var a=e.entangledLanes;if(a!==0)for(e=e.entanglements,a&=t;0<a;){var u=31-Rt(a),f=1<<u;t|=e[u],a&=~f}return Ks=t,pi(),s}function zx(e,t){ct=null,A.H=Wa,t===Qr||t===Ei?(t=Zh(),Mt=3):t===nd?(t=Zh(),Mt=4):Mt=t===kd?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Pn=t,ht===null&&(Kt=1,Li(e,Zn(t,e.current)))}function Lx(){var e=Un.current;return e===null?!0:(bt&4194048)===bt?ts===null:(bt&62914560)===bt||(bt&536870912)!==0?e===ts:!1}function Ix(){var e=A.H;return A.H=Wa,e===null?Wa:e}function Bx(){var e=A.A;return A.A=QE,e}function Xi(){Kt=4,No||(bt&4194048)!==bt&&Un.current!==null||(oa=!0),(jo&134217727)===0&&(lr&134217727)===0||Ht===null||Co(Ht,bt,Yn,!1)}function Wd(e,t,s){var a=kt;kt|=2;var u=Ix(),f=Bx();(Ht!==e||bt!==t)&&(qi=null,la(e,t)),t=!1;var y=Kt;e:do try{if(Mt!==0&&ht!==null){var R=ht,X=Pn;switch(Mt){case 8:Jd(),y=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(t=!0);var ue=Mt;if(Mt=0,Pn=null,ia(e,R,X,ue),s&&oa){y=0;break e}break;default:ue=Mt,Mt=0,Pn=null,ia(e,R,X,ue)}}WE(),y=Kt;break}catch(ye){zx(e,ye)}while(!0);return t&&e.shellSuspendCounter++,Us=Jo=null,kt=a,A.H=u,A.A=f,ht===null&&(Ht=null,bt=0,pi()),y}function WE(){for(;ht!==null;)Ux(ht)}function eN(e,t){var s=kt;kt|=2;var a=Ix(),u=Bx();Ht!==e||bt!==t?(qi=null,Gi=U()+500,la(e,t)):oa=Oe(e,t);e:do try{if(Mt!==0&&ht!==null){t=ht;var f=Pn;t:switch(Mt){case 1:Mt=0,Pn=null,ia(e,t,f,1);break;case 2:case 9:if(Kh(f)){Mt=0,Pn=null,Hx(t);break}t=function(){Mt!==2&&Mt!==9||Ht!==e||(Mt=7),bs(e)},f.then(t,t);break e;case 3:Mt=7;break e;case 4:Mt=5;break e;case 7:Kh(f)?(Mt=0,Pn=null,Hx(t)):(Mt=0,Pn=null,ia(e,t,f,7));break;case 5:var y=null;switch(ht.tag){case 26:y=ht.memoizedState;case 5:case 27:var R=ht;if(y?Tb(y):R.stateNode.complete){Mt=0,Pn=null;var X=R.sibling;if(X!==null)ht=X;else{var ue=R.return;ue!==null?(ht=ue,Ki(ue)):ht=null}break t}}Mt=0,Pn=null,ia(e,t,f,5);break;case 6:Mt=0,Pn=null,ia(e,t,f,6);break;case 8:Jd(),Kt=6;break e;default:throw Error(l(462))}}tN();break}catch(ye){zx(e,ye)}while(!0);return Us=Jo=null,A.H=a,A.A=u,kt=s,ht!==null?0:(Ht=null,bt=0,pi(),Kt)}function tN(){for(;ht!==null&&!Ie();)Ux(ht)}function Ux(e){var t=cx(e.alternate,e,Ks);e.memoizedProps=e.pendingProps,t===null?Ki(e):ht=t}function Hx(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=sx(s,t,t.pendingProps,t.type,void 0,bt);break;case 11:t=sx(s,t,t.pendingProps,t.type.render,t.ref,bt);break;case 5:pd(t);default:dx(s,t),t=ht=Bh(t,Ks),t=cx(s,t,Ks)}e.memoizedProps=e.pendingProps,t===null?Ki(e):ht=t}function ia(e,t,s,a){Us=Jo=null,pd(t),Zr=null,Ga=0;var u=t.return;try{if(VE(e,u,t,s,bt)){Kt=1,Li(e,Zn(s,e.current)),ht=null;return}}catch(f){if(u!==null)throw ht=u,f;Kt=1,Li(e,Zn(s,e.current)),ht=null;return}t.flags&32768?(Et||a===1?e=!0:oa||(bt&536870912)!==0?e=!1:(No=e=!0,(a===2||a===9||a===3||a===6)&&(a=Un.current,a!==null&&a.tag===13&&(a.flags|=16384))),Px(t,e)):Ki(t)}function Ki(e){var t=e;do{if((t.flags&32768)!==0){Px(t,No);return}e=t.return;var s=qE(t.alternate,t,Ks);if(s!==null){ht=s;return}if(t=t.sibling,t!==null){ht=t;return}ht=t=e}while(t!==null);Kt===0&&(Kt=5)}function Px(e,t){do{var s=$E(e.alternate,e);if(s!==null){s.flags&=32767,ht=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){ht=e;return}ht=e=s}while(e!==null);Kt=6,ht=null}function Yx(e,t,s,a,u,f,y,R,X){e.cancelPendingCommit=null;do Qi();while(rn!==0);if((kt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(f=t.lanes|t.childLanes,f|=Pu,qt(e,s,f,y,R,X),e===Ht&&(ht=Ht=null,bt=0),aa=t,wo=e,Qs=s,Kd=f,Qd=u,_x=a,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,rN(ae,function(){return $x(),null})):(e.callbackNode=null,e.callbackPriority=0),a=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||a){a=A.T,A.T=null,u=D.p,D.p=2,y=kt,kt|=4;try{XE(e,t,s)}finally{kt=y,D.p=u,A.T=a}}rn=1,Vx(),Fx(),Gx()}}function Vx(){if(rn===1){rn=0;var e=wo,t=aa,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=A.T,A.T=null;var a=D.p;D.p=2;var u=kt;kt|=4;try{Nx(t,e);var f=ff,y=Oh(e.containerInfo),R=f.focusedElem,X=f.selectionRange;if(y!==R&&R&&R.ownerDocument&&Rh(R.ownerDocument.documentElement,R)){if(X!==null&&Lu(R)){var ue=X.start,ye=X.end;if(ye===void 0&&(ye=ue),"selectionStart"in R)R.selectionStart=ue,R.selectionEnd=Math.min(ye,R.value.length);else{var Ne=R.ownerDocument||document,fe=Ne&&Ne.defaultView||window;if(fe.getSelection){var he=fe.getSelection(),$e=R.textContent.length,et=Math.min(X.start,$e),Bt=X.end===void 0?et:Math.min(X.end,$e);!he.extend&&et>Bt&&(y=Bt,Bt=et,et=y);var se=Ch(R,et),W=Ch(R,Bt);if(se&&W&&(he.rangeCount!==1||he.anchorNode!==se.node||he.anchorOffset!==se.offset||he.focusNode!==W.node||he.focusOffset!==W.offset)){var ce=Ne.createRange();ce.setStart(se.node,se.offset),he.removeAllRanges(),et>Bt?(he.addRange(ce),he.extend(W.node,W.offset)):(ce.setEnd(W.node,W.offset),he.addRange(ce))}}}}for(Ne=[],he=R;he=he.parentNode;)he.nodeType===1&&Ne.push({element:he,left:he.scrollLeft,top:he.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<Ne.length;R++){var Ee=Ne[R];Ee.element.scrollLeft=Ee.left,Ee.element.scrollTop=Ee.top}}ic=!!df,ff=df=null}finally{kt=u,D.p=a,A.T=s}}e.current=t,rn=2}}function Fx(){if(rn===2){rn=0;var e=wo,t=aa,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=A.T,A.T=null;var a=D.p;D.p=2;var u=kt;kt|=4;try{bx(e,t.alternate,t)}finally{kt=u,D.p=a,A.T=s}}rn=3}}function Gx(){if(rn===4||rn===3){rn=0,ee();var e=wo,t=aa,s=Qs,a=_x;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?rn=5:(rn=0,aa=wo=null,qx(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(To=null),Ln(s),t=t.stateNode,mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(_t,t,void 0,(t.current.flags&128)===128)}catch{}if(a!==null){t=A.T,u=D.p,D.p=2,A.T=null;try{for(var f=e.onRecoverableError,y=0;y<a.length;y++){var R=a[y];f(R.value,{componentStack:R.stack})}}finally{A.T=t,D.p=u}}(Qs&3)!==0&&Qi(),bs(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Zd?il++:(il=0,Zd=e):il=0,cl(0)}}function qx(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Va(t)))}function Qi(){return Vx(),Fx(),Gx(),$x()}function $x(){if(rn!==5)return!1;var e=wo,t=Kd;Kd=0;var s=Ln(Qs),a=A.T,u=D.p;try{D.p=32>s?32:s,A.T=null,s=Qd,Qd=null;var f=wo,y=Qs;if(rn=0,aa=wo=null,Qs=0,(kt&6)!==0)throw Error(l(331));var R=kt;if(kt|=4,Rx(f.current),Tx(f,f.current,y,s),kt=R,cl(0,!1),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(_t,f)}catch{}return!0}finally{D.p=u,A.T=a,qx(e,t)}}function Xx(e,t,s){t=Zn(s,t),t=Od(e.stateNode,t,2),e=yo(e,t,2),e!==null&&(ot(e,2),bs(e))}function At(e,t,s){if(e.tag===3)Xx(e,e,s);else for(;t!==null;){if(t.tag===3){Xx(t,e,s);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(To===null||!To.has(a))){e=Zn(s,e),s=Kg(2),a=yo(t,s,2),a!==null&&(Qg(s,a,t,e),ot(a,2),bs(a));break}}t=t.return}}function ef(e,t,s){var a=e.pingCache;if(a===null){a=e.pingCache=new ZE;var u=new Set;a.set(t,u)}else u=a.get(t),u===void 0&&(u=new Set,a.set(t,u));u.has(s)||(qd=!0,u.add(s),e=nN.bind(null,e,t,s),t.then(e,e))}function nN(e,t,s){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Ht===e&&(bt&s)===s&&(Kt===4||Kt===3&&(bt&62914560)===bt&&300>U()-Fi?(kt&2)===0&&la(e,0):$d|=s,ra===bt&&(ra=0)),bs(e)}function Kx(e,t){t===0&&(t=nt()),e=Ko(e,t),e!==null&&(ot(e,t),bs(e))}function sN(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Kx(e,s)}function oN(e,t){var s=0;switch(e.tag){case 31:case 13:var a=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(l(314))}a!==null&&a.delete(t),Kx(e,s)}function rN(e,t){return Ue(e,t)}var Zi=null,ca=null,tf=!1,Ji=!1,nf=!1,Ro=0;function bs(e){e!==ca&&e.next===null&&(ca===null?Zi=ca=e:ca=ca.next=e),Ji=!0,tf||(tf=!0,lN())}function cl(e,t){if(!nf&&Ji){nf=!0;do for(var s=!1,a=Zi;a!==null;){if(e!==0){var u=a.pendingLanes;if(u===0)var f=0;else{var y=a.suspendedLanes,R=a.pingedLanes;f=(1<<31-Rt(42|e)+1)-1,f&=u&~(y&~R),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(s=!0,Wx(a,f))}else f=bt,f=be(a,a===Ht?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(f&3)===0||Oe(a,f)||(s=!0,Wx(a,f));a=a.next}while(s);nf=!1}}function aN(){Qx()}function Qx(){Ji=tf=!1;var e=0;Ro!==0&&xN()&&(e=Ro);for(var t=U(),s=null,a=Zi;a!==null;){var u=a.next,f=Zx(a,t);f===0?(a.next=null,s===null?Zi=u:s.next=u,u===null&&(ca=s)):(s=a,(e!==0||(f&3)!==0)&&(Ji=!0)),a=u}rn!==0&&rn!==5||cl(e),Ro!==0&&(Ro=0)}function Zx(e,t){for(var s=e.suspendedLanes,a=e.pingedLanes,u=e.expirationTimes,f=e.pendingLanes&-62914561;0<f;){var y=31-Rt(f),R=1<<y,X=u[y];X===-1?((R&s)===0||(R&a)!==0)&&(u[y]=Ze(R,t)):X<=t&&(e.expiredLanes|=R),f&=~R}if(t=Ht,s=bt,s=be(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a=e.callbackNode,s===0||e===t&&(Mt===2||Mt===9)||e.cancelPendingCommit!==null)return a!==null&&a!==null&&Pe(a),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Oe(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(a!==null&&Pe(a),Ln(s)){case 2:case 8:s=xe;break;case 32:s=ae;break;case 268435456:s=He;break;default:s=ae}return a=Jx.bind(null,e),s=Ue(s,a),e.callbackPriority=t,e.callbackNode=s,t}return a!==null&&a!==null&&Pe(a),e.callbackPriority=2,e.callbackNode=null,2}function Jx(e,t){if(rn!==0&&rn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(Qi()&&e.callbackNode!==s)return null;var a=bt;return a=be(e,e===Ht?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a===0?null:(Ax(e,a,t),Zx(e,U()),e.callbackNode!=null&&e.callbackNode===s?Jx.bind(null,e):null)}function Wx(e,t){if(Qi())return null;Ax(e,t,!0)}function lN(){yN(function(){(kt&6)!==0?Ue(je,aN):Qx()})}function sf(){if(Ro===0){var e=Xr;e===0&&(e=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),Ro=e}return Ro}function eb(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ai(""+e)}function tb(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function iN(e,t,s,a,u){if(t==="submit"&&s&&s.stateNode===u){var f=eb((u[wn]||null).action),y=a.submitter;y&&(t=(t=y[wn]||null)?eb(t.formAction):y.getAttribute("formAction"),t!==null&&(f=t,y=null));var R=new ui("action","action",null,a,u);e.push({event:R,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(Ro!==0){var X=y?tb(u,y):new FormData(u);Nd(s,{pending:!0,data:X,method:u.method,action:f},null,X)}}else typeof f=="function"&&(R.preventDefault(),X=y?tb(u,y):new FormData(u),Nd(s,{pending:!0,data:X,method:u.method,action:f},f,X))},currentTarget:u}]})}}for(var of=0;of<Hu.length;of++){var rf=Hu[of],cN=rf.toLowerCase(),uN=rf[0].toUpperCase()+rf.slice(1);cs(cN,"on"+uN)}cs(Mh,"onAnimationEnd"),cs(Ah,"onAnimationIteration"),cs(Dh,"onAnimationStart"),cs("dblclick","onDoubleClick"),cs("focusin","onFocus"),cs("focusout","onBlur"),cs(wE,"onTransitionRun"),cs(CE,"onTransitionStart"),cs(RE,"onTransitionCancel"),cs(zh,"onTransitionEnd"),Dr("onMouseEnter",["mouseout","mouseover"]),Dr("onMouseLeave",["mouseout","mouseover"]),Dr("onPointerEnter",["pointerout","pointerover"]),Dr("onPointerLeave",["pointerout","pointerover"]),Go("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Go("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Go("onBeforeInput",["compositionend","keypress","textInput","paste"]),Go("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Go("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Go("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ul="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),dN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ul));function nb(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var a=e[s],u=a.event;a=a.listeners;e:{var f=void 0;if(t)for(var y=a.length-1;0<=y;y--){var R=a[y],X=R.instance,ue=R.currentTarget;if(R=R.listener,X!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=ue;try{f(u)}catch(ye){mi(ye)}u.currentTarget=null,f=X}else for(y=0;y<a.length;y++){if(R=a[y],X=R.instance,ue=R.currentTarget,R=R.listener,X!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=ue;try{f(u)}catch(ye){mi(ye)}u.currentTarget=null,f=X}}}}function gt(e,t){var s=t[bu];s===void 0&&(s=t[bu]=new Set);var a=e+"__bubble";s.has(a)||(sb(t,e,2,!1),s.add(a))}function af(e,t,s){var a=0;t&&(a|=4),sb(s,e,a,t)}var Wi="_reactListening"+Math.random().toString(36).slice(2);function lf(e){if(!e[Wi]){e[Wi]=!0,Qp.forEach(function(s){s!=="selectionchange"&&(dN.has(s)||af(s,!1,e),af(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Wi]||(t[Wi]=!0,af("selectionchange",!1,t))}}function sb(e,t,s,a){switch(Mb(t)){case 2:var u=UN;break;case 8:u=HN;break;default:u=Nf}s=u.bind(null,t,s,e),u=void 0,!Cu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),a?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function cf(e,t,s,a,u){var f=a;if((t&1)===0&&(t&2)===0&&a!==null)e:for(;;){if(a===null)return;var y=a.tag;if(y===3||y===4){var R=a.stateNode.containerInfo;if(R===u)break;if(y===4)for(y=a.return;y!==null;){var X=y.tag;if((X===3||X===4)&&y.stateNode.containerInfo===u)return;y=y.return}for(;R!==null;){if(y=_r(R),y===null)return;if(X=y.tag,X===5||X===6||X===26||X===27){a=f=y;continue e}R=R.parentNode}}a=a.return}ih(function(){var ue=f,ye=Tu(s),Ne=[];e:{var fe=Lh.get(e);if(fe!==void 0){var he=ui,$e=e;switch(e){case"keypress":if(ii(s)===0)break e;case"keydown":case"keyup":he=oE;break;case"focusin":$e="focus",he=_u;break;case"focusout":$e="blur",he=_u;break;case"beforeblur":case"afterblur":he=_u;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":he=dh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":he=qS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":he=lE;break;case Mh:case Ah:case Dh:he=KS;break;case zh:he=cE;break;case"scroll":case"scrollend":he=FS;break;case"wheel":he=dE;break;case"copy":case"cut":case"paste":he=ZS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":he=mh;break;case"toggle":case"beforetoggle":he=mE}var et=(t&4)!==0,Bt=!et&&(e==="scroll"||e==="scrollend"),se=et?fe!==null?fe+"Capture":null:fe;et=[];for(var W=ue,ce;W!==null;){var Ee=W;if(ce=Ee.stateNode,Ee=Ee.tag,Ee!==5&&Ee!==26&&Ee!==27||ce===null||se===null||(Ee=Ma(W,se),Ee!=null&&et.push(dl(W,Ee,ce))),Bt)break;W=W.return}0<et.length&&(fe=new he(fe,$e,null,s,ye),Ne.push({event:fe,listeners:et}))}}if((t&7)===0){e:{if(fe=e==="mouseover"||e==="pointerover",he=e==="mouseout"||e==="pointerout",fe&&s!==ju&&($e=s.relatedTarget||s.fromElement)&&(_r($e)||$e[kr]))break e;if((he||fe)&&(fe=ye.window===ye?ye:(fe=ye.ownerDocument)?fe.defaultView||fe.parentWindow:window,he?($e=s.relatedTarget||s.toElement,he=ue,$e=$e?_r($e):null,$e!==null&&(Bt=d($e),et=$e.tag,$e!==Bt||et!==5&&et!==27&&et!==6)&&($e=null)):(he=null,$e=ue),he!==$e)){if(et=dh,Ee="onMouseLeave",se="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(et=mh,Ee="onPointerLeave",se="onPointerEnter",W="pointer"),Bt=he==null?fe:_a(he),ce=$e==null?fe:_a($e),fe=new et(Ee,W+"leave",he,s,ye),fe.target=Bt,fe.relatedTarget=ce,Ee=null,_r(ye)===ue&&(et=new et(se,W+"enter",$e,s,ye),et.target=ce,et.relatedTarget=Bt,Ee=et),Bt=Ee,he&&$e)t:{for(et=fN,se=he,W=$e,ce=0,Ee=se;Ee;Ee=et(Ee))ce++;Ee=0;for(var Je=W;Je;Je=et(Je))Ee++;for(;0<ce-Ee;)se=et(se),ce--;for(;0<Ee-ce;)W=et(W),Ee--;for(;ce--;){if(se===W||W!==null&&se===W.alternate){et=se;break t}se=et(se),W=et(W)}et=null}else et=null;he!==null&&ob(Ne,fe,he,et,!1),$e!==null&&Bt!==null&&ob(Ne,Bt,$e,et,!0)}}e:{if(fe=ue?_a(ue):window,he=fe.nodeName&&fe.nodeName.toLowerCase(),he==="select"||he==="input"&&fe.type==="file")var wt=Sh;else if(yh(fe))if(Eh)wt=NE;else{wt=SE;var Xe=vE}else he=fe.nodeName,!he||he.toLowerCase()!=="input"||fe.type!=="checkbox"&&fe.type!=="radio"?ue&&Nu(ue.elementType)&&(wt=Sh):wt=EE;if(wt&&(wt=wt(e,ue))){vh(Ne,wt,s,ye);break e}Xe&&Xe(e,fe,ue),e==="focusout"&&ue&&fe.type==="number"&&ue.memoizedProps.value!=null&&Eu(fe,"number",fe.value)}switch(Xe=ue?_a(ue):window,e){case"focusin":(yh(Xe)||Xe.contentEditable==="true")&&(Hr=Xe,Iu=ue,Ha=null);break;case"focusout":Ha=Iu=Hr=null;break;case"mousedown":Bu=!0;break;case"contextmenu":case"mouseup":case"dragend":Bu=!1,kh(Ne,s,ye);break;case"selectionchange":if(TE)break;case"keydown":case"keyup":kh(Ne,s,ye)}var dt;if(Au)e:{switch(e){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else Ur?xh(e,s)&&(yt="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(yt="onCompositionStart");yt&&(ph&&s.locale!=="ko"&&(Ur||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&Ur&&(dt=ch()):(fo=ye,Ru="value"in fo?fo.value:fo.textContent,Ur=!0)),Xe=ec(ue,yt),0<Xe.length&&(yt=new fh(yt,e,null,s,ye),Ne.push({event:yt,listeners:Xe}),dt?yt.data=dt:(dt=bh(s),dt!==null&&(yt.data=dt)))),(dt=hE?gE(e,s):xE(e,s))&&(yt=ec(ue,"onBeforeInput"),0<yt.length&&(Xe=new fh("onBeforeInput","beforeinput",null,s,ye),Ne.push({event:Xe,listeners:yt}),Xe.data=dt)),iN(Ne,e,ue,s,ye)}nb(Ne,t)})}function dl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function ec(e,t){for(var s=t+"Capture",a=[];e!==null;){var u=e,f=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||f===null||(u=Ma(e,s),u!=null&&a.unshift(dl(e,u,f)),u=Ma(e,t),u!=null&&a.push(dl(e,u,f))),e.tag===3)return a;e=e.return}return[]}function fN(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function ob(e,t,s,a,u){for(var f=t._reactName,y=[];s!==null&&s!==a;){var R=s,X=R.alternate,ue=R.stateNode;if(R=R.tag,X!==null&&X===a)break;R!==5&&R!==26&&R!==27||ue===null||(X=ue,u?(ue=Ma(s,f),ue!=null&&y.unshift(dl(s,ue,X))):u||(ue=Ma(s,f),ue!=null&&y.push(dl(s,ue,X)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var mN=/\r\n?/g,pN=/\u0000|\uFFFD/g;function rb(e){return(typeof e=="string"?e:""+e).replace(mN,`
9
+ `).replace(pN,"")}function ab(e,t){return t=rb(t),rb(e)===t}function It(e,t,s,a,u,f){switch(s){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Lr(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Lr(e,""+a);break;case"className":oi(e,"class",a);break;case"tabIndex":oi(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":oi(e,s,a);break;case"style":ah(e,a,f);break;case"data":if(t!=="object"){oi(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(s);break}a=ai(""+a),e.setAttribute(s,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof f=="function"&&(s==="formAction"?(t!=="input"&&It(e,t,"name",u.name,u,null),It(e,t,"formEncType",u.formEncType,u,null),It(e,t,"formMethod",u.formMethod,u,null),It(e,t,"formTarget",u.formTarget,u,null)):(It(e,t,"encType",u.encType,u,null),It(e,t,"method",u.method,u,null),It(e,t,"target",u.target,u,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(s);break}a=ai(""+a),e.setAttribute(s,a);break;case"onClick":a!=null&&(e.onclick=zs);break;case"onScroll":a!=null&&gt("scroll",e);break;case"onScrollEnd":a!=null&&gt("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(l(61));if(s=a.__html,s!=null){if(u.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}s=ai(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,""+a):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":a===!0?e.setAttribute(s,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,a):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(s,a):e.removeAttribute(s);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(s):e.setAttribute(s,a);break;case"popover":gt("beforetoggle",e),gt("toggle",e),si(e,"popover",a);break;case"xlinkActuate":Ds(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Ds(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Ds(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Ds(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Ds(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Ds(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Ds(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Ds(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Ds(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":si(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=YS.get(s)||s,si(e,s,a))}}function uf(e,t,s,a,u,f){switch(s){case"style":ah(e,a,f);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(l(61));if(s=a.__html,s!=null){if(u.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"children":typeof a=="string"?Lr(e,a):(typeof a=="number"||typeof a=="bigint")&&Lr(e,""+a);break;case"onScroll":a!=null&&gt("scroll",e);break;case"onScrollEnd":a!=null&&gt("scrollend",e);break;case"onClick":a!=null&&(e.onclick=zs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Zp.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(u=s.endsWith("Capture"),t=s.slice(2,u?s.length-7:void 0),f=e[wn]||null,f=f!=null?f[s]:null,typeof f=="function"&&e.removeEventListener(t,f,u),typeof a=="function")){typeof f!="function"&&f!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,a,u);break e}s in e?e[s]=a:a===!0?e.setAttribute(s,""):si(e,s,a)}}}function bn(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":gt("error",e),gt("load",e);var a=!1,u=!1,f;for(f in s)if(s.hasOwnProperty(f)){var y=s[f];if(y!=null)switch(f){case"src":a=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:It(e,t,f,y,s,null)}}u&&It(e,t,"srcSet",s.srcSet,s,null),a&&It(e,t,"src",s.src,s,null);return;case"input":gt("invalid",e);var R=f=y=u=null,X=null,ue=null;for(a in s)if(s.hasOwnProperty(a)){var ye=s[a];if(ye!=null)switch(a){case"name":u=ye;break;case"type":y=ye;break;case"checked":X=ye;break;case"defaultChecked":ue=ye;break;case"value":f=ye;break;case"defaultValue":R=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,t));break;default:It(e,t,a,ye,s,null)}}nh(e,f,R,X,ue,y,u,!1);return;case"select":gt("invalid",e),a=y=f=null;for(u in s)if(s.hasOwnProperty(u)&&(R=s[u],R!=null))switch(u){case"value":f=R;break;case"defaultValue":y=R;break;case"multiple":a=R;default:It(e,t,u,R,s,null)}t=f,s=y,e.multiple=!!a,t!=null?zr(e,!!a,t,!1):s!=null&&zr(e,!!a,s,!0);return;case"textarea":gt("invalid",e),f=u=a=null;for(y in s)if(s.hasOwnProperty(y)&&(R=s[y],R!=null))switch(y){case"value":a=R;break;case"defaultValue":u=R;break;case"children":f=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(l(91));break;default:It(e,t,y,R,s,null)}oh(e,a,u,f);return;case"option":for(X in s)s.hasOwnProperty(X)&&(a=s[X],a!=null)&&(X==="selected"?e.selected=a&&typeof a!="function"&&typeof a!="symbol":It(e,t,X,a,s,null));return;case"dialog":gt("beforetoggle",e),gt("toggle",e),gt("cancel",e),gt("close",e);break;case"iframe":case"object":gt("load",e);break;case"video":case"audio":for(a=0;a<ul.length;a++)gt(ul[a],e);break;case"image":gt("error",e),gt("load",e);break;case"details":gt("toggle",e);break;case"embed":case"source":case"link":gt("error",e),gt("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ue in s)if(s.hasOwnProperty(ue)&&(a=s[ue],a!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:It(e,t,ue,a,s,null)}return;default:if(Nu(t)){for(ye in s)s.hasOwnProperty(ye)&&(a=s[ye],a!==void 0&&uf(e,t,ye,a,s,void 0));return}}for(R in s)s.hasOwnProperty(R)&&(a=s[R],a!=null&&It(e,t,R,a,s,null))}function hN(e,t,s,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,f=null,y=null,R=null,X=null,ue=null,ye=null;for(he in s){var Ne=s[he];if(s.hasOwnProperty(he)&&Ne!=null)switch(he){case"checked":break;case"value":break;case"defaultValue":X=Ne;default:a.hasOwnProperty(he)||It(e,t,he,null,a,Ne)}}for(var fe in a){var he=a[fe];if(Ne=s[fe],a.hasOwnProperty(fe)&&(he!=null||Ne!=null))switch(fe){case"type":f=he;break;case"name":u=he;break;case"checked":ue=he;break;case"defaultChecked":ye=he;break;case"value":y=he;break;case"defaultValue":R=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(l(137,t));break;default:he!==Ne&&It(e,t,fe,he,a,Ne)}}Su(e,y,R,X,ue,ye,f,u);return;case"select":he=y=R=fe=null;for(f in s)if(X=s[f],s.hasOwnProperty(f)&&X!=null)switch(f){case"value":break;case"multiple":he=X;default:a.hasOwnProperty(f)||It(e,t,f,null,a,X)}for(u in a)if(f=a[u],X=s[u],a.hasOwnProperty(u)&&(f!=null||X!=null))switch(u){case"value":fe=f;break;case"defaultValue":R=f;break;case"multiple":y=f;default:f!==X&&It(e,t,u,f,a,X)}t=R,s=y,a=he,fe!=null?zr(e,!!s,fe,!1):!!a!=!!s&&(t!=null?zr(e,!!s,t,!0):zr(e,!!s,s?[]:"",!1));return;case"textarea":he=fe=null;for(R in s)if(u=s[R],s.hasOwnProperty(R)&&u!=null&&!a.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:It(e,t,R,null,a,u)}for(y in a)if(u=a[y],f=s[y],a.hasOwnProperty(y)&&(u!=null||f!=null))switch(y){case"value":fe=u;break;case"defaultValue":he=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(l(91));break;default:u!==f&&It(e,t,y,u,a,f)}sh(e,fe,he);return;case"option":for(var $e in s)fe=s[$e],s.hasOwnProperty($e)&&fe!=null&&!a.hasOwnProperty($e)&&($e==="selected"?e.selected=!1:It(e,t,$e,null,a,fe));for(X in a)fe=a[X],he=s[X],a.hasOwnProperty(X)&&fe!==he&&(fe!=null||he!=null)&&(X==="selected"?e.selected=fe&&typeof fe!="function"&&typeof fe!="symbol":It(e,t,X,fe,a,he));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var et in s)fe=s[et],s.hasOwnProperty(et)&&fe!=null&&!a.hasOwnProperty(et)&&It(e,t,et,null,a,fe);for(ue in a)if(fe=a[ue],he=s[ue],a.hasOwnProperty(ue)&&fe!==he&&(fe!=null||he!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(l(137,t));break;default:It(e,t,ue,fe,a,he)}return;default:if(Nu(t)){for(var Bt in s)fe=s[Bt],s.hasOwnProperty(Bt)&&fe!==void 0&&!a.hasOwnProperty(Bt)&&uf(e,t,Bt,void 0,a,fe);for(ye in a)fe=a[ye],he=s[ye],!a.hasOwnProperty(ye)||fe===he||fe===void 0&&he===void 0||uf(e,t,ye,fe,a,he);return}}for(var se in s)fe=s[se],s.hasOwnProperty(se)&&fe!=null&&!a.hasOwnProperty(se)&&It(e,t,se,null,a,fe);for(Ne in a)fe=a[Ne],he=s[Ne],!a.hasOwnProperty(Ne)||fe===he||fe==null&&he==null||It(e,t,Ne,fe,a,he)}function lb(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function gN(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),a=0;a<s.length;a++){var u=s[a],f=u.transferSize,y=u.initiatorType,R=u.duration;if(f&&R&&lb(y)){for(y=0,R=u.responseEnd,a+=1;a<s.length;a++){var X=s[a],ue=X.startTime;if(ue>R)break;var ye=X.transferSize,Ne=X.initiatorType;ye&&lb(Ne)&&(X=X.responseEnd,y+=ye*(X<R?1:(R-ue)/(X-ue)))}if(--a,t+=8*(f+y)/(u.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var df=null,ff=null;function tc(e){return e.nodeType===9?e:e.ownerDocument}function ib(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function cb(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function mf(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var pf=null;function xN(){var e=window.event;return e&&e.type==="popstate"?e===pf?!1:(pf=e,!0):(pf=null,!1)}var ub=typeof setTimeout=="function"?setTimeout:void 0,bN=typeof clearTimeout=="function"?clearTimeout:void 0,db=typeof Promise=="function"?Promise:void 0,yN=typeof queueMicrotask=="function"?queueMicrotask:typeof db<"u"?function(e){return db.resolve(null).then(e).catch(vN)}:ub;function vN(e){setTimeout(function(){throw e})}function Oo(e){return e==="head"}function fb(e,t){var s=t,a=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"||s==="/&"){if(a===0){e.removeChild(u),ma(t);return}a--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")a++;else if(s==="html")fl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,fl(s);for(var f=s.firstChild;f;){var y=f.nextSibling,R=f.nodeName;f[ka]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&f.rel.toLowerCase()==="stylesheet"||s.removeChild(f),f=y}}else s==="body"&&fl(e.ownerDocument.body);s=u}while(s);ma(t)}function mb(e,t){var s=e;e=0;do{var a=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),a&&a.nodeType===8)if(s=a.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=a}while(s)}function hf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":hf(s),yu(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function SN(e,t,s,a){for(;e.nodeType===1;){var u=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(a){if(!e[ka])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(f=e.getAttribute("rel"),f==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(f!==u.rel||e.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||e.getAttribute("title")!==(u.title==null?null:u.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(f=e.getAttribute("src"),(f!==(u.src==null?null:u.src)||e.getAttribute("type")!==(u.type==null?null:u.type)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&f&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var f=u.name==null?null:""+u.name;if(u.type==="hidden"&&e.getAttribute("name")===f)return e}else return e;if(e=ns(e.nextSibling),e===null)break}return null}function EN(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=ns(e.nextSibling),e===null))return null;return e}function pb(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=ns(e.nextSibling),e===null))return null;return e}function gf(e){return e.data==="$?"||e.data==="$~"}function xf(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function NN(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var a=function(){t(),s.removeEventListener("DOMContentLoaded",a)};s.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}function ns(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var bf=null;function hb(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return ns(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function gb(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function xb(e,t,s){switch(t=tc(s),e){case"html":if(e=t.documentElement,!e)throw Error(l(452));return e;case"head":if(e=t.head,!e)throw Error(l(453));return e;case"body":if(e=t.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function fl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yu(e)}var ss=new Map,bb=new Set;function nc(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Zs=D.d;D.d={f:jN,r:TN,D:wN,C:CN,L:RN,m:ON,X:_N,S:kN,M:MN};function jN(){var e=Zs.f(),t=$i();return e||t}function TN(e){var t=Mr(e);t!==null&&t.tag===5&&t.type==="form"?zg(t):Zs.r(e)}var ua=typeof document>"u"?null:document;function yb(e,t,s){var a=ua;if(a&&typeof t=="string"&&t){var u=Kn(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),bb.has(u)||(bb.add(u),e={rel:e,crossOrigin:s,href:t},a.querySelector(u)===null&&(t=a.createElement("link"),bn(t,"link",e),cn(t),a.head.appendChild(t)))}}function wN(e){Zs.D(e),yb("dns-prefetch",e,null)}function CN(e,t){Zs.C(e,t),yb("preconnect",e,t)}function RN(e,t,s){Zs.L(e,t,s);var a=ua;if(a&&e&&t){var u='link[rel="preload"][as="'+Kn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(u+='[imagesrcset="'+Kn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(u+='[imagesizes="'+Kn(s.imageSizes)+'"]')):u+='[href="'+Kn(e)+'"]';var f=u;switch(t){case"style":f=da(e);break;case"script":f=fa(e)}ss.has(f)||(e=x({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),ss.set(f,e),a.querySelector(u)!==null||t==="style"&&a.querySelector(ml(f))||t==="script"&&a.querySelector(pl(f))||(t=a.createElement("link"),bn(t,"link",e),cn(t),a.head.appendChild(t)))}}function ON(e,t){Zs.m(e,t);var s=ua;if(s&&e){var a=t&&typeof t.as=="string"?t.as:"script",u='link[rel="modulepreload"][as="'+Kn(a)+'"][href="'+Kn(e)+'"]',f=u;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=fa(e)}if(!ss.has(f)&&(e=x({rel:"modulepreload",href:e},t),ss.set(f,e),s.querySelector(u)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(pl(f)))return}a=s.createElement("link"),bn(a,"link",e),cn(a),s.head.appendChild(a)}}}function kN(e,t,s){Zs.S(e,t,s);var a=ua;if(a&&e){var u=Ar(a).hoistableStyles,f=da(e);t=t||"default";var y=u.get(f);if(!y){var R={loading:0,preload:null};if(y=a.querySelector(ml(f)))R.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":t},s),(s=ss.get(f))&&yf(e,s);var X=y=a.createElement("link");cn(X),bn(X,"link",e),X._p=new Promise(function(ue,ye){X.onload=ue,X.onerror=ye}),X.addEventListener("load",function(){R.loading|=1}),X.addEventListener("error",function(){R.loading|=2}),R.loading|=4,sc(y,t,a)}y={type:"stylesheet",instance:y,count:1,state:R},u.set(f,y)}}}function _N(e,t){Zs.X(e,t);var s=ua;if(s&&e){var a=Ar(s).hoistableScripts,u=fa(e),f=a.get(u);f||(f=s.querySelector(pl(u)),f||(e=x({src:e,async:!0},t),(t=ss.get(u))&&vf(e,t),f=s.createElement("script"),cn(f),bn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function MN(e,t){Zs.M(e,t);var s=ua;if(s&&e){var a=Ar(s).hoistableScripts,u=fa(e),f=a.get(u);f||(f=s.querySelector(pl(u)),f||(e=x({src:e,async:!0,type:"module"},t),(t=ss.get(u))&&vf(e,t),f=s.createElement("script"),cn(f),bn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function vb(e,t,s,a){var u=(u=P.current)?nc(u):null;if(!u)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=da(s.href),s=Ar(u).hoistableStyles,a=s.get(t),a||(a={type:"style",instance:null,count:0,state:null},s.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=da(s.href);var f=Ar(u).hoistableStyles,y=f.get(e);if(y||(u=u.ownerDocument||u,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(e,y),(f=u.querySelector(ml(e)))&&!f._p&&(y.instance=f,y.state.loading=5),ss.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},ss.set(e,s),f||AN(u,e,s,y.state))),t&&a===null)throw Error(l(528,""));return y}if(t&&a!==null)throw Error(l(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=fa(s),s=Ar(u).hoistableScripts,a=s.get(t),a||(a={type:"script",instance:null,count:0,state:null},s.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function da(e){return'href="'+Kn(e)+'"'}function ml(e){return'link[rel="stylesheet"]['+e+"]"}function Sb(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function AN(e,t,s,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),bn(t,"link",s),cn(t),e.head.appendChild(t))}function fa(e){return'[src="'+Kn(e)+'"]'}function pl(e){return"script[async]"+e}function Eb(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Kn(s.href)+'"]');if(a)return t.instance=a,cn(a),a;var u=x({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),cn(a),bn(a,"style",u),sc(a,s.precedence,e),t.instance=a;case"stylesheet":u=da(s.href);var f=e.querySelector(ml(u));if(f)return t.state.loading|=4,t.instance=f,cn(f),f;a=Sb(s),(u=ss.get(u))&&yf(a,u),f=(e.ownerDocument||e).createElement("link"),cn(f);var y=f;return y._p=new Promise(function(R,X){y.onload=R,y.onerror=X}),bn(f,"link",a),t.state.loading|=4,sc(f,s.precedence,e),t.instance=f;case"script":return f=fa(s.src),(u=e.querySelector(pl(f)))?(t.instance=u,cn(u),u):(a=s,(u=ss.get(f))&&(a=x({},s),vf(a,u)),e=e.ownerDocument||e,u=e.createElement("script"),cn(u),bn(u,"link",a),e.head.appendChild(u),t.instance=u);case"void":return null;default:throw Error(l(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,sc(a,s.precedence,e));return t.instance}function sc(e,t,s){for(var a=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=a.length?a[a.length-1]:null,f=u,y=0;y<a.length;y++){var R=a[y];if(R.dataset.precedence===t)f=R;else if(f!==u)break}f?f.parentNode.insertBefore(e,f.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function yf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function vf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var oc=null;function Nb(e,t,s){if(oc===null){var a=new Map,u=oc=new Map;u.set(s,a)}else u=oc,a=u.get(s),a||(a=new Map,u.set(s,a));if(a.has(e))return a;for(a.set(e,null),s=s.getElementsByTagName(e),u=0;u<s.length;u++){var f=s[u];if(!(f[ka]||f[on]||e==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var y=f.getAttribute(t)||"";y=e+y;var R=a.get(y);R?R.push(f):a.set(y,[f])}}return a}function jb(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function DN(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Tb(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function zN(e,t,s,a){if(s.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var u=da(a.href),f=t.querySelector(ml(u));if(f){t=f._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=rc.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=f,cn(f);return}f=t.ownerDocument||t,a=Sb(a),(u=ss.get(u))&&yf(a,u),f=f.createElement("link"),cn(f);var y=f;y._p=new Promise(function(R,X){y.onload=R,y.onerror=X}),bn(f,"link",a),s.instance=f}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=rc.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var Sf=0;function LN(e,t){return e.stylesheets&&e.count===0&&lc(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var a=setTimeout(function(){if(e.stylesheets&&lc(e,e.stylesheets),e.unsuspend){var f=e.unsuspend;e.unsuspend=null,f()}},6e4+t);0<e.imgBytes&&Sf===0&&(Sf=62500*gN());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&lc(e,e.stylesheets),e.unsuspend)){var f=e.unsuspend;e.unsuspend=null,f()}},(e.imgBytes>Sf?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(u)}}:null}function rc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)lc(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ac=null;function lc(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ac=new Map,t.forEach(IN,e),ac=null,rc.call(e))}function IN(e,t){if(!(t.state.loading&4)){var s=ac.get(e);if(s)var a=s.get(null);else{s=new Map,ac.set(e,s);for(var u=e.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<u.length;f++){var y=u[f];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(s.set(y.dataset.precedence,y),a=y)}a&&s.set(null,a)}u=t.instance,y=u.getAttribute("data-precedence"),f=s.get(y)||a,f===a&&s.set(null,u),s.set(y,u),this.count++,a=rc.bind(this),u.addEventListener("load",a),u.addEventListener("error",a),f?f.parentNode.insertBefore(u,f.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(u,e.firstChild)),t.state.loading|=4}}var hl={$$typeof:k,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function BN(e,t,s,a,u,f,y,R,X){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=at(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=at(0),this.hiddenUpdates=at(null),this.identifierPrefix=a,this.onUncaughtError=u,this.onCaughtError=f,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=X,this.incompleteTransitions=new Map}function wb(e,t,s,a,u,f,y,R,X,ue,ye,Ne){return e=new BN(e,t,s,y,X,ue,ye,Ne,R),t=1,f===!0&&(t|=24),f=Bn(3,null,null,t),e.current=f,f.stateNode=e,t=Wu(),t.refCount++,e.pooledCache=t,t.refCount++,f.memoizedState={element:a,isDehydrated:s,cache:t},sd(f),e}function Cb(e){return e?(e=Vr,e):Vr}function Rb(e,t,s,a,u,f){u=Cb(u),a.context===null?a.context=u:a.pendingContext=u,a=bo(t),a.payload={element:s},f=f===void 0?null:f,f!==null&&(a.callback=f),s=yo(e,a,t),s!==null&&(Mn(s,e,t),$a(s,e,t))}function Ob(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Ef(e,t){Ob(e,t),(e=e.alternate)&&Ob(e,t)}function kb(e){if(e.tag===13||e.tag===31){var t=Ko(e,67108864);t!==null&&Mn(t,e,67108864),Ef(e,67108864)}}function _b(e){if(e.tag===13||e.tag===31){var t=Vn();t=uo(t);var s=Ko(e,t);s!==null&&Mn(s,e,t),Ef(e,t)}}var ic=!0;function UN(e,t,s,a){var u=A.T;A.T=null;var f=D.p;try{D.p=2,Nf(e,t,s,a)}finally{D.p=f,A.T=u}}function HN(e,t,s,a){var u=A.T;A.T=null;var f=D.p;try{D.p=8,Nf(e,t,s,a)}finally{D.p=f,A.T=u}}function Nf(e,t,s,a){if(ic){var u=jf(a);if(u===null)cf(e,t,a,cc,s),Ab(e,a);else if(YN(u,e,t,s,a))a.stopPropagation();else if(Ab(e,a),t&4&&-1<PN.indexOf(e)){for(;u!==null;){var f=Mr(u);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var y=ne(f.pendingLanes);if(y!==0){var R=f;for(R.pendingLanes|=2,R.entangledLanes|=2;y;){var X=1<<31-Rt(y);R.entanglements[1]|=X,y&=~X}bs(f),(kt&6)===0&&(Gi=U()+500,cl(0))}}break;case 31:case 13:R=Ko(f,2),R!==null&&Mn(R,f,2),$i(),Ef(f,2)}if(f=jf(a),f===null&&cf(e,t,a,cc,s),f===u)break;u=f}u!==null&&a.stopPropagation()}else cf(e,t,a,null,s)}}function jf(e){return e=Tu(e),Tf(e)}var cc=null;function Tf(e){if(cc=null,e=_r(e),e!==null){var t=d(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=m(t),e!==null)return e;e=null}else if(s===31){if(e=g(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return cc=e,null}function Mb(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch($()){case je:return 2;case xe:return 8;case ae:case Re:return 32;case He:return 268435456;default:return 32}default:return 32}}var wf=!1,ko=null,_o=null,Mo=null,gl=new Map,xl=new Map,Ao=[],PN="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Ab(e,t){switch(e){case"focusin":case"focusout":ko=null;break;case"dragenter":case"dragleave":_o=null;break;case"mouseover":case"mouseout":Mo=null;break;case"pointerover":case"pointerout":gl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":xl.delete(t.pointerId)}}function bl(e,t,s,a,u,f){return e===null||e.nativeEvent!==f?(e={blockedOn:t,domEventName:s,eventSystemFlags:a,nativeEvent:f,targetContainers:[u]},t!==null&&(t=Mr(t),t!==null&&kb(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function YN(e,t,s,a,u){switch(t){case"focusin":return ko=bl(ko,e,t,s,a,u),!0;case"dragenter":return _o=bl(_o,e,t,s,a,u),!0;case"mouseover":return Mo=bl(Mo,e,t,s,a,u),!0;case"pointerover":var f=u.pointerId;return gl.set(f,bl(gl.get(f)||null,e,t,s,a,u)),!0;case"gotpointercapture":return f=u.pointerId,xl.set(f,bl(xl.get(f)||null,e,t,s,a,u)),!0}return!1}function Db(e){var t=_r(e.target);if(t!==null){var s=d(t);if(s!==null){if(t=s.tag,t===13){if(t=m(s),t!==null){e.blockedOn=t,ni(e.priority,function(){_b(s)});return}}else if(t===31){if(t=g(s),t!==null){e.blockedOn=t,ni(e.priority,function(){_b(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function uc(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=jf(e.nativeEvent);if(s===null){s=e.nativeEvent;var a=new s.constructor(s.type,s);ju=a,s.target.dispatchEvent(a),ju=null}else return t=Mr(s),t!==null&&kb(t),e.blockedOn=s,!1;t.shift()}return!0}function zb(e,t,s){uc(e)&&s.delete(t)}function VN(){wf=!1,ko!==null&&uc(ko)&&(ko=null),_o!==null&&uc(_o)&&(_o=null),Mo!==null&&uc(Mo)&&(Mo=null),gl.forEach(zb),xl.forEach(zb)}function dc(e,t){e.blockedOn===t&&(e.blockedOn=null,wf||(wf=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,VN)))}var fc=null;function Lb(e){fc!==e&&(fc=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){fc===e&&(fc=null);for(var t=0;t<e.length;t+=3){var s=e[t],a=e[t+1],u=e[t+2];if(typeof a!="function"){if(Tf(a||s)===null)continue;break}var f=Mr(s);f!==null&&(e.splice(t,3),t-=3,Nd(f,{pending:!0,data:u,method:s.method,action:a},a,u))}}))}function ma(e){function t(X){return dc(X,e)}ko!==null&&dc(ko,e),_o!==null&&dc(_o,e),Mo!==null&&dc(Mo,e),gl.forEach(t),xl.forEach(t);for(var s=0;s<Ao.length;s++){var a=Ao[s];a.blockedOn===e&&(a.blockedOn=null)}for(;0<Ao.length&&(s=Ao[0],s.blockedOn===null);)Db(s),s.blockedOn===null&&Ao.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(a=0;a<s.length;a+=3){var u=s[a],f=s[a+1],y=u[wn]||null;if(typeof f=="function")y||Lb(s);else if(y){var R=null;if(f&&f.hasAttribute("formAction")){if(u=f,y=f[wn]||null)R=y.formAction;else if(Tf(u)!==null)continue}else R=y.action;typeof R=="function"?s[a+1]=R:(s.splice(a,3),a-=3),Lb(s)}}}function Ib(){function e(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(y){return u=y})},focusReset:"manual",scroll:"manual"})}function t(){u!==null&&(u(),u=null),a||setTimeout(s,20)}function s(){if(!a&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var a=!1,u=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){a=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),u!==null&&(u(),u=null)}}}function Cf(e){this._internalRoot=e}mc.prototype.render=Cf.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var s=t.current,a=Vn();Rb(s,a,e,t,null,null)},mc.prototype.unmount=Cf.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Rb(e.current,2,null,e,null,null),$i(),t[kr]=null}};function mc(e){this._internalRoot=e}mc.prototype.unstable_scheduleHydration=function(e){if(e){var t=As();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Ao.length&&t!==0&&t<Ao[s].priority;s++);Ao.splice(s,0,e),s===0&&Db(e)}};var Bb=o.version;if(Bb!=="19.2.8")throw Error(l(527,Bb,"19.2.8"));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=p(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var FN={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var pc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!pc.isDisabled&&pc.supportsFiber)try{_t=pc.inject(FN),mt=pc}catch{}}return vl.createRoot=function(e,t){if(!c(e))throw Error(l(299));var s=!1,a="",u=Gg,f=qg,y=$g;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(u=t.onUncaughtError),t.onCaughtError!==void 0&&(f=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=wb(e,1,!1,null,null,s,a,null,u,f,y,Ib),e[kr]=t.current,lf(e),new Cf(t)},vl.hydrateRoot=function(e,t,s){if(!c(e))throw Error(l(299));var a=!1,u="",f=Gg,y=qg,R=$g,X=null;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(f=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(R=s.onRecoverableError),s.formState!==void 0&&(X=s.formState)),t=wb(e,1,!0,t,s??null,a,u,X,f,y,R,Ib),t.context=Cb(null),s=t.current,a=Vn(),a=uo(a),u=bo(a),u.callback=null,yo(s,u,a),s=a,t.current.lanes=s,ot(t,s),bs(t),e[kr]=t.current,lf(e),new mc(t)},vl.version="19.2.8",vl}var Xb;function tj(){if(Xb)return kf.exports;Xb=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(o){console.error(o)}}return n(),kf.exports=ej(),kf.exports}var nj=tj();const Ta=["character","setting","location","hook","event","timepoint"],Bm=["belongs_to","owns","masters","ally","rival","mentor","family","kills","appears_in","occurs_at","plot_edge","plants","advances","resolves","depends_on","involves","occurs_in"],sj="plot_edge",oj=["mystery","relationship","item","character_growth","world_building"],$v=["inner","personal","extra_personal"],rj=[5,10,15,30,60],Kb=30;function is(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=l=>String(l).padStart(2,"0");return`${o.getFullYear()}-${r(o.getMonth()+1)}-${r(o.getDate())} ${r(o.getHours())}:${r(o.getMinutes())}`}function gr(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=Math.floor((Date.now()-o.getTime())/6e4);if(r<1)return"刚刚";if(r<60)return`${r} 分钟前`;const l=Math.floor(r/60);if(l<24)return`${l} 小时前`;const c=Math.floor(l/24);return c<30?`${c} 天前`:is(n)}const aj=["outline","entities","canvas","hooks","timeline","trash","settings"];function Qb(n){const o=n.replace(/^#/,"").replace(/^\/+/,""),r=o===""?[]:o.split("/").filter(c=>c!=="");return r.length>0&&!aj.includes(r[0])?{path:"/",segments:[],isFallback:!0}:{path:`/${r.join("/")}`,segments:r,isFallback:!1}}function lj(){const[n,o]=h.useState(()=>Qb(window.location.hash));return h.useEffect(()=>{const r=()=>{const l=Qb(window.location.hash);o(l),l.isFallback&&window.location.hash!=="#/"&&window.location.replace("#/")};return window.addEventListener("hashchange",r),r(),()=>window.removeEventListener("hashchange",r)},[]),n}function Tn(n){const o=n.startsWith("#")?n:`#${n.startsWith("/")?n:`/${n}`}`;window.location.hash!==o&&(window.location.hash=o)}const Xv=(...n)=>n.filter((o,r,l)=>!!o&&o.trim()!==""&&l.indexOf(o)===r).join(" ").trim();const ij=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const cj=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,r,l)=>l?l.toUpperCase():r.toLowerCase());const Zb=n=>{const o=cj(n);return o.charAt(0).toUpperCase()+o.slice(1)};var Df={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"};const uj=n=>{for(const o in n)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1},dj=h.createContext({}),fj=()=>h.useContext(dj),mj=h.forwardRef(({color:n,size:o,strokeWidth:r,absoluteStrokeWidth:l,className:c="",children:d,iconNode:m,...g},b)=>{const{size:p=24,strokeWidth:v=2,absoluteStrokeWidth:x=!1,color:S="currentColor",className:j=""}=fj()??{},E=l??x?Number(r??v)*24/Number(o??p):r??v;return h.createElement("svg",{ref:b,...Df,width:o??p??Df.width,height:o??p??Df.height,stroke:n??S,strokeWidth:E,className:Xv("lucide",j,c),...!d&&!uj(g)&&{"aria-hidden":"true"},...g},[...m.map(([_,O])=>h.createElement(_,O)),...Array.isArray(d)?d:[d]])});const lt=(n,o)=>{const r=h.forwardRef(({className:l,...c},d)=>h.createElement(mj,{ref:d,iconNode:o,className:Xv(`lucide-${ij(Zb(n))}`,`lucide-${n}`,l),...c}));return r.displayName=Zb(n),r};const pj=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hj=lt("arrow-up",pj);const gj=[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]],Ll=lt("book-open",gj);const xj=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],bj=lt("calendar-clock",xj);const yj=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Kv=lt("check",yj);const vj=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Sj=lt("chevron-down",vj);const Ej=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Um=lt("chevron-right",Ej);const Nj=[["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"}]],Hm=lt("circle-alert",Nj);const jj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Pm=lt("circle-check",jj);const Tj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],wj=lt("circle",Tj);const Cj=[["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"}]],Rj=lt("download",Cj);const Oj=[["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"}]],kj=lt("eye",Oj);const _j=[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]],Mj=lt("fast-forward",_j);const Aj=[["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"}]],Ym=lt("grip-vertical",Aj);const Dj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qv=lt("info",Dj);const zj=[["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"}]],Lj=lt("layout-grid",zj);const Ij=[["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"}]],Bj=lt("list-ordered",Ij);const Uj=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],Hj=lt("list-tree",Uj);const Pj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Il=lt("loader-circle",Pj);const Yj=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Bl=lt("message-square",Yj);const Vj=[["path",{d:"M5 12h14",key:"1ays0h"}]],Fj=lt("minus",Vj);const Gj=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],qj=lt("moon",Gj);const $j=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Xj=lt("network",$j);const Kj=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Qj=lt("octagon-x",Kj);const Zj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Jj=lt("panel-left-close",Zj);const Wj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],eT=lt("panel-left-open",Wj);const tT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],nT=lt("panel-right-close",tT);const sT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],oT=lt("panel-right-open",sT);const rT=[["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"}]],Kl=lt("pencil",rT);const aT=[["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"}]],lT=lt("pin",aT);const iT=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Zc=lt("plus",iT);const cT=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],uT=lt("puzzle",cT);const dT=[["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"}]],fT=lt("refresh-cw",dT);const mT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],pT=lt("rotate-ccw",mT);const hT=[["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"}]],gT=lt("send",hT);const xT=[["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"}]],bT=lt("settings",xT);const yT=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],vT=lt("shapes",yT);const ST=[["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"}]],Zv=lt("sparkles",ST);const ET=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],NT=lt("sun",ET);const jT=[["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"}]],Ql=lt("trash-2",jT);const TT=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Vm=lt("triangle-alert",TT);const wT=[["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"}]],CT=lt("upload",wT);const RT=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],OT=lt("wrench",RT);const kT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],fs=lt("x",kT);function Fm(n){const[o,r]=h.useState(()=>window.matchMedia(n).matches);return h.useEffect(()=>{const l=window.matchMedia(n),c=d=>r(d.matches);return r(l.matches),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[n]),o}const Ul=160,Gm=480,Hl=240,qm=720,_T=320,Jv="ai-editor:panels",Jb=1024,cm=1440;function Pl(n,o,r){return Math.round(Math.min(Math.max(n,o),r))}function hc(n){const o=Number.isFinite(n)&&n>0?n:cm;return{sidebarWidth:o<Jb?Ul:Pl(o*.1,Ul,Gm),chatWidth:o<Jb?Hl:Pl(o*.4,Hl,qm),collapsedSidebar:!1,collapsedChat:!1}}function MT(n,o){if(!n)return hc(o);let r;try{r=JSON.parse(n)}catch{return hc(o)}if(typeof r!="object"||r===null||Array.isArray(r))return hc(o);const l=r,c=l.sidebarWidth,d=l.chatWidth;return typeof c!="number"||!Number.isFinite(c)||typeof d!="number"||!Number.isFinite(d)?hc(o):{sidebarWidth:Pl(c,Ul,Gm),chatWidth:Pl(d,Hl,qm),collapsedSidebar:l.collapsedSidebar===!0,collapsedChat:l.collapsedChat===!0}}function Wb(n){return JSON.stringify({sidebarWidth:n.sidebarWidth,chatWidth:n.chatWidth,collapsedSidebar:n.collapsedSidebar,collapsedChat:n.collapsedChat})}function AT(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Jv)}catch{return null}}function ey(n){try{window.localStorage.setItem(Jv,n)}catch{}}function DT(){if(typeof window>"u")return cm;const n=window.innerWidth;return Number.isFinite(n)&&n>0?n:cm}function zT(){const[n,o]=h.useState(()=>MT(AT(),DT())),[r,l]=h.useState(null),c=Fm("(min-width: 1024px)"),d=h.useRef(null);h.useEffect(()=>{!c&&d.current!==null&&(d.current=null,l(null))},[c]);function m(x){const S=x.lastX-x.startX,[j,E]=x.side==="sidebar"?[Ul,Gm]:[Hl,qm],_=x.side==="sidebar"?x.startWidth+S:x.startWidth-S;return Pl(_,j,E)}function g(x,S){const j=x==="sidebar"?n.sidebarWidth:n.chatWidth;d.current={side:x,startX:S,startWidth:j,lastX:S},l(x)}function b(x,S){const j=d.current;if(!j||j.side!==x)return;j.lastX=S;const E=m(j);o(_=>({..._,...x==="sidebar"?{sidebarWidth:E}:{chatWidth:E}}))}function p(){const x=d.current;if(!x)return;const S=m(x);d.current=null,l(null),o(j=>{const E={...j,...x.side==="sidebar"?{sidebarWidth:S}:{chatWidth:S}};return ey(Wb(E)),E})}function v(x){o(S=>{const j=x==="sidebar"?{...S,collapsedSidebar:!S.collapsedSidebar}:{...S,collapsedChat:!S.collapsedChat};return ey(Wb(j)),j})}return{layout:n,isDesktop:c,dragSide:r,toggleCollapse:v,startResize:g,moveResize:b,endResize:p}}function Wv(n){var o,r,l="";if(typeof n=="string"||typeof n=="number")l+=n;else if(typeof n=="object")if(Array.isArray(n)){var c=n.length;for(o=0;o<c;o++)n[o]&&(r=Wv(n[o]))&&(l&&(l+=" "),l+=r)}else for(r in n)n[r]&&(l&&(l+=" "),l+=r);return l}function e0(){for(var n,o,r=0,l="",c=arguments.length;r<c;r++)(n=arguments[r])&&(o=Wv(n))&&(l&&(l+=" "),l+=o);return l}const LT=(n,o)=>{const r=new Array(n.length+o.length);for(let l=0;l<n.length;l++)r[l]=n[l];for(let l=0;l<o.length;l++)r[n.length+l]=o[l];return r},IT=(n,o)=>({classGroupId:n,validator:o}),t0=(n=new Map,o=null,r)=>({nextPart:n,validators:o,classGroupId:r}),Bc="-",ty=[],BT="arbitrary..",UT=n=>{const o=PT(n),{conflictingClassGroups:r,conflictingClassGroupModifiers:l}=n;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return HT(m);const g=m.split(Bc),b=g[0]===""&&g.length>1?1:0;return n0(g,b,o)},getConflictingClassGroupIds:(m,g)=>{if(g){const b=l[m],p=r[m];return b?p?LT(p,b):b:p||ty}return r[m]||ty}}},n0=(n,o,r)=>{if(n.length-o===0)return r.classGroupId;const c=n[o],d=r.nextPart.get(c);if(d){const p=n0(n,o+1,d);if(p)return p}const m=r.validators;if(m===null)return;const g=o===0?n.join(Bc):n.slice(o).join(Bc),b=m.length;for(let p=0;p<b;p++){const v=m[p];if(v.validator(g))return v.classGroupId}},HT=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const o=n.slice(1,-1),r=o.indexOf(":"),l=o.slice(0,r);return l?BT+l:void 0})(),PT=n=>{const{theme:o,classGroups:r}=n;return YT(r,o)},YT=(n,o)=>{const r=t0();for(const l in n){const c=n[l];$m(c,r,l,o)}return r},$m=(n,o,r,l)=>{const c=n.length;for(let d=0;d<c;d++){const m=n[d];VT(m,o,r,l)}},VT=(n,o,r,l)=>{if(typeof n=="string"){FT(n,o,r);return}if(typeof n=="function"){GT(n,o,r,l);return}qT(n,o,r,l)},FT=(n,o,r)=>{const l=n===""?o:s0(o,n);l.classGroupId=r},GT=(n,o,r,l)=>{if($T(n)){$m(n(l),o,r,l);return}o.validators===null&&(o.validators=[]),o.validators.push(IT(r,n))},qT=(n,o,r,l)=>{const c=Object.entries(n),d=c.length;for(let m=0;m<d;m++){const[g,b]=c[m];$m(b,s0(o,g),r,l)}},s0=(n,o)=>{let r=n;const l=o.split(Bc),c=l.length;for(let d=0;d<c;d++){const m=l[d];let g=r.nextPart.get(m);g||(g=t0(),r.nextPart.set(m,g)),r=g}return r},$T=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,XT=n=>{if(n<1)return{get:()=>{},set:()=>{}};let o=0,r=Object.create(null),l=Object.create(null);const c=(d,m)=>{r[d]=m,o++,o>n&&(o=0,l=r,r=Object.create(null))};return{get(d){let m=r[d];if(m!==void 0)return m;if((m=l[d])!==void 0)return c(d,m),m},set(d,m){d in r?r[d]=m:c(d,m)}}},um="!",ny=":",KT=[],sy=(n,o,r,l,c)=>({modifiers:n,hasImportantModifier:o,baseClassName:r,maybePostfixModifierPosition:l,isExternal:c}),QT=n=>{const{prefix:o,experimentalParseClassName:r}=n;let l=c=>{const d=[];let m=0,g=0,b=0,p;const v=c.length;for(let _=0;_<v;_++){const O=c[_];if(m===0&&g===0){if(O===ny){d.push(c.slice(b,_)),b=_+1;continue}if(O==="/"){p=_;continue}}O==="["?m++:O==="]"?m--:O==="("?g++:O===")"&&g--}const x=d.length===0?c:c.slice(b);let S=x,j=!1;x.endsWith(um)?(S=x.slice(0,-1),j=!0):x.startsWith(um)&&(S=x.slice(1),j=!0);const E=p&&p>b?p-b:void 0;return sy(d,j,S,E)};if(o){const c=o+ny,d=l;l=m=>m.startsWith(c)?d(m.slice(c.length)):sy(KT,!1,m,void 0,!0)}if(r){const c=l;l=d=>r({className:d,parseClassName:c})}return l},ZT=n=>{const o=new Map;return n.orderSensitiveModifiers.forEach((r,l)=>{o.set(r,1e6+l)}),r=>{const l=[];let c=[];for(let d=0;d<r.length;d++){const m=r[d],g=m[0]==="[",b=o.has(m);g||b?(c.length>0&&(c.sort(),l.push(...c),c=[]),l.push(m)):c.push(m)}return c.length>0&&(c.sort(),l.push(...c)),l}},JT=n=>({cache:XT(n.cacheSize),parseClassName:QT(n),sortModifiers:ZT(n),postfixLookupClassGroupIds:WT(n),...UT(n)}),WT=n=>{const o=Object.create(null),r=n.postfixLookupClassGroups;if(r)for(let l=0;l<r.length;l++)o[r[l]]=!0;return o},ew=/\s+/,tw=(n,o)=>{const{parseClassName:r,getClassGroupId:l,getConflictingClassGroupIds:c,sortModifiers:d,postfixLookupClassGroupIds:m}=o,g=[],b=n.trim().split(ew);let p="";for(let v=b.length-1;v>=0;v-=1){const x=b[v],{isExternal:S,modifiers:j,hasImportantModifier:E,baseClassName:_,maybePostfixModifierPosition:O}=r(x);if(S){p=x+(p.length>0?" "+p:p);continue}let N=!!O,T;if(N){const L=_.substring(0,O);T=l(L);const w=T&&m[T]?l(_):void 0;w&&w!==T&&(T=w,N=!1)}else T=l(_);if(!T){if(!N){p=x+(p.length>0?" "+p:p);continue}if(T=l(_),!T){p=x+(p.length>0?" "+p:p);continue}N=!1}const k=j.length===0?"":j.length===1?j[0]:d(j).join(":"),C=E?k+um:k,H=C+T;if(g.indexOf(H)>-1)continue;g.push(H);const M=c(T,N);for(let L=0;L<M.length;++L){const w=M[L];g.push(C+w)}p=x+(p.length>0?" "+p:p)}return p},nw=(...n)=>{let o=0,r,l,c="";for(;o<n.length;)(r=n[o++])&&(l=o0(r))&&(c&&(c+=" "),c+=l);return c},o0=n=>{if(typeof n=="string")return n;let o,r="";for(let l=0;l<n.length;l++)n[l]&&(o=o0(n[l]))&&(r&&(r+=" "),r+=o);return r},sw=(n,...o)=>{let r,l,c,d;const m=b=>{const p=o.reduce((v,x)=>x(v),n());return r=JT(p),l=r.cache.get,c=r.cache.set,d=g,g(b)},g=b=>{const p=l(b);if(p)return p;const v=tw(b,r);return c(b,v),v};return d=m,(...b)=>d(nw(...b))},ow=[],an=n=>{const o=r=>r[n]||ow;return o.isThemeGetter=!0,o},r0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,a0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rw=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,aw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lw=/\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$/,iw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zo=n=>rw.test(n),ft=n=>!!n&&!Number.isNaN(Number(n)),ys=n=>!!n&&Number.isInteger(Number(n)),zf=n=>n.endsWith("%")&&ft(n.slice(0,-1)),Js=n=>aw.test(n),l0=()=>!0,dw=n=>lw.test(n)&&!iw.test(n),Xm=()=>!1,fw=n=>cw.test(n),mw=n=>uw.test(n),pw=n=>!Ve(n)&&!Ge(n),hw=n=>n.startsWith("@container")&&(n[10]==="/"&&n[11]!==void 0||n[11]==="s"&&n[16]!==void 0&&n.startsWith("-size/",10)||n[11]==="n"&&n[18]!==void 0&&n.startsWith("-normal/",10)),gw=n=>Yo(n,u0,Xm),Ve=n=>r0.test(n),ir=n=>Yo(n,d0,dw),oy=n=>Yo(n,jw,ft),xw=n=>Yo(n,m0,l0),bw=n=>Yo(n,f0,Xm),ry=n=>Yo(n,i0,Xm),yw=n=>Yo(n,c0,mw),gc=n=>Yo(n,p0,fw),Ge=n=>a0.test(n),Sl=n=>jr(n,d0),vw=n=>jr(n,f0),ay=n=>jr(n,i0),Sw=n=>jr(n,u0),Ew=n=>jr(n,c0),xc=n=>jr(n,p0,!0),Nw=n=>jr(n,m0,!0),Yo=(n,o,r)=>{const l=r0.exec(n);return l?l[1]?o(l[1]):r(l[2]):!1},jr=(n,o,r=!1)=>{const l=a0.exec(n);return l?l[1]?o(l[1]):r:!1},i0=n=>n==="position"||n==="percentage",c0=n=>n==="image"||n==="url",u0=n=>n==="length"||n==="size"||n==="bg-size",d0=n=>n==="length",jw=n=>n==="number",f0=n=>n==="family-name",m0=n=>n==="number"||n==="weight",p0=n=>n==="shadow",Tw=()=>{const n=an("color"),o=an("font"),r=an("text"),l=an("font-weight"),c=an("tracking"),d=an("leading"),m=an("breakpoint"),g=an("container"),b=an("spacing"),p=an("radius"),v=an("shadow"),x=an("inset-shadow"),S=an("text-shadow"),j=an("drop-shadow"),E=an("blur"),_=an("perspective"),O=an("aspect"),N=an("ease"),T=an("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],H=()=>[...C(),Ge,Ve],M=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],w=()=>[Ge,Ve,b],J=()=>[zo,"full","auto",...w()],oe=()=>[ys,"none","subgrid",Ge,Ve],ie=()=>["auto",{span:["full",ys,Ge,Ve]},ys,Ge,Ve],te=()=>[ys,"auto",Ge,Ve],Q=()=>["auto","min","max","fr",Ge,Ve],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],K=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...w()],D=()=>[zo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],B=()=>[zo,"screen","full","dvw","lvw","svw","min","max","fit",...w()],I=()=>[zo,"screen","full","lh","dvh","lvh","svh","min","max","fit",...w()],V=()=>[n,Ge,Ve],z=()=>[...C(),ay,ry,{position:[Ge,Ve]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",Sw,gw,{size:[Ge,Ve]}],Y=()=>[zf,Sl,ir],q=()=>["","none","full",p,Ge,Ve],P=()=>["",ft,Sl,ir],me=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[ft,zf,ay,ry],Le=()=>["","none",E,Ge,Ve],De=()=>["none",ft,Ge,Ve],we=()=>["none",ft,Ge,Ve],Be=()=>[ft,Ge,Ve],ge=()=>[zo,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Js],breakpoint:[Js],color:[l0],container:[Js],"drop-shadow":[Js],ease:["in","out","in-out"],font:[pw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Js],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Js],shadow:[Js],spacing:["px",ft],text:[Js],"text-shadow":[Js],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zo,Ve,Ge,O]}],container:["container"],"container-type":[{"@container":["","normal","size",Ge,Ve]}],"container-named":[hw],columns:[{columns:[ft,Ve,Ge,g]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:H()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{"inset-s":J(),start:J()}],end:[{"inset-e":J(),end:J()}],"inset-bs":[{"inset-bs":J()}],"inset-be":[{"inset-be":J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[ys,"auto",Ge,Ve]}],basis:[{basis:[zo,"full","auto",g,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ft,zo,"auto","initial","none",Ve]}],grow:[{grow:["",ft,Ge,Ve]}],shrink:[{shrink:["",ft,Ge,Ve]}],order:[{order:[ys,"first","last","none",Ge,Ve]}],"grid-cols":[{"grid-cols":oe()}],"col-start-end":[{col:ie()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":oe()}],"row-start-end":[{row:ie()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...K(),"normal"]}],"justify-self":[{"justify-self":["auto",...K()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...K(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...K(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...K(),"baseline"]}],"place-self":[{"place-self":["auto",...K()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...I()]}],"min-block-size":[{"min-block":["auto",...I()]}],"max-block-size":[{"max-block":["none",...I()]}],w:[{w:[g,"screen",...D()]}],"min-w":[{"min-w":[g,"screen","none",...D()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[m]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,Sl,ir]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,Nw,xw]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zf,Ve]}],"font-family":[{font:[vw,bw,o]}],"font-features":[{"font-features":[Ve]}],"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:[c,Ge,Ve]}],"line-clamp":[{"line-clamp":[ft,"none",Ge,oy]}],leading:[{leading:[d,...w()]}],"list-image":[{"list-image":["none",Ge,Ve]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ge,Ve]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...me(),"wavy"]}],"text-decoration-thickness":[{decoration:[ft,"from-font","auto",Ge,ir]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[ft,"auto",Ge,Ve]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"tab-size":[{tab:[ys,Ge,Ve]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ge,Ve]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ge,Ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ys,Ge,Ve],radial:["",Ge,Ve],conic:[ys,Ge,Ve]},Ew,yw]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:q()}],"rounded-s":[{"rounded-s":q()}],"rounded-e":[{"rounded-e":q()}],"rounded-t":[{"rounded-t":q()}],"rounded-r":[{"rounded-r":q()}],"rounded-b":[{"rounded-b":q()}],"rounded-l":[{"rounded-l":q()}],"rounded-ss":[{"rounded-ss":q()}],"rounded-se":[{"rounded-se":q()}],"rounded-ee":[{"rounded-ee":q()}],"rounded-es":[{"rounded-es":q()}],"rounded-tl":[{"rounded-tl":q()}],"rounded-tr":[{"rounded-tr":q()}],"rounded-br":[{"rounded-br":q()}],"rounded-bl":[{"rounded-bl":q()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...me(),"hidden","none"]}],"divide-style":[{divide:[...me(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ft,Ge,Ve]}],"outline-w":[{outline:["",ft,Sl,ir]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",v,xc,gc]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",x,xc,gc]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[ft,ir]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",S,xc,gc]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[ft,Ge,Ve]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ft]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Ge,Ve]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[ft]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ge,Ve]}],filter:[{filter:["","none",Ge,Ve]}],blur:[{blur:Le()}],brightness:[{brightness:[ft,Ge,Ve]}],contrast:[{contrast:[ft,Ge,Ve]}],"drop-shadow":[{"drop-shadow":["","none",j,xc,gc]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",ft,Ge,Ve]}],"hue-rotate":[{"hue-rotate":[ft,Ge,Ve]}],invert:[{invert:["",ft,Ge,Ve]}],saturate:[{saturate:[ft,Ge,Ve]}],sepia:[{sepia:["",ft,Ge,Ve]}],"backdrop-filter":[{"backdrop-filter":["","none",Ge,Ve]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[ft,Ge,Ve]}],"backdrop-contrast":[{"backdrop-contrast":[ft,Ge,Ve]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ft,Ge,Ve]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ft,Ge,Ve]}],"backdrop-invert":[{"backdrop-invert":["",ft,Ge,Ve]}],"backdrop-opacity":[{"backdrop-opacity":[ft,Ge,Ve]}],"backdrop-saturate":[{"backdrop-saturate":[ft,Ge,Ve]}],"backdrop-sepia":[{"backdrop-sepia":["",ft,Ge,Ve]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ge,Ve]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ft,"initial",Ge,Ve]}],ease:[{ease:["linear","initial",N,Ge,Ve]}],delay:[{delay:[ft,Ge,Ve]}],animate:[{animate:["none",T,Ge,Ve]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,Ge,Ve]}],"perspective-origin":[{"perspective-origin":H()}],rotate:[{rotate:De()}],"rotate-x":[{"rotate-x":De()}],"rotate-y":[{"rotate-y":De()}],"rotate-z":[{"rotate-z":De()}],scale:[{scale:we()}],"scale-x":[{"scale-x":we()}],"scale-y":[{"scale-y":we()}],"scale-z":[{"scale-z":we()}],"scale-3d":["scale-3d"],skew:[{skew:Be()}],"skew-x":[{"skew-x":Be()}],"skew-y":[{"skew-y":Be()}],transform:[{transform:[Ge,Ve,"","none","gpu","cpu"]}],"transform-origin":[{origin:H()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ge()}],"translate-x":[{"translate-x":ge()}],"translate-y":[{"translate-y":ge()}],"translate-z":[{"translate-z":ge()}],"translate-none":["translate-none"],zoom:[{zoom:[ys,Ge,Ve]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"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",Ge,Ve]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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",Ge,Ve]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[ft,Sl,ir,oy]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-bs","border-w-be","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-bs","border-color-be","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-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ww=sw(Tw);function Qe(...n){return ww(e0(n))}const ly=n=>{let o;const r=new Set,l=(p,v)=>{const x=typeof p=="function"?p(o):p;if(!Object.is(x,o)){const S=o;o=v??(typeof x!="object"||x===null)?x:Object.assign({},o,x),r.forEach(j=>j(o,S))}},c=()=>o,g={setState:l,getState:c,getInitialState:()=>b,subscribe:p=>(r.add(p),()=>r.delete(p))},b=o=n(l,c,g);return g},Cw=(n=>n?ly(n):ly),Rw=n=>n;function Ow(n,o=Rw){const r=Me.useSyncExternalStore(n.subscribe,Me.useCallback(()=>o(n.getState()),[n,o]),Me.useCallback(()=>o(n.getInitialState()),[n,o]));return Me.useDebugValue(r),r}const iy=n=>{const o=Cw(n),r=l=>Ow(o,l);return Object.assign(r,o),r},Km=(n=>n?iy(n):iy),kw="/api/v1",ut="CLIENT_NETWORK_ERROR";class _e extends Error{code;constructor(o,r){super(r),this.name="ApiError",this.code=o}}function _w(n){const o=new URLSearchParams;for(const[l,c]of Object.entries(n))c!=null&&o.set(l,String(c));const r=o.toString();return r?`?${r}`:""}function h0(n,o){const r=n.startsWith("/")?n:`/${n}`;return`${kw}${r}${_w(o??{})}`}function Mw(n){return typeof n=="object"&&n!==null&&n.success===!0}function g0(n){if(typeof n!="object"||n===null)return!1;const o=n.error;return n.success===!1&&typeof o=="object"&&o!==null&&typeof o.code=="string"&&typeof o.message=="string"}async function it(n,o={}){const{method:r="GET",body:l,query:c,headers:d,signal:m}=o;let g;try{g=await fetch(h0(n,c),{method:r,headers:l===void 0||l instanceof FormData?d:{"Content-Type":"application/json",...d},body:l===void 0?void 0:l instanceof FormData?l:JSON.stringify(l),signal:m})}catch(p){throw new _e(ut,p instanceof Error?p.message:"网络请求失败")}const b=await g.json().catch(()=>null);if(Mw(b))return b.data;throw g0(b)?new _e(b.error.code,b.error.message):new _e(ut,`非预期响应(HTTP ${g.status})`)}function Aw(){return it("/project/config")}function Dw(n){return it("/project/config",{method:"PUT",body:n})}function zw(){return it("/outline")}function Lw(n){return it("/outline",{method:"POST",body:n})}function x0(n,o){return it(`/outline/${n}`,{method:"PUT",body:o})}function cy(n,o){return it(`/outline/${n}/move`,{method:"PUT",body:o})}function Iw(n){return it(`/outline/${n}`,{method:"DELETE"})}function Bw(){return it("/trash")}function Uw(n,o){return it(`/trash/entity/${n}/${o}/restore`,{method:"POST"})}function Hw(n,o){return it(`/trash/entity/${n}/${o}`,{method:"DELETE"})}function uy(n){return it(`/trash/outline/${n}/restore`,{method:"POST"})}function Pw(n){return it(`/trash/outline/${n}`,{method:"DELETE"})}function ls(n,o={}){return it(`/entity/${n}`,{query:o})}function fr(n,o){return it(`/entity/${n}/${o}`)}function Uc(n,o){return it(`/entity/${n}`,{method:"POST",body:o})}function xr(n,o,r){return it(`/entity/${n}/${o}`,{method:"PUT",body:r})}function Jc(n,o){return it(`/entity/${n}/${o}`,{method:"DELETE"})}function Yw(n,o){return it(`/entity/event/${n}/move`,{method:"PUT",body:o})}function Vw(n,o){return it(`/entity/timepoint/${n}/move`,{method:"PUT",body:o})}function b0(n,o){return it(`/entity/event/${n}/move_to`,{method:"POST",body:o})}function br(n){return it("/relation",{query:{source_type:n.source_type,source_id:n.source_id,target_type:n.target_type,target_id:n.target_id,relation_type:n.relation_type,depth:n.depth}})}function yr(n){return it("/relation",{method:"POST",body:n})}function Wc(n){return it(`/relation/${n}`,{method:"DELETE"})}function Fw(n,o){return it(`/relation/${n}`,{method:"PUT",body:{metadata:o}})}function Gw(n){return it(`/delta/node/${n}`)}function qw(n){return it("/delta/compute",{method:"POST",body:n})}function Qm(n){return it("/delta",{method:"POST",body:n})}function $w(){return it("/project/list")}function Xw(n,o){return it("/project/create",{method:"POST",body:{path:n,...o!==void 0?{config:o}:{}}})}function Kw(n){return it("/project/open",{method:"POST",body:{path:n}})}function Qw(){return it("/project/close",{method:"POST"})}function Zw(n){if(n!==null){const o=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(n);if(o)try{return decodeURIComponent(o[1])}catch{}const r=/filename\s*=\s*"?([^";]+)"?/i.exec(n);if(r)return r[1]}return"project.zip"}async function Jw(){let n;try{n=await fetch(h0("/project/export"))}catch(r){throw new _e(ut,r instanceof Error?r.message:"网络请求失败")}const o=n.headers.get("content-type")??"";if(n.ok&&(o.includes("zip")||o.includes("octet-stream")))return{blob:await n.blob(),filename:Zw(n.headers.get("content-disposition"))};if(o.includes("application/json")){const r=await n.json().catch(()=>null);if(g0(r))throw new _e(r.error.code,r.error.message)}throw new _e(ut,`非预期响应(HTTP ${n.status})`)}async function Ww(n,o){const r=new FormData;return r.append("file",n,"backup.zip"),r.append("name",o),it("/project/import",{method:"POST",body:r})}function e2(){return it("/project/backups")}function t2(n){return it("/project/backup",{method:"POST",...n!==void 0?{body:{name:n}}:{}})}function n2(n){return it("/project/backup/restore",{method:"POST",body:{fileName:n}})}function s2(n,o){const r=o?.trim()??"";return it("/project/backup/rename",{method:"POST",body:{fileName:n,name:r}})}function o2(n){return it("/project/rename",{method:"POST",body:{name:n}})}function r2(){return it("/settings/llm")}function Lf(n){return it("/settings/llm",{method:"PUT",body:n})}function a2(){return it("/chat/sessions").then(n=>n.sessions)}function l2(n){return it(`/chat/sessions/${n}/messages`)}function i2(n){return it(`/proposal/${n}/confirm`,{method:"POST"})}function c2(n){return it(`/proposal/${n}/reject`,{method:"POST"})}const dm=3e3;let u2=0;const Ce=Km((n,o)=>({error:null,showError:(r,l)=>n({error:{code:r,message:l}}),clearError:()=>n({error:null}),toast:null,showToast:(r,l="success")=>{const c=++u2;n({toast:{id:c,kind:l,text:r}}),setTimeout(()=>{n(d=>d.toast?.id===c?{toast:null}:{})},dm)},clearToast:()=>n({toast:null}),confirmState:null,confirm:r=>new Promise(l=>{n({confirmState:{...r,resolve:l}})}),resolveConfirm:r=>{const l=o().confirmState;l&&(l.resolve(r),n({confirmState:null}))},focusOutlineNodeId:null,setFocusOutlineNode:r=>n({focusOutlineNodeId:r}),clearFocusOutlineNode:()=>n({focusOutlineNodeId:null}),dataVersion:0,notifyDataChanged:()=>n(r=>({dataVersion:r.dataVersion+1}))})),ze=Km((n,o)=>({config:null,configLoading:!1,loadError:null,outline:null,outlineLoading:!1,bookshelf:null,bookshelfLoading:!1,bookshelfError:null,loadConfig:async()=>{if(!o().configLoading){n({configLoading:!0});try{const r=await Aw();n({config:r,loadError:null})}catch(r){const l=r instanceof _e?r.code:"CLIENT_NETWORK_ERROR";n({config:null,loadError:l})}finally{n({configLoading:!1})}}},updateConfig:async r=>{await Dw(r),await o().loadConfig()},loadOutline:async()=>{if(!o().outlineLoading){n({outlineLoading:!0});try{const r=await zw();n({outline:r})}catch{n({outline:null})}finally{n({outlineLoading:!1})}}},loadBookshelf:async()=>{if(!o().bookshelfLoading){n({bookshelfLoading:!0});try{const r=await $w();n({bookshelf:r,bookshelfError:null})}catch(r){const l=r instanceof _e?r.code:"CLIENT_NETWORK_ERROR";n({bookshelf:null,bookshelfError:l})}finally{n({bookshelfLoading:!1})}}},openProjectAt:async r=>{const l=await Kw(r);n({config:l.config,loadError:null}),Ce.getState().clearFocusOutlineNode(),l.rebuilt?Ce.getState().showToast(`项目已按新版本重建${l.fromVersion!==void 0?`(v${l.fromVersion})`:""},备份已保留`):l.migrated&&Ce.getState().showToast(`项目数据已自动升级${l.fromVersion!==void 0?`(v${l.fromVersion} → 当前版本)`:""},快照已保留`),await o().loadOutline()},createProjectAt:async(r,l)=>{await Xw(r,l),await o().openProjectAt(r)},closeProject:async()=>{await Qw(),n({config:null,loadError:null,outline:null}),Ce.getState().clearFocusOutlineNode()}}));function y0(n,o){if(n.id===o)return n;if("children"in n&&n.children)for(const r of n.children){const l=y0(r,o);if(l)return l}return null}function v0(n,o){if(!n||!o)return null;for(const r of n.children){const l=y0(r,o);if(l)return l.title}return null}function S0(n,o){return`${n.replace(/\/+$/,"")}/books/${o.trim()}`}const d2="[DONE]",f2=6e4;function m2(n){const o=[];let r=n,l;for(;(l=r.indexOf(`
10
+
11
+ `))!==-1;)o.push(r.slice(0,l)),r=r.slice(l+2);return{frames:o,rest:r}}function dy(n){let o="message";const r=[];for(const l of n.split(`
12
+ `))if(!(l===""||l.startsWith(":"))){if(l.startsWith("event:"))o=l.slice(6).trim();else if(l.startsWith("data:")){let c=l.slice(5);c.startsWith(" ")&&(c=c.slice(1)),r.push(c)}}return r.length===0?null:{event:o,data:r.join(`
13
+ `)}}function fy(n){if(typeof n!="object"||n===null)return!1;const o=n.error;return typeof o=="object"&&o!==null&&typeof o.code=="string"&&typeof o.message=="string"}function p2(n,o){const{onEvent:r,timeoutMs:l=f2,onTimeout:c,onEnd:d,signal:m,body:g}=o,b=new AbortController,p=()=>b.abort();m&&(m.aborted?b.abort():m.addEventListener("abort",p));let v="",x=!1,S=!1,j=!1,E=!1,_=null;const O=()=>{_!==null&&(clearTimeout(_),_=null)},N=()=>{O(),_=setTimeout(()=>{x||(S=!0,x=!0,c?.(),b.abort())},l)},T=k=>{if(k.data===d2)return!1;let C=k.data;try{C=JSON.parse(k.data)}catch{}return r(k.event,C),k.event!=="error"};return N(),(async()=>{try{const k=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:g===void 0?void 0:JSON.stringify(g),signal:b.signal});if(!k.ok||!k.body){const M=await k.json().catch(()=>null),L=fy(M)?M.error.code:ut,w=fy(M)?M.error.message:`SSE 请求失败(HTTP ${k.status})`;x=!0,E=!0,r("error",{code:L,message:w});return}const C=k.body.getReader(),H=new TextDecoder;for(;!x;){const{done:M,value:L}=await C.read();if(M)break;v=(v+H.decode(L,{stream:!0})).replace(/\r\n/g,`
14
+ `);const{frames:w,rest:J}=m2(v);v=J;for(const oe of w){const ie=dy(oe);if(ie){if(!T(ie)){x=!0;break}N()}}}if(!x&&v.trim()!==""){const M=dy(v.trim());M&&!T(M)&&(x=!0)}}catch{!S&&!j&&(x=!0,E=!0,r("error",{code:ut,message:"网络请求失败"}))}finally{O(),m&&m.removeEventListener("abort",p),x=!0,!S&&!j&&!E&&d?.()}})(),()=>{x||(j=!0,x=!0,O(),b.abort())}}function h2(n,o){return o.includes("HTTP 404")?"聊天服务暂不可用":n==="CLIENT_NETWORK_ERROR"&&!o.includes("HTTP ")?"连接失败,请确认服务已启动":o}function g2(n,o){switch(n){case"INTERNAL_ERROR":return"提案执行失败,请让 AI 重新生成提案";case"CLIENT_NETWORK_ERROR":return"网络请求失败,请重试";default:return o}}let pa=0,ha=0,my=0,cr=null,vs=null,ga=null;const St=Km((n,o)=>{const r=async(l,c,d)=>{const m=o().proposals.find(g=>g.proposalId===l);if(!(!m||m.status!=="pending"||m.processing===!0)){n(g=>({proposals:g.proposals.map(b=>b.proposalId===l?{...b,processing:!0}:b)}));try{await c(l),n(g=>({proposals:g.proposals.map(b=>b.proposalId===l?{...b,status:d,processing:!1}:b)})),d==="confirmed"&&Ce.getState().notifyDataChanged()}catch(g){const b=g instanceof _e?g.code:"CLIENT_NETWORK_ERROR",p=g instanceof Error?g.message:"网络请求失败";switch(b){case"PROPOSAL_STALE":n(v=>({proposals:v.proposals.map(x=>x.proposalId===l?{...x,status:"stale",processing:!1}:x)}));return;case"PROPOSAL_NOT_FOUND":case"PROPOSAL_PROJECT_MISMATCH":n(v=>({proposals:v.proposals.filter(x=>x.proposalId!==l)}));return;default:Ce.getState().showToast(g2(b,p),"error"),n(v=>({proposals:v.proposals.map(x=>x.proposalId===l?{...x,processing:!1}:x)}));return}}}};return{sessions:null,sessionsLoading:!1,sessionsError:null,currentSessionId:null,messages:[],messagesLoading:!1,loadSessions:async()=>{if(o().sessionsLoading)return;const l=++pa;n({sessionsLoading:!0});try{const c=await a2();if(l!==pa)return;n({sessions:c,sessionsError:null}),o().currentSessionId===null&&c.length>0&&o().setCurrentSession(c[0].id)}catch(c){if(l!==pa)return;const d=c instanceof _e?c.code:"CLIENT_NETWORK_ERROR";n({sessions:null,sessionsError:d})}finally{l===pa&&n({sessionsLoading:!1})}},setCurrentSession:l=>{l!==o().currentSessionId&&(ha++,cr?.(),cr=null,vs=null,ga=null,n({currentSessionId:l,messages:[],messagesLoading:!1,streaming:!1,streamError:null,disconnected:!1,focusContext:null,proposals:[],streamTools:[]}),l!==null&&o().loadMessages(l))},newSession:()=>{pa++,o().setCurrentSession(null)},clearSessions:()=>{pa++,ha++,cr?.(),cr=null,vs=null,ga=null,n({sessions:null,sessionsLoading:!1,sessionsError:null,currentSessionId:null,messages:[],messagesLoading:!1,streaming:!1,streamError:null,disconnected:!1,focusContext:null,proposals:[],streamTools:[]})},loadMessages:async l=>{const c=++ha;n({messagesLoading:!0});try{const d=await l2(l);if(c!==ha)return;const m=d.messages.map(g=>({...g,sessionId:d.sessionId}));n({messages:m})}catch{if(c!==ha)return;n({messages:[]})}finally{c===ha&&n({messagesLoading:!1})}},streaming:!1,streamError:null,setStreamError:l=>n({streamError:l}),focusContext:null,setFocusContext:l=>n({focusContext:l}),clearFocusContext:()=>n({focusContext:null}),disconnected:!1,setDisconnected:l=>n({disconnected:l}),proposals:[],streamTools:[],sendMessage:l=>{const{streaming:c,messagesLoading:d,currentSessionId:m,focusContext:g}=o(),b=l.trim();if(!b||c||d)return;cr?.(),cr=null;const p=new Date().toISOString(),v=m??"",x=`local-${++my}`;vs=x,ga=b,n(j=>({messages:[...j.messages,{id:`local-${++my}`,sessionId:v,role:"user",content:b,createdAt:p},{id:x,sessionId:v,role:"assistant",content:"",createdAt:p}],streaming:!0,streamError:null,disconnected:!1,proposals:[],streamTools:[]}));const S={message:b};m&&(S.session_id=m),g&&(S.context=g),cr=p2("/api/v1/chat",{body:S,onEvent:(j,E)=>{switch(j){case"ping":break;case"text":{const _=E?.delta??"";vs&&n(O=>({messages:O.messages.map(N=>N.id===vs?{...N,content:(N.content??"")+_}:N)}));break}case"tool_call":{const{tool:_,args:O,id:N}=E;if(!N||!_)break;n(T=>({streamTools:[...T.streamTools,{id:N,tool:_,args:O,status:"running"}]}));break}case"tool_result":{const{id:_}=E;if(!_)break;n(O=>({streamTools:O.streamTools.map(N=>N.id===_?{...N,result:E.result,status:"ok"}:N)}));break}case"proposal":{const{proposal_id:_,type:O,preview:N}=E;if(!_||!O)break;n(T=>({proposals:[...T.proposals,{proposalId:_,type:O,preview:N,status:"pending"}]}));break}case"done":{if(vs===null)break;const _=E?.session_id;n({streaming:!1,currentSessionId:_??o().currentSessionId}),_&&o().loadSessions();break}case"error":{const{code:_,message:O}=E;n({streaming:!1,streamError:h2(_??"",O??"")});break}}},onTimeout:()=>{vs===x&&(vs=null,n({streaming:!1,disconnected:!0,proposals:[],streamTools:[]}))},onEnd:()=>{vs===x&&(vs=null,n(j=>j.streaming?{streaming:!1}:{}))}})},resendLast:()=>{const{messages:l,streaming:c}=o();if(c||!ga)return;let d=l;d[d.length-1]?.role==="assistant"&&(d=d.slice(0,-1));const g=d[d.length-1];g?.role==="user"&&g.content===ga&&(d=d.slice(0,-1)),n({messages:d}),o().sendMessage(ga)},confirmProposal:l=>r(l,i2,"confirmed"),rejectProposal:l=>r(l,c2,"rejected")}});let py=ze.getState().config?.id??null;ze.subscribe(n=>{const o=n.config?.id??null;o!==py&&(py=o,St.getState().clearSessions(),o!==null&&St.getState().loadSessions())});function eu(){return typeof window<"u"}function yn(n){return Zm(n)?(n.nodeName||"").toLowerCase():"#document"}function Qt(n){var o;return(n==null||(o=n.ownerDocument)==null?void 0:o.defaultView)||window}function io(n){var o;return(o=(Zm(n)?n.ownerDocument:n.document)||window.document)==null?void 0:o.documentElement}function Zm(n){return eu()?n instanceof Node||n instanceof Qt(n).Node:!1}function vt(n){return eu()?n instanceof Element||n instanceof Qt(n).Element:!1}function Yt(n){return eu()?n instanceof HTMLElement||n instanceof Qt(n).HTMLElement:!1}function wa(n){return!eu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Qt(n).ShadowRoot}function Tr(n){const{overflow:o,overflowX:r,overflowY:l,display:c}=Gn(n);return/auto|scroll|overlay|hidden|clip/.test(o+l+r)&&c!=="inline"&&c!=="contents"}function x2(n){return/^(table|td|th)$/.test(yn(n))}function tu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const b2=/transform|translate|scale|rotate|perspective|filter/,y2=/paint|layout|strict|content/,ur=n=>!!n&&n!=="none";let If;function Jm(n){const o=vt(n)?Gn(n):n;return ur(o.transform)||ur(o.translate)||ur(o.scale)||ur(o.rotate)||ur(o.perspective)||!Wm()&&(ur(o.backdropFilter)||ur(o.filter))||b2.test(o.willChange||"")||y2.test(o.contain||"")}function v2(n){let o=ro(n);for(;Yt(o)&&!eo(o);){if(Jm(o))return o;if(tu(o))return null;o=ro(o)}return null}function Wm(){return If==null&&(If=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),If}function eo(n){return/^(html|body|#document)$/.test(yn(n))}function Gn(n){return Qt(n).getComputedStyle(n)}function nu(n){return vt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ro(n){if(yn(n)==="html")return n;const o=n.assignedSlot||n.parentNode||wa(n)&&n.host||io(n);return wa(o)?o.host:o}function E0(n){const o=ro(n);return eo(o)?(n.ownerDocument||n).body:Yt(o)&&Tr(o)?o:E0(o)}function Yl(n,o,r){var l;o===void 0&&(o=[]),r===void 0&&(r=!0);const c=E0(n),d=c===((l=n.ownerDocument)==null?void 0:l.body),m=Qt(c);if(d){const g=fm(m);return o.concat(m,m.visualViewport||[],Tr(c)?c:[],g&&r?Yl(g):[])}else return o.concat(c,Yl(c,[],r))}function fm(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const ep={...QN},hy={};function zn(n,o){const r=h.useRef(hy);return r.current===hy&&(r.current=n(o)),r}const Bf=ep.useInsertionEffect,S2=Bf&&Bf!==ep.useLayoutEffect?Bf:n=>n();function st(n){const o=zn(E2).current;return o.next=n,S2(o.effect),o.trampoline}function E2(){const n={next:void 0,callback:N2,trampoline:(...o)=>n.callback?.(...o),effect:()=>{n.callback=n.next}};return n}function N2(){}const j2=()=>{},Ke=typeof document<"u"?h.useLayoutEffect:j2;function mm(n,o){if(n&&!o)return n;if(!n&&o)return o;if(n||o)return{...n,...o}}const tp={};function to(n,o,r,l,c){if(!r&&!l&&!c&&!n)return Hc(o);let d=Hc(n);return o&&(d=kl(d,o)),r&&(d=kl(d,r)),l&&(d=kl(d,l)),c&&(d=kl(d,c)),d}function T2(n){if(n.length===0)return tp;if(n.length===1)return Hc(n[0]);let o=Hc(n[0]);for(let r=1;r<n.length;r+=1)o=kl(o,n[r]);return o}function Hc(n){return np(n)?{...j0(n,tp)}:w2(n)}function kl(n,o){return np(o)?j0(o,n):C2(n,o)}function w2(n){const o={...n};for(const r in o){const l=o[r];N0(r,l)&&(o[r]=T0(l))}return o}function C2(n,o){if(!o)return n;for(const r in o){const l=o[r];switch(r){case"style":{n[r]=mm(n.style,l);break}case"className":{n[r]=w0(n.className,l);break}default:N0(r,l)?n[r]=R2(n[r],l):n[r]=l}}return n}function N0(n,o){const r=n.charCodeAt(0),l=n.charCodeAt(1),c=n.charCodeAt(2);return r===111&&l===110&&c>=65&&c<=90&&(typeof o=="function"||typeof o>"u")}function np(n){return typeof n=="function"}function j0(n,o){return np(n)?n(o):n??tp}function R2(n,o){return o?n?(...r)=>{const l=r[0];if(C0(l)){const d=l;Pc(d);const m=o(...r);return d.baseUIHandlerPrevented||n?.(...r),m}const c=o(...r);return n?.(...r),c}:T0(o):n}function T0(n){return n&&((...o)=>{const r=o[0];return C0(r)&&Pc(r),n(...o)})}function Pc(n){return n.preventBaseUIHandler=()=>{n.baseUIHandlerPrevented=!0},n}function w0(n,o){return o?n?o+" "+n:o:n}function C0(n){return n!=null&&typeof n=="object"&&"nativeEvent"in n}function O2(n,o){return function(l,...c){const d=new URL(n);return d.searchParams.set("code",l.toString()),c.forEach(m=>d.searchParams.append("args[]",m)),`${o} error #${l}; visit ${d} for the full message.`}}const En=O2("https://base-ui.com/production-error","Base UI"),k2=h.createContext(void 0);function sp(n=!1){const o=h.useContext(k2);if(o===void 0&&!n)throw new Error(En(16));return o}function _2(n){const{focusableWhenDisabled:o,disabled:r,composite:l=!1,tabIndex:c=0,isNativeButton:d}=n,m=l&&o!==!1,g=l&&o===!1;return{props:h.useMemo(()=>{const p={onKeyDown(v){r&&o&&v.key!=="Tab"&&v.preventDefault()}};return l||(p.tabIndex=c,!d&&r&&(p.tabIndex=o?c:-1)),(d&&(o||m)||!d&&r)&&(p["aria-disabled"]=r),d&&(!o||g)&&(p.disabled=r),p},[l,r,o,m,g,d,c])}}function Zl(n={}){const{disabled:o=!1,focusableWhenDisabled:r,tabIndex:l=0,native:c=!0,composite:d}=n,m=h.useRef(null),g=sp(!0),b=d??g!==void 0,{props:p}=_2({focusableWhenDisabled:r,disabled:o,composite:b,tabIndex:l,isNativeButton:c}),v=h.useCallback(()=>{const j=m.current;Uf(j)&&b&&o&&p.disabled===void 0&&j.disabled&&(j.disabled=!1)},[o,p.disabled,b]);Ke(v,[v]);const x=h.useCallback((j={})=>{const{onClick:E,onMouseDown:_,onKeyUp:O,onKeyDown:N,onPointerDown:T,...k}=j;return to({onClick(C){if(o){C.preventDefault();return}E?.(C)},onMouseDown(C){o||_?.(C)},onKeyDown(C){if(o||(Pc(C),N?.(C),C.baseUIHandlerPrevented))return;const H=C.target===C.currentTarget,M=C.currentTarget,L=Uf(M),w=!c&&M2(M),J=H&&(c?L:!w),oe=C.key==="Enter",ie=C.key===" ",te=M.getAttribute("role"),Q=te?.startsWith("menuitem")||te==="option"||te==="gridcell";if(H&&b&&ie){if(C.defaultPrevented&&Q)return;C.preventDefault(),w||c&&L?(M.click(),C.preventBaseUIHandler()):J&&(E?.(C),C.preventBaseUIHandler());return}J&&(!c&&(ie||oe)&&C.preventDefault(),!c&&oe&&E?.(C))},onKeyUp(C){if(!o){if(Pc(C),O?.(C),C.target===C.currentTarget&&c&&b&&Uf(C.currentTarget)&&C.key===" "){C.preventDefault();return}C.baseUIHandlerPrevented||C.target===C.currentTarget&&!c&&!b&&C.key===" "&&E?.(C)}},onPointerDown(C){if(o){C.preventDefault();return}T?.(C)}},c?{type:"button"}:{role:"button"},p,k)},[o,p,b,c]),S=st(j=>{m.current=j,v()});return{getButtonProps:x,buttonRef:S}}function Uf(n){return Yt(n)&&n.tagName==="BUTTON"}function M2(n){return!!(n?.tagName==="A"&&n?.href)}function Ca(n,o,r,l){const c=zn(R0).current;return D2(c,n,o,r,l)&&O0(c,[n,o,r,l]),c.callback}function A2(n){const o=zn(R0).current;return z2(o,n)&&O0(o,n),o.callback}function R0(){return{callback:null,cleanup:null,refs:[]}}function D2(n,o,r,l,c){return n.refs[0]!==o||n.refs[1]!==r||n.refs[2]!==l||n.refs[3]!==c}function z2(n,o){return n.refs.length!==o.length||n.refs.some((r,l)=>r!==o[l])}function O0(n,o){if(n.refs=o,o.every(r=>r==null)){n.callback=null;return}n.callback=r=>{if(n.cleanup&&(n.cleanup(),n.cleanup=null),r!=null){const l=Array(o.length).fill(null);for(let c=0;c<o.length;c+=1){const d=o[c];if(d!=null)switch(typeof d){case"function":{const m=d(r);typeof m=="function"&&(l[c]=m);break}case"object":{d.current=r;break}}}n.cleanup=()=>{for(let c=0;c<o.length;c+=1){const d=o[c];if(d!=null)switch(typeof d){case"function":{const m=l[c];typeof m=="function"?m():d(null);break}case"object":{d.current=null;break}}}}}}}const L2=parseInt(h.version,10);function op(n){return L2>=n}function gy(n){if(!h.isValidElement(n))return null;const o=n,r=o.props;return(op(19)?r?.ref:o.ref)??null}function dn(){}const Yc=Object.freeze([]),Vt=Object.freeze({});function I2(n,o){const r={};for(const l in n){const c=n[l];if(o?.hasOwnProperty(l)){const d=o[l](c);d!=null&&Object.assign(r,d);continue}c===!0?r[`data-${l.toLowerCase()}`]="":c&&(r[`data-${l.toLowerCase()}`]=c.toString())}return r}function B2(n,o){return typeof n=="function"?n(o):n}function U2(n,o){return typeof n=="function"?n(o):n}function mn(n,o,r={}){const l=o.render,c=H2(o,r);if(r.enabled===!1)return null;const d=r.state??Vt;return V2(n,l,c,d)}function H2(n,o={}){const{className:r,style:l,render:c}=n,{state:d=Vt,ref:m,props:g,stateAttributesMapping:b,enabled:p=!0}=o,v=p?B2(r,d):void 0,x=p?U2(l,d):void 0,S=p?I2(d,b):Vt,j=p&&g?P2(g):void 0,E=p?mm(S,j)??{}:Vt;return typeof document<"u"&&(p?Array.isArray(m)?E.ref=A2([E.ref,gy(c),...m]):E.ref=Ca(E.ref,gy(c),m):Ca(null,null)),p?(v!==void 0&&(E.className=w0(E.className,v)),x!==void 0&&(E.style=mm(E.style,x)),E):Vt}function P2(n){return Array.isArray(n)?T2(n):to(void 0,n)}const Y2=Symbol.for("react.lazy");function V2(n,o,r,l){if(o){if(typeof o=="function")return o(r,l);const c=to(r,o.props);c.ref=r.ref;let d=o;return d?.$$typeof===Y2&&(d=h.Children.toArray(o)[0]),h.cloneElement(d,c)}if(n&&typeof n=="string")return F2(n,r);throw new Error(En(8))}function F2(n,o){return n==="button"?h.createElement("button",{type:"button",...o,key:o.key}):n==="img"?h.createElement("img",{alt:"",...o,key:o.key}):h.createElement(n,o)}const G2=h.forwardRef(function(o,r){const{render:l,className:c,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:g=!0,style:b,...p}=o,{getButtonProps:v,buttonRef:x}=Zl({disabled:d,focusableWhenDisabled:m,native:g});return mn("button",o,{state:{disabled:d},ref:[r,x],props:[p,v]})}),xy=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,by=e0,q2=(n,o)=>r=>{var l;if(o?.variants==null)return by(n,r?.class,r?.className);const{variants:c,defaultVariants:d}=o,m=Object.keys(c).map(p=>{const v=r?.[p],x=d?.[p];if(v===null)return null;const S=xy(v)||xy(x);return c[p][S]}),g=r&&Object.entries(r).reduce((p,v)=>{let[x,S]=v;return S===void 0||(p[x]=S),p},{}),b=o==null||(l=o.compoundVariants)===null||l===void 0?void 0:l.reduce((p,v)=>{let{class:x,className:S,...j}=v;return Object.entries(j).every(E=>{let[_,O]=E;return Array.isArray(O)?O.includes({...d,...g}[_]):{...d,...g}[_]===O})?[...p,x,S]:p},[]);return by(n,m,b,r?.class,r?.className)},pm=q2("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function pe({className:n,variant:o="default",size:r="default",...l}){return i.jsx(G2,{"data-slot":"button",className:Qe(pm({variant:o,size:r,className:n})),...l})}const k0=h.createContext(void 0);function _0(n){const o=h.useContext(k0);if(o===void 0&&!n)throw new Error(En(33));return o}const M0=h.createContext(void 0);function wr(n){const o=h.useContext(M0);if(o===void 0&&!n)throw new Error(En(36));return o}let Vl=(function(n){return n.startingStyle="data-starting-style",n.endingStyle="data-ending-style",n})({});const $2={[Vl.startingStyle]:""},X2={[Vl.endingStyle]:""},su={transitionStatus(n){return n==="starting"?$2:n==="ending"?X2:null}};let mr=(function(n){return n.open="data-open",n.closed="data-closed",n[n.startingStyle=Vl.startingStyle]="startingStyle",n[n.endingStyle=Vl.endingStyle]="endingStyle",n.anchorHidden="data-anchor-hidden",n.side="data-side",n.align="data-align",n})({}),hm=(function(n){return n.popupOpen="data-popup-open",n.pressed="data-pressed",n})({});const K2={[hm.popupOpen]:""},Q2={[hm.popupOpen]:"",[hm.pressed]:""},Z2={[mr.open]:""},J2={[mr.closed]:""},W2={[mr.anchorHidden]:""},eC={open(n){return n?K2:null}},gm={open(n){return n?Q2:null}},Jl={open(n){return n?Z2:J2},anchorHidden(n){return n?W2:null}},tC=h.createContext(void 0);function ou(n=!0){const o=h.useContext(tC);if(o===void 0&&!n)throw new Error(En(25));return o}const A0="none",vr="trigger-press",fn="trigger-hover",Al="trigger-focus",rp="outside-press",D0="item-press",z0="close-press",Sr="focus-out",ru="escape-key",xm="list-navigation",nC="cancel-open",_l="sibling-open",ap="imperative-action";function sC({controlled:n,default:o,name:r,state:l="value"}){const{current:c}=h.useRef(n!==void 0),[d,m]=h.useState(o),g=c?n:d,b=h.useCallback(p=>{c||m(p)},[]);return[g,b]}function oC(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:rC,platform:aC,maxTouchPoints:lC}=oC(),au=rC.toLowerCase(),Fl=aC.toLowerCase(),lu=/^i(os$|p)/.test(Fl)||Fl==="macintel"&&lC>1,yy="android",bm=Fl===yy||au.includes(yy),lp=!lu&&Fl.startsWith("mac");Fl.startsWith("win");const iC=lp||lu,Cr=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none");!Cr&&au.includes("firefox");!Cr&&au.includes("chrom");const cC=iC,ip=/jsdom|happydom/.test(au);function uC(n){const{closeOnClick:o,highlighted:r,id:l,nodeId:c,store:d,typingRef:m,itemRef:g,itemMetadata:b}=n,{events:p}=d.useState("floatingTreeRoot"),v=d.useState("open"),x=ou(!0),S=x!==void 0;return h.useMemo(()=>({id:l,role:"menuitem",tabIndex:v&&r?0:-1,onKeyDown(j){j.key===" "&&m?.current&&j.preventDefault()},onMouseMove(j){c&&p.emit("itemhover",{nodeId:c,target:j.currentTarget})},onClick(j){o&&p.emit("close",{domEvent:j,reason:D0})},onMouseUp(j){if(x){const E=x.initialCursorPointRef.current;if(x.initialCursorPointRef.current=null,S&&E&&Math.abs(j.clientX-E.x)<=1&&Math.abs(j.clientY-E.y)<=1||S&&!lp&&j.button===2)return}g.current&&d.context.allowMouseUpTriggerRef.current&&(!S||j.button===2)&&(!b||b.type==="regular-item")&&g.current.click()}}),[o,r,l,p,c,v,d,m,g,x,S,b])}const dC={type:"regular-item"};function fC(n){const{closeOnClick:o,disabled:r=!1,highlighted:l,id:c,store:d,typingRef:m=d.context.typingRef,nativeButton:g,itemMetadata:b,nodeId:p}=n,v=d.useState("disabled"),x=r||v,S=h.useRef(null),{getButtonProps:j,buttonRef:E}=Zl({disabled:x,focusableWhenDisabled:!0,native:g,composite:!0}),_=uC({closeOnClick:o,highlighted:l,id:c,nodeId:p,store:d,typingRef:m,itemRef:S,itemMetadata:b}),O=h.useCallback(T=>to(_,{onMouseEnter(){b.type==="submenu-trigger"&&b.setActive()}},T,j),[_,j,b]),N=Ca(S,E);return h.useMemo(()=>({getItemProps:O,itemRef:N}),[O,N])}const L0=h.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function mC(){return h.useContext(L0)}let pC=(function(n){return n[n.None=0]="None",n[n.GuessFromOrder=1]="GuessFromOrder",n})({});function I0(n={}){const{label:o,metadata:r,textRef:l,indexGuessBehavior:c,index:d}=n,{register:m,unregister:g,subscribeMapChange:b,elementsRef:p,labelsRef:v,nextIndexRef:x}=mC(),S=h.useRef(-1),[j,E]=h.useState(d??(c===pC.GuessFromOrder?()=>{if(S.current===-1){const N=x.current;x.current+=1,S.current=N}return S.current}:-1)),_=h.useRef(null),O=h.useCallback(N=>{if(_.current=N,j!==-1&&N!==null&&(p.current[j]=N,v)){const T=o!==void 0;v.current[j]=T?o:l?.current?.textContent??N.textContent}},[j,p,v,o,l]);return Ke(()=>{if(d!=null)return;const N=_.current;if(N)return m(N,r),()=>{g(N)}},[d,m,g,r]),Ke(()=>{if(d==null)return b(N=>{const T=_.current?N.get(_.current)?.index:null;T!=null&&E(T)})},[d,b,E]),{ref:O,index:j}}let vy=0;function hC(n,o="mui"){const[r,l]=h.useState(n),c=n||r;return h.useEffect(()=>{r==null&&(vy+=1,l(`${o}-${vy}`))},[r,o]),c}const Sy=ep.useId;function Er(n,o){if(Sy!==void 0){const r=Sy();return n??(o?`${o}-${r}`:r)}return hC(n,o)}function Rr(n){return Er(n,"base-ui")}function jt(n,o,r,l){let c=!1,d=!1;const m=Vt;return{reason:n,event:o??new Event("base-ui"),cancel(){c=!0},allowPropagation(){d=!0},get isCanceled(){return c},get isPropagationAllowed(){return d},trigger:r,...m}}const gC=[];function cp(n){h.useEffect(n,gC)}const bc=null;class xC{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=o=>{this.isScheduled=!1;const r=this.callbacks,l=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,l>0)for(let c=0;c<r.length;c+=1)r[c]?.(o)};request(o){const r=this.nextId;return this.nextId+=1,this.callbacks.push(o),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(o){const r=o-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const yc=new xC;class Ns{static create(){return new Ns}static request(o){return yc.request(o)}static cancel(o){return yc.cancel(o)}currentId=bc;request(o){this.cancel(),this.currentId=yc.request(()=>{this.currentId=bc,o()})}cancel=()=>{this.currentId!==bc&&(yc.cancel(this.currentId),this.currentId=bc)};disposeEffect=()=>this.cancel}function Gl(){const n=zn(Ns.create).current;return cp(n.disposeEffect),n}function bC(n,o=!1,r=!1){const[l,c]=h.useState(n&&o?"idle":void 0),[d,m]=h.useState(n);return n&&!d&&(m(!0),c("starting")),!n&&d&&l!=="ending"&&!r&&c("ending"),!n&&!d&&l==="ending"&&c(void 0),Ke(()=>{if(!n&&d&&l!=="ending"&&r){const g=Ns.request(()=>{c("ending")});return()=>{Ns.cancel(g)}}},[n,d,l,r]),Ke(()=>{if(!n||o)return;const g=Ns.request(()=>{c(void 0)});return()=>{Ns.cancel(g)}},[o,n]),Ke(()=>{if(!n||!o)return;n&&d&&l!=="idle"&&c("starting");const g=Ns.request(()=>{c("idle")});return()=>{Ns.cancel(g)}},[o,n,d,l]),{mounted:d,setMounted:m,transitionStatus:l}}var ao=qv();const yC=Gv(ao);function Ws(n){return n==null?n:"current"in n?n.current:n}function up(n,o=!1,r=!0){const l=Gl();return st((c,d=null)=>{l.cancel();const m=Ws(n);if(m==null)return;const g=m,b=()=>{ao.flushSync(c)};if(typeof g.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){c();return}function p(){Promise.all(g.getAnimations().map(v=>v.finished)).then(()=>{d?.aborted||b()}).catch(()=>{if(r){d?.aborted||b();return}const v=g.getAnimations();!d?.aborted&&v.length>0&&v.some(x=>x.pending||x.playState!=="finished")&&p()})}if(o){const v=Vl.startingStyle;if(!g.hasAttribute(v)){l.request(p);return}const x=new MutationObserver(()=>{g.hasAttribute(v)||(x.disconnect(),p())});x.observe(g,{attributes:!0,attributeFilter:[v]}),d?.addEventListener("abort",()=>x.disconnect(),{once:!0});return}l.request(p)})}function iu(n){const{enabled:o=!0,open:r,ref:l,onComplete:c}=n,d=st(c),m=up(l,r,!1);h.useEffect(()=>{if(!o)return;const g=new AbortController;return m(d,g.signal),()=>{g.abort()}},[o,r,d,m])}const B0=h.createContext(void 0);function vC(){const n=h.useContext(B0);if(n===void 0)throw new Error(En(31));return n}const SC=h.forwardRef(function(o,r){const{render:l,className:c,style:d,...m}=o,[g,b]=h.useState(void 0),p=mn("div",o,{ref:r,props:{role:"group","aria-labelledby":g,...m}});return i.jsx(B0.Provider,{value:b,children:p})}),EC=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,b=Rr(m),p=vC();return Ke(()=>(p(b),()=>{p(void 0)}),[p,b]),mn("div",o,{ref:r,props:{id:b,role:"presentation",...g}})}),NC=h.forwardRef(function(o,r){const{render:l,className:c,id:d,label:m,nativeButton:g=!1,disabled:b=!1,closeOnClick:p=!0,style:v,...x}=o,S=I0({label:m}),j=_0(!0),E=Rr(d),{store:_}=wr(),O=_.useState("isActive",S.index),N=_.useState("itemProps"),{getItemProps:T,itemRef:k}=fC({closeOnClick:p,disabled:b,highlighted:O,id:E,store:_,nativeButton:g,nodeId:j?.context.nodeId,itemMetadata:dC});return mn("div",o,{state:{disabled:b,highlighted:O},props:[N,x,T],ref:[k,r,S.ref]})}),El=0;class ms{static create(){return new ms}currentId=El;start(o,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=El,r()},o)}isStarted(){return this.currentId!==El}clear=()=>{this.currentId!==El&&(clearTimeout(this.currentId),this.currentId=El)};disposeEffect=()=>this.clear}function qn(){const n=zn(ms.create).current;return cp(n.disposeEffect),n}function Es(n){n.preventDefault(),n.stopPropagation()}function jC(n){return"nativeEvent"in n}function U0(n){return n.pointerType===""&&n.isTrusted?!0:bm&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function H0(n){return ip?!1:!bm&&n.width===0&&n.height===0||bm&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function ql(n,o){const r=["mouse","pen"];return o||r.push("",void 0),r.includes(n)}function TC(n){const o=n.type;return o==="click"||o==="mousedown"||o==="keydown"||o==="keyup"}const ym="data-base-ui-focusable",P0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",cu="ArrowLeft",uu="ArrowRight",Y0="ArrowUp",dp="ArrowDown";function jn(n){let o=n.activeElement;for(;o?.shadowRoot?.activeElement!=null;)o=o.shadowRoot.activeElement;return o}function tt(n,o){if(!n||!o)return!1;const r=o.getRootNode?.();if(n.contains(o))return!0;if(r&&wa(r)){let l=o;for(;l;){if(n===l)return!0;l=l.parentNode||l.host}}return!1}function Dn(n){return"composedPath"in n?n.composedPath()[0]:n.target}function Vc(n,o){if(!vt(n))return!1;const r=n;if(o.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,l]of o.entries())if(tt(l,r))return!l.hasAttribute("data-trigger-disabled");return!1}function Hf(n,o){if(o==null)return!1;if("composedPath"in n)return n.composedPath().includes(o);const r=n;return r.target!=null&&o.contains(r.target)}function wC(n){return n.matches("html,body")}function du(n){return Yt(n)&&n.matches(P0)}function CC(n){return n?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${P0}`)!=null}function vm(n){return n?n.getAttribute("role")==="combobox"&&du(n):!1}function RC(n){if(!n||ip)return!0;try{return n.matches(":focus-visible")}catch{return!0}}function Sm(n){return n?n.hasAttribute(ym)?n:n.querySelector(`[${ym}]`)||n:null}function OC(n,o){return o!=null&&!ql(o)?0:typeof n=="function"?n():n}function Em(n,o,r){const l=OC(n,r);return typeof l=="number"?l:l?.[o]}function Ey(n){return typeof n=="function"?n():n}function V0(n,o){return o||n==="click"||n==="mousedown"}function kC(n){return n?.includes("mouse")&&n!=="mousedown"}function xt(n,o,r,l){return n.addEventListener(o,r,l),()=>{n.removeEventListener(o,r,l)}}function _s(...n){return()=>{for(let o=0;o<n.length;o+=1){const r=n[o];r&&r()}}}function ln(n){const o=zn(_C,n).current;return o.next=n,Ke(o.effect),o}function _C(n){const o={current:n,next:n,effect:()=>{o.current=o.next}};return o}function Nt(n){return n?.ownerDocument||document}const MC={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},AC={...MC,position:"fixed",top:0,left:0},Ho=h.forwardRef(function(o,r){const[l,c]=h.useState();Ke(()=>{cC&&Cr&&c("button")},[]);const d={tabIndex:0,role:l};return i.jsx("span",{...o,ref:r,style:AC,"aria-hidden":l?void 0:!0,...d,"data-base-ui-focus-guard":""})}),DC=["top","right","bottom","left"],Ra=Math.min,no=Math.max,Fc=Math.round,vc=Math.floor,so=n=>({x:n,y:n}),zC={left:"right",right:"left",bottom:"top",top:"bottom"};function F0(n,o,r){return no(n,Ra(o,r))}function lo(n,o){return typeof n=="function"?n(o):n}function Fn(n){return n.split("-")[0]}function Vo(n){return n.split("-")[1]}function fp(n){return n==="x"?"y":"x"}function mp(n){return n==="y"?"height":"width"}function as(n){const o=n[0];return o==="t"||o==="b"?"y":"x"}function pp(n){return fp(as(n))}function LC(n,o,r){r===void 0&&(r=!1);const l=Vo(n),c=pp(n),d=mp(c);let m=c==="x"?l===(r?"end":"start")?"right":"left":l==="start"?"bottom":"top";return o.reference[d]>o.floating[d]&&(m=Gc(m)),[m,Gc(m)]}function IC(n){const o=Gc(n);return[Nm(n),o,Nm(o)]}function Nm(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Ny=["left","right"],jy=["right","left"],BC=["top","bottom"],UC=["bottom","top"];function HC(n,o,r){switch(n){case"top":case"bottom":return r?o?jy:Ny:o?Ny:jy;case"left":case"right":return o?BC:UC;default:return[]}}function PC(n,o,r,l){const c=Vo(n);let d=HC(Fn(n),r==="start",l);return c&&(d=d.map(m=>m+"-"+c),o&&(d=d.concat(d.map(Nm)))),d}function Gc(n){const o=Fn(n);return zC[o]+n.slice(o.length)}function YC(n){var o,r,l,c;return{top:(o=n.top)!=null?o:0,right:(r=n.right)!=null?r:0,bottom:(l=n.bottom)!=null?l:0,left:(c=n.left)!=null?c:0}}function G0(n){return typeof n!="number"?YC(n):{top:n,right:n,bottom:n,left:n}}function qc(n){const{x:o,y:r,width:l,height:c}=n;return{width:l,height:c,top:r,left:o,right:o+l,bottom:r+c,x:o,y:r}}function Ty(n,o){return o<0||o>=n.length}function Pf(n,o){return Ea(n.current,{disabledIndices:o})}function wy(n,o){return Ea(n.current,{decrement:!0,startingIndex:n.current.length,disabledIndices:o})}function Ea(n,{startingIndex:o=-1,decrement:r=!1,disabledIndices:l,amount:c=1}={}){let d=o;do d+=r?-c:c;while(d>=0&&d<=n.length-1&&q0(n,d,l));return d}function q0(n,o,r){if(typeof r=="function"?r(o):r?.includes(o)??!1)return!0;const c=n[o];return c?fu(c)?!r&&(c.hasAttribute("disabled")||c.getAttribute("aria-disabled")==="true"):!0:!1}function VC(n){return n.visibility==="hidden"||n.visibility==="collapse"}function fu(n,o=n?Gn(n):null){return!n||!n.isConnected||!o||VC(o)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():o.display!=="none"&&o.display!=="contents"}const FC='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function GC(n){const o=n.assignedSlot;if(o)return o;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return wa(r)?r.host:null}function jm(n){for(const o of Array.from(n.children))if(yn(o)==="summary")return o;return null}function qC(n,o){const r=jm(o);return!!r&&(n===r||tt(r,n))}function $0(n){const o=n?yn(n):"";return n!=null&&n.matches(FC)&&(o!=="summary"||n.parentElement!=null&&yn(n.parentElement)==="details"&&jm(n.parentElement)===n)&&(o!=="details"||jm(n)==null)&&(o!=="input"||n.type!=="hidden")}function X0(n){if(!$0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let o=n;o;o=GC(o)){const r=o!==n,l=yn(o)==="slot";if(o.hasAttribute("inert")||r&&yn(o)==="details"&&!o.open&&!qC(n,o)||o.hasAttribute("hidden")||!l&&!$C(o,r))return!1}return!0}function $C(n,o){const r=Gn(n);return o?r.display!=="none":fu(n,r)}function K0(n){const o=n.tabIndex;if(o<0){const r=yn(n);if(r==="details"||r==="audio"||r==="video"||Yt(n)&&n.isContentEditable)return 0}return o}function Yf(n){if(yn(n)!=="input")return null;const o=n;return o.type==="radio"&&o.name!==""?o:null}function XC(n,o){const r=Yf(n);if(!r)return!0;const l=o.find(c=>{const d=Yf(c);return d?.name===r.name&&d.form===r.form&&d.checked});return l?l===r:o.find(c=>{const d=Yf(c);return d?.name===r.name&&d.form===r.form})===r}function Q0(n){if(Yt(n)&&yn(n)==="slot"){const o=n.assignedElements({flatten:!0});if(o.length>0)return o}return Yt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function Z0(n,o){Q0(n).forEach(r=>{$0(r)&&o.push(r),Z0(r,o)})}function J0(n,o,r){Q0(n).forEach(l=>{Yt(l)&&l.matches(o)&&r.push(l),J0(l,o,r)})}function hp(n){return X0(n)&&K0(n)>=0}function W0(n){const o=[];return Z0(n,o),o.filter(X0)}function Wl(n){const o=W0(n);return o.filter(r=>K0(r)>=0&&XC(r,o))}function e1(n,o){const r=Wl(n),l=r.length;if(l===0)return;const c=jn(Nt(n)),d=r.indexOf(c),m=d===-1?o===1?0:l-1:d+o;return r[m]}function gp(n){return e1(Nt(n).body,1)||n}function t1(n){return e1(Nt(n).body,-1)||n}function n1(n,o){if(!n)return null;const r=Wl(Nt(n).body),l=r.length;if(l===0)return null;const c=r.indexOf(n);if(c===-1)return null;const d=(c+o+l)%l;return r[d]}function KC(n){return n1(n,1)}function QC(n){return n1(n,-1)}function Na(n,o){const r=o||n.currentTarget,l=n.relatedTarget;return!l||!tt(r,l)}function ZC(n){Wl(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function Cy(n){const o=[];J0(n,"[data-tabindex]",o),o.forEach(r=>{const l=r.dataset.tabindex;delete r.dataset.tabindex,l?r.setAttribute("tabindex",l):r.removeAttribute("tabindex")})}function Po(n,o,r=!0){return n.filter(c=>c.parentId===o).flatMap(c=>[...!r||c.context?.open?[c]:[],...Po(n,c.id,r)])}function Ry(n,o){let r=[],l=n.find(c=>c.id===o)?.parentId;for(;l;){const c=n.find(d=>d.id===l);l=c?.parentId,c&&(r=r.concat(c))}return r}function $l(n){return`data-base-ui-${n}`}let Sc=0;function Mc(n,o={}){const{preventScroll:r=!1,sync:l=!1,shouldFocus:c}=o;cancelAnimationFrame(Sc);function d(){c&&!c()||n?.focus({preventScroll:r})}if(l)return d(),dn;const m=requestAnimationFrame(d);return Sc=m,()=>{Sc===m&&(cancelAnimationFrame(m),Sc=0)}}const Vf={inert:new WeakMap,"aria-hidden":new WeakMap},Oy="data-base-ui-inert",Tm={inert:new WeakSet,"aria-hidden":new WeakSet};let Nl=new WeakMap,Ff=0;function JC(n){return Tm[n]}function s1(n){return n?wa(n)?n.host:s1(n.parentNode):null}const ky=(n,o)=>o.map(r=>{if(n.contains(r))return r;const l=s1(r);return n.contains(l)?l:null}).filter(r=>r!=null),_y=n=>{const o=new Set;return n.forEach(r=>{let l=r;for(;l&&!o.has(l);)o.add(l),l=l.parentNode}),o},My=(n,o,r)=>{const l=[],c=d=>{!d||r.has(d)||Array.from(d.children).forEach(m=>{yn(m)!=="script"&&(o.has(m)?c(m):l.push(m))})};return c(n),l};function WC(n,o,r,l,{mark:c=!0}){let d=null;l?d="inert":r&&(d="aria-hidden");let m=null,g=null;const b=ky(o,n),p=c?My(o,_y(b),new Set(b)):[],v=[],x=[];if(d){const S=Vf[d],j=JC(d);g=j,m=S;const E=ky(o,Array.from(o.querySelectorAll("[aria-live]"))),_=b.concat(E);My(o,_y(_),new Set(_)).forEach(N=>{const T=N.getAttribute(d),k=T!==null&&T!=="false",C=(S.get(N)||0)+1;S.set(N,C),v.push(N),C===1&&k&&j.add(N),k||N.setAttribute(d,d==="inert"?"":"true")})}return c&&p.forEach(S=>{const j=(Nl.get(S)||0)+1;Nl.set(S,j),x.push(S),j===1&&S.setAttribute(Oy,"")}),Ff+=1,()=>{m&&v.forEach(S=>{const E=(m.get(S)||0)-1;m.set(S,E),E||(!g?.has(S)&&d&&S.removeAttribute(d),g?.delete(S))}),c&&x.forEach(S=>{const j=(Nl.get(S)||0)-1;Nl.set(S,j),j||S.removeAttribute(Oy)}),Ff-=1,Ff||(Vf.inert=new WeakMap,Vf["aria-hidden"]=new WeakMap,Tm.inert=new WeakSet,Tm["aria-hidden"]=new WeakSet,Nl=new WeakMap)}}function Ay(n,o={}){const{ariaHidden:r=!1,inert:l=!1,mark:c=!0}=o,d=Nt(n[0]).body;return WC(n,d,r,l,{mark:c})}const eR=500,o1=500,tR={style:{transition:"none"}},r1="data-base-ui-click-trigger",nR={fallbackAxisSide:"none"},a1={fallbackAxisSide:"end"},sR={clipPath:"inset(50%)",position:"fixed",top:0,left:0},l1=h.createContext(null),i1=()=>h.useContext(l1),oR=$l("portal");function rR(n={}){const{ref:o,container:r,componentProps:l=Vt,elementProps:c}=n,d=Er(),g=i1()?.portalNode,[b,p]=h.useState(null),[v,x]=h.useState(null),S=st(O=>{O!==null&&x(O)}),j=h.useRef(null);Ke(()=>{if(r===null){j.current&&(j.current=null,x(null),p(null));return}if(d==null)return;const O=(r&&(Zm(r)?r:r.current))??g??document.body;if(O==null){j.current&&(j.current=null,x(null),p(null));return}j.current!==O&&(j.current=O,x(null),p(O))},[r,g,d]);const E=mn("div",l,{ref:[o,S],props:[{id:d,[oR]:""},c]});return{portalNode:v,portalSubtree:b&&E?ao.createPortal(E,b):null}}const xp=h.forwardRef(function(o,r){const{render:l,className:c,style:d,children:m,container:g,renderGuards:b,...p}=o,{portalNode:v,portalSubtree:x}=rR({container:g,ref:r,componentProps:o,elementProps:p}),S=h.useRef(null),j=h.useRef(null),E=h.useRef(null),_=h.useRef(null),[O,N]=h.useState(null),T=h.useRef(!1),k=O?.modal,C=O?.open,H=typeof b=="boolean"?b:!!O&&!O.modal&&O.open&&!!v;h.useEffect(()=>{if(!v||k)return;function L(w){v&&w.relatedTarget&&Na(w)&&(w.type==="focusin"?T.current&&(Cy(v),T.current=!1):(ZC(v),T.current=!0))}return _s(xt(v,"focusin",L,!0),xt(v,"focusout",L,!0))},[v,k]),Ke(()=>{!v||C!==!0||!T.current||(Cy(v),T.current=!1)},[C,v]);const M=h.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:j,beforeInsideRef:E,afterInsideRef:_,portalNode:v,setFocusManagerState:N}),[v]);return i.jsxs(h.Fragment,{children:[x,i.jsxs(l1.Provider,{value:M,children:[H&&v&&i.jsx(Ho,{"data-type":"outside",ref:S,onFocus:L=>{if(Na(L,v))E.current?.focus();else{const w=O?O.domReference:null;t1(w)?.focus()}}}),H&&v&&i.jsx("span",{"aria-owns":v.id,style:sR}),v&&ao.createPortal(m,v),H&&v&&i.jsx(Ho,{"data-type":"outside",ref:j,onFocus:L=>{if(Na(L,v))_.current?.focus();else{const w=O?O.domReference:null;gp(w)?.focus(),O?.closeOnFocusOut&&O?.onOpenChange(!1,jt(Sr,L.nativeEvent))}}})]})]})});function c1(){const n=new Map;return{emit(o,r){n.get(o)?.forEach(l=>l(r))},on(o,r){n.has(o)||n.set(o,new Set),n.get(o).add(r)},off(o,r){n.get(o)?.delete(r)}}}class bp{nodesRef={current:[]};events=c1();addNode(o){this.nodesRef.current.push(o)}removeNode(o){const r=this.nodesRef.current.findIndex(l=>l===o);r!==-1&&this.nodesRef.current.splice(r,1)}}const u1=h.createContext(null),d1=h.createContext(null),co=()=>h.useContext(u1)?.id||null,Fo=n=>{const o=h.useContext(d1);return n??o};function yp(n){const o=Er(),r=Fo(n),l=co();return Ke(()=>{if(!o)return;const c={id:o,parentId:l};return r?.addNode(c),()=>{r?.removeNode(c)}},[r,o,l]),o}function f1(n){const{children:o,id:r}=n,l=co();return i.jsx(u1.Provider,{value:h.useMemo(()=>({id:r,parentId:l}),[r,l]),children:o})}function m1(n){const{children:o,externalTree:r}=n,l=zn(()=>r??new bp).current;return i.jsx(d1.Provider,{value:l,children:o})}function aR(n,o){const r=Qt(Dn(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?o||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?o||(n.detail===0?"keyboard":"mouse"):""}const Dy=20;let Io=[];function vp(){Io=Io.filter(n=>n.deref()?.isConnected)}function zy(n){vp(),n&&yn(n)!=="body"&&(Io.push(new WeakRef(n)),Io.length>Dy&&(Io=Io.slice(-Dy)))}function Ly(){return vp(),Io[Io.length-1]?.deref()}function lR(n){return n?hp(n)?n:Wl(n)[0]||n:null}function Iy(n){if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!n.getAttribute("role")?.includes("dialog"))return;const r=W0(n).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return hp(c)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=n.getAttribute("tabindex");r.length===0?l!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(l!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function Sp(n){const{context:o,children:r,disabled:l=!1,initialFocus:c=!0,returnFocus:d=!0,restoreFocus:m=!1,modal:g=!0,closeOnFocusOut:b=!0,openInteractionType:p="",nextFocusableElement:v,previousFocusableElement:x,beforeContentFocusGuardRef:S,externalTree:j,getInsideElements:E}=n,_="rootStore"in o?o.rootStore:o,O=_.useState("open"),N=_.useState("domReferenceElement"),T=_.useState("floatingElement"),{events:k,dataRef:C}=_.context,H=st(()=>C.current.floatingContext?.nodeId),M=c===!1,L=vm(N)&&M,w=ln(c),J=ln(d),oe=ln(p),ie=ln(O),te=Fo(j),Q=i1(),G=h.useRef(!1),K=h.useRef(!1),A=h.useRef(!1),D=h.useRef(null),B=h.useRef(""),I=h.useRef(""),V=h.useRef(null),z=h.useRef(null),Z=Ca(V,S,Q?.beforeInsideRef),F=Ca(z,Q?.afterInsideRef),Y=qn(),q=qn(),P=Gl(),me=Q!=null,re=Sm(T),de=st((we=re)=>we?Wl(we):[]),Le=st(()=>E?.().filter(we=>we!=null)??[]);h.useEffect(()=>{if(l||!g)return;function we(ge){ge.key==="Tab"&&tt(re,jn(Nt(re)))&&de().length===0&&!L&&Es(ge)}const Be=Nt(re);return xt(Be,"keydown",we)},[l,re,g,L,de]),h.useEffect(()=>{if(l||!O)return;const we=Nt(re);function Be(){A.current=!1}function ge(Ye){const ke=Dn(Ye),Ae=Le(),ve=tt(T,ke)||tt(N,ke)||tt(Q?.portalNode,ke)||Ae.some(Ue=>Ue===ke||tt(Ue,ke));A.current=!ve,I.current=Ye.pointerType||"keyboard",ke?.closest(`[${r1}]`)&&(K.current=!0,q.start(0,()=>{K.current=!1}))}function le(){I.current="keyboard"}return _s(xt(we,"pointerdown",ge,!0),xt(we,"pointerup",Be,!0),xt(we,"pointercancel",Be,!0),xt(we,"keydown",le,!0),Be)},[l,T,N,re,O,Q,q,Le]),h.useEffect(()=>{if(l||!b)return;const we=Nt(re);function Be(){K.current=!0,q.start(0,()=>{K.current=!1})}function ge(Ae){const ve=Dn(Ae);hp(ve)&&(D.current=ve)}function le(Ae){const ve=Ae.relatedTarget,Ue=Ae.currentTarget,Pe=Dn(Ae);g&&ve==null&&Pe!=null&&tt(T,Pe)&&zy(Pe),queueMicrotask(()=>{const Ie=H(),ee=_.context.triggerElements,U=Le(),$=ve?.hasAttribute($l("focus-guard"))&&[V.current,z.current,Q?.beforeInsideRef.current,Q?.afterInsideRef.current,Q?.beforeOutsideRef.current,Q?.afterOutsideRef.current,Ws(x),Ws(v)].includes(ve),je=!(tt(N,ve)||tt(T,ve)||tt(ve,T)||tt(Q?.portalNode,ve)||U.some(xe=>xe===ve||tt(xe,ve))||ve!=null&&ee.hasElement(ve)||ee.hasMatchingElement(xe=>tt(xe,ve))||$||te&&(Po(te.nodesRef.current,Ie).find(xe=>tt(xe.context?.elements.floating,ve)||tt(xe.context?.elements.domReference,ve))||Ry(te.nodesRef.current,Ie).find(xe=>[xe.context?.elements.floating,Sm(xe.context?.elements.floating)].includes(ve)||xe.context?.elements.domReference===ve)));if(Ue===N&&re&&Iy(re),m&&Ue!==N&&!fu(Pe)&&jn(we)===we.body){if(Yt(re)&&(re.focus(),m==="popup")){P.request(()=>{re.focus()});return}const xe=de(),ae=D.current,Re=(ae&&xe.includes(ae)?ae:null)||xe[xe.length-1]||re;Yt(Re)&&Re.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(L||!g)&&ve&&je&&!K.current&&(L||ve!==Ly())&&(G.current=!0,_.setOpen(!1,jt(Sr,Ae)))})}function Ye(){A.current||(C.current.insideReactTree=!0,Y.start(0,()=>{C.current.insideReactTree=!1}))}const ke=Yt(N)?N:null;if(!(!T&&!ke))return _s(ke&&xt(ke,"focusout",le),ke&&xt(ke,"pointerdown",Be),T&&xt(T,"focusin",ge),T&&xt(T,"focusout",le),T&&Q&&xt(T,"focusout",Ye,!0))},[l,N,T,re,g,te,Q,_,b,m,de,L,H,C,Y,q,P,v,x,Le]),h.useEffect(()=>{if(l||!T||!O)return;const we=Array.from(Q?.portalNode?.querySelectorAll(`[${$l("portal")}]`)||[]),ge=(te?Ry(te.nodesRef.current,H()):[]).find(Ue=>vm(Ue.context?.elements.domReference||null))?.context?.elements.domReference,Ye=[...[T,...we,V.current,z.current,Q?.beforeOutsideRef.current,Q?.afterOutsideRef.current,...Le()],ge,Ws(x),Ws(v),L?N:null].filter(Ue=>Ue!=null),ke=Ay(Ye,{ariaHidden:g||L,mark:!1}),Ae=[T,...we].filter(Ue=>Ue!=null),ve=Ay(Ae);return()=>{ve(),ke()}},[O,l,N,T,g,Q,L,te,H,v,x,Le]),Ke(()=>{if(!O||l||!Yt(re))return;const we=Nt(re),Be=jn(we);queueMicrotask(()=>{const ge=w.current,le=typeof ge=="function"?ge(oe.current||""):ge;if(le===void 0||le===!1||tt(re,Be))return;let ke=null;const Ae=()=>(ke==null&&(ke=de(re)),ke[0]||re);let ve;le===!0||le===null?ve=Ae():ve=Ws(le),ve=ve||Ae();const Ue=tt(re,jn(we));Mc(ve,{preventScroll:ve===re,shouldFocus(){if(!ie.current)return!1;if(Ue)return!0;const Pe=jn(we);return!(Pe!==ve&&tt(re,Pe))}})})},[l,O,re,de,w,oe,ie]),Ke(()=>{if(l||!re)return;const we=Nt(re),Be=jn(we),ge=oe.current==null;zy(Be);function le(ke){if(ke.open||(B.current=aR(ke.nativeEvent,I.current)),ke.reason===fn&&ke.nativeEvent.type==="mouseleave"&&(G.current=!0),ke.reason===rp)if(ke.nested)G.current=!1;else if(U0(ke.nativeEvent)||H0(ke.nativeEvent))G.current=!1;else{let Ae=!1;Nt(re).createElement("div").focus({get preventScroll(){return Ae=!0,!1}}),Ae?G.current=!1:G.current=!0}}k.on("openchange",le);function Ye(){const ke=J.current;let Ae=typeof ke=="function"?ke(B.current):ke;if(Ae===void 0||Ae===!1)return null;Ae===null&&(Ae=!0);const ve=N?.isConnected?N:null,Ue=Be?.isConnected&&yn(Be)!=="body"?Be:null;let Pe=ge?Ue||ve:ve||Ue;return Pe||(Pe=Ly()||null),typeof Ae=="boolean"?Pe:Ws(Ae)||Pe||null}return()=>{k.off("openchange",le);const ke=jn(we),Ae=Le(),ve=tt(T,ke)||Ae.some(Ie=>Ie===ke||tt(Ie,ke))||te&&Po(te.nodesRef.current,H(),!1).some(Ie=>tt(Ie.context?.elements.floating,ke)),Ue=J.current,Pe=Ye();queueMicrotask(()=>{const Ie=lR(Pe),ee=typeof Ue!="boolean";Ue&&!G.current&&Yt(Ie)&&(!(!ee&&Ie!==ke&&ke!==we.body)||ve)&&Ie.focus({preventScroll:!0}),G.current=!1})}},[l,T,re,J,oe,k,te,N,H,Le]),Ke(()=>{if(!Cr||O||!T)return;const we=jn(Nt(T));!Yt(we)||!du(we)||tt(T,we)&&we.blur()},[O,T]),Ke(()=>{if(!(l||!Q))return Q.setFocusManagerState({modal:g,closeOnFocusOut:b,open:O,onOpenChange:_.setOpen,domReference:N}),()=>{Q.setFocusManagerState(null)}},[l,Q,g,O,_,b,N]),Ke(()=>{if(!(l||!re))return Iy(re),()=>{queueMicrotask(vp)}},[l,re]);const De=!l&&(g?!L:!0)&&(me||g);return i.jsxs(h.Fragment,{children:[De&&i.jsx(Ho,{"data-type":"inside",ref:Z,onFocus:we=>{if(g){const Be=de();Mc(Be[Be.length-1])}else Q?.portalNode&&(G.current=!1,Na(we,Q.portalNode)?gp(N)?.focus():Ws(x??Q.beforeOutsideRef)?.focus())}}),r,De&&i.jsx(Ho,{"data-type":"inside",ref:F,onFocus:we=>{g?Mc(de()[0]):Q?.portalNode&&(b&&(G.current=!0),Na(we,Q.portalNode)?t1(N)?.focus():Ws(v??Q.afterOutsideRef)?.focus())}})]})}function p1(n,o={}){const{enabled:r=!0,event:l="click",toggle:c=!0,ignoreMouse:d=!1,stickIfOpen:m=!0,touchOpenDelay:g=0,reason:b=vr}=o,p="rootStore"in n?n.rootStore:n,v=p.context.dataRef,x=h.useRef(void 0),S=Gl(),j=qn(),E=h.useMemo(()=>{function _(N,T,k,C){const H=jt(b,T,k);N&&C==="touch"&&g>0?j.start(g,()=>{p.setOpen(!0,H)}):p.setOpen(N,H)}function O(N,T,k){const C=v.current.openEvent,H=p.select("domReferenceElement")!==T;return N&&H||!N||!c?!0:C&&m?!k(C.type):!1}return{onPointerDown(N){x.current=N.pointerType},onMouseDown(N){const T=x.current,k=N.nativeEvent,C=p.select("open");if(N.button!==0||l==="click"||ql(T,!0)&&d)return;const H=O(C,N.currentTarget,w=>w==="click"||w==="mousedown"),M=Dn(k);if(du(M)){_(H,k,M,T);return}const L=N.currentTarget;S.request(()=>{_(H,k,L,T)})},onClick(N){if(l==="mousedown-only")return;const T=x.current;if(l==="mousedown"&&T){x.current=void 0;return}if(ql(T,!0)&&d)return;const k=p.select("open"),C=O(k,N.currentTarget,H=>H==="click"||H==="mousedown"||H==="keydown"||H==="keyup");_(C,N.nativeEvent,N.currentTarget,T)},onKeyDown(){x.current=void 0}}},[v,l,d,b,p,m,c,S,j,g]);return h.useMemo(()=>r?{reference:E}:Vt,[r,E])}function iR(){return!1}function cR(n){return{escapeKey:typeof n=="boolean"?n:n?.escapeKey??!1,outsidePress:typeof n=="boolean"?n:n?.outsidePress??!0}}function Ep(n,o={}){const{enabled:r=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="sloppy",referencePress:m=iR,bubbles:g,externalTree:b}=o,p="rootStore"in n?n.rootStore:n,v=p.useState("open"),x=p.useState("floatingElement"),{dataRef:S}=p.context,j=Fo(b),E=st(typeof c=="function"?c:()=>!1),_=typeof c=="function"?E:c,O=_!==!1,N=st(()=>d),{escapeKey:T,outsidePress:k}=cR(g),C=h.useRef(!1),H=h.useRef(!1),M=h.useRef(!1),L=h.useRef(!1),w=h.useRef(""),J=h.useRef(null),oe=qn(),ie=qn(),te=st(()=>{ie.clear(),S.current.insideReactTree=!1}),Q=st(Z=>{const F=S.current.floatingContext?.nodeId;return(j?Po(j.nodesRef.current,F):[]).some(q=>q.context?.open&&!q.context.dataRef.current[Z])}),G=st(Z=>Hf(Z,p.select("floatingElement"))||Hf(Z,p.select("domReferenceElement"))),K=st(Z=>{m()&&p.setOpen(!1,jt(vr,Z.nativeEvent))}),A=st(Z=>{if(!v||!r||!l||Z.key!=="Escape"||L.current||!T&&Q("__escapeKeyBubbles"))return;const F=jC(Z)?Z.nativeEvent:Z,Y=jt(ru,F);p.setOpen(!1,Y),Y.isCanceled||Z.preventDefault(),!T&&!Y.isPropagationAllowed&&Z.stopPropagation()}),D=st(()=>{S.current.insideReactTree=!0,ie.start(0,te)}),B=st(Z=>{if(!v||!r||Z.button!==0)return;const F=Dn(Z.nativeEvent);tt(p.select("floatingElement"),F)&&(C.current||(C.current=!0,H.current=!1))}),I=st(Z=>{!v||!r||(Z.defaultPrevented||Z.nativeEvent.defaultPrevented)&&C.current&&(H.current=!0)});h.useEffect(()=>{if(!v||!r)return;S.current.__escapeKeyBubbles=T,S.current.__outsidePressBubbles=k;const Z=new ms,F=new ms;function Y(){Z.clear(),L.current=!0}function q(){Z.start(Cr?5:0,()=>{L.current=!1})}function P(){M.current=!0,F.start(0,()=>{M.current=!1})}function me(){C.current=!1,H.current=!1}function re(){const U=w.current,$=U==="pen"||!U?"mouse":U,je=N(),xe=typeof je=="function"?je():je;return typeof xe=="string"?xe:xe[$]}function de(U){const $=re();return $==="intentional"&&U.type!=="click"||$==="sloppy"&&U.type==="click"}function Le(U){const $=S.current.floatingContext?.nodeId,je=j&&Po(j.nodesRef.current,$).some(xe=>Hf(U,xe.context?.elements.floating));return G(U)||je}function De(U){if(de(U)){U.type!=="click"&&!G(U)&&(F.clear(),M.current=!1),te();return}if(S.current.insideReactTree){te();return}const $=Dn(U),je=`[${$l("inert")}]`,xe=vt($)?$.getRootNode():null,ae=Array.from((wa(xe)?xe:Nt(p.select("floatingElement"))).querySelectorAll(je)),Re=p.context.triggerElements;if($&&(Re.hasElement($)||Re.hasMatchingElement(We=>tt(We,$))))return;let He=vt($)?$:null;for(;He&&!eo(He);){const We=ro(He);if(eo(We)||!vt(We))break;He=We}if(!(ae.length&&vt($)&&!wC($)&&!tt($,p.select("floatingElement"))&&ae.every(We=>!tt(He,We)))){if(Yt($)&&!("touches"in U)){const We=eo($),pt=Gn($),_t=/auto|scroll/,mt=We||_t.test(pt.overflowX),Tt=We||_t.test(pt.overflowY),Rt=mt&&$.clientWidth>0&&$.scrollWidth>$.clientWidth,zt=Tt&&$.clientHeight>0&&$.scrollHeight>$.clientHeight,Te=pt.direction==="rtl",Se=zt&&(Te?U.offsetX<=$.offsetWidth-$.clientWidth:U.offsetX>$.clientWidth),Fe=Rt&&U.offsetY>$.clientHeight;if(Se||Fe)return}if(!Le(U)){if(re()==="intentional"&&M.current){F.clear(),M.current=!1;return}typeof _=="function"&&!_(U)||Q("__outsidePressBubbles")||(p.setOpen(!1,jt(rp,U)),te())}}}function we(U){re()!=="sloppy"||U.pointerType==="touch"||!p.select("open")||!r||G(U)||De(U)}function Be(U){if(re()!=="sloppy"||!p.select("open")||!r||G(U))return;const $=U.touches[0];$&&(J.current={startTime:Date.now(),startX:$.clientX,startY:$.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},oe.start(1e3,()=>{J.current&&(J.current.dismissOnTouchEnd=!1,J.current.dismissOnMouseDown=!1)}))}function ge(U,$){const je=Dn(U);if(!je)return;const xe=xt(je,U.type,()=>{$(U),xe()})}function le(U){w.current="touch",ge(U,Be)}function Ye(U){oe.clear(),U.type==="pointerdown"&&(w.current=U.pointerType),!(U.type==="mousedown"&&J.current&&!J.current.dismissOnMouseDown)&&ge(U,$=>{$.type==="pointerdown"?we($):De($)})}function ke(U){if(!C.current)return;const $=H.current;if(me(),re()==="intentional"){if(U.type==="pointercancel"){$&&P();return}if(!Le(U)){if($){P();return}typeof _=="function"&&!_(U)||(F.clear(),M.current=!0,te())}}}function Ae(U){if(re()!=="sloppy"||!J.current||G(U))return;const $=U.touches[0];if(!$)return;const je=Math.abs($.clientX-J.current.startX),xe=Math.abs($.clientY-J.current.startY),ae=Math.sqrt(je*je+xe*xe);ae>5&&(J.current.dismissOnTouchEnd=!0),ae>10&&(De(U),oe.clear(),J.current=null)}function ve(U){ge(U,Ae)}function Ue(U){re()!=="sloppy"||!J.current||G(U)||(J.current.dismissOnTouchEnd&&De(U),oe.clear(),J.current=null)}function Pe(U){ge(U,Ue)}const Ie=Nt(x),ee=_s(l&&_s(xt(Ie,"keydown",A),xt(Ie,"compositionstart",Y),xt(Ie,"compositionend",q)),O&&_s(xt(Ie,"click",Ye,!0),xt(Ie,"pointerdown",Ye,!0),xt(Ie,"pointerup",ke,!0),xt(Ie,"pointercancel",ke,!0),xt(Ie,"mousedown",Ye,!0),xt(Ie,"mouseup",ke,!0),xt(Ie,"touchstart",le,!0),xt(Ie,"touchmove",ve,!0),xt(Ie,"touchend",Pe,!0)));return()=>{ee(),Z.clear(),F.clear(),me(),M.current=!1}},[S,x,l,O,_,v,r,T,k,A,te,N,Q,G,j,p,oe]),h.useEffect(te,[_,te]);const V=h.useMemo(()=>({onKeyDown:A,onPointerDown:K,onClick:K}),[A,K]),z=h.useMemo(()=>({onKeyDown:A,onPointerDown:I,onMouseDown:I,onClickCapture:D,onMouseDownCapture(Z){D(),B(Z)},onPointerDownCapture(Z){D(),B(Z)},onMouseUpCapture:D,onTouchEndCapture:D,onTouchMoveCapture:D}),[A,D,B,I]);return h.useMemo(()=>r?{reference:V,floating:z,trigger:V}:{},[r,V,z])}function By(n,o,r){let{reference:l,floating:c}=n;const d=as(o),m=pp(o),g=mp(m),b=Fn(o),p=d==="y",v=l.x+l.width/2-c.width/2,x=l.y+l.height/2-c.height/2,S=l[g]/2-c[g]/2;let j;switch(b){case"top":j={x:v,y:l.y-c.height};break;case"bottom":j={x:v,y:l.y+l.height};break;case"right":j={x:l.x+l.width,y:x};break;case"left":j={x:l.x-c.width,y:x};break;default:j={x:l.x,y:l.y}}const E=Vo(o);return E&&(j[m]+=S*(E==="end"?1:-1)*(r&&p?-1:1)),j}async function uR(n,o){var r;o===void 0&&(o={});const{x:l,y:c,platform:d,rects:m,elements:g,strategy:b}=n,{boundary:p="clippingAncestors",rootBoundary:v="viewport",elementContext:x="floating",altBoundary:S=!1,padding:j=0}=lo(o,n),E=G0(j),O=g[S?x==="floating"?"reference":"floating":x],N=qc(await d.getClippingRect({element:(r=await(d.isElement==null?void 0:d.isElement(O)))==null||r?O:O.contextElement||await(d.getDocumentElement==null?void 0:d.getDocumentElement(g.floating)),boundary:p,rootBoundary:v,strategy:b})),T=x==="floating"?{x:l,y:c,width:m.floating.width,height:m.floating.height}:m.reference,k=await(d.getOffsetParent==null?void 0:d.getOffsetParent(g.floating)),C=await(d.isElement==null?void 0:d.isElement(k))&&await(d.getScale==null?void 0:d.getScale(k))||{x:1,y:1},H=qc(d.convertOffsetParentRelativeRectToViewportRelativeRect?await d.convertOffsetParentRelativeRectToViewportRelativeRect({elements:g,rect:T,offsetParent:k,strategy:b}):T);return{top:(N.top-H.top+E.top)/C.y,bottom:(H.bottom-N.bottom+E.bottom)/C.y,left:(N.left-H.left+E.left)/C.x,right:(H.right-N.right+E.right)/C.x}}const dR=50,fR=async(n,o,r)=>{const{placement:l="bottom",strategy:c="absolute",middleware:d=[],platform:m}=r,g=m.detectOverflow?m:{...m,detectOverflow:uR},b=await(m.isRTL==null?void 0:m.isRTL(o));let p=await m.getElementRects({reference:n,floating:o,strategy:c}),{x:v,y:x}=By(p,l,b),S=l,j=0;const E={};for(let _=0;_<d.length;_++){const O=d[_];if(!O)continue;const{name:N,fn:T}=O,{x:k,y:C,data:H,reset:M}=await T({x:v,y:x,initialPlacement:l,placement:S,strategy:c,middlewareData:E,rects:p,platform:g,elements:{reference:n,floating:o}});v=k??v,x=C??x,E[N]={...E[N],...H},M&&j<dR&&(j++,typeof M=="object"&&(M.placement&&(S=M.placement),M.rects&&(p=M.rects===!0?await m.getElementRects({reference:n,floating:o,strategy:c}):M.rects),{x:v,y:x}=By(p,S,b)),_=-1)}return{x:v,y:x,placement:S,strategy:c,middlewareData:E}},mR=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(o){var r,l;const{placement:c,middlewareData:d,rects:m,initialPlacement:g,platform:b,elements:p}=o,{mainAxis:v=!0,crossAxis:x=!0,fallbackPlacements:S,fallbackStrategy:j="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:_=!0,...O}=lo(n,o);if((r=d.arrow)!=null&&r.alignmentOffset)return{};const N=Fn(c),T=as(g),k=Fn(g)===g,C=await(b.isRTL==null?void 0:b.isRTL(p.floating)),H=S||(k||!_?[Gc(g)]:IC(g)),M=E!=="none";!S&&M&&H.push(...PC(g,_,E,C));const L=[g,...H],w=await b.detectOverflow(o,O),J=[];let oe=((l=d.flip)==null?void 0:l.overflows)||[];if(v&&J.push(w[N]),x){const G=LC(c,m,C);J.push(w[G[0]],w[G[1]])}if(oe=[...oe,{placement:c,overflows:J}],!J.every(G=>G<=0)){var ie,te;const G=(((ie=d.flip)==null?void 0:ie.index)||0)+1,K=L[G];if(K&&(!(x==="alignment"?T!==as(K):!1)||oe.every(B=>as(B.placement)===T?B.overflows[0]>0:!0)))return{data:{index:G,overflows:oe},reset:{placement:K}};let A=(te=oe.filter(D=>D.overflows[0]<=0).sort((D,B)=>D.overflows[1]-B.overflows[1])[0])==null?void 0:te.placement;if(!A)switch(j){case"bestFit":{var Q;const D=(Q=oe.filter(B=>{if(M){const I=as(B.placement);return I===T||I==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(I=>I>0).reduce((I,V)=>I+V,0)]).sort((B,I)=>B[1]-I[1])[0])==null?void 0:Q[0];D&&(A=D);break}case"initialPlacement":A=g;break}if(c!==A)return{reset:{placement:A}}}return{}}}};function Uy(n,o){return{top:n.top-o.height,right:n.right-o.width,bottom:n.bottom-o.height,left:n.left-o.width}}function Hy(n){return DC.some(o=>n[o]>=0)}const pR=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(o){const{rects:r,platform:l}=o,{strategy:c="referenceHidden",...d}=lo(n,o);switch(c){case"referenceHidden":{const m=await l.detectOverflow(o,{...d,elementContext:"reference"}),g=Uy(m,r.reference);return{data:{referenceHiddenOffsets:g,referenceHidden:Hy(g)}}}case"escaped":{const m=await l.detectOverflow(o,{...d,altBoundary:!0}),g=Uy(m,r.floating);return{data:{escapedOffsets:g,escaped:Hy(g)}}}default:return{}}}}},h1=new Set(["left","top"]);async function hR(n,o){const{placement:r,platform:l,elements:c}=n,d=await(l.isRTL==null?void 0:l.isRTL(c.floating)),m=Fn(r),g=Vo(r),b=as(r)==="y",p=h1.has(m)?-1:1,v=d&&b?-1:1,x=lo(o,n);let{mainAxis:S,crossAxis:j,alignmentAxis:E}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return g&&typeof E=="number"&&(j=g==="end"?E*-1:E),b?{x:j*v,y:S*p}:{x:S*p,y:j*v}}const gR=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(o){var r,l;const{x:c,y:d,placement:m,middlewareData:g}=o,b=await hR(o,n);return m===((r=g.offset)==null?void 0:r.placement)&&(l=g.arrow)!=null&&l.alignmentOffset?{}:{x:c+b.x,y:d+b.y,data:{...b,placement:m}}}}},xR=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(o){const{x:r,y:l,placement:c,platform:d}=o,{mainAxis:m=!0,crossAxis:g=!1,limiter:b={fn:T=>{let{x:k,y:C}=T;return{x:k,y:C}}},...p}=lo(n,o),v={x:r,y:l},x=await d.detectOverflow(o,p),S=as(c),j=fp(S);let E=v[j],_=v[S];const O=(T,k)=>F0(k+x[T==="y"?"top":"left"],k,k-x[T==="y"?"bottom":"right"]);m&&(E=O(j,E)),g&&(_=O(S,_));const N=b.fn({...o,[j]:E,[S]:_});return{...N,data:{x:N.x-r,y:N.y-l,enabled:{[j]:m,[S]:g}}}}}},bR=function(n){return n===void 0&&(n={}),{options:n,fn(o){var r,l;const{x:c,y:d,placement:m,rects:g,middlewareData:b}=o,{offset:p=0,mainAxis:v=!0,crossAxis:x=!0}=lo(n,o),S={x:c,y:d},j=as(m),E=fp(j);let _=S[E],O=S[j];const N=lo(p,o),T=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(r=N.mainAxis)!=null?r:0,crossAxis:(l=N.crossAxis)!=null?l:0};if(v){const H=E==="y"?"height":"width",M=g.reference[E]-g.floating[H]+T.mainAxis,L=g.reference[E]+g.reference[H]-T.mainAxis;_<M?_=M:_>L&&(_=L)}if(x){var k,C;const H=E==="y"?"width":"height",M=h1.has(Fn(m)),L=g.reference[j]-g.floating[H]+(M&&((k=b.offset)==null?void 0:k[j])||0)+(M?0:T.crossAxis),w=g.reference[j]+g.reference[H]+(M?0:((C=b.offset)==null?void 0:C[j])||0)-(M?T.crossAxis:0);O<L?O=L:O>w&&(O=w)}return{[E]:_,[j]:O}}}},yR=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(o){const{placement:r,rects:l,platform:c,elements:d}=o,{apply:m=()=>{},...g}=lo(n,o),b=await c.detectOverflow(o,g),p=Fn(r),v=Vo(r),x=as(r)==="y",{width:S,height:j}=l.floating;let E,_;p==="top"||p==="bottom"?(E=p,_=v===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(_=p,E=v==="end"?"top":"bottom");const O=j-b.top-b.bottom,N=S-b.left-b.right,T=Ra(j-b[E],O),k=Ra(S-b[_],N),C=o.middlewareData.shift,H=!C;let M=T,L=k;C!=null&&C.enabled.x&&(L=N),C!=null&&C.enabled.y&&(M=O),H&&!v&&(x?L=S-2*no(b.left,b.right):M=j-2*no(b.top,b.bottom)),await m({...o,availableWidth:L,availableHeight:M});const w=await c.getDimensions(d.floating);return S!==w.width||j!==w.height?{reset:{rects:!0}}:{}}}};function g1(n){const o=Gn(n);let r=parseFloat(o.width)||0,l=parseFloat(o.height)||0;const c=Yt(n),d=c?n.offsetWidth:r,m=c?n.offsetHeight:l,g=Fc(r)!==d||Fc(l)!==m;return g&&(r=d,l=m),{width:r,height:l,$:g}}function Np(n){return vt(n)?n:n.contextElement}function ja(n){const o=Np(n);if(!Yt(o))return so(1);const r=o.getBoundingClientRect(),{width:l,height:c,$:d}=g1(o);let m=(d?Fc(r.width):r.width)/l,g=(d?Fc(r.height):r.height)/c;return(!m||!Number.isFinite(m))&&(m=1),(!g||!Number.isFinite(g))&&(g=1),{x:m,y:g}}const vR=so(0);function x1(n){const o=Qt(n);return!Wm()||!o.visualViewport?vR:{x:o.visualViewport.offsetLeft,y:o.visualViewport.offsetTop}}function SR(n,o,r){return o===void 0&&(o=!1),!!r&&o&&r===Qt(n)}function Nr(n,o,r,l){o===void 0&&(o=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),d=Np(n);let m=so(1);o&&(l?vt(l)&&(m=ja(l)):m=ja(n));const g=SR(d,r,l)?x1(d):so(0);let b=(c.left+g.x)/m.x,p=(c.top+g.y)/m.y,v=c.width/m.x,x=c.height/m.y;if(d&&l){const S=Qt(d),j=vt(l)?Qt(l):l;let E=S,_=fm(E);for(;_&&j!==E;){const O=ja(_),N=_.getBoundingClientRect(),T=Gn(_),k=N.left+(_.clientLeft+parseFloat(T.paddingLeft))*O.x,C=N.top+(_.clientTop+parseFloat(T.paddingTop))*O.y;b*=O.x,p*=O.y,v*=O.x,x*=O.y,b+=k,p+=C,E=Qt(_),_=fm(E)}}return qc({width:v,height:x,x:b,y:p})}function mu(n,o){const r=nu(n).scrollLeft;return o?o.left+r:Nr(io(n)).left+r}function b1(n,o){const r=n.getBoundingClientRect(),l=r.left+o.scrollLeft-mu(n,r),c=r.top+o.scrollTop;return{x:l,y:c}}function ER(n){let{elements:o,rect:r,offsetParent:l,strategy:c}=n;const d=c==="fixed",m=io(l),g=o?tu(o.floating):!1;if(l===m||g&&d)return r;let b={scrollLeft:0,scrollTop:0},p=so(1);const v=so(0),x=Yt(l);if((x||!d)&&((yn(l)!=="body"||Tr(m))&&(b=nu(l)),x)){const j=Nr(l);p=ja(l),v.x=j.x+l.clientLeft,v.y=j.y+l.clientTop}const S=m&&!x&&!d?b1(m,b):so(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-b.scrollLeft*p.x+v.x+S.x,y:r.y*p.y-b.scrollTop*p.y+v.y+S.y}}function NR(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function jR(n){const o=nu(n),r=n.ownerDocument.body,l=no(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=no(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let d=-o.scrollLeft+mu(n);const m=-o.scrollTop;return Gn(r).direction==="rtl"&&(d+=no(n.clientWidth,r.clientWidth)-l),{width:l,height:c,x:d,y:m}}const TR=25;function wR(n,o,r){r===void 0&&(r="viewport");const l=r==="layoutViewport",c=Qt(n),d=io(n),m=c.visualViewport;let g=d.clientWidth,b=d.clientHeight,p=0,v=0;if(m){const S=!Wm()||o==="fixed";l?S||(p=-m.offsetLeft,v=-m.offsetTop):(g=m.width,b=m.height,S&&(p=m.offsetLeft,v=m.offsetTop))}if(mu(d)<=0){const S=d.ownerDocument,j=S.body,E=getComputedStyle(j),_=S.compatMode==="CSS1Compat"&&parseFloat(E.marginLeft)+parseFloat(E.marginRight)||0,O=Math.abs(d.clientWidth-j.clientWidth-_),N=getComputedStyle(d).scrollbarGutter==="stable both-edges"?O/2:O;N<=TR&&(g-=N)}return{width:g,height:b,x:p,y:v}}function CR(n,o){const r=Nr(n,!0,o==="fixed"),l=r.top+n.clientTop,c=r.left+n.clientLeft,d=ja(n),m=n.clientWidth*d.x,g=n.clientHeight*d.y,b=c*d.x,p=l*d.y;return{width:m,height:g,x:b,y:p}}function Py(n,o,r){let l;if(o==="viewport"||o==="layoutViewport")l=wR(n,r,o);else if(o==="document")l=jR(io(n));else if(vt(o))l=CR(o,r);else{const c=x1(n);l={x:o.x-c.x,y:o.y-c.y,width:o.width,height:o.height}}return qc(l)}function RR(n,o){const r=o.get(n);if(r)return r;let l=Yl(n,[],!1).filter(g=>vt(g)&&yn(g)!=="body"),c=null;const d=Gn(n).position==="fixed";let m=d?ro(n):n;for(;vt(m)&&!eo(m);){const g=Gn(m),b=Jm(m),p=c?c.position:d?"fixed":"";!b&&(p==="fixed"||p==="absolute"&&g.position==="static")?l=l.filter(x=>x!==m):c=g,m=ro(m)}return o.set(n,l),l}function OR(n){let{element:o,boundary:r,rootBoundary:l,strategy:c}=n;const m=[...r==="clippingAncestors"?tu(o)?[]:RR(o,this._c):[].concat(r),l],g=Py(o,m[0],c);let b=g.top,p=g.right,v=g.bottom,x=g.left;for(let S=1;S<m.length;S++){const j=Py(o,m[S],c);b=no(j.top,b),p=Ra(j.right,p),v=Ra(j.bottom,v),x=no(j.left,x)}return{width:p-x,height:v-b,x,y:b}}function kR(n){const{width:o,height:r}=g1(n);return{width:o,height:r}}function _R(n,o,r){const l=Yt(o),c=io(o),d=r==="fixed",m=Nr(n,!0,d,o);let g={scrollLeft:0,scrollTop:0};const b=so(0);if((l||!d)&&((yn(o)!=="body"||Tr(c))&&(g=nu(o)),l)){const S=Nr(o,!0,d,o);b.x=S.x+o.clientLeft,b.y=S.y+o.clientTop}!l&&c&&(b.x=mu(c));const p=c&&!l&&!d?b1(c,g):so(0),v=m.left+g.scrollLeft-b.x-p.x,x=m.top+g.scrollTop-b.y-p.y;return{x:v,y:x,width:m.width,height:m.height}}function Gf(n){return Gn(n).position==="static"}function Yy(n,o){if(!Yt(n)||Gn(n).position==="fixed")return null;if(o)return o(n);let r=n.offsetParent;return io(n)===r&&(r=r.ownerDocument.body),r}function y1(n,o){const r=Qt(n);if(tu(n))return r;if(!Yt(n)){let c=ro(n);for(;c&&!eo(c);){if(vt(c)&&!Gf(c))return c;c=ro(c)}return r}let l=Yy(n,o);for(;l&&x2(l)&&Gf(l);)l=Yy(l,o);return l&&eo(l)&&Gf(l)&&!Jm(l)?r:l||v2(n)||r}const MR=async function(n){const o=this.getOffsetParent||y1,r=this.getDimensions,l=await r(n.floating);return{reference:_R(n.reference,await o(n.floating),n.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function AR(n){return Gn(n).direction==="rtl"}const DR={convertOffsetParentRelativeRectToViewportRelativeRect:ER,getDocumentElement:io,getClippingRect:OR,getOffsetParent:y1,getElementRects:MR,getClientRects:NR,getDimensions:kR,getScale:ja,isElement:vt,isRTL:AR};function v1(n,o){return n.x===o.x&&n.y===o.y&&n.width===o.width&&n.height===o.height}function zR(n,o,r){let l=null,c;const d=io(n);function m(){var v;clearTimeout(c),(v=l)==null||v.disconnect(),l=null}function g(v,x){v===void 0&&(v=!1),x===void 0&&(x=1),m();const S=n.getBoundingClientRect(),{left:j,top:E,width:_,height:O}=S;if(v||o(),!_||!O)return;const N=vc(E),T=vc(d.clientWidth-(j+_)),k=vc(d.clientHeight-(E+O)),C=vc(j),M={rootMargin:-N+"px "+-T+"px "+-k+"px "+-C+"px",threshold:no(0,Ra(1,x))||1};let L=!0;function w(J){const oe=J[0].intersectionRatio;if(!v1(S,n.getBoundingClientRect()))return g();if(oe!==x){if(!L)return g();oe?g(!1,oe):c=setTimeout(()=>{g(!1,1e-7)},1e3)}L=!1}try{l=new IntersectionObserver(w,{...M,root:d.ownerDocument})}catch{l=new IntersectionObserver(w,M)}l.observe(n)}const b=Qt(n),p=()=>g(r);return b.addEventListener("resize",p),g(!0),()=>{b.removeEventListener("resize",p),m()}}function Vy(n,o,r,l){l===void 0&&(l={});const{ancestorScroll:c=!0,ancestorResize:d=!0,elementResize:m=typeof ResizeObserver=="function",layoutShift:g=typeof IntersectionObserver=="function",animationFrame:b=!1}=l,p=Np(n),v=c||d?[...p?Yl(p):[],...o?Yl(o):[]]:[];v.forEach(N=>{c&&N.addEventListener("scroll",r),d&&N.addEventListener("resize",r)});const x=p&&g?zR(p,r,d):null;let S=-1,j=null;m&&(j=new ResizeObserver(N=>{let[T]=N;T&&T.target===p&&j&&o&&(j.unobserve(o),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var k;(k=j)==null||k.observe(o)})),r()}),p&&!b&&j.observe(p),o&&j.observe(o));let E,_=b?Nr(n):null;b&&O();function O(){const N=Nr(n);_&&!v1(_,N)&&r(),_=N,E=requestAnimationFrame(O)}return r(),()=>{var N;v.forEach(T=>{c&&T.removeEventListener("scroll",r),d&&T.removeEventListener("resize",r)}),x?.(),(N=j)==null||N.disconnect(),j=null,b&&cancelAnimationFrame(E)}}const LR=gR,IR=xR,BR=mR,UR=yR,HR=pR,PR=bR,YR=(n,o,r)=>{const l=new Map,c=r??{},d={...DR,...c.platform,_c:l};return fR(n,o,{...c,platform:d})};var VR=typeof document<"u",FR=function(){},Ac=VR?h.useLayoutEffect:FR;function $c(n,o){if(n===o)return!0;if(typeof n!=typeof o)return!1;if(typeof n=="function"&&n.toString()===o.toString())return!0;let r,l,c;if(n&&o&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==o.length)return!1;for(l=r;l--!==0;)if(!$c(n[l],o[l]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(o).length)return!1;for(l=r;l--!==0;)if(!{}.hasOwnProperty.call(o,c[l]))return!1;for(l=r;l--!==0;){const d=c[l];if(!(d==="_owner"&&n.$$typeof)&&!$c(n[d],o[d]))return!1}return!0}return n!==n&&o!==o}function S1(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Fy(n,o){const r=S1(n);return Math.round(o*r)/r}function qf(n){const o=h.useRef(n);return Ac(()=>{o.current=n}),o}function GR(n){n===void 0&&(n={});const{placement:o="bottom",strategy:r="absolute",middleware:l=[],platform:c,elements:{reference:d,floating:m}={},transform:g=!0,whileElementsMounted:b,open:p}=n,[v,x]=h.useState({x:0,y:0,strategy:r,placement:o,middlewareData:{},isPositioned:!1}),[S,j]=h.useState(l);$c(S,l)||j(l);const[E,_]=h.useState(null),[O,N]=h.useState(null),T=h.useCallback(B=>{B!==M.current&&(M.current=B,_(B))},[]),k=h.useCallback(B=>{B!==L.current&&(L.current=B,N(B))},[]),C=d||E,H=m||O,M=h.useRef(null),L=h.useRef(null),w=h.useRef(v),J=b!=null,oe=qf(b),ie=qf(c),te=qf(p),Q=h.useCallback(()=>{if(!M.current||!L.current)return;const B={placement:o,strategy:r,middleware:S};ie.current&&(B.platform=ie.current),YR(M.current,L.current,B).then(I=>{const V={...I,isPositioned:te.current!==!1};G.current&&!$c(w.current,V)&&(w.current=V,ao.flushSync(()=>{x(V)}))})},[S,o,r,ie,te]);Ac(()=>{p===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,x(B=>({...B,isPositioned:!1})))},[p]);const G=h.useRef(!1);Ac(()=>(G.current=!0,()=>{G.current=!1}),[]),Ac(()=>{if(C&&(M.current=C),H&&(L.current=H),C&&H){if(oe.current)return oe.current(C,H,Q);Q()}},[C,H,Q,oe,J]);const K=h.useMemo(()=>({reference:M,floating:L,setReference:T,setFloating:k}),[T,k]),A=h.useMemo(()=>({reference:C,floating:H}),[C,H]),D=h.useMemo(()=>{const B={position:r,left:0,top:0};if(!A.floating)return B;const I=Fy(A.floating,v.x),V=Fy(A.floating,v.y);return g?{...B,transform:"translate("+I+"px, "+V+"px)",...S1(A.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:I,top:V}},[r,g,A.floating,v.x,v.y]);return h.useMemo(()=>({...v,update:Q,refs:K,elements:A,floatingStyles:D}),[v,Q,K,A,D])}const qR=(n,o)=>{const r=LR(n);return{name:r.name,fn:r.fn,options:[n,o]}},$R=(n,o)=>{const r=IR(n);return{name:r.name,fn:r.fn,options:[n,o]}},XR=(n,o)=>({fn:PR(n).fn,options:[n,o]}),KR=(n,o)=>{const r=BR(n);return{name:r.name,fn:r.fn,options:[n,o]}},QR=(n,o)=>{const r=UR(n);return{name:r.name,fn:r.fn,options:[n,o]}},ZR=(n,o)=>{const r=HR(n);return{name:r.name,fn:r.fn,options:[n,o]}};function E1(n){const o=h.useRef(!0);o.current&&(o.current=!1,n())}const qe=(n,o,r,l,c,d,...m)=>{if(m.length>0)throw new Error(En(1));let g;if(n)g=n;else throw new Error("Missing arguments");return g};var $f={exports:{}},Xf={};var Gy;function JR(){if(Gy)return Xf;Gy=1;var n=Xl();function o(x,S){return x===S&&(x!==0||1/x===1/S)||x!==x&&S!==S}var r=typeof Object.is=="function"?Object.is:o,l=n.useState,c=n.useEffect,d=n.useLayoutEffect,m=n.useDebugValue;function g(x,S){var j=S(),E=l({inst:{value:j,getSnapshot:S}}),_=E[0].inst,O=E[1];return d(function(){_.value=j,_.getSnapshot=S,b(_)&&O({inst:_})},[x,j,S]),c(function(){return b(_)&&O({inst:_}),x(function(){b(_)&&O({inst:_})})},[x]),m(j),j}function b(x){var S=x.getSnapshot;x=x.value;try{var j=S();return!r(x,j)}catch{return!0}}function p(x,S){return S()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:g;return Xf.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:v,Xf}var qy;function N1(){return qy||(qy=1,$f.exports=JR()),$f.exports}var j1=N1(),Kf={exports:{}},Qf={};var $y;function WR(){if($y)return Qf;$y=1;var n=Xl(),o=N1();function r(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var l=typeof Object.is=="function"?Object.is:r,c=o.useSyncExternalStore,d=n.useRef,m=n.useEffect,g=n.useMemo,b=n.useDebugValue;return Qf.useSyncExternalStoreWithSelector=function(p,v,x,S,j){var E=d(null);if(E.current===null){var _={hasValue:!1,value:null};E.current=_}else _=E.current;E=g(function(){function N(M){if(!T){if(T=!0,k=M,M=S(M),j!==void 0&&_.hasValue){var L=_.value;if(j(L,M))return C=L}return C=M}if(L=C,l(k,M))return L;var w=S(M);return j!==void 0&&j(L,w)?(k=M,L):(k=M,C=w)}var T=!1,k,C,H=x===void 0?null:x;return[function(){return N(v())},H===null?void 0:function(){return N(H())}]},[v,x,S,j]);var O=c(p,E[0],E[1]);return m(function(){_.hasValue=!0,_.value=O},[O]),b(O),O},Qf}var Xy;function eO(){return Xy||(Xy=1,Kf.exports=WR()),Kf.exports}var tO=eO();const wm=[];let Cm;function nO(){return Cm}function sO(n){wm.push(n)}function T1(n){const o=(r,l)=>{const c=zn(rO).current;let d;try{Cm=c;for(const m of wm)m.before(c);d=n(r,l);for(const m of wm)m.after(c);c.didInitialize=!0}finally{Cm=void 0}return d};return o.displayName=n.displayName||n.name,o}function oO(n){return h.forwardRef(T1(n))}function rO(){return{didInitialize:!1}}const aO=op(19),lO=aO?cO:uO;function w1(n,o,r,l,c){return lO(n,o,r,l,c)}function iO(n,o,r,l,c){const d=h.useCallback(()=>o(n.getSnapshot(),r,l,c),[n,o,r,l,c]);return j1.useSyncExternalStore(n.subscribe,d,d)}sO({before(n){n.syncIndex=0,n.didInitialize||(n.syncTick=1,n.syncHooks=[],n.didChangeStore=!0,n.getSnapshot=()=>{let o=!1;for(let r=0;r<n.syncHooks.length;r+=1){const l=n.syncHooks[r],c=l.selector(l.store.state,l.a1,l.a2,l.a3);Object.is(l.value,c)||(o=!0,l.value=c)}return o&&(n.syncTick+=1),n.syncTick})},after(n){n.syncHooks.length>0&&(n.didChangeStore&&(n.didChangeStore=!1,n.subscribe=o=>{const r=new Set;for(const c of n.syncHooks)r.add(c.store);const l=[];for(const c of r)l.push(c.subscribe(o));return()=>{for(const c of l)c()}}),j1.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot))}});function cO(n,o,r,l,c){const d=nO();if(!d)return iO(n,o,r,l,c);const m=d.syncIndex;d.syncIndex+=1;let g;return d.didInitialize?(g=d.syncHooks[m],(g.store!==n||g.selector!==o||!Object.is(g.a1,r)||!Object.is(g.a2,l)||!Object.is(g.a3,c))&&(g.store!==n&&(d.didChangeStore=!0),g.store=n,g.selector=o,g.a1=r,g.a2=l,g.a3=c,g.value=o(n.getSnapshot(),r,l,c))):(g={store:n,selector:o,a1:r,a2:l,a3:c,value:o(n.getSnapshot(),r,l,c)},d.syncHooks.push(g)),g.value}function uO(n,o,r,l,c){return tO.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getSnapshot,d=>o(d,r,l,c))}class dO{constructor(o){this.state=o,this.listeners=new Set,this.updateTick=0}subscribe=o=>(this.listeners.add(o),()=>{this.listeners.delete(o)});getSnapshot=()=>this.state;setState(o){if(this.state===o)return;this.state=o,this.updateTick+=1;const r=this.updateTick;for(const l of this.listeners){if(r!==this.updateTick)return;l(o)}}update(o){for(const r in o)if(!Object.is(this.state[r],o[r])){this.setState({...this.state,...o});return}}set(o,r){Object.is(this.state[o],r)||this.setState({...this.state,[o]:r})}notifyAll(){const o={...this.state};this.setState(o)}use(o,r,l,c){return w1(this,o,r,l,c)}}class pu extends dO{constructor(o,r={},l){super(o),this.context=r,this.selectors=l}useSyncedValue(o,r){h.useDebugValue(o);const l=this;Ke(()=>{l.state[o]!==r&&l.set(o,r)},[l,o,r])}useSyncedValueWithCleanup(o,r){const l=this;Ke(()=>(l.state[o]!==r&&l.set(o,r),()=>{l.set(o,void 0)}),[l,o,r])}useSyncedValues(o){const r=this,l=Object.values(o);Ke(()=>{r.update(o)},[r,...l])}useControlledProp(o,r){h.useDebugValue(o);const l=this,c=r!==void 0;Ke(()=>{c&&!Object.is(l.state[o],r)&&l.setState({...l.state,[o]:r})},[l,o,r,c])}select(o,r,l,c){const d=this.selectors[o];return d(this.state,r,l,c)}useState(o,r,l,c){return h.useDebugValue(o),w1(this,this.selectors[o],r,l,c)}useContextCallback(o,r){h.useDebugValue(o);const l=st(r??dn);this.context[o]=l}useStateSetter(o){const r=h.useRef(void 0);return r.current===void 0&&(r.current=l=>{this.set(o,l)}),r.current}observe(o,r){let l;typeof o=="function"?l=o:l=this.selectors[o];let c=l(this.state);return r(c,c,this),this.subscribe(d=>{const m=l(d);if(!Object.is(c,m)){const g=c;c=m,r(m,g,this)}})}}const fO={open:qe(n=>n.open),transitionStatus:qe(n=>n.transitionStatus),domReferenceElement:qe(n=>n.domReferenceElement),referenceElement:qe(n=>n.positionReference??n.referenceElement),floatingElement:qe(n=>n.floatingElement),floatingId:qe(n=>n.floatingId)};class hu extends pu{constructor(o){const{syncOnly:r,nested:l,onOpenChange:c,triggerElements:d,...m}=o;super({...m,positionReference:m.referenceElement,domReferenceElement:m.referenceElement},{onOpenChange:c,dataRef:{current:{}},events:c1(),nested:l,triggerElements:d},fO),this.syncOnly=r}syncOpenEvent=(o,r)=>{(!o||!this.state.open||r!=null&&TC(r))&&(this.context.dataRef.current.openEvent=o?r:void 0)};dispatchOpenChange=(o,r)=>{this.syncOpenEvent(o,r.event);const l={open:o,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",l)};setOpen=(o,r)=>{if(this.syncOnly){this.context.onOpenChange?.(o,r);return}this.dispatchOpenChange(o,r),this.context.onOpenChange?.(o,r)}}function C1(n){const{popupStore:o,treatPopupAsFloatingElement:r=!1,floatingRootContext:l,floatingId:c,nested:d,onOpenChange:m}=n,g=o.useState("open"),b=o.useState("activeTriggerElement"),p=o.useState(r?"popupElement":"positionerElement"),v=o.context.triggerElements,x=m,S=h.useRef(null);l===void 0&&S.current===null&&(S.current=new hu({open:g,transitionStatus:void 0,referenceElement:b,floatingElement:p,triggerElements:v,onOpenChange:x,floatingId:c,syncOnly:!0,nested:d}));const j=l??S.current;return o.useSyncedValue("floatingId",c),Ke(()=>{const E={open:g,floatingId:c,referenceElement:b,floatingElement:p};vt(b)&&(E.domReferenceElement=b),j.state.positionReference===j.state.referenceElement&&(E.positionReference=b),j.update(E)},[g,c,b,p,j]),j.context.onOpenChange=x,j.context.nested=d,j}const gu={tabIndex:-1,[ym]:""};function R1(n){return o=>o==="touch"?n.current:!0}function O1(n,o,r=!1){const l=Er(),c=co()!=null,d=h.useRef(null);n===void 0&&d.current===null&&(d.current=o(l,c));const m=n??d.current;return C1({popupStore:m,treatPopupAsFloatingElement:r,floatingRootContext:m.state.floatingRootContext,floatingId:l,nested:c,onOpenChange:m.setOpen}),{store:m,internalStore:d.current}}function mO(n,o){const r=h.useRef(null),l=h.useRef(null);return h.useCallback(c=>{if(n===void 0)return;let d=!1;if(r.current!==null){const m=r.current,g=l.current,b=o.context.triggerElements.getById(m);g&&b===g&&(o.context.triggerElements.delete(m),d=!0),r.current=null,l.current=null}if(c!==null&&(r.current=n,l.current=c,o.context.triggerElements.add(n,c),d=!0),d){const m=o.context.triggerElements.size;o.select("open")&&o.state.triggerCount!==m&&o.set("triggerCount",m)}},[o,n])}function jp(n,o,r,l=!1){o?n.preventUnmountingOnClose=!1:l&&(n.preventUnmountingOnClose=!0);const c=r?.id??null;(c||o)&&(n.activeTriggerId=c,n.activeTriggerElement=r??null)}function k1(n){let o=!1;return n.preventUnmountOnClose=()=>{o=!0},()=>o}function _1(n,o,r,l){E1(()=>{o===void 0&&n.state.open===!1&&r&&(n.state={...n.state,open:!0,activeTriggerId:l,preventUnmountingOnClose:!1})})}function M1(n,o,r,l){const c=r.useState("isMountedByTrigger",n),d=mO(n,r),m=st(g=>{if(d(g),!g)return;const b=r.select("open"),p=r.select("activeTriggerId");if(p===n){r.update({activeTriggerElement:g,...b?l:null});return}p==null&&b&&r.update({activeTriggerId:n,activeTriggerElement:g,...l})});return Ke(()=>{c&&r.update({activeTriggerElement:o.current,...l})},[c,r,o,...Object.values(l)]),{registerTrigger:m,isMountedByThisTrigger:c}}function Tp(n,o={}){const{closeOnActiveTriggerUnmount:r=!1}=o,l=n.useState("open"),c=n.useState("triggerCount");Ke(()=>{if(!l){n.state.triggerCount!==0&&n.set("triggerCount",0);return}const d=n.context.triggerElements.size,m={};n.state.triggerCount!==d&&(m.triggerCount=d);const g=n.select("activeTriggerId");let b=null;if(g){const p=n.context.triggerElements.getById(g);p?p!==n.state.activeTriggerElement&&(m.activeTriggerElement=p):b=g}if(!b&&!g&&d===1){const p=n.context.triggerElements.entries().next();if(!p.done){const[v,x]=p.value;m.activeTriggerId=v,m.activeTriggerElement=x}}(m.triggerCount!==void 0||m.activeTriggerId!==void 0||m.activeTriggerElement!==void 0)&&n.update(m),b&&r&&queueMicrotask(()=>{if(n.select("open")&&n.select("activeTriggerId")===b&&!n.context.triggerElements.getById(b)){const p=jt(A0);n.setOpen(!1,p),p.isCanceled||n.update({activeTriggerId:null,activeTriggerElement:null})}})},[l,n,c,r])}function wp(n,o,r){const{mounted:l,setMounted:c,transitionStatus:d}=bC(n),m=o.useState("preventUnmountingOnClose"),g=n?!1:m;o.useSyncedValues({mounted:l,transitionStatus:d,preventUnmountingOnClose:g});const b=st(()=>{c(!1),o.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),r?.(),o.context.onOpenChangeComplete?.(!1)});return iu({enabled:l&&!n&&!g,open:n,ref:o.context.popupRef,onComplete(){n||b()}}),{forceUnmount:b,transitionStatus:d}}function Cp(n,o){n.useSyncedValues(o),Ke(()=>()=>{n.update({activeTriggerProps:Vt,inactiveTriggerProps:Vt,popupProps:Vt})},[n])}function A1(n,o){Ke(()=>{!o&&n.state.openMethod!==null&&n.set("openMethod",null)},[o,n]),Ke(()=>()=>{n.state.openMethod!==null&&n.set("openMethod",null)},[n])}class ei{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(o,r){const l=this.idMap.get(o);l!==r&&(l!==void 0&&this.elementsSet.delete(l),this.elementsSet.add(r),this.idMap.set(o,r))}delete(o){const r=this.idMap.get(o);r&&(this.elementsSet.delete(r),this.idMap.delete(o))}hasElement(o){return this.elementsSet.has(o)}hasMatchingElement(o){for(const r of this.elementsSet)if(o(r))return!0;return!1}getById(o){return this.idMap.get(o)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function pO(){return new hu({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new ei,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function Rp(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:pO(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Vt,inactiveTriggerProps:Vt,popupProps:Vt}}function D1(n,o,r=!1){return new hu({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:n,floatingId:o,syncOnly:!0,nested:r,onOpenChange:void 0})}const Dl=qe(n=>n.triggerIdProp??n.activeTriggerId),Op=qe(n=>n.openProp??n.open),Ky=qe(n=>(n.popupElement?.id??n.floatingId)||void 0);function z1(n,o){return o!==void 0&&Op(n)&&Dl(n)===o}function hO(n,o){return z1(n,o)?!0:o!==void 0&&Op(n)&&Dl(n)==null&&n.triggerCount===1}const kp={open:Op,mounted:qe(n=>n.mounted),transitionStatus:qe(n=>n.transitionStatus),floatingRootContext:qe(n=>n.floatingRootContext),triggerCount:qe(n=>n.triggerCount),preventUnmountingOnClose:qe(n=>n.preventUnmountingOnClose),payload:qe(n=>n.payload),activeTriggerId:Dl,activeTriggerElement:qe(n=>n.mounted?n.activeTriggerElement:null),popupId:Ky,isTriggerActive:qe((n,o)=>o!==void 0&&Dl(n)===o),isOpenedByTrigger:qe((n,o)=>z1(n,o)),isMountedByTrigger:qe((n,o)=>o!==void 0&&Dl(n)===o&&n.mounted),triggerProps:qe((n,o)=>o?n.activeTriggerProps:n.inactiveTriggerProps),triggerPopupId:qe((n,o)=>hO(n,o)?Ky(n):void 0),popupProps:qe(n=>n.popupProps),popupElement:qe(n=>n.popupElement),positionerElement:qe(n=>n.positionerElement)};function gO(n){const{open:o=!1,onOpenChange:r,elements:l={}}=n,c=Er(),d=co()!=null,m=zn(()=>new hu({open:o,transitionStatus:void 0,onOpenChange:r,referenceElement:l.reference??null,floatingElement:l.floating??null,triggerElements:new ei,floatingId:c,syncOnly:!1,nested:d})).current;return Ke(()=>{const g={open:o,floatingId:c};l.reference!==void 0&&(g.referenceElement=l.reference,g.domReferenceElement=vt(l.reference)?l.reference:null),l.floating!==void 0&&(g.floatingElement=l.floating),m.update(g)},[o,c,l.reference,l.floating,m]),m.context.onOpenChange=r,m.context.nested=d,m}function xO(n={}){const{nodeId:o,externalTree:r}=n,l=gO(n),c=n.rootContext||l,d=c.useState("referenceElement"),m=c.useState("floatingElement"),g=c.useState("domReferenceElement"),b=c.useState("open"),p=c.useState("floatingId"),[v,x]=h.useState(null),[S,j]=h.useState(void 0),[E,_]=h.useState(void 0),O=h.useRef(null),N=Fo(r),T=h.useMemo(()=>({reference:d,floating:m,domReference:g}),[d,m,g]),k=GR({...n,elements:{...T,...v&&{reference:v}}}),C=vt(S)?S:null,H=E===void 0?c.state.floatingElement:E;c.useSyncedValue("referenceElement",S??null),c.useSyncedValue("domReferenceElement",S===void 0?g:C),c.useSyncedValue("floatingElement",H);const M=h.useCallback(te=>{const Q=vt(te)?{getBoundingClientRect:()=>te.getBoundingClientRect(),getClientRects:()=>te.getClientRects(),contextElement:te}:te;x(Q),k.refs.setReference(Q)},[k.refs]),L=h.useCallback(te=>{(vt(te)||te===null)&&(O.current=te,j(te)),(vt(k.refs.reference.current)||k.refs.reference.current===null||te!==null&&!vt(te))&&k.refs.setReference(te)},[k.refs,j]),w=h.useCallback(te=>{_(te),k.refs.setFloating(te)},[k.refs]),J=h.useMemo(()=>({...k.refs,setReference:L,setFloating:w,setPositionReference:M,domReference:O}),[k.refs,L,w,M]),oe=h.useMemo(()=>({...k.elements,domReference:g}),[k.elements,g]),ie=h.useMemo(()=>({...k,dataRef:c.context.dataRef,open:b,onOpenChange:c.setOpen,events:c.context.events,floatingId:p,refs:J,elements:oe,nodeId:o,rootStore:c}),[k,J,oe,o,c,b,p]);return Ke(()=>{g&&(O.current=g)},[g]),Ke(()=>{c.context.dataRef.current.floatingContext=ie;const te=N?.nodesRef.current.find(Q=>Q.id===o);te&&(te.context=ie)}),h.useMemo(()=>({...k,context:ie,refs:J,elements:oe,rootStore:c}),[k,J,oe,ie,c])}const Zf=lp&&Cr;function bO(n,o={}){const{enabled:r=!0,delay:l}=o,c="rootStore"in n?n.rootStore:n,{events:d,dataRef:m}=c.context,g=h.useRef(!1),b=h.useRef(null),p=h.useRef(!0),v=qn();h.useEffect(()=>{const S=c.select("domReferenceElement");if(!r)return;const j=Qt(S);function E(){const N=c.select("domReferenceElement");!c.select("open")&&Yt(N)&&N===jn(Nt(N))&&(g.current=!0)}function _(){p.current=!0}function O(){p.current=!1}return _s(xt(j,"blur",E),Zf&&xt(j,"keydown",_,!0),Zf&&xt(j,"pointerdown",O,!0))},[c,r]),h.useEffect(()=>{if(!r)return;function S(j){if(j.reason===vr||j.reason===ru){const E=c.select("domReferenceElement");vt(E)&&(b.current=E,g.current=!0)}}return d.on("openchange",S),()=>{d.off("openchange",S)}},[d,r,c]);const x=h.useMemo(()=>{function S(){g.current=!1,b.current=null}return{onMouseLeave(){S()},onFocus(j){const E=j.currentTarget;if(g.current){if(b.current===E)return;S()}const _=Dn(j.nativeEvent);if(vt(_)){if(Zf&&!j.relatedTarget){if(!p.current&&!du(_))return}else if(!RC(_))return}const O=Vc(j.relatedTarget,c.context.triggerElements),{nativeEvent:N,currentTarget:T}=j,k=typeof l=="function"?l():l;if(c.select("open")&&O||k===0||k===void 0){c.setOpen(!0,jt(Al,N,T));return}v.start(k,()=>{g.current||c.setOpen(!0,jt(Al,N,T))})},onBlur(j){S();const E=j.relatedTarget,_=j.nativeEvent,O=vt(E)&&E.hasAttribute($l("focus-guard"))&&E.getAttribute("data-type")==="outside";v.start(0,()=>{const N=c.select("domReferenceElement"),T=jn(Nt(N));!E&&T===N||tt(m.current.floatingContext?.refs.floating.current,T)||tt(N,T)||O||Vc(E??T,c.context.triggerElements)||c.setOpen(!1,jt(Al,_))})}}},[m,l,c,v]);return h.useMemo(()=>r?{reference:x,trigger:x}:{},[r,x])}class _p{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ms,this.restTimeout=new ms,this.handleCloseOptions=void 0}static create(){return new _p}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const Xc=new WeakMap;function Kc(n){if(!n.performedPointerEventsMutation)return;const o=n.pointerEventsScopeElement;o&&Xc.get(o)===n&&(n.pointerEventsScopeElement?.style.removeProperty("pointer-events"),n.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),n.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),Xc.delete(o)),n.performedPointerEventsMutation=!1,n.pointerEventsScopeElement=null,n.pointerEventsReferenceElement=null,n.pointerEventsFloatingElement=null}function L1(n,o){const{scopeElement:r,referenceElement:l,floatingElement:c}=o,d=Xc.get(r);d&&d!==n&&Kc(d),Kc(n),n.performedPointerEventsMutation=!0,n.pointerEventsScopeElement=r,n.pointerEventsReferenceElement=l,n.pointerEventsFloatingElement=c,Xc.set(r,n),r.style.pointerEvents="none",l.style.pointerEvents="auto",c.style.pointerEvents="auto"}function I1(n){const o=n.context.dataRef.current,r=zn(()=>o.hoverInteractionState??_p.create()).current;return o.hoverInteractionState||(o.hoverInteractionState=r),cp(o.hoverInteractionState.disposeEffect),o.hoverInteractionState}function B1(n,o={}){const{enabled:r=!0,closeDelay:l=0,nodeId:c}=o,d="rootStore"in n?n.rootStore:n,m=d.useState("open"),g=d.useState("floatingElement"),b=d.useState("domReferenceElement"),{dataRef:p}=d.context,v=Fo(),x=co(),S=I1(d),j=qn(),E=st(()=>V0(p.current.openEvent?.type,S.interactedInside)),_=st(()=>kC(p.current.openEvent?.type)),O=st(()=>{Kc(S)});Ke(()=>{m||(S.pointerType=void 0,S.restTimeoutPending=!1,S.interactedInside=!1,O())},[m,S,O]),h.useEffect(()=>O,[O]),Ke(()=>{if(r&&m&&S.handleCloseOptions?.blockPointerEvents&&_()&&vt(b)&&g){const N=b,T=g,k=Nt(g),C=v?.nodesRef.current.find(w=>w.id===x)?.context?.elements.floating;C&&(C.style.pointerEvents="");const H=S.pointerEventsScopeElement!==T?S.pointerEventsScopeElement:null,M=C!==T?C:null,L=S.handleCloseOptions?.getScope?.()??H??M??N.closest("[data-rootownerid]")??k.body;return L1(S,{scopeElement:L,referenceElement:N,floatingElement:T}),()=>{O()}}},[r,m,b,g,S,_,v,x,O]),h.useEffect(()=>{if(!r)return;function N(){return!!(v&&x&&Po(v.nodesRef.current,x).length>0)}function T(w){const J=Em(l,"close",S.pointerType),oe=()=>{d.setOpen(!1,jt(fn,w)),v?.events.emit("floating.closed",w)};J?S.openChangeTimeout.start(J,oe):(S.openChangeTimeout.clear(),oe())}function k(w){const J=Dn(w);if(!CC(J)){S.interactedInside=!1;return}S.interactedInside=J?.closest("[aria-haspopup]")!=null}function C(){S.openChangeTimeout.clear(),j.clear(),v?.events.off("floating.closed",M),O()}function H(w){if(N()&&v){v.events.on("floating.closed",M);return}if(Vc(w.relatedTarget,d.context.triggerElements))return;const J=p.current.floatingContext?.nodeId??c,oe=w.relatedTarget;if(!(v&&J&&vt(oe)&&Po(v.nodesRef.current,J,!1).some(te=>tt(te.context?.elements.floating,oe)))){if(S.handler){S.handler(w);return}O(),_()&&!E()&&T(w)}}function M(w){!v||!x||N()||j.start(0,()=>{v.events.off("floating.closed",M),d.setOpen(!1,jt(fn,w)),v.events.emit("floating.closed",w)})}const L=g;return _s(L&&xt(L,"mouseenter",C),L&&xt(L,"mouseleave",H),L&&xt(L,"pointerdown",k,!0),()=>{v?.events.off("floating.closed",M)})},[r,g,d,p,l,c,_,E,O,S,v,x,j])}const yO={current:null};function U1(n,o={}){const{enabled:r=!0,delay:l=0,handleClose:c=null,mouseOnly:d=!1,restMs:m=0,move:g=!0,triggerElementRef:b=yO,externalTree:p,isActiveTrigger:v=!0,getHandleCloseContext:x,isClosing:S,shouldOpen:j}=o,E="rootStore"in n?n.rootStore:n,{dataRef:_,events:O}=E.context,N=Fo(p),T=I1(E),k=h.useRef(!1),C=ln(c),H=ln(l),M=ln(m),L=ln(r),w=ln(j),J=ln(S),oe=st(()=>V0(_.current.openEvent?.type,T.interactedInside)),ie=st(()=>w.current?.()!==!1),te=st((K,A,D)=>{const B=E.context.triggerElements;if(B.hasElement(A))return!K||!tt(K,A);if(!vt(D))return!1;const I=D;return B.hasMatchingElement(V=>tt(V,I))&&(!K||!tt(K,I))}),Q=st(()=>{if(!T.handler)return;Nt(E.select("domReferenceElement")).removeEventListener("mousemove",T.handler),T.handler=void 0}),G=st(()=>{Kc(T)});return v&&(T.handleCloseOptions=C.current?.__options),h.useEffect(()=>Q,[Q]),h.useEffect(()=>{if(!r)return;function K(A){A.open?k.current=!1:(k.current=A.reason===fn,Q(),T.openChangeTimeout.clear(),T.restTimeout.clear(),T.blockMouseMove=!0,T.restTimeoutPending=!1)}return O.on("openchange",K),()=>{O.off("openchange",K)}},[r,O,T,Q]),h.useEffect(()=>{if(!r)return;function K(I,V=!0){const z=Em(H.current,"close",T.pointerType);z?T.openChangeTimeout.start(z,()=>{E.setOpen(!1,jt(fn,I)),N?.events.emit("floating.closed",I)}):V&&(T.openChangeTimeout.clear(),E.setOpen(!1,jt(fn,I)),N?.events.emit("floating.closed",I))}const A=b.current??(v?E.select("domReferenceElement"):null);if(!vt(A))return;function D(I){if(T.openChangeTimeout.clear(),T.blockMouseMove=!1,d&&!ql(T.pointerType))return;const V=Ey(M.current),z=Em(H.current,"open",T.pointerType),Z=Dn(I),F=I.currentTarget??null,Y=E.select("domReferenceElement");let q=F;if(vt(Z)&&!E.context.triggerElements.hasElement(Z)){for(const ge of E.context.triggerElements.elements())if(tt(ge,Z)){q=ge;break}}vt(F)&&vt(Y)&&!E.context.triggerElements.hasElement(F)&&tt(F,Y)&&(q=Y);const P=q==null?!1:te(Y,q,Z),me=E.select("open"),re=J.current?.()??E.select("transitionStatus")==="ending",de=!me&&re&&k.current,Le=!P&&vt(q)&&vt(Y)&&tt(Y,q)&&de,De=V>0&&!z,we=P&&(me||de)||Le,Be=!me||P;if(we){ie()&&E.setOpen(!0,jt(fn,I,q));return}De||(z?T.openChangeTimeout.start(z,()=>{Be&&ie()&&E.setOpen(!0,jt(fn,I,q))}):Be&&ie()&&E.setOpen(!0,jt(fn,I,q)))}function B(I){if(oe()){G();return}Q();const V=E.select("domReferenceElement"),z=Nt(V);T.restTimeout.clear(),T.restTimeoutPending=!1;const Z=_.current.floatingContext??x?.();if(Vc(I.relatedTarget,E.context.triggerElements))return;if(C.current&&Z){E.select("open")||T.openChangeTimeout.clear();const Y=b.current;T.handler=C.current({...Z,tree:N,x:I.clientX,y:I.clientY,onClose(){G(),Q(),L.current&&!oe()&&Y===E.select("domReferenceElement")&&K(I,!0)}}),z.addEventListener("mousemove",T.handler),T.handler(I);return}(T.pointerType!=="touch"||!tt(E.select("floatingElement"),I.relatedTarget))&&K(I)}return g?_s(xt(A,"mousemove",D,{once:!0}),xt(A,"mouseenter",D),xt(A,"mouseleave",B)):_s(xt(A,"mouseenter",D),xt(A,"mouseleave",B))},[Q,G,_,H,E,r,C,T,v,te,oe,d,g,M,b,N,L,x,J,ie]),h.useMemo(()=>{if(!r)return;function K(A){T.pointerType=A.pointerType}return{onPointerDown:K,onPointerEnter:K,onMouseMove(A){const{nativeEvent:D}=A,B=A.currentTarget,I=E.select("domReferenceElement"),V=E.select("open"),z=te(I,B,A.target);if(d&&!ql(T.pointerType))return;if(V&&z&&T.handleCloseOptions?.blockPointerEvents){const Y=E.select("floatingElement");if(Y){const q=T.handleCloseOptions?.getScope?.()??B.ownerDocument.body;L1(T,{scopeElement:q,referenceElement:B,floatingElement:Y})}}const Z=Ey(M.current);if(V&&!z||Z===0||!z&&T.restTimeoutPending&&A.movementX**2+A.movementY**2<2)return;T.restTimeout.clear();function F(){if(T.restTimeoutPending=!1,oe())return;const Y=E.select("open");!T.blockMouseMove&&(!Y||z)&&ie()&&E.setOpen(!0,jt(fn,D,B))}T.pointerType==="touch"?ao.flushSync(()=>{F()}):z&&V?F():(T.restTimeoutPending=!0,T.restTimeout.start(Z,F))}}},[r,T,oe,te,d,E,M,ie])}const vO="Escape";function xu(n,o,r){switch(n){case"vertical":return o;case"horizontal":return r;default:return o||r}}function Ec(n,o){return xu(o,n===Y0||n===dp,n===cu||n===uu)}function Jf(n,o,r){return xu(o,n===dp,r?n===cu:n===uu)||n==="Enter"||n===" "||n===""}function SO(n,o,r){return xu(o,r?n===cu:n===uu,n===dp)}function EO(n,o,r,l){const c=r?n===uu:n===cu,d=n===Y0;return o==="both"||o==="horizontal"&&l?n===vO:xu(o,c,d)}function NO(n,o){const{listRef:r,activeIndex:l,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:m=null,allowEscape:g=!1,loopFocus:b=!1,nested:p=!1,rtl:v=!1,virtual:x=!1,focusItemOnOpen:S="auto",focusItemOnHover:j=!0,openOnArrowKeyDown:E=!0,disabledIndices:_=void 0,orientation:O="vertical",parentOrientation:N,id:T,resetOnPointerLeave:k=!0,externalTree:C,grid:H}=o,M=H!=null,L="rootStore"in n?n.rootStore:n,w=L.useState("open"),J=L.useState("floatingElement"),oe=L.useState("domReferenceElement"),ie=L.context.dataRef,te=Sm(J),Q=vm(oe),G=ln(te),K=co(),A=Fo(C),D=h.useRef(S),B=h.useRef(m??-1),I=h.useRef(null),V=h.useRef(!0),z=st(U=>{c(B.current===-1?null:B.current,U)}),Z=h.useRef(!!J),F=h.useRef(w),Y=h.useRef(!1),q=h.useRef(!1),P=h.useRef(null),me=ln(_),re=ln(w),de=ln(m),Le=ln(k),De=Gl(),we=Gl(),Be=st(()=>{function U(ae){x?A?.events.emit("virtualfocus",ae):P.current=Mc(ae,{sync:Y.current,preventScroll:!0})}const $=r.current[B.current],je=q.current;$&&U($),(Y.current?ae=>ae():ae=>De.request(ae))(()=>{const ae=r.current[B.current]||$;if(!ae)return;$||U(ae),ve&&(je||!V.current)&&ae.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ke(()=>{ie.current.orientation=O},[ie,O]),Ke(()=>{d&&(w&&J?(B.current=m??-1,D.current&&m!=null&&(q.current=!0,z())):Z.current&&(B.current=-1,z()))},[d,w,J,m,z]),Ke(()=>{if(d){if(!w){Y.current=!1;return}if(J)if(l==null){if(Y.current=!1,de.current!=null)return;if(Z.current&&(B.current=-1,Be()),(!F.current||!Z.current)&&D.current&&(I.current!=null||D.current===!0&&I.current==null)){let U=0;const $=()=>{r.current[0]==null?(U<2&&(U?xe=>we.request(xe):queueMicrotask)($),U+=1):(B.current=I.current==null||Jf(I.current,O,v)||p?Pf(r):wy(r),I.current=null,z())};$()}}else Ty(r.current,l)||(B.current=l,Be(),q.current=!1)}},[d,w,J,l,de,p,r,O,v,z,Be,we]),Ke(()=>{if(!d||J||!A||x||!Z.current)return;const U=A.nodesRef.current,$=U.find(ae=>ae.id===K)?.context?.elements.floating,je=jn(Nt(oe??$??null)),xe=U.some(ae=>ae.context&&tt(ae.context.elements.floating,je));$&&!xe&&V.current&&$.focus({preventScroll:!0})},[d,J,oe,A,K,x]),Ke(()=>{F.current=w,Z.current=!!J}),Ke(()=>{w||(I.current=null,D.current=S)},[w,S]);const ge=l!=null,le=st(U=>{if(!re.current)return;const $=r.current.indexOf(U.currentTarget);$!==-1&&(B.current!==$||l!==$)&&(B.current=$,z(U))}),Ye=st(()=>N??A?.nodesRef.current.find(U=>U.id===K)?.context?.dataRef?.current.orientation),ke=st(()=>Pf(r,me.current)),Ae=st(U=>{if(V.current=!1,Y.current=!0,U.which===229||!re.current&&U.currentTarget===G.current)return;if(p&&EO(U.key,O,v,M)){Ec(U.key,Ye())||Es(U),L.setOpen(!1,jt(xm,U.nativeEvent)),Yt(oe)&&(x?A?.events.emit("virtualfocus",oe):oe.focus());return}const $=B.current,je=Pf(r,_),xe=wy(r,_);if(Q||(U.key==="Home"&&(Es(U),B.current=je,z(U)),U.key==="End"&&(Es(U),B.current=xe,z(U))),H!=null){const ae=H(U,B.current,r,O,b,v,_,je,xe);if(ae!=null&&(B.current=ae,z(U)),O==="both")return}if(Ec(U.key,O)){if(Es(U),w&&!x&&jn(U.currentTarget.ownerDocument)===U.currentTarget){B.current=Jf(U.key,O,v)?je:xe,z(U);return}Jf(U.key,O,v)?b?$>=xe?g&&$!==r.current.length?B.current=-1:(Y.current=!1,B.current=je):B.current=Ea(r.current,{startingIndex:$,disabledIndices:_}):B.current=Math.min(xe,Ea(r.current,{startingIndex:$,disabledIndices:_})):b?$<=je?g&&$!==-1?B.current=r.current.length:(Y.current=!1,B.current=xe):B.current=Ea(r.current,{startingIndex:$,decrement:!0,disabledIndices:_}):B.current=Math.max(je,Ea(r.current,{startingIndex:$,decrement:!0,disabledIndices:_})),Ty(r.current,B.current)&&(B.current=-1),z(U)}}),ve=h.useMemo(()=>({onFocus($){Y.current=!0,le($)},onClick:({currentTarget:$})=>$.focus({preventScroll:!0}),onMouseMove($){Y.current=!0,q.current=!1,j&&le($)},onPointerLeave($){if(!re.current||!V.current||$.pointerType==="touch")return;Y.current=!0;const je=$.relatedTarget;if(!(!j||r.current.includes(je))&&Le.current&&(P.current?.(),P.current=null,B.current=-1,z($),!x)){const xe=G.current,ae=jn(Nt(xe));xe&&tt(xe,ae)&&xe.focus({preventScroll:!0})}}}),[le,re,G,j,r,z,Le,x]),Ue=h.useMemo(()=>x&&w&&ge&&{"aria-activedescendant":`${T}-${l}`},[x,w,ge,T,l]),Pe=h.useMemo(()=>({"aria-orientation":O==="both"?void 0:O,...Q?{}:Ue,onKeyDown(U){if(U.key==="Tab"&&U.shiftKey&&w&&!x){const $=Dn(U.nativeEvent);if($&&!tt(G.current,$))return;Es(U),L.setOpen(!1,jt(Sr,U.nativeEvent)),Yt(oe)&&oe.focus();return}Ae(U)},onPointerMove(){V.current=!0}}),[Ue,Ae,G,O,Q,L,w,x,oe]),Ie=h.useMemo(()=>{function U(xe){L.setOpen(!0,jt(xm,xe.nativeEvent,xe.currentTarget))}function $(xe){S==="auto"&&U0(xe.nativeEvent)&&(D.current=!x)}function je(xe){D.current=S,S==="auto"&&H0(xe.nativeEvent)&&(D.current=!0)}return{onKeyDown(xe){const ae=L.select("open");V.current=!1;const Re=xe.key.startsWith("Arrow"),He=SO(xe.key,Ye(),v),We=Ec(xe.key,O),pt=(p?He:We)||xe.key==="Enter"||xe.key.trim()==="";if(x&&ae)return Ae(xe);if(!(!ae&&!E&&Re)){if(pt){const _t=Ec(xe.key,Ye());I.current=p&&_t?null:xe.key}if(p){He&&(Es(xe),ae?(B.current=ke(),z(xe)):U(xe));return}We&&(de.current!=null&&(B.current=de.current),Es(xe),!ae&&E?U(xe):Ae(xe),ae&&z(xe))}},onFocus(xe){L.select("open")&&!x&&(B.current=-1,z(xe))},onPointerDown:je,onPointerEnter:je,onMouseDown:$,onClick:$}},[Ae,S,ke,p,z,L,E,O,Ye,v,de,x]),ee=h.useMemo(()=>({...Ue,...Ie}),[Ue,Ie]);return h.useMemo(()=>d?{reference:ee,floating:Pe,item:ve,trigger:Ie}:{},[d,ee,Pe,Ie,ve])}function jO(n,o){const{listRef:r,elementsRef:l,activeIndex:c,onMatch:d,disabledIndices:m,onTyping:g,enabled:b=!0,resetMs:p=750,selectedIndex:v=null}=o,x="rootStore"in n?n.rootStore:n,S=x.useState("open"),j=qn(),E=h.useRef(""),_=h.useRef(v??c??-1),O=h.useRef(null),N=st(C=>{function H(G){const K=l?.current[G];return!K||fu(K)}function M(G){return H(G)?m==null||!q0(Yc,G,m):!1}function L(G,K,A=0){if(G.length===0)return-1;const D=(A%G.length+G.length)%G.length,B=K.toLowerCase();for(let I=0;I<G.length;I+=1){const V=(D+I)%G.length;if(!(!G[V]?.toLowerCase().startsWith(B)||!M(V)))return V}return-1}const w=r.current;if(E.current.length>0&&C.key===" "&&(Es(C),g?.(!0)),E.current.length>0&&E.current[0]!==" "&&L(w,E.current)===-1&&C.key!==" "&&g?.(!1),w==null||C.key.length!==1||C.ctrlKey||C.metaKey||C.altKey)return;S&&C.key!==" "&&(Es(C),g?.(!0));const J=E.current==="";J&&(_.current=v??c??-1),w.every((G,K)=>G&&M(K)?G[0]?.toLowerCase()!==G[1]?.toLowerCase():!0)&&E.current===C.key&&(E.current="",_.current=O.current),E.current+=C.key,j.start(p,()=>{E.current="",_.current=O.current,g?.(!1)});const te=((J?v??c??-1:_.current)??0)+1,Q=L(w,E.current,te);Q!==-1?(d?.(Q),O.current=Q):C.key!==" "&&(E.current="",g?.(!1))}),T=st(C=>{const H=C.relatedTarget,M=x.select("domReferenceElement"),L=x.select("floatingElement");tt(M,H)||tt(L,H)||(j.clear(),E.current="",_.current=O.current,g?.(!1))});Ke(()=>{!S&&v!==null||(j.clear(),O.current=null,E.current!==""&&(E.current=""))},[S,v,j]),Ke(()=>{S&&E.current===""&&(_.current=v??c??-1)},[S,v,c]);const k=h.useMemo(()=>({onKeyDown:N,onBlur:T}),[N,T]);return h.useMemo(()=>b?{reference:k,floating:k}:{},[b,k])}const Qy=.1,TO=Qy*Qy,Ut=.5;function Nc(n,o,r,l,c,d){return l>=o!=d>=o&&n<=(c-r)*(o-l)/(d-l)+r}function jc(n,o,r,l,c,d,m,g,b,p){let v=!1;return Nc(n,o,r,l,c,d)&&(v=!v),Nc(n,o,c,d,m,g)&&(v=!v),Nc(n,o,m,g,b,p)&&(v=!v),Nc(n,o,b,p,r,l)&&(v=!v),v}function wO(n,o,r){return n>=r.x&&n<=r.x+r.width&&o>=r.y&&o<=r.y+r.height}function Tc(n,o,r,l,c,d){const m=Math.min(r,c),g=Math.max(r,c),b=Math.min(l,d),p=Math.max(l,d);return n>=m&&n<=g&&o>=b&&o<=p}function H1(n={}){const{blockPointerEvents:o=!1}=n,r=new ms,l=({x:c,y:d,placement:m,elements:g,onClose:b,nodeId:p,tree:v})=>{const x=m?.split("-")[0];let S=!1,j=null,E=null,_=typeof performance<"u"?performance.now():0;function O(T,k){const C=performance.now(),H=C-_;if(j===null||E===null||H===0)return j=T,E=k,_=C,!1;const M=T-j,L=k-E,w=M*M+L*L,J=H*H*TO;return j=T,E=k,_=C,w<J}function N(){r.clear(),b()}return function(k){r.clear();const C=g.domReference,H=g.floating;if(!C||!H||x==null||c==null||d==null)return;const{clientX:M,clientY:L}=k,w=Dn(k),J=k.type==="mouseleave",oe=tt(H,w),ie=tt(C,w);if(oe&&(S=!0,!J))return;if(ie&&(S=!1,!J)){S=!0;return}if(J&&vt(k.relatedTarget)&&tt(H,k.relatedTarget))return;function te(){return!!(v&&Po(v.nodesRef.current,p).length>0)}function Q(){te()||N()}if(te())return;const G=C.getBoundingClientRect(),K=H.getBoundingClientRect(),A=c>K.right-K.width/2,D=d>K.bottom-K.height/2,B=K.width>G.width,I=K.height>G.height,V=(B?G:K).left,z=(B?G:K).right,Z=(I?G:K).top,F=(I?G:K).bottom;if(x==="top"&&d>=G.bottom-1||x==="bottom"&&d<=G.top+1||x==="left"&&c>=G.right-1||x==="right"&&c<=G.left+1){Q();return}let Y=!1;switch(x){case"top":Y=Tc(M,L,V,G.top+1,z,K.bottom-1);break;case"bottom":Y=Tc(M,L,V,K.top+1,z,G.bottom-1);break;case"left":Y=Tc(M,L,K.right-1,F,G.left+1,Z);break;case"right":Y=Tc(M,L,G.right-1,F,K.left+1,Z);break}if(Y)return;if(S&&!wO(M,L,G)){Q();return}if(!J&&O(M,L)){Q();return}let q=!1;switch(x){case"top":{const P=B?Ut/2:Ut*4,me=B||A?c+P:c-P,re=B?c-P:A?c+P:c-P,de=d+Ut+1,Le=A||B?K.bottom-Ut:K.top,De=A?B?K.bottom-Ut:K.top:K.bottom-Ut;q=jc(M,L,me,de,re,de,K.left,Le,K.right,De);break}case"bottom":{const P=B?Ut/2:Ut*4,me=B||A?c+P:c-P,re=B?c-P:A?c+P:c-P,de=d-Ut,Le=A||B?K.top+Ut:K.bottom,De=A?B?K.top+Ut:K.bottom:K.top+Ut;q=jc(M,L,me,de,re,de,K.left,Le,K.right,De);break}case"left":{const P=I?Ut/2:Ut*4,me=I||D?d+P:d-P,re=I?d-P:D?d+P:d-P,de=c+Ut+1,Le=D||I?K.right-Ut:K.left,De=D?I?K.right-Ut:K.left:K.right-Ut;q=jc(M,L,Le,K.top,De,K.bottom,de,me,de,re);break}case"right":{const P=I?Ut/2:Ut*4,me=I||D?d+P:d-P,re=I?d-P:D?d+P:d-P,de=c-Ut,Le=D||I?K.left+Ut:K.right,De=D?I?K.left+Ut:K.right:K.left+Ut;q=jc(M,L,de,me,de,re,Le,K.top,De,K.bottom);break}}q?S||r.start(40,Q):Q()}};return l.__options={...n,blockPointerEvents:o},l}const CO=h.createContext(void 0);function P1(n){return h.useContext(CO)}const RO="ArrowUp",OO="ArrowDown",kO="ArrowLeft",_O="ArrowRight",MO="Home",AO="End",DO=new Set([kO,_O]),zO=new Set([RO,OO]),LO=new Set([...DO,...zO]),Mp=new Set([...LO,MO,AO]);function Ap(n){return n==="starting"?tR:Vt}const IO={...Jl,...su},BO=h.forwardRef(function(o,r){const{render:l,className:c,style:d,finalFocus:m,...g}=o,{store:b}=wr(),{side:p,align:v}=_0(),x=P1()!=null,S=b.useState("open"),j=b.useState("transitionStatus"),E=b.useState("popupProps"),_=b.useState("mounted"),O=b.useState("instantType"),N=b.useState("activeTriggerElement"),T=b.useState("parent"),k=b.useState("lastOpenChangeReason"),C=b.useState("rootId"),H=b.useState("floatingRootContext"),M=b.useState("floatingTreeRoot"),L=b.useState("closeDelay"),w=b.useState("activeTriggerElement"),J=b.useState("hoverEnabled"),oe=b.useState("disabled"),ie=b.useState("openMethod"),te=T.type==="context-menu";iu({open:S,ref:b.context.popupRef,onComplete(){S&&b.context.onOpenChangeComplete?.(!0)}}),h.useEffect(()=>{function D(B){b.setOpen(!1,jt(B.reason,B.domEvent))}return M.events.on("close",D),()=>{M.events.off("close",D)}},[M.events,b]),B1(H,{enabled:J&&!oe&&!te&&T.type!=="menubar",closeDelay:L});const Q=h.useCallback(D=>{b.set("popupElement",D)},[b]),G={transitionStatus:j,side:p,align:v,open:S,nested:T.type==="menu",instant:O},K=mn("div",o,{state:G,ref:[r,b.context.popupRef,Q],stateAttributesMapping:IO,props:[E,{onKeyDown(D){x&&Mp.has(D.key)&&D.stopPropagation()}},Ap(j),g,{"data-rootownerid":C}]});let A=T.type===void 0||te;return(N||T.type==="menubar"&&k!==rp)&&(A=!0),i.jsx(Sp,{context:H,openInteractionType:ie,modal:te,disabled:!_,returnFocus:m===void 0?A:m,initialFocus:T.type!=="menu",restoreFocus:!0,externalTree:T.type!=="menubar"?M:void 0,previousFocusableElement:w,nextFocusableElement:T.type===void 0?b.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:T.type===void 0?b.context.beforeContentFocusGuardRef:void 0,children:K})}),Y1=h.createContext(void 0);function UO(){const n=h.useContext(Y1);if(n===void 0)throw new Error(En(32));return n}const HO=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=wr();return d.useState("mounted")||l?i.jsx(Y1.Provider,{value:l,children:i.jsx(xp,{ref:r,...c})}):null});function Dp(n){return op(19)?n:n?"true":void 0}const PO=h.createContext(void 0);function V1(){return h.useContext(PO)?.direction??"ltr"}const YO=n=>({name:"arrow",options:n,async fn(o){const{x:r,y:l,placement:c,rects:d,platform:m,elements:g,middlewareData:b}=o,{element:p,padding:v=0,offsetParent:x="real"}=lo(n,o)||{};if(p==null)return{};const S=G0(v),j={x:r,y:l},E=pp(c),_=mp(E),O=await m.getDimensions(p),N=E==="y",T=N?"top":"left",k=N?"bottom":"right",C=N?"clientHeight":"clientWidth",H=d.reference[_]+d.reference[E]-j[E]-d.floating[_],M=j[E]-d.reference[E],L=x==="real"?await m.getOffsetParent?.(p):g.floating;let w=g.floating[C]||d.floating[_];(!w||!await m.isElement?.(L))&&(w=g.floating[C]||d.floating[_]);const J=H/2-M/2,oe=w/2-O[_]/2-1,ie=Math.min(S[T],oe),te=Math.min(S[k],oe),Q=ie,G=w-O[_]-te,K=w/2-O[_]/2+J,A=F0(Q,K,G),D=!b.arrow&&Vo(c)!=null&&K!==A&&d.reference[_]/2-(K<Q?ie:te)-O[_]/2<0,B=D?K<Q?K-Q:K-G:0;return{[E]:j[E]+B,data:{[E]:A,centerOffset:K-A-B,...D&&{alignmentOffset:B}},reset:D}}}),VO=(n,o)=>({...YO(n),options:[n,o]}),FO=ZR().fn,GO={name:"hide",async fn(n){const{width:o,height:r,x:l,y:c}=n.rects.reference,d=o===0&&r===0&&l===0&&c===0;return{data:{referenceHidden:(await FO(n)).data?.referenceHidden||d}}}},Dc={sideX:"left",sideY:"top"},F1={name:"adaptiveOrigin",async fn(n){const{x:o,y:r,rects:{floating:l},elements:{floating:c},platform:d,strategy:m,placement:g}=n,b=Qt(c),p=b.getComputedStyle(c);if(!(p.transitionDuration!=="0s"&&p.transitionDuration!==""))return{x:o,y:r,data:Dc};const x=await d.getOffsetParent?.(c);let S={width:0,height:0};if(m==="fixed"&&b?.visualViewport)S={width:b.visualViewport.width,height:b.visualViewport.height};else if(x===b){const T=Nt(c);S={width:T.documentElement.clientWidth,height:T.documentElement.clientHeight}}else await d.isElement?.(x)&&(S=await d.getDimensions(x));const j=Fn(g);let E=o,_=r;j==="left"&&(E=S.width-(o+l.width)),j==="top"&&(_=S.height-(r+l.height));const O=j==="left"?"right":Dc.sideX,N=j==="top"?"bottom":Dc.sideY;return{x:E,y:_,data:{sideX:O,sideY:N}}}};function G1(n,o,r){const l=n==="inline-start"||n==="inline-end";return{top:"top",right:l?r?"inline-start":"inline-end":"right",bottom:"bottom",left:l?r?"inline-end":"inline-start":"left"}[o]}function Zy(n,o,r){const{rects:l,placement:c}=n;return{side:G1(o,Fn(c),r),align:Vo(c)||"center",anchor:{width:l.reference.width,height:l.reference.height},positioner:{width:l.floating.width,height:l.floating.height}}}function q1(n){const{anchor:o,positionMethod:r="absolute",side:l="bottom",sideOffset:c=0,align:d="center",alignOffset:m=0,collisionBoundary:g,collisionPadding:b=5,sticky:p=!1,arrowPadding:v=5,disableAnchorTracking:x=!1,inline:S,keepMounted:j=!1,floatingRootContext:E,mounted:_,collisionAvoidance:O,shiftCrossAxis:N=!1,nodeId:T,adaptiveOrigin:k,lazyFlip:C=!1,externalTree:H}=n,[M,L]=h.useState(null);!_&&M!==null&&L(null);const w=O.side||"flip",J=O.align||"flip",oe=O.fallbackAxisSide||"end",ie=typeof o=="function"?o:void 0,te=st(ie),Q=ie?te:o,G=ln(o),K=ln(_),D=V1()==="rtl",B=M||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":D?"left":"right","inline-start":D?"right":"left"}[l],I=d==="center"?B:`${B}-${d}`;let V=b;const z=1,Z=l==="bottom"?z:0,F=l==="top"?z:0,Y=l==="right"?z:0,q=l==="left"?z:0;typeof V=="number"?V={top:V+Z,right:V+q,bottom:V+F,left:V+Y}:V&&(V={top:(V.top||0)+Z,right:(V.right||0)+q,bottom:(V.bottom||0)+F,left:(V.left||0)+Y});const P={boundary:g==="clipping-ancestors"?"clippingAncestors":g,padding:V},me=h.useRef(null),re=ln(c),de=ln(m),Le=typeof c!="function"?c:0,De=typeof m!="function"?m:0,we=[];S&&we.push(S),we.push(qR(Se=>{const Fe=Zy(Se,l,D),Ot=typeof re.current=="function"?re.current(Fe):re.current,Pt=typeof de.current=="function"?de.current(Fe):de.current;return{mainAxis:Ot,crossAxis:Pt,alignmentAxis:Pt}},[Le,De,D,l]));const Be=J==="none"&&w!=="shift",ge=!Be&&(p||N||w==="shift"),le=w==="none"?null:KR({...P,padding:{top:V.top+z,right:V.right+z,bottom:V.bottom+z,left:V.left+z},mainAxis:!N&&w==="flip",crossAxis:J==="flip"?"alignment":!1,fallbackAxisSideDirection:oe}),Ye=Be?null:$R(Se=>{const Fe=Nt(Se.elements.floating).documentElement;return{...P,rootBoundary:N?{x:0,y:0,width:Fe.clientWidth,height:Fe.clientHeight}:void 0,mainAxis:J!=="none",crossAxis:ge,limiter:p||N?void 0:XR(Ot=>{if(!me.current)return{};const{width:Pt,height:ne}=me.current.getBoundingClientRect(),be=as(Fn(Ot.placement)),Oe=be==="y"?Pt:ne,Ze=be==="y"?V.left+V.right:V.top+V.bottom;return{offset:Oe/2+Ze/2}})}},[P,p,N,V,J]);w==="shift"||J==="shift"||d==="center"?we.push(Ye,le):we.push(le,Ye),we.push(QR({...P,apply({elements:{floating:Se},availableWidth:Fe,availableHeight:Ot,rects:Pt}){if(!K.current)return;const ne=Se.style;ne.setProperty("--available-width",`${Fe}px`),ne.setProperty("--available-height",`${Ot}px`);const be=Qt(Se).devicePixelRatio||1,{x:Oe,y:Ze,width:nt,height:at}=Pt.reference,ot=(Math.round((Oe+nt)*be)-Math.round(Oe*be))/be,qt=(Math.round((Ze+at)*be)-Math.round(Ze*be))/be;ne.setProperty("--anchor-width",`${ot}px`),ne.setProperty("--anchor-height",`${qt}px`)}}),VO(Se=>({element:me.current||Nt(Se.elements.floating).createElement("div"),padding:v,offsetParent:"floating"}),[v]),{name:"transformOrigin",fn(Se){const{elements:Fe,middlewareData:Ot,placement:Pt,rects:ne,y:be}=Se,Oe=Fn(Pt),Ze=as(Oe),nt=me.current,at=Ot.arrow?.x||0,ot=Ot.arrow?.y||0,qt=nt?.clientWidth||0,$n=nt?.clientHeight||0,Zt=at+qt/2,pn=ot+$n/2,uo=Math.abs(Ot.shift?.y||0),Ln=ne.reference.height/2,As=typeof c=="function"?c(Zy(Se,l,D)):c,ni=uo>As,ps={top:`${Zt}px calc(100% + ${As}px)`,bottom:`${Zt}px ${-As}px`,left:`calc(100% + ${As}px) ${pn}px`,right:`${-As}px ${pn}px`}[Oe],on=`${Zt}px ${ne.reference.y+Ln-be}px`;return Fe.floating.style.setProperty("--transform-origin",ge&&Ze==="y"&&ni?on:ps),{}}},GO,k),Ke(()=>{!_&&E&&E.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,E]);const ke=h.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:Ae,elements:ve,x:Ue,y:Pe,middlewareData:Ie,update:ee,placement:U,context:$,isPositioned:je,floatingStyles:xe}=xO({rootContext:E,open:j?_:void 0,placement:I,middleware:we,strategy:r,whileElementsMounted:j?void 0:(...Se)=>Vy(...Se,ke),nodeId:T,externalTree:H}),{sideX:ae,sideY:Re}=Ie.adaptiveOrigin||Dc,He=je?r:"fixed",We=h.useMemo(()=>{const Se=k?{position:He,[ae]:Ue,[Re]:Pe}:{position:He,...xe};return je||(Se.opacity=0),Se},[k,He,ae,Ue,Re,Pe,xe,je]),pt=h.useRef(null);Ke(()=>{if(!_)return;const Se=G.current,Fe=typeof Se=="function"?Se():Se,Pt=(Jy(Fe)?Fe.current:Fe)||null||null;Pt!==pt.current&&(Ae.setPositionReference(Pt),pt.current=Pt)},[_,Ae,Q,G]),h.useEffect(()=>{if(!_)return;const Se=G.current;typeof Se!="function"&&Jy(Se)&&Se.current!==pt.current&&(Ae.setPositionReference(Se.current),pt.current=Se.current)},[_,Ae,Q,G]),h.useEffect(()=>{if(j&&_&&ve.reference&&ve.floating)return Vy(ve.reference,ve.floating,ee,ke)},[j,_,ve,ee,ke]);const _t=Fn(U),mt=G1(l,_t,D),Tt=Vo(U)||"center",Rt=!!Ie.hide?.referenceHidden;Ke(()=>{C&&_&&je&&L(_t)},[C,_,je,_t]);const zt=h.useMemo(()=>({position:"absolute",top:Ie.arrow?.y,left:Ie.arrow?.x}),[Ie.arrow]),Te=Ie.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:We,arrowStyles:zt,arrowRef:me,arrowUncentered:Te,side:mt,align:Tt,physicalSide:_t,anchorHidden:Rt,refs:Ae,context:$,isPositioned:je,update:ee}),[We,zt,me,Te,mt,Tt,_t,Rt,Ae,$,je,ee])}function Jy(n){return n!=null&&"current"in n}function qO(n){const{children:o,elementsRef:r,labelsRef:l,onMapChange:c}=n,d=st(c),m=h.useRef(0),g=zn(XO).current,b=zn($O).current,[p,v]=h.useState(0),x=h.useRef(p),S=st((N,T)=>{b.set(N,T??null),x.current+=1,v(x.current)}),j=st(N=>{b.delete(N),x.current+=1,v(x.current)}),E=h.useMemo(()=>{const N=new Map;return Array.from(b.keys()).filter(k=>k.isConnected).sort(KO).forEach((k,C)=>{const H=b.get(k)??{};N.set(k,{...H,index:C})}),N},[b,p]);Ke(()=>{if(typeof MutationObserver!="function"||E.size===0)return;const N=new MutationObserver(T=>{const k=new Set,C=H=>k.has(H)?k.delete(H):k.add(H);T.forEach(H=>{H.removedNodes.forEach(C),H.addedNodes.forEach(C)}),k.size===0&&(x.current+=1,v(x.current))});return E.forEach((T,k)=>{k.parentElement&&N.observe(k.parentElement,{childList:!0})}),()=>{N.disconnect()}},[E]),Ke(()=>{x.current===p&&(r.current.length!==E.size&&(r.current.length=E.size),l&&l.current.length!==E.size&&(l.current.length=E.size),m.current=E.size),d(E)},[d,E,r,l,p]),Ke(()=>()=>{r.current=[]},[r]),Ke(()=>()=>{l&&(l.current=[])},[l]);const _=st(N=>(g.add(N),()=>{g.delete(N)}));Ke(()=>{g.forEach(N=>N(E))},[g,E]);const O=h.useMemo(()=>({register:S,unregister:j,subscribeMapChange:_,elementsRef:r,labelsRef:l,nextIndexRef:m}),[S,j,_,r,l,m]);return i.jsx(L0.Provider,{value:O,children:o})}function $O(){return new Map}function XO(){return new Set}function KO(n,o){const r=n.compareDocumentPosition(o);return r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS?1:0}const zp=h.forwardRef(function(o,r){const{cutout:l,...c}=o;let d;if(l){const m=l.getBoundingClientRect();d=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${m.left}px ${m.top}px,${m.left}px ${m.bottom}px,${m.right}px ${m.bottom}px,${m.right}px ${m.top}px,${m.left}px ${m.top}px)`}return i.jsx("div",{ref:r,role:"presentation","data-base-ui-inert":"",...c,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:d}})});function $1(n,o,{styles:r,transitionStatus:l,props:c,refs:d,hidden:m,inert:g=!1}){const b={...r};return g&&(b.pointerEvents="none"),mn("div",n,{state:o,ref:d,props:[{role:"presentation",hidden:m,style:b},Ap(l),c],stateAttributesMapping:Jl})}let Wy={},ev={},tv="";function QO(n){if(typeof document>"u")return!1;const o=Nt(n);return Qt(o).innerWidth-o.documentElement.clientWidth>0}function ZO(n){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=Nt(n),l=r.documentElement,c=r.body,d=Tr(l)?l:c,m=d.style.overflowY,g=l.style.scrollbarGutter;l.style.scrollbarGutter="stable",d.style.overflowY="scroll";const b=d.offsetWidth;d.style.overflowY="hidden";const p=d.offsetWidth;return d.style.overflowY=m,l.style.scrollbarGutter=g,b===p}function JO(n){const o=Nt(n),r=o.documentElement,l=o.body,c=Tr(r)?r:l,d={overflowY:c.style.overflowY,overflowX:c.style.overflowX};return Object.assign(c.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(c.style,d)}}function WO(n){const o=Nt(n),r=o.documentElement,l=o.body,c=Qt(r);let d=0,m=0,g=!1;const b=Ns.create();if(Cr&&(c.visualViewport?.scale??1)!==1)return()=>{};function p(){const j=c.getComputedStyle(r),E=c.getComputedStyle(l),N=(j.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";d=r.scrollTop,m=r.scrollLeft,Wy={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY,overflowX:r.style.overflowX},tv=r.style.scrollBehavior,ev={position:l.style.position,height:l.style.height,width:l.style.width,boxSizing:l.style.boxSizing,overflowY:l.style.overflowY,overflowX:l.style.overflowX,scrollBehavior:l.style.scrollBehavior};const T=r.scrollHeight>r.clientHeight,k=r.scrollWidth>r.clientWidth,C=j.overflowY==="scroll"||E.overflowY==="scroll",H=j.overflowX==="scroll"||E.overflowX==="scroll",M=Math.max(0,c.innerWidth-l.clientWidth),L=Math.max(0,c.innerHeight-l.clientHeight),w=parseFloat(E.marginTop)+parseFloat(E.marginBottom),J=parseFloat(E.marginLeft)+parseFloat(E.marginRight),oe=Tr(r)?r:l;if(g=ZO(n),g){r.style.scrollbarGutter=N,oe.style.overflowY="hidden",oe.style.overflowX="hidden";return}Object.assign(r.style,{scrollbarGutter:N,overflowY:"hidden",overflowX:"hidden"}),(T||C)&&(r.style.overflowY="scroll"),(k||H)&&(r.style.overflowX="scroll"),Object.assign(l.style,{position:"relative",height:w||L?`calc(100dvh - ${w+L}px)`:"100dvh",width:J||M?`calc(100vw - ${J+M}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),l.scrollTop=d,l.scrollLeft=m,r.setAttribute("data-base-ui-scroll-locked",""),r.style.scrollBehavior="unset"}function v(){Object.assign(r.style,Wy),Object.assign(l.style,ev),g||(r.scrollTop=d,r.scrollLeft=m,r.removeAttribute("data-base-ui-scroll-locked"),r.style.scrollBehavior=tv)}function x(){v(),b.request(p)}p();const S=xt(c,"resize",x);return()=>{b.cancel(),v(),typeof c.removeEventListener=="function"&&S()}}class ek{lockCount=0;restore=null;timeoutLock=ms.create();timeoutUnlock=ms.create();acquire(o){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(o)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(o){if(this.lockCount===0||this.restore!==null)return;const l=Nt(o).documentElement,c=Qt(l).getComputedStyle(l).overflowY;if(c==="hidden"||c==="clip"){this.restore=dn;return}const d=lu||!QO(o);this.restore=d?JO(o):WO(o)}}const tk=new ek;function X1(n=!0,o=null){Ke(()=>{if(n)return tk.acquire(o)},[n,o])}const nk=20;function K1(n,o,r,l){const[c,d]=h.useState(!1);Ke(()=>{if(!n||!o||r==null){d(!1);return}const m=Nt(r).documentElement.clientWidth,g=r.offsetWidth;d(m>0&&g>0&&g>=m-nk)},[n,o,r]),X1(n&&(!o||c),l)}const sk=h.forwardRef(function(o,r){const{anchor:l,positionMethod:c="absolute",className:d,render:m,side:g,align:b,sideOffset:p=0,alignOffset:v=0,collisionBoundary:x="clipping-ancestors",collisionPadding:S=5,arrowPadding:j=5,sticky:E=!1,disableAnchorTracking:_=!1,collisionAvoidance:O=nR,style:N,...T}=o,{store:k}=wr(),C=UO(),H=ou(!0),M=k.useState("parent"),L=k.useState("floatingRootContext"),w=k.useState("floatingTreeRoot"),J=k.useState("mounted"),oe=k.useState("open"),ie=k.useState("modal"),te=k.useState("openMethod"),Q=k.useState("activeTriggerElement"),G=k.useState("transitionStatus"),K=k.useState("positionerElement"),A=k.useState("instantType"),D=k.useState("hasViewport"),B=k.useState("lastOpenChangeReason"),I=k.useState("floatingNodeId"),V=k.useState("floatingParentNodeId"),z=L.useState("domReferenceElement"),Z=h.useRef(null),F=up(K,!1,!1);let Y=l,q=p,P=v,me=b,re=O;M.type==="context-menu"&&(Y=l??M.context?.anchor,me=me??"start",!g&&me!=="center"&&(P=o.alignOffset??2,q=o.sideOffset??-5));let de=g,Le=me;M.type==="menu"?(de=de??"inline-end",Le=Le??"start",re=o.collisionAvoidance??a1):M.type==="menubar"&&(de=de??(M.context.orientation==="vertical"?"inline-end":"bottom"),Le=Le??"start");const De=M.type==="context-menu",we=q1({anchor:Y,floatingRootContext:L,positionMethod:H?"fixed":c,mounted:J,side:de,sideOffset:q,align:Le,alignOffset:P,arrowPadding:De?0:j,collisionBoundary:x,collisionPadding:S,sticky:E,nodeId:I,keepMounted:C,disableAnchorTracking:_,collisionAvoidance:re,shiftCrossAxis:De&&!("side"in re&&re.side==="flip"),externalTree:w,adaptiveOrigin:D?F1:void 0});h.useEffect(()=>{function Ue(Pe){Pe.open&&(Pe.parentNodeId===I&&k.set("hoverEnabled",!1),Pe.nodeId!==I&&Pe.parentNodeId===k.select("floatingParentNodeId")&&k.setOpen(!1,jt(_l)))}return w.events.on("menuopenchange",Ue),()=>{w.events.off("menuopenchange",Ue)}},[k,w.events,I]),h.useEffect(()=>{if(k.select("floatingParentNodeId")==null)return;function Ue(Pe){if(Pe.open||Pe.nodeId!==k.select("floatingParentNodeId"))return;const Ie=Pe.reason??_l;k.setOpen(!1,jt(Ie))}return w.events.on("menuopenchange",Ue),()=>{w.events.off("menuopenchange",Ue)}},[w.events,k]);const Be=qn();h.useEffect(()=>{oe||Be.clear()},[oe,Be]),h.useEffect(()=>{function Ue(Pe){if(!(!oe||Pe.nodeId!==k.select("floatingParentNodeId")))if(Pe.target&&Q&&Q!==Pe.target){const Ie=k.select("closeDelay");Ie>0?Be.isStarted()||Be.start(Ie,()=>{k.setOpen(!1,jt(_l))}):k.setOpen(!1,jt(_l))}else Be.clear()}return w.events.on("itemhover",Ue),()=>{w.events.off("itemhover",Ue)}},[w.events,oe,Q,k,Be]),h.useEffect(()=>{const Ue={open:oe,nodeId:I,parentNodeId:V,reason:k.select("lastOpenChangeReason")};w.events.emit("menuopenchange",Ue)},[w.events,oe,k,I,V]),Ke(()=>{const Ue=z,Pe=Z.current;if(Ue&&(Z.current=Ue),Pe&&Ue&&Ue!==Pe){k.set("instantType",void 0);const Ie=new AbortController;return F(()=>{k.set("instantType","trigger-change")},Ie.signal),()=>{Ie.abort()}}},[z,F,k]);const ge={open:oe,side:we.side,align:we.align,anchorHidden:we.anchorHidden,nested:M.type==="menu",instant:A},le=M.type==="menubar"&&M.context.modal;K1(oe&&(le||ie&&B!==fn),te==="touch",K,Q);const ke=$1(o,ge,{styles:we.positionerStyles,transitionStatus:G,props:T,refs:[r,k.useStateSetter("positionerElement")],hidden:!J,inert:!oe}),Ae=J&&M.type!=="menu"&&(M.type!=="menubar"&&ie&&B!==fn||M.type==="menubar"&&M.context.modal);let ve=null;return M.type==="menubar"?ve=M.context.contentElement:M.type===void 0&&(ve=Q),i.jsxs(k0.Provider,{value:we,children:[Ae&&i.jsx(zp,{ref:M.type==="context-menu"||M.type==="nested-context-menu"?M.context.internalBackdropRef:null,inert:Dp(!oe),cutout:ve}),i.jsx(f1,{id:I,children:i.jsx(qO,{elementsRef:k.context.itemDomElements,labelsRef:k.context.itemLabels,children:ke})})]})}),ok=h.createContext(null);function Q1(n){return h.useContext(ok)}function rk(n){const o=h.useRef(""),r=h.useCallback(c=>{c.defaultPrevented||(o.current=c.pointerType,n(c,c.pointerType))},[n]);return{onClick:h.useCallback(c=>{if(c.detail===0){n(c,"keyboard");return}"pointerType"in c?n(c,c.pointerType):n(c,o.current),o.current=""},[n]),onPointerDown:r}}function ak(n,o){const r=h.useRef(n),l=st(o);Ke(()=>{r.current!==n&&l(r.current)},[n,l]),Ke(()=>{r.current=n},[n])}function Z1(n,o){const r=st((d,m)=>{(typeof n=="function"?n():n)||o(m||(lu?"touch":""))}),{onClick:l,onPointerDown:c}=rk(r);return h.useMemo(()=>({onClick:l,onPointerDown:c}),[l,c])}function lk(n){const[o,r]=h.useState(null),l=Z1(n,r);return ak(n,c=>{c&&!n&&r(null)}),h.useMemo(()=>({openMethod:o,triggerProps:l}),[o,l])}const ik={...kp,disabled:qe(n=>n.parent.type==="menubar"&&n.parent.context.disabled||n.disabled),modal:qe(n=>(n.parent.type===void 0||n.parent.type==="context-menu")&&(n.modal??!0)),openMethod:qe(n=>n.openMethod),allowMouseEnter:qe(n=>n.allowMouseEnter),highlightItemOnHover:qe(n=>n.highlightItemOnHover),stickIfOpen:qe(n=>n.stickIfOpen),parent:qe(n=>n.parent),rootId:qe(n=>n.parent.type==="menu"?n.parent.store.select("rootId"):n.parent.type!==void 0?n.parent.context.rootId:n.rootId),activeIndex:qe(n=>n.activeIndex),isActive:qe((n,o)=>n.activeIndex===o),hoverEnabled:qe(n=>n.hoverEnabled),instantType:qe(n=>n.instantType),lastOpenChangeReason:qe(n=>n.openChangeReason),floatingTreeRoot:qe(n=>n.parent.type==="menu"?n.parent.store.select("floatingTreeRoot"):n.floatingTreeRoot),floatingNodeId:qe(n=>n.floatingNodeId),floatingParentNodeId:qe(n=>n.floatingParentNodeId),itemProps:qe(n=>n.itemProps),closeDelay:qe(n=>n.closeDelay),hasViewport:qe(n=>n.hasViewport),keyboardEventRelay:qe(n=>{if(n.keyboardEventRelay)return n.keyboardEventRelay;if(n.parent.type==="menu")return n.parent.store.select("keyboardEventRelay")})};class Lp extends pu{constructor(o){super({...ck(),...o},{positionerRef:h.createRef(),popupRef:h.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:h.createRef(),beforeContentFocusGuardRef:h.createRef(),onOpenChangeComplete:void 0,triggerElements:new ei},ik),this.unsubscribeParentListener=this.observe("parent",r=>{if(this.unsubscribeParentListener?.(),r.type==="menu"){let l=r.store.select("rootId"),c=r.store.select("floatingTreeRoot"),d=r.store.select("keyboardEventRelay");this.unsubscribeParentListener=r.store.subscribe(()=>{const m=r.store.select("rootId"),g=r.store.select("floatingTreeRoot"),b=r.store.select("keyboardEventRelay");l===m&&c===g&&d===b||(l=m,c=g,d=b,this.notifyAll())}),this.context.allowMouseUpTriggerRef=r.store.context.allowMouseUpTriggerRef;return}r.type!==void 0&&(this.context.allowMouseUpTriggerRef=r.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(o,r){this.state.floatingRootContext.context.events.emit("setOpen",{open:o,eventDetails:r})}static useStore(o,r){const l=zn(()=>new Lp(r)).current;return o??l}unsubscribeParentListener=null}function ck(){return{...Rp(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new bp,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Vt,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}const uk=h.createContext(void 0);function dk(){return h.useContext(uk)}const fk=T1(function(o){const{children:r,open:l,onOpenChange:c,onOpenChangeComplete:d,defaultOpen:m=!1,disabled:g=!1,modal:b,loopFocus:p=!0,orientation:v="vertical",actionsRef:x,closeParentOnEsc:S=!1,handle:j,triggerId:E,defaultTriggerId:_=null,highlightItemOnHover:O=!0}=o,N=ou(!0),T=wr(!0),k=Q1(!0),C=dk(),H=h.useMemo(()=>C&&T?{type:"menu",store:T.store}:k?{type:"menubar",context:k}:N&&!T?{type:"context-menu",context:N}:{type:void 0},[N,T,k,C]),M=Lp.useStore(j?.store,{open:m,openProp:l,activeTriggerId:_,triggerIdProp:E,parent:H});_1(M,l,m,_),M.useControlledProp("openProp",l),M.useControlledProp("triggerIdProp",E),M.useContextCallback("onOpenChangeComplete",d);const L=Er(),w=Er(),J=M.useState("floatingTreeRoot"),oe=yp(J),ie=co(),te=M.useState("open"),Q=M.useState("activeTriggerElement"),G=M.useState("positionerElement"),K=M.useState("hoverEnabled"),A=M.useState("disabled"),D=M.useState("lastOpenChangeReason"),B=M.useState("parent"),I=M.useState("activeIndex"),V=M.useState("payload"),z=M.useState("floatingParentNodeId"),Z=h.useRef(null),F=h.useRef(B.type!=="context-menu"),Y=qn(),q=h.useRef(!0),P=qn(),me=z!=null,{openMethod:re,triggerProps:de}=lk(te);M.useSyncedValues({disabled:g,highlightItemOnHover:O,modal:B.type===void 0?b:void 0,openMethod:re,rootId:L}),Tp(M);const{forceUnmount:Le}=wp(te,M,()=>{M.update({allowMouseEnter:!1,stickIfOpen:!0})});Ke(()=>{N&&!T?M.update({parent:{type:"context-menu",context:N},floatingNodeId:oe,floatingParentNodeId:ie}):T&&M.update({floatingNodeId:oe,floatingParentNodeId:ie})},[N,T,oe,ie,M]),h.useEffect(()=>{if(te||(Z.current=null),B.type==="context-menu"){if(!te){Y.clear(),F.current=!1;return}Y.start(500,()=>{F.current=!0})}},[Y,te,B.type]),Ke(()=>{!te&&!K&&M.set("hoverEnabled",!0)},[te,K,M]);const De=st((ae,Re)=>{const He=Re.reason;if(te===ae&&Re.trigger===Q&&D===He)return;const We=k1(Re);if(!ae&&Re.trigger==null&&(Re.trigger=Q??void 0),c?.(ae,Re),Re.isCanceled)return;M.state.floatingRootContext.dispatchOpenChange(ae,Re);const pt=Re.event;if(ae===!1&&pt?.type==="click"&&pt.pointerType==="touch"&&!q.current)return;ae&&He===Al?(q.current=!1,P.start(300,()=>{q.current=!0})):(q.current=!0,P.clear());const _t=(He===vr||He===D0)&&pt.detail===0&&pt?.isTrusted,mt=!ae&&(He===ru||He==null),Tt={open:ae,openChangeReason:He};Z.current=Re.event??null,jp(Tt,ae,Re.trigger,We()),M.update(Tt),B.type==="menubar"&&(He===Al||He===Sr||He===fn||He===xm||He===_l)?M.set("instantType","group"):_t||mt?M.set("instantType",_t?"click":"dismiss"):M.set("instantType",void 0)}),we=C1({popupStore:M,floatingId:w,nested:ie!=null,onOpenChange:De}),Be=we.context.events;h.useEffect(()=>{const ae=({open:Re,eventDetails:He})=>De(Re,He);return Be.on("setOpen",ae),()=>{Be?.off("setOpen",ae)}},[Be,De]);const ge=h.useCallback(()=>{M.setOpen(!1,jt(ap))},[M]);h.useImperativeHandle(x,()=>({unmount:Le,close:ge}),[Le,ge]);let le;B.type==="context-menu"&&(le=B.context),h.useImperativeHandle(le?.positionerRef,()=>G,[G]),h.useImperativeHandle(le?.actionsRef,()=>({setOpen:De}),[De]);const Ye=Ep(we,{enabled:!A,bubbles:{escapeKey:S&&B.type==="menu"},outsidePress(){return B.type!=="context-menu"||Z.current?.type==="contextmenu"?!0:F.current},externalTree:me?J:void 0}),ke=V1(),Ae=h.useCallback(ae=>{M.select("activeIndex")!==ae&&M.set("activeIndex",ae)},[M]),ve=NO(we,{enabled:!A,listRef:M.context.itemDomElements,activeIndex:I,nested:B.type!==void 0,loopFocus:p,orientation:v,parentOrientation:B.type==="menubar"?B.context.orientation:void 0,rtl:ke==="rtl",disabledIndices:Yc,onNavigate:Ae,openOnArrowKeyDown:B.type!=="context-menu",externalTree:me?J:void 0,focusItemOnHover:O}),Ue=h.useCallback(ae=>{M.context.typingRef.current=ae},[M]),Pe=jO(we,{enabled:!A,listRef:M.context.itemLabels,elementsRef:M.context.itemDomElements,activeIndex:I,resetMs:eR,onMatch:ae=>{te&&ae!==I&&M.set("activeIndex",ae)},onTyping:Ue}),Ie=h.useMemo(()=>{const ae=to(Pe.reference,ve.reference,Ye.reference,{onMouseMove(){M.set("allowMouseEnter",!0)}},de);return ae["aria-haspopup"]="menu",ae["aria-expanded"]=te,ae},[M,Pe.reference,ve.reference,Ye.reference,de,te]),ee=h.useMemo(()=>{const ae=to(ve.trigger,Ye.trigger,de);return ae["aria-haspopup"]="menu",ae["aria-expanded"]=!1,ae},[ve.trigger,Ye.trigger,de]),U=h.useMemo(()=>to(gu,{id:w,role:"menu","aria-labelledby":Q?.id,onMouseMove(){M.set("allowMouseEnter",!0),B.type==="menu"&&M.set("hoverEnabled",!1)},onClick(){M.select("hoverEnabled")&&M.set("hoverEnabled",!1)},onKeyDown(ae){const Re=M.select("keyboardEventRelay");Re&&!ae.isPropagationStopped()&&Re(ae)}},Pe.floating,ve.floating,Ye.floating),[Q,w,B.type,M,Pe.floating,ve.floating,Ye.floating]),$=ve.item??Vt;Cp(M,{floatingRootContext:we,activeTriggerProps:Ie,inactiveTriggerProps:ee,popupProps:U,itemProps:$});const je=h.useMemo(()=>({store:M,parent:H}),[M,H]),xe=i.jsx(M0.Provider,{value:je,children:typeof r=="function"?r({payload:V}):r});return B.type===void 0||B.type==="context-menu"?i.jsx(m1,{externalTree:J,children:xe}):xe});function mk(n){const o=n.getBoundingClientRect(),r=Qt(n);if(ip)return o;const l=r.getComputedStyle(n,"::before"),c=r.getComputedStyle(n,"::after");if(!(l.content!=="none"||c.content!=="none"))return o;const m=parseFloat(l.width)||0,g=parseFloat(l.height)||0,b=parseFloat(c.width)||0,p=parseFloat(c.height)||0,v=Math.max(o.width,m,b),x=Math.max(o.height,g,p),S=v-o.width,j=x-o.height;return{left:o.left-S/2,right:o.right+S/2,top:o.top-j/2,bottom:o.bottom+j/2}}function pk(n={}){const{highlightItemOnHover:o,highlightedIndex:r,onHighlightedIndexChange:l}=sp(),{ref:c,index:d}=I0(n),m=r===d,g=h.useRef(null),b=Ca(c,g);return{compositeProps:{tabIndex:m?0:-1,onFocus(){l(d)},onMouseMove(){const v=g.current;if(!o||!v)return;const x=v.hasAttribute("disabled")||v.ariaDisabled==="true";!m&&!x&&v.focus()}},compositeRef:b,index:d}}function hk(n){const{render:o,className:r,style:l,state:c=Vt,props:d=Yc,refs:m=Yc,metadata:g,stateAttributesMapping:b,tag:p="div",...v}=n,{compositeProps:x,compositeRef:S}=pk({metadata:g});return mn(p,n,{state:c,ref:[...m,S],props:[x,...d,v],stateAttributesMapping:b})}function J1(n){if(Yt(n)&&n.hasAttribute("data-rootownerid"))return n.getAttribute("data-rootownerid")??void 0;if(!eo(n))return J1(ro(n))}function W1(n,o){const r=h.useRef(null);function l(d){ao.flushSync(()=>{n.setOpen(!1,jt(Sr,d.nativeEvent,d.currentTarget))}),QC(r.current)?.focus()}function c(d){const m=n.select("positionerElement");if(m&&Na(d,m))n.context.beforeContentFocusGuardRef.current?.focus();else{ao.flushSync(()=>{n.setOpen(!1,jt(Sr,d.nativeEvent,d.currentTarget))});let g=KC(n.context.triggerFocusTargetRef.current||o.current);for(;g!==null&&tt(m,g);){const b=g;if(g=gp(g),g===b)break}g?.focus()}}return{preFocusGuardRef:r,handlePreFocusGuardFocus:l,handleFocusTargetFocus:c}}function gk(n){const{enabled:o=!0,mouseDownAction:r,open:l}=n,c=h.useRef(!1);return h.useMemo(()=>o?{onMouseDown:d=>{(r==="open"&&!l||r==="close"&&l)&&(c.current=!0,Nt(d.currentTarget).addEventListener("click",()=>{c.current=!1},{once:!0}))},onClick:d=>{c.current&&(c.current=!1,d.preventBaseUIHandler())}}:Vt,[o,r,l])}const wc=2,xk=oO(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,id:b,openOnHover:p,delay:v=100,closeDelay:x=0,handle:S,payload:j,...E}=o,_=wr(!0),O=S?.store??_?.store;if(!O)throw new Error(En(85));const N=Rr(b),T=O.useState("isTriggerActive",N),k=O.useState("floatingRootContext"),C=O.useState("isOpenedByTrigger",N),H=O.useState("triggerPopupId",N),M=h.useRef(null),L=yk(),w=sp(!0),J=Fo(),oe=h.useMemo(()=>J??new bp,[J]),ie=yp(oe),te=co(),{registerTrigger:Q,isMountedByThisTrigger:G}=M1(N,M,O,{payload:j,closeDelay:x,parent:L,floatingTreeRoot:oe,floatingNodeId:ie,floatingParentNodeId:te,keyboardEventRelay:w?.relayKeyboardEvent}),K=L.type==="menubar",A=O.useState("disabled"),D=m||A||K&&L.context.disabled,{getButtonProps:B,buttonRef:I}=Zl({disabled:D,native:g});h.useEffect(()=>{!C&&L.type===void 0&&(O.context.allowMouseUpTriggerRef.current=!1)},[O,C,L.type]);const V=h.useRef(null),z=qn(),Z=st(ve=>{if(!V.current)return;z.clear(),O.context.allowMouseUpTriggerRef.current=!1;const Ue=ve.target;if(tt(V.current,Ue)||tt(O.select("positionerElement"),Ue)||Ue===V.current||Ue!=null&&J1(Ue)===O.select("rootId"))return;const Pe=mk(V.current);ve.clientX>=Pe.left-wc&&ve.clientX<=Pe.right+wc&&ve.clientY>=Pe.top-wc&&ve.clientY<=Pe.bottom+wc||oe.events.emit("close",{domEvent:ve,reason:nC})});h.useEffect(()=>{C&&O.select("lastOpenChangeReason")===fn&&Nt(V.current).addEventListener("mouseup",Z,{once:!0})},[C,Z,O]);const F=K&&L.context.hasSubmenuOpen,q=U1(k,{enabled:(p??F)&&!D&&L.type!=="context-menu"&&(!K||F&&!G),handleClose:H1({blockPointerEvents:!K}),mouseOnly:!0,move:!1,restMs:L.type===void 0?v:void 0,delay:{close:x},triggerElementRef:M,externalTree:oe,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),P=bk(C,O.select("lastOpenChangeReason")),me=p1(k,{enabled:!D&&L.type!=="context-menu",event:C&&K?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:L.type===void 0?P:!1}),re=bO(k,{enabled:!D&&F}),de=gk({open:C,enabled:K,mouseDownAction:"open"}),Le=h.useMemo(()=>to(re.reference,me.reference),[re.reference,me.reference]),De=O.useState("triggerProps",G),{preFocusGuardRef:we,handlePreFocusGuardFocus:Be,handleFocusTargetFocus:ge}=W1(O,M),le={disabled:D,open:C},Ye=[V,r,I,Q,M],ke=[Le,q??Vt,De,{"aria-haspopup":"menu","aria-controls":H,id:N,onMouseDown:ve=>{if(O.select("open"))return;z.start(200,()=>{O.context.allowMouseUpTriggerRef.current=!0}),Nt(ve.currentTarget).addEventListener("mouseup",Z,{once:!0})}},K?{role:"menuitem"}:{},de,E,B],Ae=mn("button",o,{enabled:!K,stateAttributesMapping:gm,state:le,ref:Ye,props:ke});return K?i.jsx(hk,{tag:"button",render:l,className:c,style:d,state:le,refs:Ye,props:ke,stateAttributesMapping:gm}):C?i.jsxs(h.Fragment,{children:[i.jsx(Ho,{ref:we,onFocus:Be},`${N}-pre-focus-guard`),i.jsx(h.Fragment,{children:Ae},N),i.jsx(Ho,{ref:O.context.triggerFocusTargetRef,onFocus:ge},`${N}-post-focus-guard`)]}):i.jsx(h.Fragment,{children:Ae},N)});function bk(n,o){const r=qn(),[l,c]=h.useState(!1);return Ke(()=>{n&&o==="trigger-hover"?(c(!0),r.start(o1,()=>{c(!1)})):n||(r.clear(),c(!1))},[n,o,r]),l}function yk(){const n=ou(!0),o=wr(!0),r=Q1();return h.useMemo(()=>r?{type:"menubar",context:r}:n&&!o?{type:"context-menu",context:n}:{type:void 0},[n,o,r])}const vk=h.forwardRef(function(o,r){const{className:l,render:c,orientation:d="horizontal",style:m,...g}=o;return mn("div",o,{state:{orientation:d},ref:r,props:[{role:"separator","aria-orientation":d},g]})});function Sk({...n}){return i.jsx(fk,{"data-slot":"dropdown-menu",...n})}function Ek({...n}){return i.jsx(xk,{"data-slot":"dropdown-menu-trigger",...n})}function Nk({align:n="start",alignOffset:o=0,side:r="bottom",sideOffset:l=4,className:c,...d}){return i.jsx(HO,{children:i.jsx(sk,{className:"isolate z-50 outline-none",align:n,alignOffset:o,side:r,sideOffset:l,children:i.jsx(BO,{"data-slot":"dropdown-menu-content",className:Qe("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",c),...d})})})}function jk({...n}){return i.jsx(SC,{"data-slot":"dropdown-menu-group",...n})}function Tk({className:n,inset:o,...r}){return i.jsx(EC,{"data-slot":"dropdown-menu-label","data-inset":o,className:Qe("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",n),...r})}function wk({className:n,inset:o,variant:r="default",...l}){return i.jsx(NC,{"data-slot":"dropdown-menu-item","data-inset":o,"data-variant":r,className:Qe("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",n),...l})}function Ck({className:n,...o}){return i.jsx(vk,{"data-slot":"dropdown-menu-separator",className:Qe("-mx-1 my-1 h-px bg-border",n),...o})}const Rk={propose_create_entity:"新建实体",propose_update_entity:"更新实体",propose_add_relation:"新增关系",propose_outline_node:"新建大纲节点",propose_reorder_timepoints:"重排时间轴时间点"},Ok={character:"角色",setting:"设定",location:"地点",hook:"伏笔"};function kk(n){const o=n.focus_entity_id??n.focus_node_id??"",r=n.focus_entity_type?Ok[n.focus_entity_type]??n.focus_entity_type:n.focus_node_id?"大纲节点":"";return r?`${r} ${o}`:o||"当前内容"}const _k=n=>typeof n=="object"&&n!==null?n:{};function Mk({disabled:n,onClose:o,onToggleCollapse:r}){const l=St(p=>p.sessions),c=St(p=>p.currentSessionId),d=St(p=>p.setCurrentSession),m=St(p=>p.newSession),g=l?.find(p=>p.id===c)??null,b=g?g.lastMessage||"(空会话)":"新会话";return i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-1 border-b border-border px-2.5",children:[i.jsx(Bl,{className:"size-4 shrink-0 text-muted-foreground"}),i.jsxs(Sk,{children:[i.jsx(Ek,{render:i.jsxs(pe,{variant:"outline",size:"sm",disabled:n,className:"max-w-44 justify-start gap-1 px-1.5",children:[i.jsx("span",{className:"truncate text-sm font-medium",title:b,children:b}),i.jsx(Sj,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),i.jsxs(Nk,{align:"start",className:"w-64",children:[i.jsx(jk,{children:i.jsx(Tk,{children:"会话(本项目)"})}),i.jsx(Ck,{}),l&&l.length===0&&i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"暂无历史会话"}),l?.map(p=>i.jsx(wk,{onClick:()=>d(p.id),className:Qe(p.id===c&&"bg-accent text-accent-foreground"),children:i.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"truncate text-sm",children:p.lastMessage||"(空会话)"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.messageCount," 条 · ",gr(p.updatedAt)]})]})},p.id))]})]}),i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground",disabled:n,onClick:m,"aria-label":"新会话",title:"新会话",children:i.jsx(Zc,{className:"size-4"})}),r&&i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:r,"aria-label":"收起聊天面板",title:"收起聊天面板",children:i.jsx(nT,{className:"size-4"})}),o&&i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:o,"aria-label":"关闭聊天面板",children:i.jsx(fs,{className:"size-4"})})]})}function Ak(){const n=St(l=>l.disconnected),o=St(l=>l.setDisconnected),r=St(l=>l.resendLast);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:[i.jsx(Vm,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"上次会话已取消"}),i.jsx(pe,{size:"xs",variant:"outline",className:"shrink-0",onClick:r,children:"重新发送"}),i.jsx("button",{className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",onClick:()=>o(!1),"aria-label":"关闭断连提示",children:i.jsx(fs,{className:"size-3.5"})})]}):null}function Dk(){const n=St(r=>r.streamError),o=St(r=>r.setStreamError);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:[i.jsx(Hm,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:n}),i.jsx("button",{className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",onClick:()=>o(null),"aria-label":"关闭错误提示",children:i.jsx(fs,{className:"size-3.5"})})]}):null}function eS({toolName:n,args:o,result:r,status:l}){const[c,d]=h.useState(!1),m=l==="ok"||r!==void 0;return i.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/40 px-2 py-1",children:[i.jsxs("button",{className:"flex w-full items-center gap-1.5 rounded-md border border-border px-2 py-1 text-left text-xs text-muted-foreground",onClick:()=>d(g=>!g),"aria-expanded":c,children:[i.jsx(Um,{className:Qe("size-3 shrink-0 transition-transform",c&&"rotate-90")}),i.jsx(OT,{className:"size-3 shrink-0"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["调用了 ",n]}),l==="error"&&i.jsx("span",{className:"shrink-0 text-destructive",children:"✗"}),m&&i.jsx("span",{className:"shrink-0 text-primary",children:"✓"})]}),c&&i.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap text-xs text-muted-foreground",children:typeof o=="string"?o:JSON.stringify(o??{},null,2)})]})}function zk({message:n,toolResults:o}){if(n.role==="user")return i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[85%] rounded-lg bg-secondary px-3 py-2 text-sm text-secondary-foreground",children:n.content})});if(n.role==="tool")return null;const r=Array.isArray(n.toolCalls)?n.toolCalls:[];return i.jsxs("div",{className:"space-y-1.5",children:[r.map((l,c)=>{const d=_k(l),m=d.id??`hist-${c}`,g=m?o.get(m):void 0;return i.jsx(eS,{toolName:d.tool??d.name??"工具",args:d.args,result:g?.content,status:g?"ok":void 0},m)}),n.content?i.jsx("p",{className:"whitespace-pre-wrap font-serif text-[17px] leading-[1.72] text-foreground",children:n.content}):null]})}function Lk({proposal:n}){const o=St(d=>d.confirmProposal),r=St(d=>d.rejectProposal),l=Rk[n.type]??n.type,c=n.status!=="pending"||n.processing===!0;return i.jsxs("div",{className:"rounded-lg border border-primary/25 bg-primary/5 p-2.5",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-foreground",children:[i.jsx(Zv,{className:"size-3.5 shrink-0 text-primary"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["提案:",l]}),n.status==="confirmed"&&i.jsx("span",{className:"shrink-0 text-xs text-primary",children:"✓ 已确认"}),n.status==="rejected"&&i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已拒绝"}),n.status==="stale"&&i.jsx("span",{className:"shrink-0 text-xs text-destructive",children:"⚠ 数据已变化,此提案已失效"})]}),n.preview!==void 0&&i.jsx("pre",{className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap text-xs text-muted-foreground",children:typeof n.preview=="string"?n.preview:JSON.stringify(n.preview,null,2)}),i.jsxs("div",{className:"mt-2 flex gap-1.5",children:[i.jsx(pe,{size:"xs",disabled:c,onClick:()=>{o(n.proposalId)},children:"确认"}),i.jsx(pe,{size:"xs",variant:"outline",disabled:c,onClick:()=>{r(n.proposalId)},children:"拒绝"})]})]})}function Ik(){const n=St(r=>r.focusContext),o=St(r=>r.clearFocusContext);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-t border-border bg-accent/40 px-3 py-1.5 text-xs",children:[i.jsx(Zv,{className:"size-3.5 shrink-0 text-primary"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["正在讨论:",kk(n)]}),i.jsx("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted",onClick:o,"aria-label":"清除讨论上下文",children:i.jsx(fs,{className:"size-3.5"})})]}):null}function Bk({disabled:n}){const[o,r]=h.useState(""),l=St(g=>g.streaming),c=St(g=>g.sendMessage),d=!n&&!l&&o.trim().length>0,m=()=>{d&&(c(o),r(""))};return i.jsx("div",{className:"shrink-0 border-t border-border p-3",children:i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("textarea",{value:o,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),m())},placeholder:l?"AI 思考中…":"输入消息…",rows:1,disabled:n||l,className:"max-h-32 min-h-9 flex-1 resize-none rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs(pe,{onClick:m,disabled:!d,className:"shrink-0",children:[l?i.jsx(Il,{className:"size-4 animate-spin"}):i.jsx(gT,{className:"size-4"}),l?"思考中":"发送"]})]})})}function Uk({disabled:n}){const o=St(p=>p.messages),r=St(p=>p.messagesLoading),l=St(p=>p.streamTools),c=St(p=>p.proposals),d=h.useRef(null),m=h.useMemo(()=>{const p=new Map;for(const v of o)v.role==="tool"&&v.toolCallId&&p.set(v.toolCallId,v);return p},[o]),g=o.length;if(h.useEffect(()=>{const p=d.current;p&&(p.scrollTop=p.scrollHeight)},[g,r,l.length,c.length]),n)return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-4",children:[i.jsx(Bl,{className:"size-8 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground/70",children:"打开项目后可用"})]});if(r)return i.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-4",children:[0,1].map(p=>i.jsx("div",{className:"animate-pulse rounded-lg bg-muted/60",style:{height:40,width:p%2?"70%":"90%"}},p))});const b=o.length===0&&l.length===0&&c.length===0;return i.jsx("div",{ref:d,className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:b?i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-4 text-center",children:[i.jsx(Bl,{className:"size-7 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"试试问:这个设定有没有漏洞?"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"第 4 章剧情往哪走合理?"})]}):i.jsxs("div",{className:"flex flex-col gap-3",children:[o.map(p=>i.jsx(zk,{message:p,toolResults:m},p.id)),l.map(p=>i.jsx(eS,{toolName:p.tool,args:p.args,result:p.result,status:p.status},p.id)),c.map(p=>i.jsx(Lk,{proposal:p},p.proposalId))]})})}function nv({onClose:n,onToggleCollapse:o}){const l=!ze(c=>c.config);return i.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i.jsx(Mk,{disabled:l,onClose:n,onToggleCollapse:o}),!l&&i.jsxs(i.Fragment,{children:[i.jsx(Ak,{}),i.jsx(Dk,{})]}),i.jsx(Uk,{disabled:l}),!l&&i.jsxs(i.Fragment,{children:[i.jsx(Ik,{}),i.jsx(Bk,{disabled:l})]})]})}function Hk({open:n,onClose:o,width:r,onToggleCollapse:l}){return Fm("(min-width: 1024px)")?i.jsx("aside",{className:"flex min-w-0 flex-[4_1_40%] flex-col border-l border-border bg-background",style:r!==void 0?{flex:`0 1 ${r}px`,minWidth:Hl}:void 0,children:i.jsx(nv,{onToggleCollapse:l})}):n?i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"absolute inset-0 bg-foreground/40 animate-in fade-in",onClick:o}),i.jsx("div",{className:"absolute inset-y-0 right-0 w-[85vw] max-w-md border-l border-border bg-background shadow-xl animate-in slide-in-from-right duration-300",children:i.jsx(nv,{onClose:o})})]}):null}function Pk(n){if(typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",o.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}const Yk=n=>{switch(n){case"success":return Gk;case"info":return $k;case"warning":return qk;case"error":return Xk;default:return null}},Vk=Array(12).fill(0),Fk=({visible:n,className:o})=>Me.createElement("div",{className:["sonner-loading-wrapper",o].filter(Boolean).join(" "),"data-visible":n},Me.createElement("div",{className:"sonner-spinner"},Vk.map((r,l)=>Me.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),Gk=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),qk=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),$k=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Xk=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Kk=Me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Me.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Me.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Qk=()=>{const[n,o]=Me.useState(document.hidden);return Me.useEffect(()=>{const r=()=>{o(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),n};let Rm=1;class Zk{constructor(){this.subscribe=o=>(this.subscribers.push(o),()=>{const r=this.subscribers.indexOf(o);this.subscribers.splice(r,1)}),this.publish=o=>{this.subscribers.forEach(r=>r(o))},this.addToast=o=>{this.publish(o),this.toasts=[...this.toasts,o]},this.create=o=>{var r;const{message:l,...c}=o,d=typeof o?.id=="number"||((r=o.id)==null?void 0:r.length)>0?o.id:Rm++,m=this.toasts.find(b=>b.id===d),g=o.dismissible===void 0?!0:o.dismissible;return this.dismissedToasts.has(d)&&this.dismissedToasts.delete(d),m?this.toasts=this.toasts.map(b=>b.id===d?(this.publish({...b,...o,id:d,title:l}),{...b,...o,id:d,dismissible:g,title:l}):b):this.addToast({title:l,...c,dismissible:g,id:d}),d},this.dismiss=o=>(o?(this.dismissedToasts.add(o),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:o,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(l=>l({id:r.id,dismiss:!0}))}),o),this.message=(o,r)=>this.create({...r,message:o}),this.error=(o,r)=>this.create({...r,message:o,type:"error"}),this.success=(o,r)=>this.create({...r,type:"success",message:o}),this.info=(o,r)=>this.create({...r,type:"info",message:o}),this.warning=(o,r)=>this.create({...r,type:"warning",message:o}),this.loading=(o,r)=>this.create({...r,type:"loading",message:o}),this.promise=(o,r)=>{if(!r)return;let l;r.loading!==void 0&&(l=this.create({...r,promise:o,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const c=Promise.resolve(o instanceof Function?o():o);let d=l!==void 0,m;const g=c.then(async p=>{if(m=["resolve",p],Me.isValidElement(p))d=!1,this.create({id:l,type:"default",message:p});else if(Wk(p)&&!p.ok){d=!1;const x=typeof r.error=="function"?await r.error(`HTTP error! status: ${p.status}`):r.error,S=typeof r.description=="function"?await r.description(`HTTP error! status: ${p.status}`):r.description,E=typeof x=="object"&&!Me.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...E})}else if(p instanceof Error){d=!1;const x=typeof r.error=="function"?await r.error(p):r.error,S=typeof r.description=="function"?await r.description(p):r.description,E=typeof x=="object"&&!Me.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...E})}else if(r.success!==void 0){d=!1;const x=typeof r.success=="function"?await r.success(p):r.success,S=typeof r.description=="function"?await r.description(p):r.description,E=typeof x=="object"&&!Me.isValidElement(x)?x:{message:x};this.create({id:l,type:"success",description:S,...E})}}).catch(async p=>{if(m=["reject",p],r.error!==void 0){d=!1;const v=typeof r.error=="function"?await r.error(p):r.error,x=typeof r.description=="function"?await r.description(p):r.description,j=typeof v=="object"&&!Me.isValidElement(v)?v:{message:v};this.create({id:l,type:"error",description:x,...j})}}).finally(()=>{d&&(this.dismiss(l),l=void 0),r.finally==null||r.finally.call(r)}),b=()=>new Promise((p,v)=>g.then(()=>m[0]==="reject"?v(m[1]):p(m[1])).catch(v));return typeof l!="string"&&typeof l!="number"?{unwrap:b}:Object.assign(l,{unwrap:b})},this.custom=(o,r)=>{const l=r?.id||Rm++;return this.create({jsx:o(l),id:l,...r}),l},this.getActiveToasts=()=>this.toasts.filter(o=>!this.dismissedToasts.has(o.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const An=new Zk,Jk=(n,o)=>{const r=o?.id||Rm++;return An.addToast({title:n,...o,id:r}),r},Wk=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",e_=Jk,t_=()=>An.toasts,n_=()=>An.getActiveToasts(),sv=Object.assign(e_,{success:An.success,info:An.info,warning:An.warning,error:An.error,custom:An.custom,message:An.message,promise:An.promise,dismiss:An.dismiss,loading:An.loading},{getHistory:t_,getToasts:n_});Pk("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Cc(n){return n.label!==void 0}const s_=3,o_="24px",r_="16px",ov=4e3,a_=356,l_=14,i_=45,c_=200;function Ss(...n){return n.filter(Boolean).join(" ")}function u_(n){const[o,r]=n.split("-"),l=[];return o&&l.push(o),r&&l.push(r),l}const d_=n=>{var o,r,l,c,d,m,g,b,p;const{invert:v,toast:x,unstyled:S,interacting:j,setHeights:E,visibleToasts:_,heights:O,index:N,toasts:T,expanded:k,removeToast:C,defaultRichColors:H,closeButton:M,style:L,cancelButtonStyle:w,actionButtonStyle:J,className:oe="",descriptionClassName:ie="",duration:te,position:Q,gap:G,expandByDefault:K,classNames:A,icons:D,closeButtonAriaLabel:B="Close toast"}=n,[I,V]=Me.useState(null),[z,Z]=Me.useState(null),[F,Y]=Me.useState(!1),[q,P]=Me.useState(!1),[me,re]=Me.useState(!1),[de,Le]=Me.useState(!1),[De,we]=Me.useState(!1),[Be,ge]=Me.useState(0),[le,Ye]=Me.useState(0),ke=Me.useRef(x.duration||te||ov),Ae=Me.useRef(null),ve=Me.useRef(null),Ue=N===0,Pe=N+1<=_,Ie=x.type,ee=x.dismissible!==!1,U=x.className||"",$=x.descriptionClassName||"",je=Me.useMemo(()=>O.findIndex(be=>be.toastId===x.id)||0,[O,x.id]),xe=Me.useMemo(()=>{var be;return(be=x.closeButton)!=null?be:M},[x.closeButton,M]),ae=Me.useMemo(()=>x.duration||te||ov,[x.duration,te]),Re=Me.useRef(0),He=Me.useRef(0),We=Me.useRef(0),pt=Me.useRef(null),[_t,mt]=Q.split("-"),Tt=Me.useMemo(()=>O.reduce((be,Oe,Ze)=>Ze>=je?be:be+Oe.height,0),[O,je]),Rt=Qk(),zt=x.invert||v,Te=Ie==="loading";He.current=Me.useMemo(()=>je*G+Tt,[je,Tt]),Me.useEffect(()=>{ke.current=ae},[ae]),Me.useEffect(()=>{Y(!0)},[]),Me.useEffect(()=>{const be=ve.current;if(be){const Oe=be.getBoundingClientRect().height;return Ye(Oe),E(Ze=>[{toastId:x.id,height:Oe,position:x.position},...Ze]),()=>E(Ze=>Ze.filter(nt=>nt.toastId!==x.id))}},[E,x.id]),Me.useLayoutEffect(()=>{if(!F)return;const be=ve.current,Oe=be.style.height;be.style.height="auto";const Ze=be.getBoundingClientRect().height;be.style.height=Oe,Ye(Ze),E(nt=>nt.find(ot=>ot.toastId===x.id)?nt.map(ot=>ot.toastId===x.id?{...ot,height:Ze}:ot):[{toastId:x.id,height:Ze,position:x.position},...nt])},[F,x.title,x.description,E,x.id,x.jsx,x.action,x.cancel]);const Se=Me.useCallback(()=>{P(!0),ge(He.current),E(be=>be.filter(Oe=>Oe.toastId!==x.id)),setTimeout(()=>{C(x)},c_)},[x,C,E,He]);Me.useEffect(()=>{if(x.promise&&Ie==="loading"||x.duration===1/0||x.type==="loading")return;let be;return k||j||Rt?(()=>{if(We.current<Re.current){const nt=new Date().getTime()-Re.current;ke.current=ke.current-nt}We.current=new Date().getTime()})():ke.current!==1/0&&(Re.current=new Date().getTime(),be=setTimeout(()=>{x.onAutoClose==null||x.onAutoClose.call(x,x),Se()},ke.current)),()=>clearTimeout(be)},[k,j,x,Ie,Rt,Se]),Me.useEffect(()=>{x.delete&&(Se(),x.onDismiss==null||x.onDismiss.call(x,x))},[Se,x.delete]);function Fe(){var be;if(D?.loading){var Oe;return Me.createElement("div",{className:Ss(A?.loader,x==null||(Oe=x.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":Ie==="loading"},D.loading)}return Me.createElement(Fk,{className:Ss(A?.loader,x==null||(be=x.classNames)==null?void 0:be.loader),visible:Ie==="loading"})}const Ot=x.icon||D?.[Ie]||Yk(Ie);var Pt,ne;return Me.createElement("li",{tabIndex:0,ref:ve,className:Ss(oe,U,A?.toast,x==null||(o=x.classNames)==null?void 0:o.toast,A?.default,A?.[Ie],x==null||(r=x.classNames)==null?void 0:r[Ie]),"data-sonner-toast":"","data-rich-colors":(Pt=x.richColors)!=null?Pt:H,"data-styled":!(x.jsx||x.unstyled||S),"data-mounted":F,"data-promise":!!x.promise,"data-swiped":De,"data-removed":q,"data-visible":Pe,"data-y-position":_t,"data-x-position":mt,"data-index":N,"data-front":Ue,"data-swiping":me,"data-dismissible":ee,"data-type":Ie,"data-invert":zt,"data-swipe-out":de,"data-swipe-direction":z,"data-expanded":!!(k||K&&F),"data-testid":x.testId,style:{"--index":N,"--toasts-before":N,"--z-index":T.length-N,"--offset":`${q?Be:He.current}px`,"--initial-height":K?"auto":`${le}px`,...L,...x.style},onDragEnd:()=>{re(!1),V(null),pt.current=null},onPointerDown:be=>{be.button!==2&&(Te||!ee||(Ae.current=new Date,ge(He.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(re(!0),pt.current={x:be.clientX,y:be.clientY})))},onPointerUp:()=>{var be,Oe,Ze;if(de||!ee)return;pt.current=null;const nt=Number(((be=ve.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((Oe=ve.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ot=new Date().getTime()-((Ze=Ae.current)==null?void 0:Ze.getTime()),qt=I==="x"?nt:at,$n=Math.abs(qt)/ot;if(Math.abs(qt)>=i_||$n>.11){ge(He.current),x.onDismiss==null||x.onDismiss.call(x,x),Z(I==="x"?nt>0?"right":"left":at>0?"down":"up"),Se(),Le(!0);return}else{var Zt,pn;(Zt=ve.current)==null||Zt.style.setProperty("--swipe-amount-x","0px"),(pn=ve.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}we(!1),re(!1),V(null)},onPointerMove:be=>{var Oe,Ze,nt;if(!pt.current||!ee||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;const ot=be.clientY-pt.current.y,qt=be.clientX-pt.current.x;var $n;const Zt=($n=n.swipeDirections)!=null?$n:u_(Q);!I&&(Math.abs(qt)>1||Math.abs(ot)>1)&&V(Math.abs(qt)>Math.abs(ot)?"x":"y");let pn={x:0,y:0};const uo=Ln=>1/(1.5+Math.abs(Ln)/20);if(I==="y"){if(Zt.includes("top")||Zt.includes("bottom"))if(Zt.includes("top")&&ot<0||Zt.includes("bottom")&&ot>0)pn.y=ot;else{const Ln=ot*uo(ot);pn.y=Math.abs(Ln)<Math.abs(ot)?Ln:ot}}else if(I==="x"&&(Zt.includes("left")||Zt.includes("right")))if(Zt.includes("left")&&qt<0||Zt.includes("right")&&qt>0)pn.x=qt;else{const Ln=qt*uo(qt);pn.x=Math.abs(Ln)<Math.abs(qt)?Ln:qt}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&we(!0),(Ze=ve.current)==null||Ze.style.setProperty("--swipe-amount-x",`${pn.x}px`),(nt=ve.current)==null||nt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},xe&&!x.jsx&&Ie!=="loading"?Me.createElement("button",{"aria-label":B,"data-disabled":Te,"data-close-button":!0,onClick:Te||!ee?()=>{}:()=>{Se(),x.onDismiss==null||x.onDismiss.call(x,x)},className:Ss(A?.closeButton,x==null||(l=x.classNames)==null?void 0:l.closeButton)},(ne=D?.close)!=null?ne:Kk):null,(Ie||x.icon||x.promise)&&x.icon!==null&&(D?.[Ie]!==null||x.icon)?Me.createElement("div",{"data-icon":"",className:Ss(A?.icon,x==null||(c=x.classNames)==null?void 0:c.icon)},x.promise||x.type==="loading"&&!x.icon?x.icon||Fe():null,x.type!=="loading"?Ot:null):null,Me.createElement("div",{"data-content":"",className:Ss(A?.content,x==null||(d=x.classNames)==null?void 0:d.content)},Me.createElement("div",{"data-title":"",className:Ss(A?.title,x==null||(m=x.classNames)==null?void 0:m.title)},x.jsx?x.jsx:typeof x.title=="function"?x.title():x.title),x.description?Me.createElement("div",{"data-description":"",className:Ss(ie,$,A?.description,x==null||(g=x.classNames)==null?void 0:g.description)},typeof x.description=="function"?x.description():x.description):null),Me.isValidElement(x.cancel)?x.cancel:x.cancel&&Cc(x.cancel)?Me.createElement("button",{"data-button":!0,"data-cancel":!0,style:x.cancelButtonStyle||w,onClick:be=>{Cc(x.cancel)&&ee&&(x.cancel.onClick==null||x.cancel.onClick.call(x.cancel,be),Se())},className:Ss(A?.cancelButton,x==null||(b=x.classNames)==null?void 0:b.cancelButton)},x.cancel.label):null,Me.isValidElement(x.action)?x.action:x.action&&Cc(x.action)?Me.createElement("button",{"data-button":!0,"data-action":!0,style:x.actionButtonStyle||J,onClick:be=>{Cc(x.action)&&(x.action.onClick==null||x.action.onClick.call(x.action,be),!be.defaultPrevented&&Se())},className:Ss(A?.actionButton,x==null||(p=x.classNames)==null?void 0:p.actionButton)},x.action.label):null)};function rv(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function f_(n,o){const r={};return[n,o].forEach((l,c)=>{const d=c===1,m=d?"--mobile-offset":"--offset",g=d?r_:o_;function b(p){["top","right","bottom","left"].forEach(v=>{r[`${m}-${v}`]=typeof p=="number"?`${p}px`:p})}typeof l=="number"||typeof l=="string"?b(l):typeof l=="object"?["top","right","bottom","left"].forEach(p=>{l[p]===void 0?r[`${m}-${p}`]=g:r[`${m}-${p}`]=typeof l[p]=="number"?`${l[p]}px`:l[p]}):b(g)}),r}const m_=Me.forwardRef(function(o,r){const{id:l,invert:c,position:d="bottom-right",hotkey:m=["altKey","KeyT"],expand:g,closeButton:b,className:p,offset:v,mobileOffset:x,theme:S="light",richColors:j,duration:E,style:_,visibleToasts:O=s_,toastOptions:N,dir:T=rv(),gap:k=l_,icons:C,containerAriaLabel:H="Notifications"}=o,[M,L]=Me.useState([]),w=Me.useMemo(()=>l?M.filter(F=>F.toasterId===l):M.filter(F=>!F.toasterId),[M,l]),J=Me.useMemo(()=>Array.from(new Set([d].concat(w.filter(F=>F.position).map(F=>F.position)))),[w,d]),[oe,ie]=Me.useState([]),[te,Q]=Me.useState(!1),[G,K]=Me.useState(!1),[A,D]=Me.useState(S!=="system"?S:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=Me.useRef(null),I=m.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=Me.useRef(null),z=Me.useRef(!1),Z=Me.useCallback(F=>{L(Y=>{var q;return(q=Y.find(P=>P.id===F.id))!=null&&q.delete||An.dismiss(F.id),Y.filter(({id:P})=>P!==F.id)})},[]);return Me.useEffect(()=>An.subscribe(F=>{if(F.dismiss){requestAnimationFrame(()=>{L(Y=>Y.map(q=>q.id===F.id?{...q,delete:!0}:q))});return}setTimeout(()=>{yC.flushSync(()=>{L(Y=>{const q=Y.findIndex(P=>P.id===F.id);return q!==-1?[...Y.slice(0,q),{...Y[q],...F},...Y.slice(q+1)]:[F,...Y]})})})}),[M]),Me.useEffect(()=>{if(S!=="system"){D(S);return}if(S==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:Y})=>{D(Y?"dark":"light")})}catch{F.addListener(({matches:q})=>{try{D(q?"dark":"light")}catch(P){console.error(P)}})}},[S]),Me.useEffect(()=>{M.length<=1&&Q(!1)},[M]),Me.useEffect(()=>{const F=Y=>{var q;if(m.every(re=>Y[re]||Y.code===re)){var me;Q(!0),(me=B.current)==null||me.focus()}Y.code==="Escape"&&(document.activeElement===B.current||(q=B.current)!=null&&q.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[m]),Me.useEffect(()=>{if(B.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,z.current=!1)}},[B.current]),Me.createElement("section",{ref:r,"aria-label":`${H} ${I}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},J.map((F,Y)=>{var q;const[P,me]=F.split("-");return w.length?Me.createElement("ol",{key:F,dir:T==="auto"?rv():T,tabIndex:-1,ref:B,className:p,"data-sonner-toaster":!0,"data-sonner-theme":A,"data-y-position":P,"data-x-position":me,style:{"--front-toast-height":`${((q=oe[0])==null?void 0:q.height)||0}px`,"--width":`${a_}px`,"--gap":`${k}px`,..._,...f_(v,x)},onBlur:re=>{z.current&&!re.currentTarget.contains(re.relatedTarget)&&(z.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||z.current||(z.current=!0,V.current=re.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{G||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||K(!0)},onPointerUp:()=>K(!1)},w.filter(re=>!re.position&&Y===0||re.position===F).map((re,de)=>{var Le,De;return Me.createElement(d_,{key:re.id,icons:C,index:de,toast:re,defaultRichColors:j,duration:(Le=N?.duration)!=null?Le:E,className:N?.className,descriptionClassName:N?.descriptionClassName,invert:c,visibleToasts:O,closeButton:(De=N?.closeButton)!=null?De:b,interacting:G,position:F,style:N?.style,unstyled:N?.unstyled,classNames:N?.classNames,cancelButtonStyle:N?.cancelButtonStyle,actionButtonStyle:N?.actionButtonStyle,closeButtonAriaLabel:N?.closeButtonAriaLabel,removeToast:Z,toasts:w.filter(we=>we.position==re.position),heights:oe.filter(we=>we.position==re.position),setHeights:ie,expandByDefault:g,gap:k,expanded:te,swipeDirections:o.swipeDirections})})):null}))}),tS=h.createContext(!1),nS=h.createContext(void 0);function Or(n){const o=h.useContext(nS);if(n===!1&&o===void 0)throw new Error(En(27));return o}const p_={...Jl,...su},h_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,forceRender:m=!1,...g}=o,{store:b}=Or(),p=b.useState("open"),v=b.useState("nested"),x=b.useState("mounted"),S=b.useState("transitionStatus");return mn("div",o,{state:{open:p,transitionStatus:S},ref:[b.context.backdropRef,r],stateAttributesMapping:p_,props:[{role:"presentation",hidden:!x,style:{userSelect:"none",WebkitUserSelect:"none"}},g],enabled:m||!v})}),sS=h.forwardRef(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,...b}=o,{store:p}=Or(),v=p.useState("open"),{getButtonProps:x,buttonRef:S}=Zl({disabled:m,native:g}),j={disabled:m};function E(_){v&&p.setOpen(!1,jt(z0,_.nativeEvent))}return mn("button",o,{state:j,ref:[r,S],props:[{onClick:E},b,x]})}),g_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,{store:b}=Or(),p=Rr(m);return b.useSyncedValueWithCleanup("descriptionElementId",p),mn("p",o,{ref:r,props:[{id:p},g]})});let x_=(function(n){return n.nestedDialogs="--nested-dialogs",n})({}),b_=(function(n){return n[n.open=mr.open]="open",n[n.closed=mr.closed]="closed",n[n.startingStyle=mr.startingStyle]="startingStyle",n[n.endingStyle=mr.endingStyle]="endingStyle",n.nested="data-nested",n.nestedDialogOpen="data-nested-dialog-open",n})({});const oS=h.createContext(void 0);function y_(){const n=h.useContext(oS);if(n===void 0)throw new Error(En(26));return n}const v_={...Jl,...su,nestedDialogOpen(n){return n?{[b_.nestedDialogOpen]:""}:null}},S_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,finalFocus:m,initialFocus:g,...b}=o,{store:p}=Or(),v=p.useState("descriptionElementId"),x=p.useState("disablePointerDismissal"),S=p.useState("floatingRootContext"),j=p.useState("popupProps"),E=p.useState("modal"),_=p.useState("mounted"),O=p.useState("nested"),N=p.useState("nestedOpenDialogCount"),T=p.useState("open"),k=p.useState("openMethod"),C=p.useState("titleElementId"),H=p.useState("transitionStatus"),M=p.useState("role"),L=S.useState("floatingId"),w=b.id??L;y_(),iu({open:T,ref:p.context.popupRef,onComplete(){T&&p.context.onOpenChangeComplete?.(!0)}});const J=g===void 0?R1(p.context.popupRef):g,oe=N>0,ie=p.useStateSetter("popupElement"),Q=mn("div",o,{state:{open:T,nested:O,transitionStatus:H,nestedDialogOpen:oe},props:[j,{id:w,"aria-labelledby":C??void 0,"aria-describedby":v??void 0,role:M,...gu,hidden:!_,onKeyDown(G){Mp.has(G.key)&&G.stopPropagation()},style:{[x_.nestedDialogs]:N}},b],ref:[r,p.context.popupRef,ie],stateAttributesMapping:v_});return i.jsx(Sp,{context:S,openInteractionType:k,disabled:!_,closeOnFocusOut:!x,initialFocus:J,returnFocus:m,modal:E!==!1,restoreFocus:"popup",children:Q})}),E_=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=Or(),m=d.useState("mounted"),g=d.useState("modal"),b=d.useState("open");return m||l?i.jsx(oS.Provider,{value:l,children:i.jsxs(xp,{ref:r,...c,children:[m&&g===!0&&i.jsx(zp,{ref:d.context.internalBackdropRef,inert:Dp(!b)}),o.children]})}):null});function N_(n){const{store:o,actionsRef:r}=n,l=o.useState("open");A1(o,l),Tp(o);const{forceUnmount:c}=wp(l,o),d=h.useCallback(()=>{o.setOpen(!1,jt(ap))},[o]);h.useImperativeHandle(r,()=>({unmount:c,close:d}),[c,d])}function j_({store:n,parentContext:o,isDrawer:r}){const l=n.useState("open"),c=n.useState("disablePointerDismissal"),d=n.useState("modal"),m=n.useState("popupElement"),g=n.useState("floatingRootContext"),[b,p]=h.useState(0),[v,x]=h.useState(0),S=b===0,j=Ep(g,{outsidePressEvent(){return n.context.internalBackdropRef.current||n.context.backdropRef.current?"intentional":{mouse:d==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(N){if(!n.context.outsidePressEnabledRef.current||"button"in N&&N.button!==0||"touches"in N&&N.touches.length!==1)return!1;const T=Dn(N);return S&&!c?d&&(n.context.internalBackdropRef.current||n.context.backdropRef.current)?n.context.internalBackdropRef.current===T||n.context.backdropRef.current===T||tt(T,m)&&!T?.hasAttribute("data-base-ui-portal"):!0:!1},escapeKey:S});X1(l&&d===!0,m),n.useContextCallback("onNestedDialogOpen",(N,T)=>{p(N),x(T)}),n.useContextCallback("onNestedDialogClose",()=>{p(0),x(0)}),h.useEffect(()=>(o?.onNestedDialogOpen&&l&&o.onNestedDialogOpen(b+1,v+(r?1:0)),o?.onNestedDialogClose&&!l&&o.onNestedDialogClose(),()=>{o?.onNestedDialogClose&&l&&o.onNestedDialogClose()}),[r,l,b,v,o]);const E=j.reference??Vt,_=j.trigger??Vt,O=j.floating??Vt;return Cp(n,{activeTriggerProps:E,inactiveTriggerProps:_,popupProps:O,nestedOpenDialogCount:b,nestedOpenDrawerCount:v}),null}const T_={...kp,modal:qe(n=>n.modal),nested:qe(n=>n.nested),nestedOpenDialogCount:qe(n=>n.nestedOpenDialogCount),nestedOpenDrawerCount:qe(n=>n.nestedOpenDrawerCount),disablePointerDismissal:qe(n=>n.disablePointerDismissal),openMethod:qe(n=>n.openMethod),descriptionElementId:qe(n=>n.descriptionElementId),titleElementId:qe(n=>n.titleElementId),viewportElement:qe(n=>n.viewportElement),role:qe(n=>n.role)};class Ip extends pu{constructor(o,r,l=!1){const c=new ei,d=w_(o);d.floatingRootContext=D1(c,r,l),super(d,{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:c,onOpenChange:void 0,onOpenChangeComplete:void 0},T_)}setOpen=(o,r)=>{if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!o&&r.trigger==null&&this.state.activeTriggerId!=null&&(r.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(o,r),r.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,r);const l={open:o};jp(l,o,r.trigger),this.update(l)};static useStore(o,r){return O1(o,(c,d)=>new Ip(r,c,d),!0).store}}function w_(n={}){return{...Rp(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...n}}function C_(n,o="dialog"){const{children:r,open:l,defaultOpen:c=!1,onOpenChange:d,onOpenChangeComplete:m,disablePointerDismissal:g=!1,modal:b=!0,actionsRef:p,handle:v,triggerId:x,defaultTriggerId:S=null}=n,j=o==="drawer",E=o==="alert-dialog",_=E?!0:b,O=E||g,N=E?"alertdialog":"dialog",T=Or(!0),C={modal:_,disablePointerDismissal:O,nested:!!T,role:N},H=Ip.useStore(v?.store,{open:c,openProp:l,activeTriggerId:S,triggerIdProp:x,...C});E1(()=>{const ie=l===void 0&&H.state.open===!1&&c===!0?{open:!0,activeTriggerId:S}:null;E?H.update(ie?{...C,...ie}:C):ie&&H.update(ie)}),H.useControlledProp("openProp",l),H.useControlledProp("triggerIdProp",x),H.useSyncedValues(C),H.useContextCallback("onOpenChange",d),H.useContextCallback("onOpenChangeComplete",m);const M=H.useState("open"),L=H.useState("mounted"),w=H.useState("payload");N_({store:H,actionsRef:p});const J=M||L,oe=h.useMemo(()=>({store:H}),[H]);return i.jsx(tS.Provider,{value:!1,children:i.jsxs(nS.Provider,{value:oe,children:[J&&i.jsx(j_,{store:H,parentContext:T?.store.context,isDrawer:j}),typeof r=="function"?r({payload:w}):r]})})}function R_(n){const o=h.useContext(tS)?"drawer":"dialog";return C_(n,o)}const O_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,{store:b}=Or(),p=Rr(m);return b.useSyncedValueWithCleanup("titleElementId",p),mn("h2",o,{ref:r,props:[{id:p},g]})});function Ts({...n}){return i.jsx(R_,{"data-slot":"dialog",...n})}function k_({...n}){return i.jsx(E_,{"data-slot":"dialog-portal",...n})}function __({className:n,...o}){return i.jsx(h_,{"data-slot":"dialog-overlay",className:Qe("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",n),...o})}function ws({className:n,children:o,showCloseButton:r=!0,...l}){return i.jsxs(k_,{children:[i.jsx(__,{}),i.jsxs(S_,{"data-slot":"dialog-content",className:Qe("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...l,children:[o,r&&i.jsxs(sS,{"data-slot":"dialog-close",render:i.jsx(pe,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[i.jsx(fs,{}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Cs({className:n,...o}){return i.jsx("div",{"data-slot":"dialog-header",className:Qe("flex flex-col gap-2",n),...o})}function Rs({className:n,showCloseButton:o=!1,children:r,...l}){return i.jsxs("div",{"data-slot":"dialog-footer",className:Qe("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",n),...l,children:[r,o&&i.jsx(sS,{render:i.jsx(pe,{variant:"outline"}),children:"Close"})]})}function Os({className:n,...o}){return i.jsx(O_,{"data-slot":"dialog-title",className:Qe("font-heading text-base leading-none font-medium",n),...o})}function M_({className:n,...o}){return i.jsx(g_,{"data-slot":"dialog-description",className:Qe("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",n),...o})}const os={volume:"卷",chapter:"章",scene:"场"},A_={volume:"chapter",chapter:"scene",scene:null};function Oa({title:n,description:o,confirmLabel:r,danger:l=!1,onConfirm:c,onClose:d}){const[m,g]=h.useState(null),[b,p]=h.useState(!1);async function v(){p(!0),g(null);try{await c(),d()}catch(x){g(x instanceof _e?x.message:"操作失败,请稍后重试")}finally{p(!1)}}return i.jsx(Ts,{open:!0,onOpenChange:x=>!x&&d(),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsx(Os,{children:n})}),i.jsx("p",{className:"text-sm text-muted-foreground",children:o}),m&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:m}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:d,disabled:b,children:"取消"}),i.jsx(pe,{variant:l?"destructive":"default",type:"button",onClick:()=>{v()},disabled:b,children:r})]})]})})}const av="ai-editor:theme";function rS(){const[n,o]=h.useState("light");h.useEffect(()=>{const c=localStorage.getItem(av)==="dark"?"dark":"light";o(c),document.documentElement.classList.toggle("dark",c==="dark")},[]);function r(){const l=n==="dark"?"light":"dark";localStorage.setItem(av,l),document.documentElement.classList.toggle("dark",l==="dark"),o(l)}return{theme:n,toggleTheme:r}}const D_=({...n})=>{const{theme:o="light"}=rS();return i.jsx(m_,{theme:o,position:"top-right",className:"toaster group",icons:{success:i.jsx(Pm,{className:"size-4"}),info:i.jsx(Qv,{className:"size-4"}),warning:i.jsx(Vm,{className:"size-4"}),error:i.jsx(Qj,{className:"size-4"}),loading:i.jsx(Il,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...n})};function z_(n,o){return n!==null&&n.id!==o}function L_(){const n=Ce(r=>r.confirmState),o=Ce(r=>r.resolveConfirm);return n===null?null:i.jsx(Oa,{title:n.title,description:n.description??"",confirmLabel:"确认",danger:n.danger,onConfirm:async()=>o(!0),onClose:()=>o(!1)})}function I_(){const n=Ce(c=>c.toast),o=Ce(c=>c.error),r=Ce(c=>c.clearError),l=h.useRef(null);return h.useEffect(()=>{!n||!z_(n,l.current)||(l.current=n.id,n.kind==="error"?sv.error(n.text,{duration:dm}):sv.success(n.text,{duration:dm}))},[n]),i.jsxs(i.Fragment,{children:[i.jsx(D_,{}),i.jsx(L_,{}),o&&i.jsxs("div",{role:"alert",className:"fixed top-4 left-1/2 z-50 flex w-[min(92vw,32rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive shadow-lg",children:[i.jsx(Hm,{className:"size-4 shrink-0"}),i.jsx("p",{className:"min-w-0 flex-1",children:o.message}),i.jsx("button",{type:"button","aria-label":"关闭错误提示",onClick:r,className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",children:i.jsx(fs,{className:"size-4"})})]})]})}function B_({chatOpen:n,onToggleChat:o}){const r=ze(v=>v.config),l=ze(v=>v.configLoading),c=ze(v=>v.outline),d=Ce(v=>v.setFocusOutlineNode),m=Ce(v=>v.notifyDataChanged),g=Fm("(min-width: 1024px)"),b=r?.currentPosition!=null?v0(c,r.currentPosition)??r.currentPosition:null,p=l?"加载中…":r?.name??"书架";return i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[i.jsxs("a",{href:"#/",className:"flex min-w-0 items-center gap-1.5 font-serif text-base font-medium text-foreground hover:text-primary",children:[i.jsx("span",{className:"text-primary",children:"◈"}),i.jsx("span",{className:"truncate",children:p})]}),i.jsxs("a",{href:"#/outline",onClick:()=>{r?.currentPosition!=null&&d(r.currentPosition)},title:r?.currentPosition!=null?"跳转大纲并定位该节点":void 0,className:"flex min-w-0 items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx("span",{className:"shrink-0",children:"当前位置:"}),i.jsx("span",{className:"truncate text-foreground",children:b??"未设置"})]}),i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:m,"aria-label":"刷新数据",title:"刷新数据",children:i.jsx(fT,{className:"size-4"})}),i.jsxs("span",{className:"shrink-0 text-sm text-muted-foreground",children:["语言: ",r?.language??"—"]}),!g&&i.jsx(pe,{variant:"ghost",size:"icon-sm",className:n?"bg-secondary text-foreground":"text-muted-foreground",onClick:o,"aria-label":n?"关闭聊天面板":"打开聊天面板",children:i.jsx(Bl,{className:"size-4"})})]})}const U_=[{label:"概览",href:"#/",segment:null,icon:Lj},{label:"大纲",href:"#/outline",segment:"outline",icon:Hj},{label:"画布",href:"#/canvas",segment:"canvas",icon:vT},{label:"实体关系",href:"#/entities/character",segment:"entities",icon:Xj},{label:"伏笔",href:"#/hooks",segment:"hooks",icon:uT},{label:"时间轴",href:"#/timeline",segment:"timeline",icon:bj},{label:"回收站",href:"#/trash",segment:"trash",icon:Ql}];function H_({route:n}){const o=n.segments[0]??null,r=ze(d=>d.loadError==="NO_PROJECT_OPEN"),l=Ce(d=>d.showToast),c=(d,m)=>{!r||m.segment===null||(d.preventDefault(),window.location.hash="#/",l("请先创建或打开项目"))};return i.jsx("nav",{"aria-label":"页面导航",className:"flex items-center gap-1 rounded-lg bg-secondary/30 p-1",children:U_.map(d=>{const m=d.icon,g=o===d.segment;return i.jsxs("a",{href:d.href,"aria-current":g?"page":void 0,onClick:b=>c(b,d),className:Qe("flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",g&&"bg-card text-foreground shadow-sm"),children:[i.jsx(m,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:d.label})]},d.label)})})}function P_({route:n,chatOpen:o,onToggleChat:r,isDesktop:l,children:c}){const d=ze(m=>m.loadConfig);return h.useEffect(()=>{d()},[d]),i.jsxs("main",{className:"flex min-w-0 flex-[5_1_50%] flex-col",style:l?{flex:"1 1 0%",minWidth:_T}:void 0,children:[i.jsx(B_,{chatOpen:o,onToggleChat:r}),i.jsx("div",{className:"shrink-0 px-3 py-2",children:i.jsx(H_,{route:n})}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:c})]})}function zl(n){switch(n){case"INVALID_PROJECT_PATH":return"路径无效:请使用绝对路径,且目标目录须已含 project.json(不是项目目录)";case"PROJECT_ALREADY_EXISTS":return"该目录已是项目,请直接打开(书架列表或「打开其他路径」)";case"PROJECT_VERSION_NEWER":return"该项目由更高版本的 ai-editor 创建,请升级程序后再打开(避免降级导致数据丢失)";case"NO_PROJECT_OPEN":return"";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"操作失败,请稍后重试"}}function Y_(n,o){switch(n){case"PROJECT_ALREADY_EXISTS":return"同名书籍已存在,请换一个书名";case"SCHEMA_VERSION_MISMATCH":return o;case"VALIDATION_ERROR":return o;case"NO_PROJECT_OPEN":return"";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"导入失败,请稍后重试"}}function V_(n,o){return n==="CLIENT_NETWORK_ERROR"?"无法连接服务,请确认 ai-editor 服务已启动":o}function zc(n){const o=n.trim();return o===""?"请输入书名":/[\\/]|^\.+$|[\u0000-\u001f]/.test(o)?"书名不能包含 /、\\ 或为 . / ..":null}let lv=(function(n){return n.disabled="data-disabled",n.valid="data-valid",n.invalid="data-invalid",n.touched="data-touched",n.dirty="data-dirty",n.filled="data-filled",n.focused="data-focused",n})({});const F_={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ml={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},G_={disabled:!1,...Ml},q_={valid(n){return n===null?null:n?{[lv.valid]:""}:{[lv.invalid]:""}}},$_={invalid:void 0,name:void 0,validityData:{state:F_,errors:[],error:"",value:"",initialValue:null},setValidityData:dn,disabled:void 0,touched:Ml.touched,setTouched:dn,dirty:Ml.dirty,setDirty:dn,filled:Ml.filled,setFilled:dn,focused:Ml.focused,setFocused:dn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:G_,markedDirtyRef:{current:!1},registerFieldControl:dn,validation:{getValidationProps:(n,o=Vt)=>o,inputRef:{current:null},registerInput:dn,commit:async()=>{},change:dn}},X_=h.createContext($_);function aS(n=!0){const o=h.useContext(X_);if(o.setValidityData===dn&&!n)throw new Error(En(28));return o}const K_=h.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:dn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function Q_(){return h.useContext(K_)}const Z_=h.createContext({controlId:void 0,registerControlId:dn,labelId:void 0,setLabelId:dn,messageIds:[],setMessageIds:dn,getDescriptionProps:n=>n});function lS(){return h.useContext(Z_)}function J_(n={}){const{id:o,implicit:r=!1,controlRef:l}=n,{controlId:c,registerControlId:d}=lS(),m=Rr(o),g=r?c:void 0,b=zn(()=>Symbol("labelable-control")),p=h.useRef(!1),v=h.useRef(o!=null),x=st(()=>{!p.current||d===dn||(p.current=!1,d(b.current,void 0))});return Ke(()=>{if(d===dn)return;let S;if(r){const j=l?.current;vt(j)&&j.closest("label")!=null?S=o??null:S=g??m}else if(o!=null)v.current=!0,S=o;else if(v.current)S=m;else{x();return}if(S===void 0){x();return}p.current=!0,d(b.current,S)},[o,l,g,d,r,m,b,x]),h.useEffect(()=>x,[x]),c??m}function W_(n,o,r,l,c=!0,d){const{registerFieldControl:m}=aS(),g=h.useRef(null);g.current||(g.current=Symbol()),Ke(()=>{const b=g.current;return!b||!c?void 0:(m(b,{controlRef:n,getValue:l,id:o,name:d,value:r}),()=>{m(b,void 0)})},[n,c,l,o,d,m,r])}const e3=h.forwardRef(function(o,r){const{render:l,className:c,id:d,name:m,value:g,disabled:b=!1,onValueChange:p,defaultValue:v,autoFocus:x=!1,style:S,...j}=o,{state:E,name:_,disabled:O,setTouched:N,setDirty:T,validityData:k,setFocused:C,setFilled:H,validationMode:M,validation:L}=aS(),{clearErrors:w}=Q_(),J=O||b,oe=_??m,ie={...E,disabled:J},{labelId:te}=lS(),Q=J_({id:d});Ke(()=>{const V=g!=null;L.inputRef.current?.value||V&&g!==""?H(!0):V&&g===""&&H(!1)},[L.inputRef,H,g]);const G=h.useRef(null);Ke(()=>{x&&G.current===jn(Nt(G.current))&&C(!0)},[x,C]);const[K]=sC({controlled:g,default:v,name:"FieldControl",state:"value"}),A=g!==void 0,D=A?K:void 0,B=st(()=>L.inputRef.current?.value);return W_(L.inputRef,Q,D,B,!J,m),mn("input",o,{ref:[r,G],state:ie,props:[{id:Q,disabled:J,name:oe,ref:L.inputRef,"aria-labelledby":te,autoFocus:x,...A?{value:D}:{defaultValue:v},onChange(V){const z=V.currentTarget.value;p?.(z,jt(A0,V.nativeEvent)),T(z!==k.initialValue),H(z!==""),V.nativeEvent.defaultPrevented||(w(oe),L.change(z))},onFocus(){C(!0)},onBlur(V){N(!0),C(!1),M==="onBlur"&&L.commit(V.currentTarget.value)},onKeyDown(V){V.currentTarget.tagName==="INPUT"&&V.key==="Enter"&&(N(!0),L.commit(V.currentTarget.value))}},j,V=>L.getValidationProps(J,V)],stateAttributesMapping:q_})}),t3=h.forwardRef(function(o,r){return i.jsx(e3,{ref:r,...o})});function Dt({className:n,type:o,...r}){return i.jsx(t3,{type:o,"data-slot":"input",className:Qe("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...r})}function n3(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=c=>String(c).padStart(2,"0");return o.getFullYear()===new Date().getFullYear()?`${r(o.getMonth()+1)}-${r(o.getDate())}`:`${String(o.getFullYear()).slice(-2)}-${r(o.getMonth()+1)}-${r(o.getDate())}`}function s3(){const n=St(m=>m.sessions),o=St(m=>m.sessionsLoading),r=St(m=>m.sessionsError),l=St(m=>m.loadSessions),c=St(m=>m.currentSessionId),d=St(m=>m.setCurrentSession);return h.useEffect(()=>{n===null&&!o&&r===null&&l()},[n,o,r,l]),n===null?r!==null?r==="NO_PROJECT_OPEN"?i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"打开项目后查看会话"}):i.jsxs("div",{className:"ml-3 border-l border-border py-1 pl-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"会话加载失败"}),i.jsx(pe,{variant:"outline",size:"xs",className:"mt-0.5",onClick:()=>{l()},children:"重试"})]}):i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"会话加载中…"}):n.length===0?i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"暂无会话"}):i.jsx("ul",{className:"ml-3 border-l border-border py-0.5 pl-1.5",children:n.map(m=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:m.lastMessage||"空会话",onClick:()=>d(m.id),className:Qe("flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",c===m.id?"bg-accent font-medium text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[i.jsx(Bl,{className:"size-3 shrink-0 opacity-70"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.lastMessage||"(空会话)"}),i.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",children:gr(m.updatedAt)})]})},m.id))})}function o3({width:n,onToggleCollapse:o}){const{theme:r,toggleTheme:l}=rS(),c=ze(ee=>ee.config),d=ze(ee=>ee.bookshelf),m=ze(ee=>ee.bookshelfLoading),g=ze(ee=>ee.bookshelfError),b=ze(ee=>ee.loadBookshelf),p=ze(ee=>ee.openProjectAt),v=ze(ee=>ee.createProjectAt),[x,S]=h.useState(null),[j,E]=h.useState(!1),[_,O]=h.useState(""),[N,T]=h.useState(null),[k,C]=h.useState(!1),[H,M]=h.useState(!1),[L,w]=h.useState(null),[J,oe]=h.useState(""),[ie,te]=h.useState(null),[Q,G]=h.useState(!1),[K,A]=h.useState(!1),[D,B]=h.useState(""),[I,V]=h.useState(!1),[z,Z]=h.useState(null),[F,Y]=h.useState(""),[q,P]=h.useState(null),[me,re]=h.useState(!1),de=h.useRef(null);h.useEffect(()=>{!m&&d===null&&g===null&&b()},[m,d,g,b]);async function Le(ee){try{await p(ee),S(ee)}catch(U){Ce.getState().showToast(zl(U instanceof _e?U.code:null),"error")}}const De=c?.id??null,we=h.useRef(De);h.useEffect(()=>{we.current!==De&&(we.current=De,S(null),Z(null))},[De]);function Be(){O(""),T(null),E(!1)}async function ge(ee){ee.preventDefault();const U=_.trim(),$=zc(U);if($!==null){T($);return}if(!d){T("书架未加载,请稍后重试");return}C(!0),T(null);try{await v(S0(d.rootPath,U),{name:U,language:"zh"}),Ce.getState().showToast(`已创建并打开《${U}》`),await b();const je=ze.getState().bookshelf?.books.find(xe=>xe.name===U);je&&S(je.path),O(""),E(!1)}catch(je){T(zl(je instanceof _e?je.code:null))}finally{C(!1)}}async function le(ee){if(!I){V(!0);try{const{blob:U,filename:$}=await Jw(),je=URL.createObjectURL(U),xe=document.createElement("a");xe.href=je,xe.download=$,document.body.appendChild(xe),xe.click(),xe.remove(),setTimeout(()=>URL.revokeObjectURL(je),0),Ce.getState().showToast(`已导出《${ee}》备份`)}catch(U){Ce.getState().showToast(V_(U instanceof _e?U.code:null,U instanceof _e?U.message:"导出失败,请重试"),"error")}finally{V(!1)}}}function Ye(ee){const U=ee.target.files?.[0]??null;if(w(U),te(null),U){const $=U.name.replace(/\.zip$/i,""),je=J.trim()===""?$:J;oe(je),ke(je)}}function ke(ee){const U=ee.trim(),$=je=>d?.books.some(xe=>xe.name===je)??!1;if(K){if(U===`${D} (2)`||U===D&&$(U))return;if($(U)){B(U),oe(`${U} (2)`);return}A(!1),B("");return}U!==""&&$(U)&&(B(U),A(!0),oe(`${U} (2)`))}function Ae(ee){const U=ee.target.value;oe(U),ke(U)}async function ve(ee,U){const $=ee.trim();if(!L){te("请选择备份文件");return}const je=zc($);if(je!==null){te(je);return}G(!0),te(null);try{const xe=await Ww(L,$);Ce.getState().showToast(xe.mode==="restored"?`已恢复备份《${xe.name}》`:`已导入为新书《${xe.name}》`),await b(),M(!1),w(null),oe(""),A(!1),B("")}catch(xe){const ae=Y_(xe instanceof _e?xe.code:null,xe instanceof _e?xe.message:"导入失败,请重试");te(ae),ae!==""&&Ce.getState().showToast(ae,"error")}finally{G(!1)}}function Ue(ee){Z(ee.path),Y(ee.name),P(null),window.setTimeout(()=>de.current?.focus(),150)}function Pe(){Z(null),Y(""),P(null)}async function Ie(){if(z===null||me)return;const ee=F.trim();if(ee===ze.getState().config?.name){Pe();return}const U=zc(ee);if(U!==null){P(U);return}re(!0),P(null);try{await o2(ee),Ce.getState().showToast(`已重命名为《${ee}》`),await Promise.all([b(),ze.getState().loadConfig()]),Pe()}catch($){($ instanceof _e?$.code:null)==="PROJECT_ALREADY_EXISTS"?P("书架已有同名书籍,请换一个名字"):$ instanceof _e&&$.code!==ut?P($.message):P("无法连接服务,请确认 ai-editor 服务已启动")}finally{re(!1)}}return i.jsxs("aside",{className:"flex min-w-0 flex-[1_1_10%] flex-col border-r border-border bg-sidebar",style:n!==void 0?{flex:`0 1 ${n}px`,minWidth:Ul}:void 0,children:[i.jsxs("div",{className:"flex h-12 shrink-0 items-center border-b border-border",children:[i.jsxs("a",{href:"#/",className:"flex h-full min-w-0 flex-1 items-center gap-1.5 px-3 font-serif text-base italic text-foreground hover:text-primary",children:[i.jsx("span",{className:"text-primary",children:"◈"}),i.jsx("span",{className:"truncate",children:"我的小说"})]}),o&&i.jsx("button",{type:"button",onClick:o,"aria-label":"收起左栏",title:"收起左栏",className:"mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(Jj,{className:"size-4"})})]}),i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[i.jsxs("div",{className:"mb-1 flex items-center justify-between px-1",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"书架"}),i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx(pe,{variant:"ghost",size:"icon-xs",onClick:()=>M(!0),"aria-label":"导入备份",title:"导入备份(zip)",children:i.jsx(CT,{})}),j?i.jsx(pe,{variant:"ghost",size:"icon-xs",onClick:Be,"aria-label":"取消新建项目",title:"取消新建",children:i.jsx(fs,{})}):i.jsx(pe,{variant:"ghost",size:"icon-xs",onClick:()=>E(!0),"aria-label":"新建项目",title:"新建项目",children:i.jsx(Zc,{})})]})]}),j&&i.jsxs("form",{onSubmit:ge,className:"mb-1 flex flex-col gap-1 px-1","aria-label":"新建项目",children:[i.jsx(Dt,{value:_,onChange:ee=>O(ee.target.value),onKeyDown:ee=>{ee.key==="Escape"&&Be()},onBlur:Be,placeholder:"书名,回车创建",maxLength:60,disabled:k,autoFocus:!0,"aria-label":"书名"}),N&&i.jsx("p",{className:"text-xs text-destructive",children:N})]}),g!==null&&i.jsxs("div",{className:"flex flex-col items-start gap-1 px-1 py-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:g===ut?"无法连接服务":"书架加载失败"}),i.jsx(pe,{variant:"outline",size:"xs",onClick:()=>{b()},children:"重试"})]}),m&&d===null&&i.jsx("div",{className:"space-y-1 px-1 py-2",children:[0,1,2].map(ee=>i.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-muted"},ee))}),g===null&&!m&&d&&d.books.length===0&&i.jsx("p",{className:"px-1 py-2 text-xs text-muted-foreground/70",children:"还没有书,先创建一本"}),g===null&&d&&d.books.length>0&&i.jsx("ul",{className:"space-y-0.5",children:d.books.map(ee=>{const U=x===ee.path,$=c!==null&&ee.name===c.name,je=z===ee.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"flex items-center",children:[je?i.jsxs("div",{className:"flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg bg-muted px-2",children:[i.jsx(Ll,{className:"size-3.5 shrink-0 text-primary"}),i.jsx(Dt,{ref:de,value:F,onChange:xe=>Y(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"?(xe.preventDefault(),Ie()):xe.key==="Escape"&&Pe()},onBlur:()=>{Ie()},maxLength:60,disabled:me,"aria-label":"重命名书名",className:"h-6 min-w-0 flex-1 rounded-md bg-transparent px-1.5 text-sm focus-visible:ring-2"})]}):i.jsxs("button",{type:"button",title:`打开《${ee.name}》`,onClick:()=>{Le(ee.path)},className:Qe("flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 text-left text-sm transition-colors",$?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[i.jsx(Ll,{className:Qe("size-3.5 shrink-0",$?"text-primary":"text-muted-foreground/60")}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:ee.name}),i.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",title:is(ee.updatedAt),children:n3(ee.updatedAt)})]}),$&&i.jsx("button",{type:"button",onClick:()=>{le(ee.name)},disabled:I,"aria-label":`导出《${ee.name}》备份`,title:"导出备份(zip)",className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:I?i.jsx(Il,{className:"size-3.5 animate-spin"}):i.jsx(Rj,{className:"size-3.5"})}),i.jsx("button",{type:"button",onClick:()=>S(xe=>xe===ee.path?null:ee.path),"aria-expanded":U,"aria-label":U?`收起《${ee.name}》会话`:`展开《${ee.name}》会话`,className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(Um,{className:Qe("size-4 transition-transform duration-200",U&&"rotate-90")})}),$&&i.jsx("button",{type:"button","aria-label":`重命名《${ee.name}》`,title:"重命名",onClick:()=>Ue(ee),className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(Kl,{className:"size-3.5"})})]}),je&&q&&i.jsx("p",{className:"px-2 pb-1 text-xs text-destructive",children:q}),U&&i.jsx(s3,{})]},ee.path)})})]}),i.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-t border-border p-2",children:[i.jsxs("a",{href:"#/settings",className:"flex h-8 items-center gap-2 rounded-lg px-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[i.jsx(bT,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:"设置"})]}),i.jsxs(pe,{variant:"outline",size:"sm",className:"justify-start text-muted-foreground",onClick:l,"aria-label":"切换主题",children:[r==="dark"?i.jsx(NT,{className:"size-4 shrink-0"}):i.jsx(qj,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:r==="dark"?"浅色模式":"深色模式"})]})]}),i.jsx(Ts,{open:H,onOpenChange:ee=>{M(ee),ee||(te(null),w(null),oe(""),A(!1),B(""))},children:i.jsxs(ws,{className:"sm:max-w-sm",children:[i.jsxs(Cs,{children:[i.jsx(Os,{children:"导入书籍"}),i.jsx(M_,{children:"从备份 zip 导入;与书架已有书 id 匹配时覆盖恢复,否则导入为新书(同名可重命名或保持原样并存)"})]}),i.jsxs("form",{id:"import-book-form",onSubmit:ee=>{ee.preventDefault(),ve(J)},className:"flex flex-col gap-3",children:[i.jsx("input",{type:"file",accept:".zip,application/zip",onChange:Ye,disabled:Q,"aria-label":"选择备份文件",className:"block w-full cursor-pointer rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground file:mr-2 file:cursor-pointer file:rounded file:border-0 file:bg-muted file:px-2 file:py-1 file:text-xs file:text-muted-foreground disabled:opacity-50"}),i.jsx(Dt,{value:J,onChange:Ae,placeholder:"书名(默认取文件名)",maxLength:60,disabled:Q}),K&&i.jsxs("p",{className:"text-sm text-primary",children:["书架已有同名书籍《",D,"》——可重命名导入,或保持原样(服务端自动去重)"]}),ie&&i.jsx("p",{className:"text-sm text-destructive",children:ie})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>M(!1),disabled:Q,children:"取消"}),K?i.jsxs(i.Fragment,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>{ve(D)},disabled:Q||L===null,children:Q?"导入中…":"保持原样导入"}),i.jsx(pe,{type:"button",onClick:()=>{ve(J)},disabled:Q||L===null,children:Q?"导入中…":"重命名导入"})]}):i.jsx(pe,{type:"submit",form:"import-book-form",disabled:Q||L===null,children:Q?"导入中…":"导入"})]})]})})]})}function iv({side:n,active:o,onStart:r,onMove:l,onEnd:c}){return i.jsxs("div",{role:"separator","aria-orientation":"vertical","aria-label":n==="sidebar"?"调整左栏宽度":"调整右栏宽度",title:n==="sidebar"?"拖动调整左栏宽度":"拖动调整右栏宽度",onPointerDown:d=>{d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),r(n,d.clientX)},onPointerMove:d=>l(n,d.clientX),onPointerUp:c,onPointerCancel:c,className:Qe("group relative z-10 h-full w-1.5 shrink-0 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-border",o&&"bg-border"),children:[i.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border/60 transition-colors group-hover:bg-primary/70"}),i.jsx(Ym,{className:"absolute inset-y-0 left-1/2 size-4 -translate-x-1/2 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100"})]})}function cv({side:n,onExpand:o}){const r=n==="sidebar",l=r?eT:oT;return i.jsx("div",{className:Qe("flex h-full w-8 shrink-0 flex-col items-center bg-sidebar",r?"border-r border-border":"border-l border-border"),children:i.jsx("button",{type:"button",onClick:o,"aria-label":r?"展开左栏":"展开右栏",title:r?"展开左栏":"展开右栏",className:"mt-3 flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(l,{className:"size-4"})})})}function r3({route:n,children:o}){const[r,l]=h.useState(!1),{layout:c,isDesktop:d,dragSide:m,toggleCollapse:g,startResize:b,moveResize:p,endResize:v}=zT(),x=m!==null;return i.jsxs("div",{className:Qe("flex h-screen overflow-hidden",x&&"select-none"),children:[d&&c.collapsedSidebar?i.jsx(cv,{side:"sidebar",onExpand:()=>g("sidebar")}):i.jsx(o3,{width:d?c.sidebarWidth:void 0,onToggleCollapse:d?()=>g("sidebar"):void 0}),d&&!c.collapsedSidebar&&i.jsx(iv,{side:"sidebar",active:m==="sidebar",onStart:b,onMove:p,onEnd:v}),i.jsx(P_,{isDesktop:d,route:n,chatOpen:r,onToggleChat:()=>l(S=>!S),children:o}),d&&!c.collapsedChat&&i.jsx(iv,{side:"chat",active:m==="chat",onStart:b,onMove:p,onEnd:v}),d&&c.collapsedChat?i.jsx(cv,{side:"chat",onExpand:()=>g("chat")}):i.jsx(Hk,{open:r,onClose:()=>l(!1),width:d?c.chatWidth:void 0,onToggleCollapse:d?()=>g("chat"):void 0}),i.jsx(I_,{})]})}class a3 extends h.Component{state={error:null};static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,r){console.error("[ErrorBoundary] 渲染异常:",o,r.componentStack)}render(){const{error:o}=this.state;return o===null?this.props.children:i.jsx("div",{className:"flex h-full min-h-64 flex-col items-center justify-center gap-3 p-8",children:i.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-xl border border-destructive/30 bg-destructive/10 px-8 py-6 text-center",children:[i.jsx(Hm,{className:"size-8 text-destructive"}),i.jsx("p",{className:"font-serif text-base font-medium text-foreground",children:"界面出现异常"}),i.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:"数据不会丢失,请重新加载页面继续写作。"}),i.jsx("p",{className:"max-w-md break-all font-mono text-xs text-destructive/80",children:o.message||String(o)}),i.jsxs("div",{className:"mt-2 flex gap-2",children:[i.jsxs(pe,{type:"button",onClick:()=>window.location.reload(),children:[i.jsx(pT,{className:"size-4"}),"重新加载"]}),i.jsx(pe,{variant:"outline",type:"button",onClick:()=>{window.location.hash="#/",window.location.reload()},children:"回到首页"})]})]})})}}function Ms(n){const o=Ce(l=>l.dataVersion),r=h.useRef(o);h.useEffect(()=>{o!==r.current&&(r.current=o,n())},[o])}const uv={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},dv=["character","setting","location","hook"];function l3(n){const o={volumes:0,chapters:0,scenes:0,updatedAt:null},r=l=>{for(const c of l)c.type==="volume"?o.volumes+=1:c.type==="chapter"?o.chapters+=1:o.scenes+=1,(o.updatedAt===null||c.updatedAt>o.updatedAt)&&(o.updatedAt=c.updatedAt),c.type!=="scene"&&c.children&&r(c.children)};return r(n),o}function Wf(n){return n instanceof _e?n.code:null}function fv(){const n=ze(le=>le.config),o=ze(le=>le.configLoading),r=ze(le=>le.outline),l=ze(le=>le.outlineLoading),c=ze(le=>le.loadOutline),d=ze(le=>le.bookshelf),m=ze(le=>le.bookshelfLoading),g=ze(le=>le.bookshelfError),b=ze(le=>le.loadBookshelf),p=ze(le=>le.openProjectAt),v=ze(le=>le.createProjectAt),x=St(le=>le.sessions),S=St(le=>le.sessionsLoading),j=St(le=>le.sessionsError),E=St(le=>le.loadSessions),_=St(le=>le.setCurrentSession),O=St(le=>le.currentSessionId),N=Ce(le=>le.setFocusOutlineNode),[T,k]=h.useState(""),[C,H]=h.useState(null),[M,L]=h.useState(null),[w,J]=h.useState(!1),[oe,ie]=h.useState(!1),[te,Q]=h.useState(""),[G,K]=h.useState(null),[A,D]=h.useState(!1),[B,I]=h.useState(null),[V,z]=h.useState(!1),[Z,F]=h.useState(null),[Y,q]=h.useState(0),[P,me]=h.useState(!1),re=n===null&&!o,de=r?l3(r.children):null,Le=n?.currentPosition!=null?v0(r,n.currentPosition)??n.currentPosition:null;h.useEffect(()=>{re&&!m&&d===null&&g===null&&b()},[re,m,d,g,b]),h.useEffect(()=>{me(!1)},[n?.id]),Ms(()=>{q(le=>le+1),c(),E()}),h.useEffect(()=>{L(null)},[n?.id]),h.useEffect(()=>{n!==null&&r===null&&!l&&!P&&(me(!0),c())},[n,r,l,P,c]),h.useEffect(()=>{if(n===null)return;let le=!1;return I(null),z(!0),F(null),Promise.allSettled(dv.map(async Ye=>({type:Ye,total:(await ls(Ye,{limit:1})).total}))).then(Ye=>{if(le)return;const ke={};let Ae=!1;for(const ve of Ye)ve.status==="fulfilled"?ke[ve.value.type]=ve.value.total:Ae=!0;I(ke),F(Ae?"要素统计加载失败":null),z(!1)}),()=>{le=!0}},[n,Y]),h.useEffect(()=>{n!==null&&x===null&&!S&&j===null&&E()},[n,x,S,j,E]);async function De(le){le.preventDefault();const Ye=T.trim(),ke=zc(Ye);if(ke!==null){H(ke);return}if(!d){H("书架未加载,请稍后重试");return}D(!0),H(null);try{await v(S0(d.rootPath,Ye),{name:Ye,language:"zh"}),await b(),Ce.getState().showToast(`已创建并打开《${Ye}》`),k("")}catch(Ae){H(zl(Wf(Ae)))}finally{D(!1)}}async function we(le){if(le.preventDefault(),!te.trim()){K("请输入项目目录路径(绝对路径)");return}D(!0),K(null);try{await p(te.trim())}catch(Ye){K(zl(Wf(Ye)))}finally{D(!1)}}async function Be(le){L(null);try{await p(le)}catch(Ye){L(zl(Wf(Ye)))}}function ge(){n?.currentPosition!=null&&N(n.currentPosition)}if(o)return i.jsx("section",{children:i.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"加载中…"})});if(re){let le=function(ve){return i.jsxs("form",{onSubmit:De,className:ve,children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Dt,{value:T,onChange:Ue=>k(Ue.target.value),placeholder:"书名",maxLength:60,disabled:A}),i.jsx(pe,{type:"submit",disabled:A||d===null,children:"新建"})]}),C&&i.jsx("p",{className:"text-left text-sm text-destructive",children:C})]})};const Ye=d===null&&m,ke=g!==null,Ae=d!==null&&d.books.length>0;return i.jsxs("section",{children:[g!==null&&i.jsxs("div",{className:"mx-auto mt-2 max-w-md rounded-md border border-border bg-card p-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:g===ut?"无法连接服务,请确认 ai-editor 服务已启动后重试。":"书架加载失败,请重试。"}),i.jsx(pe,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{b()},type:"button",children:"重试"})]}),i.jsx("div",{className:"mx-auto mt-10 max-w-md rounded-2xl border border-dashed border-border bg-card px-6 py-8 text-center",children:Ye?i.jsxs("div",{className:"py-2",children:[i.jsx("div",{className:"mx-auto h-6 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"mx-auto mt-2 h-4 w-1/2 animate-pulse rounded bg-muted"}),i.jsxs("div",{className:"mt-5 space-y-2",children:[i.jsx("div",{className:"h-10 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"h-10 animate-pulse rounded-lg bg-muted"})]})]}):i.jsxs(i.Fragment,{children:[Ae?i.jsxs(i.Fragment,{children:[i.jsx("h1",{className:"font-serif text-lg text-foreground",children:"书架里有书,打开即可写作"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"选择一本书打开,或新建一本"}),i.jsx("ul",{className:"mt-5 divide-y divide-border overflow-hidden rounded-lg border border-border text-left",children:d.books.map(ve=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:`打开《${ve.name}》`,onClick:()=>{Be(ve.path)},className:"flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[i.jsx(Ll,{className:"size-4 shrink-0 text-muted-foreground/60"}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:ve.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:gr(ve.updatedAt)})]})},ve.path))}),M!==null&&i.jsx("p",{className:"mt-3 text-left text-sm text-destructive",children:M}),i.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[i.jsx("button",{type:"button",className:"rounded-md border border-border px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>J(ve=>!ve),children:w?"收起":"新建一本…"}),w&&le("mt-2 flex flex-col gap-2 text-left")]})]}):ke?i.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"书架加载失败,重试后可查看书籍或新建"}):i.jsxs(i.Fragment,{children:[i.jsx("h1",{className:"font-serif text-lg text-foreground",children:"还没有书,先创建一本"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"每本书一个独立目录(books/书名/),写作数据互不干扰"}),le("mx-auto mt-5 flex flex-col gap-2"),i.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"创建于 创作根/books/书名/ 目录"})]}),i.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[i.jsx("button",{type:"button",className:"rounded-md border border-border px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>ie(ve=>!ve),children:oe?"收起":"打开其他路径…"}),oe&&i.jsxs("form",{onSubmit:we,className:"mt-2 flex flex-col gap-2 text-left",children:[i.jsx(Dt,{value:te,onChange:ve=>Q(ve.target.value),placeholder:"/absolute/path/to/project(须含 project.json)",disabled:A}),i.jsx("div",{children:i.jsx(pe,{type:"submit",variant:"outline",disabled:A,children:"打开"})}),G&&i.jsx("p",{className:"text-sm text-destructive",children:G})]})]})]})})]})}return i.jsxs("section",{children:[i.jsx("div",{className:"mb-4",children:i.jsx("h1",{className:"font-serif text-xl font-medium text-foreground",children:"项目概览"})}),i.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"项目信息"}),i.jsxs("dl",{className:"mt-3 space-y-2 text-sm",children:[i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"名称"}),i.jsx("dd",{className:"min-w-0 truncate font-medium text-foreground",children:n?.name})]}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"语言"}),i.jsx("dd",{className:"text-foreground",children:n?.language==="zh"?"中文":"English"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"当前位置"}),i.jsx("dd",{className:"min-w-0 flex-1 truncate",children:n?.currentPosition!=null?i.jsx("a",{href:"#/outline",onClick:ge,className:"text-primary hover:underline",children:Le??n.currentPosition}):i.jsx("span",{className:"text-muted-foreground",children:"未设置"})}),i.jsx("a",{href:"#/outline",onClick:ge,className:pm({variant:"outline",size:"xs"}),children:"去大纲"})]})]}),i.jsxs("div",{className:"mt-3 border-t border-border pt-3",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"项目提示词"}),i.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-foreground/90",children:n?.prompt||"(未设置)"})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"创作要素"}),V&&B===null?i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[0,1,2,3].map(le=>i.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-muted"},le))}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:dv.map(le=>i.jsxs("a",{href:`#/entities/${le}`,className:"group rounded-lg border border-border bg-background p-3 transition-colors hover:border-primary/40 hover:bg-muted",title:`查看${uv[le]}列表`,children:[i.jsx("p",{className:"font-serif text-2xl font-semibold text-foreground",children:B?.[le]??"–"}),i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:uv[le]})]},le))}),Z!==null&&i.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-destructive",children:[Z,i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>q(le=>le+1),children:"重试"})]})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4 lg:col-span-2",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"大纲概览"}),r===null&&(l||!P)?i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:"h-5 w-2/5 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"})]}):r===null?i.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>me(!1),children:"重试"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"mt-3 text-sm text-foreground",children:["卷 ",de?.volumes??0," · 章 ",de?.chapters??0," · 场景"," ",de?.scenes??0]}),i.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["最近更新: ",de?.updatedAt?gr(de.updatedAt):"—"]}),r.children.length===0&&i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"大纲还是空的"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>_(null),children:"和 AI 聊聊设定"})]}),i.jsx("div",{className:"mt-3",children:i.jsx("a",{href:"#/outline",onClick:ge,className:Qe(pm({variant:"outline",size:"sm"})),children:"去大纲编辑"})})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4 lg:col-span-2",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"最近会话"}),x===null?j!==null?i.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:["会话加载失败",i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>{E()},children:"重试"})]}):i.jsx("div",{className:"mt-3 space-y-2",children:[0,1,2].map(le=>i.jsx("div",{className:"h-8 animate-pulse rounded-md bg-muted"},le))}):x.length===0?i.jsxs("div",{className:"mt-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有会话,和 AI 聊聊设定吧"}),i.jsx(pe,{variant:"outline",size:"sm",className:"mt-3",type:"button",onClick:()=>_(null),children:"开始新对话"})]}):i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"mt-3 divide-y divide-border rounded-lg border border-border",children:x.slice(0,5).map(le=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:le.lastMessage||"空会话",onClick:()=>_(le.id),className:Qe("flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-muted",O===le.id&&"bg-accent/40 hover:bg-accent/40"),children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:le.lastMessage||"(空会话)"}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[le.messageCount," 条消息"]}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:gr(le.updatedAt)})]})},le.id))}),i.jsx("div",{className:"mt-3",children:i.jsx(pe,{variant:"outline",size:"sm",type:"button",onClick:()=>_(null),children:"开始新对话"})})]})]})]})]})}const mv={plants:"埋设",advances:"推进",resolves:"回收"},i3={plants:lT,advances:Mj,resolves:Pm};function iS({mark:n}){const o=i3[n.relationType];return i.jsx("span",{className:"shrink-0 rounded px-0.5 text-muted-foreground hover:text-foreground",title:`${mv[n.relationType]}伏笔:${n.hookName}`,"aria-label":`${mv[n.relationType]}伏笔:${n.hookName}`,children:i.jsx(o,{className:"size-3"})})}const Bp=["plants","advances","resolves"],pv=["plants","advances","resolves"];function hv(n){const o=pv.indexOf(n);return o===-1?pv.length:o}function cS(n){const o=new Map;for(const r of n){if(!Bp.includes(r.relationType)||r.sourceType!=="outline_node"||r.targetType!=="hook")continue;const l={relationType:r.relationType,hookId:r.targetId,hookName:r.targetName??r.targetId},c=o.get(r.sourceId);c===void 0?o.set(r.sourceId,[l]):c.push(l)}for(const r of o.values())r.sort((l,c)=>hv(l.relationType)-hv(c.relationType)||(l.hookName<c.hookName?-1:l.hookName>c.hookName?1:0)||(l.hookId<c.hookId?-1:l.hookId>c.hookId?1:0));return o}const Sn="root",gv={id:Sn,label:"(根)",depth:0};function c3(n,o){if(o==="volume")return[gv];const r=o==="chapter"?[gv]:[],l=(c,d)=>{for(const m of c)o==="chapter"&&m.type==="volume"?r.push({id:m.id,label:m.title,depth:d}):o==="scene"&&m.type==="chapter"&&r.push({id:m.id,label:m.title,depth:d}),m.children&&l(m.children,d+1)};return l(n,1),r}function Bo(n,o){for(const r of n){if(r.id===o)return r;if(r.type!=="scene"&&r.children){const l=Bo(r.children,o);if(l)return l}}return null}function Up(n,o,r=[]){for(const l of n){const c=[...r,l.id];if(l.id===o)return c;if(l.type!=="scene"&&l.children){const d=Up(l.children,o,c);if(d)return d}}return null}function oo(n,o=0,r=[]){for(const l of n)r.push({id:l.id,label:l.title,depth:o}),l.type!=="scene"&&l.children&&oo(l.children,o+1,r);return r}function u3(n,o,r){const l=Bo(n,o);if(!l)return!1;const c=d=>d.id===r?!0:d.type!=="scene"&&d.children?d.children.some(m=>c(m)):!1;return c(l)}function Rc(n,o,r){return o===n.id||u3(r,n.id,o)?!1:c3(r,n.type).some(l=>l.id===o)}function uS(n,o){const r=o.trim();return r!==""&&r!==n.trim()}function dS(n,o){return o.trim()!==(n??"").trim()}function d3(n){return n==="OUTLINE_NODE_NOT_FOUND"?"abandon":"restore"}function fS(n,o){if(o===Sn)return n;const r=l=>{for(const c of l){if(c.id===o)return c.children??[];if(c.children){const d=r(c.children);if(d)return d}}return null};return r(n)}function xv(n,o,r){const l=r===void 0?n:n.filter(d=>d.id!==r);if(o.kind==="end")return l.length;const c=l.findIndex(d=>d.id===o.nodeId);return c===-1?l.length:o.kind==="before"?c:c+1}function bv(n,o){return n===null||o===null?n===o:n.kind==="root-end"||o.kind==="root-end"?n.kind===o.kind:n.kind===o.kind&&n.nodeId===o.nodeId}function Om(n,o){const r=(l,c)=>{for(const d of l){if(d.id===o)return c;if(d.children){const m=r(d.children,d.id);if(m!==null)return m}}return null};return r(n,Sn)}function f3(n,o){const r=Om(n,o);if(r===null)return null;const c=(fS(n,r)??[]).findIndex(d=>d.id===o);return c===-1?null:{parentId:r,index:c}}function yv(n,o,r,l){const c=f3(n,o);return c===null||c.parentId!==r?!1:l===c.index}function Oc(n){return n instanceof _e?n.code:null}function xa(n){switch(n){case"OUTLINE_NODE_NOT_FOUND":return"节点不存在(可能已被彻底删除),大纲已刷新";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"操作失败,请稍后重试"}}function Lc(n,o,r,l,c){return i.jsx("input",{autoFocus:!0,value:n,onChange:d=>o(d.target.value),onKeyDown:r,onBlur:l,maxLength:200,placeholder:c,className:"min-w-0 flex-1 rounded border border-border bg-card px-1.5 py-0.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"})}function vv({type:n,onTypeChange:o,value:r,onChange:l,onKeyDown:c,onCancel:d,className:m}){return i.jsxs("div",{className:Qe("flex items-center gap-2 rounded-md px-2 py-1",m),children:[i.jsx("div",{className:"flex shrink-0 gap-1",children:["volume","chapter"].map(g=>i.jsx("button",{type:"button",onClick:()=>o(g),className:Qe("rounded border px-2 py-0.5 text-xs transition-colors",n===g?"border-primary bg-primary text-primary-foreground":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"),children:os[g]},g))}),Lc(r,l,c,d,`新${os[n]}标题,Enter 创建`)]})}function m3(){const n=ze(ee=>ee.outline),o=ze(ee=>ee.outlineLoading),r=ze(ee=>ee.config),l=ze(ee=>ee.configLoading),c=ze(ee=>ee.loadOutline),d=Ce(ee=>ee.focusOutlineNodeId),m=Ce(ee=>ee.clearFocusOutlineNode);Ms(()=>{c()});const[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(new Set),[j,E]=h.useState(!1),[_,O]=h.useState(null),[N,T]=h.useState(null),[k,C]=h.useState(null),[H,M]=h.useState(""),[L,w]=h.useState(null),[J,oe]=h.useState(""),[ie,te]=h.useState(null),[Q,G]=h.useState(null),[K,A]=h.useState(null),D=r===null&&!l;h.useEffect(()=>{n===null&&!o&&!g&&(b(!0),c())},[n,o,g,c]),h.useEffect(()=>{if(n===null){A(null);return}let ee=!1;return Promise.all(Bp.map(U=>br({source_type:"outline_node",relation_type:U,depth:1}).then($=>$.relations).catch(()=>[]))).then(U=>{ee||A(cS(U.flat()))}),()=>{ee=!0}},[n]),h.useEffect(()=>{if(_===null)return;const ee=setTimeout(()=>O(null),3e3);return()=>clearTimeout(ee)},[_]),h.useEffect(()=>{if(d===null||n===null)return;const ee=d,U=Up(n.children,ee);if(U===null){m();return}S(je=>{if(U.every(ae=>!je.has(ae)))return je;const xe=new Set(je);for(const ae of U)xe.delete(ae);return xe});const $=setTimeout(()=>{const je=document.querySelector(`[data-node-id="${ee}"]`);je&&(je.scrollIntoView({block:"center"}),T(ee)),m()},0);return()=>clearTimeout($)},[d,n,m]),h.useEffect(()=>{if(N===null)return;const ee=setTimeout(()=>T(null),3e3);return()=>clearTimeout(ee)},[N]);async function B(ee,U){ee&&V(ee),await c(),U&&O(U)}function I(ee){S(U=>{const $=new Set(U);return $.has(ee)?$.delete(ee):$.add(ee),$})}function V(ee){S(U=>{if(!U.has(ee))return U;const $=new Set(U);return $.delete(ee),$})}function z(ee,U=[]){for(const $ of ee)$.type!=="scene"&&$.children&&$.children.length>0&&(U.push($.id),z($.children,U));return U}function Z(ee,U){me(),C({nodeId:ee.id,field:U}),M(U==="title"?ee.title:ee.summary??"")}function F(){C(null),M("")}async function Y(ee,U){if(!k||k.nodeId!==ee.id||k.field!==U||j)return;const $=H;if(!(U==="title"?uS(ee.title,$):dS(ee.summary,$))){F();return}E(!0);try{await x0(ee.id,U==="title"?{title:$.trim()}:{summary:$.trim()}),F(),Ce.getState().showToast("已保存"),await B()}catch(xe){const ae=Oc(xe);if(d3(ae)==="abandon"){F(),v(xa(ae)),await B();return}v(xa(ae))}finally{E(!1)}}function q(ee,U){return $=>{$.key==="Enter"?($.preventDefault(),Y(ee,U)):$.key==="Escape"&&F()}}function P(ee,U){F(),w({parentId:ee,type:U}),oe(""),ee!==Sn&&V(ee)}function me(){w(null),oe("")}async function re(){if(!L)return;const ee=J.trim(),{parentId:U,type:$}=L;if(!ee){me();return}me();try{const je=await Lw({type:$,title:ee,parent_id:U});Ce.getState().showToast(`已创建${os[$]}《${ee}》`),await B(U,je.id)}catch(je){v(xa(Oc(je)))}}function de(ee){ee.key==="Enter"?(ee.preventDefault(),re()):ee.key==="Escape"&&me()}function Le(ee,U){ee.dataTransfer.setData("text/plain",U.id),ee.dataTransfer.effectAllowed="move",te(U.id),G(null)}function De(){te(null),G(null)}function we(ee){const U=ee.currentTarget.getBoundingClientRect();return ee.clientY<U.top+U.height/2?"before":"after"}function Be(ee,U){ee.stopPropagation();const $=ie?Bo(n?.children??[],ie):null;if(!$)return;const je=Om(n?.children??[],U)??Sn;if(!Rc($,je,n?.children??[]))return;ee.preventDefault(),ee.dataTransfer.dropEffect="move";const xe={kind:we(ee),nodeId:U};G(ae=>bv(ae,xe)?ae:xe)}function ge(ee,U){ee.currentTarget.contains(ee.relatedTarget)||G($=>$!==null&&$.kind!=="root-end"&&$.nodeId===U?null:$)}async function le(ee,U){if(ee.stopPropagation(),ee.preventDefault(),!ie)return;const $=Bo(n?.children??[],ie);if(!$)return;const je=Om(n?.children??[],U)??Sn;if(!Rc($,je,n?.children??[]))return;if(U===$.id){te(null),G(null);return}const xe=fS(n?.children??[],je)??[],ae=xv(xe,{kind:we(ee),nodeId:U},$.id);if(yv(n?.children??[],$.id,je,ae)){te(null),G(null);return}E(!0);try{await cy($.id,{parent_id:je,order:ae}),Ce.getState().showToast(`已移动《${$.title}》`),await B(je)}catch(Re){v(xa(Oc(Re)))}finally{E(!1),te(null),G(null)}}function Ye(ee){const U=ie?Bo(n?.children??[],ie):null;!U||!Rc(U,Sn,n?.children??[])||(ee.preventDefault(),ee.dataTransfer.dropEffect="move",G($=>bv($,{kind:"root-end"})?$:{kind:"root-end"}))}function ke(ee){ee.currentTarget.contains(ee.relatedTarget)||G(U=>U?.kind==="root-end"?null:U)}async function Ae(ee){if(ee.preventDefault(),!ie)return;const U=Bo(n?.children??[],ie);if(!U||!Rc(U,Sn,n?.children??[]))return;const $=xv(n?.children??[],{kind:"end"},U.id);if(yv(n?.children??[],U.id,Sn,$)){te(null),G(null);return}E(!0);try{await cy(U.id,{parent_id:Sn,order:$}),Ce.getState().showToast(`已移动《${U.title}》`),await B()}catch(je){v(xa(Oc(je)))}finally{E(!1),te(null),G(null)}}async function ve(ee){try{const U=await Iw(ee.id),{children:$,relations:je,deltas:xe}=U.cascaded,ae=[];$>0&&ae.push(`${$} 个子节点`),je>0&&ae.push(`${je} 条关联`),xe>0&&ae.push(`${xe} 条变化记录`),Ce.getState().showToast(`已移入回收站${ae.length>0?`(含 ${ae.join("、")})`:""}`),await B()}catch(U){if(U instanceof _e&&U.code==="OUTLINE_NODE_NOT_FOUND"){v(xa("OUTLINE_NODE_NOT_FOUND")),await B();return}Ce.getState().showToast(U instanceof _e?U.message:"删除失败,请重试","error")}}function Ue(){return L?.parentId!==Sn?null:i.jsx(vv,{className:"mb-1",type:L.type,onTypeChange:ee=>w({parentId:Sn,type:ee}),value:J,onChange:oe,onKeyDown:de,onCancel:me})}function Pe(ee,U){return ee.map($=>{const je=$.type!=="scene"&&($.children?.length??0)>0,xe=x.has($.id),ae=r?.currentPosition===$.id,Re=A_[$.type],He=k?.nodeId===$.id&&k.field==="title",We=k?.nodeId===$.id&&k.field==="summary",pt=Q?.kind==="before"&&Q.nodeId===$.id,_t=Q?.kind==="after"&&Q.nodeId===$.id,mt=ie===$.id,Tt=L?.parentId===$.id,Rt=$.id===N;return i.jsxs("div",{children:[i.jsxs("div",{"data-node-id":$.id,draggable:!He&&!We&&!mt&&!j,onDragStart:zt=>Le(zt,$),onDragEnd:De,onDragOver:zt=>Be(zt,$.id),onDragLeave:zt=>ge(zt,$.id),onDrop:zt=>{le(zt,$.id)},className:Qe("relative cursor-grab rounded-md px-2 py-1 transition-colors hover:bg-muted/60 active:cursor-grabbing",$.id===_&&"bg-accent/40",Rt&&"bg-accent ring-1 ring-inset ring-ring",mt&&"opacity-50"),style:{paddingLeft:U*20+8},title:"拖动到目标行即可移动(上半=插前、下半=插后)",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[je?i.jsx("button",{type:"button",className:"w-4 shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>I($.id),"aria-label":xe?"展开":"折叠",children:xe?"▸":"▾"}):i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"flex h-5 w-7 shrink-0 items-center justify-center rounded bg-muted text-xs text-muted-foreground",children:os[$.type]}),He?Lc(H,M,q($,"title"),()=>{Y($,"title")},"标题"):i.jsx("span",{className:Qe("min-w-0 cursor-text truncate text-sm hover:underline",Rt?"text-accent-foreground":"text-foreground"),title:"点击编辑标题",onClick:()=>Z($,"title"),children:$.title}),K!==null&&(K.get($.id)?.length??0)>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:(K.get($.id)??[]).map(zt=>i.jsx(iS,{mark:zt},`${zt.relationType}-${zt.hookId}`))}),Re!==null&&i.jsx("button",{type:"button",className:"shrink-0 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:`就地新建${os[Re]}`,"aria-label":`新建${os[Re]}`,onClick:()=>P($.id,Re),children:"+"}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:"详情","aria-label":"详情",onClick:()=>Tn(`/outline/${$.id}`),children:i.jsx(Ll,{className:"size-3.5"})}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-destructive",title:"移入回收站","aria-label":"移入回收站",onClick:()=>{ve($)},children:i.jsx(Ql,{className:"size-3.5"})}),ae&&i.jsx("span",{className:"shrink-0 rounded bg-accent px-1.5 py-0.5 text-xs text-accent-foreground",children:"当前位置"}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:is($.updatedAt)})]}),We||$.summary?i.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"w-7 shrink-0"}),We?Lc(H,M,q($,"summary"),()=>{Y($,"summary")},"摘要"):i.jsx("span",{className:"min-w-0 cursor-text truncate text-xs text-muted-foreground hover:underline",title:"点击编辑摘要",onClick:()=>Z($,"summary"),children:$.summary})]}):null,pt&&i.jsx("span",{className:"pointer-events-none absolute inset-x-0 -top-px h-0.5 rounded bg-accent"}),_t&&i.jsx("span",{className:"pointer-events-none absolute inset-x-0 -bottom-px h-0.5 rounded bg-accent"})]}),je&&!xe&&i.jsx("div",{children:Pe($.children??[],U+1)}),Tt&&i.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1",style:{paddingLeft:(U+1)*20+8},children:[i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"flex h-5 w-7 shrink-0 items-center justify-center rounded bg-muted text-xs text-muted-foreground",children:os[L.type]}),Lc(J,oe,de,me,`新${os[L.type]}标题,Enter 创建`)]})]},$.id)})}function Ie(){n&&(x.size>0?S(new Set):S(new Set(z(n.children))))}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between gap-4",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"大纲"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",onClick:Ie,disabled:!n||n.children.length===0,children:x.size>0?"全部展开":"全部折叠"}),i.jsx(pe,{type:"button",onClick:()=>P(Sn,"volume"),children:"+ 新建"})]})]}),p&&i.jsx("div",{className:"mb-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:p}),D?i.jsxs("div",{className:"rounded-md border border-dashed border-zinc-300 px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"未打开项目,无法编辑大纲"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-zinc-500 underline hover:text-zinc-700",children:"回到首页打开或创建书籍"})]}):o&&n===null?i.jsx("div",{className:"space-y-2 rounded-md border border-zinc-200 p-3",children:Array.from({length:6},(ee,U)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-zinc-100",style:{width:`${92-U%3*24}%`,marginLeft:U%3*20}},U))}):n===null?i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:["大纲加载失败",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>b(!1),children:"重试"})]}):n.children.length===0?L?.parentId===Sn?i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"输入第一卷标题,Enter 创建"}),i.jsx("div",{className:"mx-auto mt-4 max-w-sm",children:i.jsx(vv,{type:L.type,onTypeChange:ee=>w({parentId:Sn,type:ee}),value:J,onChange:oe,onKeyDown:de,onCancel:me})})]}):i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"大纲还是空的,先建第一卷"}),i.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:"大纲是三层结构:卷 → 章 → 场景"}),i.jsx(pe,{className:"mt-4",type:"button",onClick:()=>P(Sn,"volume"),children:"新建第一卷"})]}):i.jsxs("div",{className:Qe("rounded-md border border-border p-2",Q?.kind==="root-end"&&"ring-1 ring-inset ring-accent"),onDragOver:Ye,onDragLeave:ke,onDrop:ee=>{Ae(ee)},children:[Ue(),Pe(n.children,0)]})]})}const jl=20;function p3(n,o){return Math.max(1,Math.ceil(n/o))}const h3={character:{key1:"role",label1:"角色",key2:"status",label2:"状态"},setting:{key1:"category",label1:"类别"},location:{key1:"type",label1:"类型"},hook:{key1:"status",label1:"状态",key2:"payoff_timing",label2:"回收时机"},event:{key1:"description",label1:"描述"},timepoint:{key1:"",label1:""}},Hp={planted:"已埋设",progressing:"推进中",resolved:"已回收",abandoned:"已弃用"},Pp={immediate:"立即",near_term:"近期",mid_arc:"中段",slow_burn:"慢热",endgame:"终局"};function em(n,o,r){return r==null||r===""?"—":n==="hook"&&o==="status"?Hp[String(r)]??String(r):n==="hook"&&o==="payoff_timing"?Pp[String(r)]??String(r):String(r)}const Sv={character:{key:"role",label:"角色定位",input:"text"},setting:{key:"category",label:"类别",input:"text"},location:{key:"type",label:"地点类型",input:"text"},hook:{key:"status",label:"状态",input:"select",options:["planted","progressing","resolved","abandoned"]},event:{key:"description",label:"描述",input:"text"},timepoint:{key:"",label:"",input:"text"}};function Yp(n){switch(n){case"character":return[{key:"role",label:"角色定位",control:"text"},{key:"gender",label:"性别",control:"text"},{key:"age",label:"年龄",control:"number"},{key:"personality",label:"性格",control:"tags"},{key:"motivation",label:"动机",control:"textarea"},{key:"abilities",label:"能力",control:"tags"},{key:"status",label:"状态",control:"text"}];case"setting":return[{key:"category",label:"类别",control:"text"},{key:"parent_id",label:"上级设定",control:"text"},{key:"description",label:"描述",control:"textarea"},{key:"rules",label:"规则",control:"tags"}];case"location":return[{key:"type",label:"地点类型",control:"text"},{key:"parent_id",label:"上级地点",control:"text"},{key:"description",label:"描述",control:"textarea"}];case"hook":return[{key:"status",label:"状态",control:"select",options:["planted","progressing","resolved","abandoned"],optionsLabels:Hp},{key:"category",label:"类别",control:"text"},{key:"expected_payoff",label:"预期回收",control:"textarea"},{key:"payoff_timing",label:"回收时机",control:"select",options:["immediate","near_term","mid_arc","slow_burn","endgame"],optionsLabels:Pp},{key:"half_life",label:"半衰期(章数)",control:"number"},{key:"is_core",label:"主线伏笔",control:"toggle"},{key:"notes",label:"备注",control:"textarea"},{key:"expected_resolve_node_id",label:"预计回收节点",control:"outline-node"}];case"event":return[{key:"description",label:"描述",control:"textarea"},{key:"tags",label:"标签",control:"tags"}];case"timepoint":return[]}}const g3={belongs_to:"所属",owns:"拥有",masters:"掌握",ally:"盟友",rival:"对手",mentor:"师徒",family:"家族",kills:"击杀",appears_in:"出现于",occurs_at:"发生于",plot_edge:"剧情连线",plants:"埋设",advances:"推进",resolves:"回收",depends_on:"依赖",involves:"涉及"};function pr(n){return g3[n]??n}function Vp(n,o){const r={};for(const l of new Set([...Object.keys(n),...Object.keys(o)])){const c=o[l];if(c===void 0)continue;const d=Ev(n[l]),m=Ev(c);JSON.stringify(d)!==JSON.stringify(m)&&(r[l]=c)}return Object.keys(r).length>0?r:null}function Ev(n){return n==null||n===""||Array.isArray(n)&&n.length===0?null:n}const tm={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},x3=Bm.filter(n=>n!=="occurs_at"),ba="w-full rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";function Fp({source:n,onCreated:o,onClose:r}){const l=ze(w=>w.outline),[c,d]=h.useState("character"),[m,g]=h.useState(null),[b,p]=h.useState(""),[v,x]=h.useState("character"),[S,j]=h.useState(null),[E,_]=h.useState(""),[O,N]=h.useState(Bm[0]),[T,k]=h.useState(null),[C,H]=h.useState(!1);h.useEffect(()=>{n||(p(""),g(null),ls(c,{limit:100}).then(w=>g(w.items)).catch(()=>g([])))},[n,c]),h.useEffect(()=>{if(_(""),v==="outline_node"){j(null);return}j(null),ls(v,{limit:100}).then(w=>j(w.items)).catch(()=>j([]))},[v]);const M=oo(l?.children??[]);async function L(w){if(w.preventDefault(),!n&&!b){k("请选择源实体");return}if(!E){k("请选择关联对象");return}H(!0),k(null);try{const J={source_type:n?n.type:c,source_id:n?n.id:b,target_type:v,target_id:E,relation_type:O};await yr(J),Ce.getState().showToast("已建立关系"),await o(),r()}catch(J){J instanceof _e&&J.code==="RELATION_EXISTS"?k("这条关系已经存在"):k(J instanceof _e?J.message:"创建失败,请重试")}finally{H(!1)}}return i.jsx(Ts,{open:!0,onOpenChange:w=>!w&&r(),children:i.jsxs(ws,{className:"sm:max-w-2xl",children:[i.jsx(Cs,{children:i.jsx(Os,{children:"新增关联"})}),i.jsxs("form",{id:"create-relation-form",onSubmit:L,className:"flex flex-col gap-3",children:[i.jsxs("div",{className:"grid grid-cols-1 items-start gap-3 sm:grid-cols-[1fr_auto_1fr]",children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"源实体"}),n?i.jsxs("div",{title:n.name,className:"min-w-0 truncate rounded-md border border-border bg-muted/40 px-3 py-1.5 text-sm text-foreground",children:[n.type==="outline_node"?"本节点":"本实体",":",n.name]}):i.jsxs(i.Fragment,{children:[i.jsx("select",{value:c,onChange:w=>d(w.target.value),className:ba,children:Ta.map(w=>i.jsx("option",{value:w,children:tm[w]},w))}),i.jsxs("select",{value:b,onChange:w=>p(w.target.value),className:ba,children:[i.jsxs("option",{value:"",children:["选择",tm[c],"…"]}),(m??[]).map(w=>i.jsx("option",{value:w.id,children:w.name},w.id))]})]})]}),i.jsxs("div",{className:"flex flex-col gap-2 sm:w-44",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"关系类型"}),i.jsx("select",{value:O,onChange:w=>N(w.target.value),className:ba,children:x3.map(w=>i.jsx("option",{value:w,children:pr(w)},w))}),i.jsx("span",{"aria-hidden":"true",className:"mt-auto select-none pb-1 text-center text-xl leading-none text-muted-foreground",children:"→"})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"目标实体"}),i.jsxs("select",{value:v,onChange:w=>x(w.target.value),className:ba,children:[i.jsx("option",{value:"character",children:"人物"}),i.jsx("option",{value:"setting",children:"设定"}),i.jsx("option",{value:"location",children:"地点"}),i.jsx("option",{value:"hook",children:"伏笔"}),i.jsx("option",{value:"outline_node",children:"大纲节点"})]}),v==="outline_node"?i.jsxs("select",{value:E,onChange:w=>_(w.target.value),className:ba,children:[i.jsx("option",{value:"",children:"选择大纲节点…"}),M.map(w=>i.jsxs("option",{value:w.id,children:[" ".repeat(w.depth),w.label]},w.id))]}):i.jsxs("select",{value:E,onChange:w=>_(w.target.value),className:ba,children:[i.jsxs("option",{value:"",children:["选择",tm[v],"…"]}),(S??[]).map(w=>i.jsx("option",{value:w.id,children:w.name},w.id))]})]})]}),T&&i.jsx("p",{className:"text-sm text-destructive",children:T})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:r,disabled:C,children:"取消"}),i.jsx(pe,{type:"submit",form:"create-relation-form",disabled:C,children:"建立"})]})]})})}const mS={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"},Nv={endpointType:"",relationType:"",nameQuery:""};function b3(n,o){const r=o.nameQuery.trim().toLowerCase();return n.filter(l=>{if(o.endpointType!==""&&l.sourceType!==o.endpointType&&l.targetType!==o.endpointType||o.relationType!==""&&l.relationType!==o.relationType)return!1;if(r){const c=(l.sourceName??l.sourceId).toLowerCase(),d=(l.targetName??l.targetId).toLowerCase();if(!c.includes(r)&&!d.includes(r))return!1}return!0})}function jv({type:n}){return i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:mS[n]??n})}function nm({type:n,id:o,name:r}){const l=r??o;if(!(Ta.includes(n)||n==="outline_node"))return i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:l,children:l}),i.jsx(jv,{type:n})]});const d=n==="outline_node"?`/outline/${o}`:`/entities/${n}/${o}`;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>Tn(d),title:`打开《${l}》`,className:"min-w-0 truncate font-medium text-foreground underline-offset-2 hover:text-primary hover:underline",children:l}),i.jsx(jv,{type:n})]})}function Tv(n,o){const r=o==="source"?n.sourceName:n.targetName,l=o==="source"?n.sourceId:n.targetId;return r??l}function pS({reloadKey:n,onOpenCreate:o,scope:r}){const[l,c]=h.useState(null),[d,m]=h.useState(!1),[g,b]=h.useState(null),[p,v]=h.useState(0),[x,S]=h.useState(Nv),[j,E]=h.useState(null);h.useEffect(()=>{let N=!1;m(!0),b(null);const T=r!==void 0?{source_type:r.type,source_id:r.id,depth:1}:{depth:1};return br(T).then(k=>{N||c(k.relations)}).catch(k=>{N||(c(null),b(k instanceof _e?k.code:ut))}).finally(()=>{N||m(!1)}),()=>{N=!0}},[n,p,r?.type,r?.id]);async function _(){if(j)try{await Wc(j.id),Ce.getState().showToast("已删除关系"),E(null),v(N=>N+1)}catch(N){throw N}}const O=l===null?[]:b3(l,x);return i.jsxs("div",{children:[r===void 0&&i.jsxs("div",{className:"mb-2 mt-3 flex flex-wrap items-center gap-3",children:[i.jsxs("select",{value:x.endpointType,onChange:N=>S(T=>({...T,endpointType:N.target.value})),"aria-label":"端点类型过滤",className:"rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("option",{value:"",children:"全部端点类型"}),Object.entries(mS).map(([N,T])=>i.jsx("option",{value:N,children:T},N))]}),i.jsxs("select",{value:x.relationType,onChange:N=>S(T=>({...T,relationType:N.target.value})),"aria-label":"关系类型过滤",className:"rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("option",{value:"",children:"全部关系类型"}),Bm.map(N=>i.jsx("option",{value:N,children:pr(N)},N))]}),i.jsx(Dt,{value:x.nameQuery,onChange:N=>S(T=>({...T,nameQuery:N.target.value})),placeholder:"搜索源/目标名称…",className:"w-52"})]}),g!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-border bg-muted px-3 py-2 text-sm text-muted-foreground",children:[g===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"关系加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>v(N=>N+1),children:"重试"})]}),d&&l===null&&g===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-border",children:Array.from({length:5},(N,T)=>i.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-3 py-3 last:border-0",children:[i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-4 w-12 animate-pulse rounded bg-muted"})]},T))}),!d&&l!==null&&l.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有关联,建立一条"}),i.jsx(pe,{className:"mt-4",type:"button",onClick:o,children:"+ 建立关联"})]}),!d&&l!==null&&l.length>0&&O.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"没有匹配的关联"}),i.jsx(pe,{variant:"outline",className:"mt-4",type:"button",onClick:()=>S(Nv),children:"清空过滤"})]}),!d&&l!==null&&O.length>0&&i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r===void 0&&i.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"w-1/4 shrink-0",children:"源"}),i.jsx("span",{className:"w-1/4 shrink-0",children:"关系"}),i.jsx("span",{className:"flex-1",children:"目标"}),i.jsx("span",{className:"w-14 shrink-0"})]}),i.jsx("ul",{className:"divide-y divide-border",children:O.map(N=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[r!==void 0?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"shrink-0 truncate rounded bg-muted px-1.5 py-0.5 text-center text-xs text-muted-foreground",children:[pr(N.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(nm,{type:N.targetType,id:N.targetId,name:N.targetName})})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"w-1/4 min-w-0 shrink-0",children:i.jsx(nm,{type:N.sourceType,id:N.sourceId,name:N.sourceName})}),i.jsxs("span",{className:"w-1/4 shrink-0 truncate rounded bg-muted px-1.5 py-0.5 text-center text-xs text-muted-foreground",children:[pr(N.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(nm,{type:N.targetType,id:N.targetId,name:N.targetName})})]}),i.jsx(pe,{variant:"outline",type:"button",className:"h-7 w-14 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>E(N),children:"删除"})]},N.id))})]}),j&&i.jsx(Oa,{title:"删除关系",description:`删除关系「${Tv(j,"source")} ${pr(j.relationType)} ${Tv(j,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:_,onClose:()=>E(null)})]})}const y3={set:"设为",update:"更新",add:"追加",remove:"移除"},v3={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"};function Gp(n){return v3[n]??n}function rs(n){return n==null?"空":typeof n=="object"?JSON.stringify(n):String(n)}function S3(n){switch(n.op){case"set":return`${n.field} = ${rs(n.to)}`;case"update":return`${n.field} ${rs(n.from)} → ${rs(n.to)}`;case"add":return`${n.field} +${rs(n.value??n.to)}`;case"remove":return`${n.field} -${rs(n.value??n.to)}`}}function E3(n,o){const r=[];for(const l of new Set([...Object.keys(n),...Object.keys(o)])){const c=n[l]??null,d=o[l]??null;JSON.stringify(c)!==JSON.stringify(d)&&r.push({field:l,from:n[l],to:o[l]})}return r}function hS({changes:n,skipped:o}){const r=o?new Set(o):null;return i.jsx("div",{className:"flex flex-wrap items-center gap-1",children:n.map((l,c)=>{const d=r?.has(c)??!1;return i.jsxs("span",{title:d?"该变更未应用(数据与变更记录不一致,见冲突标注)":void 0,className:Qe("inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs",d?"text-destructive":"text-muted-foreground"),children:[i.jsx("span",{className:Qe("shrink-0 font-medium",d?"text-destructive":"text-foreground/70"),children:y3[l.op]}),S3(l)]},c)})})}function N3({nodeId:n,reloadKey:o}){const[r,l]=h.useState(null),[c,d]=h.useState(!1),[m,g]=h.useState(null),[b,p]=h.useState(0);return h.useEffect(()=>{let v=!1;return d(!0),g(null),Gw(n).then(x=>{v||l([...x.deltas].sort((S,j)=>S.order-j.order))}).catch(x=>{v||g(x instanceof _e?x.code:ut)}).finally(()=>{v||d(!1)}),()=>{v=!0}},[n,b,o]),i.jsxs("div",{children:[c&&r===null&&m===null&&i.jsxs("div",{className:"space-y-2 py-1",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-muted"})]}),m!==null&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:m==="OUTLINE_NODE_NOT_FOUND"?"节点不存在(可能已被删除),变更记录不可用":m===ut?"无法连接服务,请确认 ai-editor 服务已启动":"变更记录加载失败"}),m!=="OUTLINE_NODE_NOT_FOUND"&&i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>p(v=>v+1),children:"重试"})]}),!c&&m===null&&r!==null&&r.length===0&&i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"该节点没有变更记录"}),!c&&m===null&&r!==null&&r.length>0&&i.jsx("ul",{className:"divide-y divide-border/70",children:r.map(v=>i.jsxs("li",{className:"py-2 first:pt-0 last:pb-0",children:[i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:v.description,children:v.description}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:is(v.createdAt)})]}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[i.jsxs("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[Gp(v.targetType),"《",v.targetName??v.targetId,"》"]}),i.jsx(hS,{changes:v.changes})]})]},v.id))})]})}const j3=Ta.filter(n=>n!=="event"&&n!=="timepoint").map(n=>({value:n,label:Gp(n)})),T3={character:["role","gender","age","personality","motivation","abilities","status","custom_fields"],setting:["category","parent_id","description","rules","custom_fields"],location:["type","parent_id","description","custom_fields"],hook:["status","category","expected_payoff","payoff_timing","half_life","is_core","notes","expected_resolve_node_id"]},w3={character:kc("character"),setting:kc("setting"),location:kc("location"),hook:kc("hook")};function kc(n){return Object.fromEntries(Yp(n).map(o=>[o.key,o.label]))}const C3={character:["personality","abilities"],setting:["rules"]},R3={character:["age"],hook:["half_life"]};function km(n,o){return(C3[n]??[]).includes(o)}function O3(n,o){return(R3[n]??[]).includes(o)}function k3(n){return(T3[n]??[]).filter(r=>r!=="custom_fields").map(r=>({key:r,label:w3[n]?.[r]??r,array:km(n,r)}))}function gS(n){if(n!==void 0){if(n===null)return null;if(typeof n=="string"||typeof n=="number")return n}}function wv(n){return n.array?{options:["add","remove"],default:"add"}:gS(n.currentValue)!==void 0?{options:["update","set"],default:"update"}:{options:["set"],default:"set"}}function _3(n){const o=n.rawValue.trim();if(o==="")return{error:"请填写值"};const r=Number(o),l=n.numeric&&!Number.isNaN(r)?r:o;switch(n.op){case"add":return{change:{field:n.field,op:"add",value:l}};case"remove":return{change:{field:n.field,op:"remove",value:l}};case"set":return{change:{field:n.field,op:"set",to:l}};case"update":{const c=gS(n.currentValue);return c===void 0?{error:"无法确定旧值(当前数据无此字段或类型不可表达),请改用「设为」"}:{change:{field:n.field,op:"update",from:c,to:l}}}}}const ya="w-full rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",M3={set:"设为",update:"更新",add:"追加",remove:"移除"};function A3({nodeId:n,onCreated:o,onClose:r}){const[l,c]=h.useState(""),[d,m]=h.useState(""),[g,b]=h.useState(""),[p,v]=h.useState("add"),[x,S]=h.useState(""),[j,E]=h.useState(""),[_,O]=h.useState(!1),[N,T]=h.useState(null),[k,C]=h.useState(null),[H,M]=h.useState(null),[L,w]=h.useState(0),[J,oe]=h.useState(null),[ie,te]=h.useState(null);h.useEffect(()=>{if(m(""),oe(null),te(null),l===""){C(null),M(null);return}let I=!1;return C(null),M(null),ls(l).then(V=>{I||C(V.items)}).catch(V=>{I||(C(null),M(V instanceof _e?V.code:ut))}),()=>{I=!0}},[l,L]),h.useEffect(()=>{if(l===""||d==="")return;let I=!1;return oe(null),te(null),fr(l,d).then(V=>{I||oe(V.data)}).catch(V=>{I||(oe(null),te(V instanceof _e?V.code:ut))}),()=>{I=!0}},[l,d]),h.useEffect(()=>{b(""),S(""),T(null)},[l,d]);const Q=k3(l),G=J?.[g],K=wv({array:km(l,g),currentValue:G});function A(I){b(I),v(wv({array:km(l,I),currentValue:J?.[I]}).default)}async function D(){if(_)return;if(l===""||d===""){T("请选择变更目标");return}if(g===""){T("请选择变更字段");return}const I=j.trim();if(I===""){T("请填写描述(本节点触发了什么变化)");return}const V=_3({field:g,op:p,rawValue:x,numeric:O3(l,g),currentValue:G});if("error"in V){T(V.error);return}O(!0),T(null);try{await Qm({node_id:n,target_type:l,target_id:d,changes:[V.change],description:I}),Ce.getState().showToast("已记录变更"),o()}catch(z){if(z instanceof _e&&z.code==="OUTLINE_NODE_NOT_FOUND"){Ce.getState().showToast("节点不存在(可能已被删除),无法记录变更","error"),r();return}T(z instanceof _e?z.message:"提交失败,请重试")}finally{O(!1)}}const B=l;return i.jsxs("div",{className:"mb-3 space-y-3 rounded-md border border-border bg-muted/40 p-3",children:[i.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"目标类型"}),i.jsxs("select",{value:l,onChange:I=>c(I.target.value),className:Qe(ya,l===""&&"text-muted-foreground"),"aria-label":"目标类型",children:[i.jsx("option",{value:"",children:"请选择目标类型"}),j3.map(I=>i.jsx("option",{value:I.value,children:I.label},I.value))]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"目标"}),l===""?i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"请先选择目标类型"}):H!==null?i.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:H===ut?"无法连接服务,请确认 ai-editor 服务已启动":"实体列表加载失败"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>w(I=>I+1),children:"重试"})]}):k===null?i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"加载中…"}):k.length===0?i.jsxs("p",{className:"py-1 text-xs text-muted-foreground",children:["暂无",Cv(B)]}):i.jsxs("select",{value:d,onChange:I=>m(I.target.value),className:Qe(ya,d===""&&"text-muted-foreground"),"aria-label":"目标实体",children:[i.jsxs("option",{value:"",children:["请选择",Cv(B)]}),k.map(I=>i.jsx("option",{value:I.id,children:I.name},I.id))]})]})]}),i.jsxs("div",{className:"grid gap-3 sm:grid-cols-[1fr_auto_1fr]",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"字段"}),i.jsxs("select",{value:g,onChange:I=>A(I.target.value),className:Qe(ya,g===""&&"text-muted-foreground"),"aria-label":"变更字段",children:[i.jsx("option",{value:"",children:"请选择字段"}),Q.map(I=>i.jsx("option",{value:I.key,children:I.label},I.key))]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"操作"}),i.jsx("select",{value:p,onChange:I=>v(I.target.value),className:Qe(ya,"min-w-20"),"aria-label":"操作",children:K.options.map(I=>i.jsx("option",{value:I,children:M3[I]},I))})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:p==="set"||p==="update"?"新值":p==="add"?"追加值":"移除值"}),i.jsx("input",{value:x,onChange:I=>S(I.target.value),placeholder:p==="remove"?"按值匹配删除":"",className:ya})]})]}),p==="update"&&i.jsx("p",{className:"text-xs text-muted-foreground",children:ie!==null?i.jsxs(i.Fragment,{children:["目标数据获取失败,无法自动取旧值(",ie==="ENTITY_NOT_FOUND"?"目标已不存在":"请稍后重试",")——可将操作改为「设为」"]}):i.jsxs(i.Fragment,{children:["旧值:",rs(G),"(自动取自目标当前数据,无需手填)"]})}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:j,onChange:I=>E(I.target.value),rows:2,maxLength:500,placeholder:"本节点触发了什么变化,如:张三获得断剑认可",className:Qe(ya,"resize-none")})]}),N!==null&&i.jsx("p",{className:"text-sm text-destructive",children:N}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx(pe,{variant:"outline",size:"sm",type:"button",onClick:r,disabled:_,children:"取消"}),i.jsx(pe,{size:"sm",type:"button",onClick:()=>{D()},disabled:_,children:_?"提交中…":"创建变更"})]})]})}function Cv(n){return Gp(n)}function qp({items:n,className:o}){return i.jsx("nav",{"aria-label":"面包屑",className:Qe("inline-flex items-center gap-1",o),children:n.map((r,l)=>{const c=l===n.length-1;return i.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.href?i.jsx("button",{type:"button",onClick:()=>Tn(r.href),className:"rounded-md border border-border px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:r.label}):i.jsx("span",{"aria-current":"page",className:"max-w-40 truncate rounded-md bg-foreground px-2.5 py-1 text-sm font-medium text-background",children:r.label}),!c&&i.jsx("span",{className:"select-none text-sm text-muted-foreground/40",children:"›"})]},l)})})}const D3={inner:"内心冲突",personal:"人际冲突",extra_personal:"社会冲突"};function z3(n){switch(n){case"scene":return[{key:"goal",label:"场景目标",control:"textarea",maxLength:1e3},{key:"conflict_levels",label:"冲突层次",control:"checkbox-group",options:$v,optionsLabels:D3},{key:"value_from",label:"开场价值",control:"text",maxLength:200},{key:"value_to",label:"收场价值",control:"text",maxLength:200}];case"chapter":return[{key:"reversal",label:"章末反转",control:"textarea",maxLength:1e3},{key:"climax_scene",label:"章高潮场景",control:"scene-select"}];case"volume":return[{key:"climax_scene",label:"幕高潮场景",control:"scene-select"},{key:"inciting_scene",label:"激励事件",control:"scene-select"}]}}function L3(n,o){return $v.includes(o)?n.includes(o)?n.filter(r=>r!==o):[...n,o]:n}function I3(n){const o=[],r=(l,c)=>{for(const d of l)d.type==="scene"?o.push({id:d.id,label:d.title,depth:c}):d.children&&r(d.children,c+1)};return r(n,0),o}function B3(n){return typeof n=="string"&&n!==""?n:""}const _m="w-full rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";function Tl({title:n,children:o,className:r,action:l}){return i.jsxs("div",{className:Qe("rounded-xl border border-border bg-card p-4",r),children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[i.jsx("h2",{className:"font-serif text-base",children:n}),l]}),o]})}function U3({nodeId:n}){const o=ze(F=>F.outline),r=ze(F=>F.outlineLoading),l=ze(F=>F.config),c=ze(F=>F.configLoading),d=ze(F=>F.loadOutline),m=ze(F=>F.updateConfig),[g,b]=h.useState(!1),[p,v]=h.useState(""),[x,S]=h.useState(""),[j,E]=h.useState(null),[_,O]=h.useState(!1),[N,T]=h.useState(null),[k,C]=h.useState(!1),[H,M]=h.useState(!1),[L,w]=h.useState(0),[J,oe]=h.useState(!1),[ie,te]=h.useState(0);h.useEffect(()=>{o===null&&!r&&!g&&(b(!0),d())},[o,r,g,d]),Ms(()=>{d(),w(F=>F+1),te(F=>F+1)});const Q=o===null?null:Bo(o.children,n),G=o!==null&&Q===null,K=Q?z3(Q.type):[],A=I3(o?.children??[]),D=l?.currentPosition===n;h.useEffect(()=>{Q!==null&&(v(Q.title),S(Q.summary??""),E(JSON.parse(JSON.stringify(Q.data??{}))))},[Q]);async function B(){if(Q===null||_)return;const F=p.trim();if(F===""){T("标题不能为空");return}const Y={};uS(Q.title,p)&&(Y.title=F),dS(Q.summary,x)&&(Y.summary=x.trim());const q=Vp(Q.data??{},j??{});if(q!==null&&(Y.data=q),Object.keys(Y).length===0){Ce.getState().showToast("没有变更");return}O(!0),T(null);try{await x0(Q.id,Y),Ce.getState().showToast("已保存"),await d()}catch(P){if(P instanceof _e&&P.code==="OUTLINE_NODE_NOT_FOUND"){await d();return}T(P instanceof _e?P.message:"保存失败,请重试")}finally{O(!1)}}function I(F,Y){E(q=>q&&{...q,[F]:Y})}async function V(){if(!(Q===null||k||D)){C(!0);try{await m({current_position:Q.id}),Ce.getState().showToast("已设为当前位置")}catch{Ce.getState().showToast("设置失败:该节点可能已删除,无法设为当前位置","error")}finally{C(!1)}}}if(G)return i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"该节点不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-border px-4 py-1.5 text-sm text-muted-foreground hover:bg-muted",children:"去回收站"}),i.jsx(pe,{variant:"outline",type:"button",onClick:()=>Tn("/outline"),children:"返回大纲"})]})]})});const z=l===null&&!c,Z=[{label:"大纲",href:"/outline"}];if(Q!==null){const F=Up(o?.children??[],n)??[];for(const Y of F.slice(0,-1)){const q=Bo(o?.children??[],Y);q&&Z.push({label:q.title,href:`/outline/${Y}`})}Z.push({label:Q.title})}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(qp,{items:Z}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:Q?.title??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",disabled:Q===null||D||k,title:D?"当前节点已是创作进度位置":"标记为创作进度位置(InfoBar 展示 + 定位跳转基准)",onClick:()=>{V()},children:D?"当前位置":"设为当前位置"}),i.jsx(pe,{type:"button",onClick:()=>{B()},disabled:Q===null||_,children:_?"保存中…":"保存"})]})]}),Q&&i.jsxs("div",{className:"mb-4 flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs",children:os[Q.type]}),i.jsxs("span",{children:["更新于 ",is(Q.updatedAt)]}),D&&i.jsx("span",{className:"shrink-0 rounded bg-accent px-1.5 py-0.5 text-xs text-accent-foreground",children:"当前位置"})]}),z?i.jsxs("div",{className:"rounded-md border border-dashed border-border px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"未打开项目,无法编辑大纲"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-muted-foreground underline hover:text-foreground",children:"回到首页打开或创建书籍"})]}):r&&o===null?i.jsx("div",{className:"space-y-2 rounded-md border border-border p-3",children:Array.from({length:6},(F,Y)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-muted",style:{width:`${92-Y%3*24}%`,marginLeft:Y%3*20}},Y))}):o===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>b(!1),children:"重试"})]}):Q===null||j===null?null:i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[i.jsx(Tl,{title:"基础信息",children:i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标题"}),i.jsx(Dt,{value:p,onChange:F=>v(F.target.value),maxLength:200,placeholder:`${os[Q.type]}标题`,className:"h-8 text-sm"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"摘要"}),i.jsx("textarea",{value:x,onChange:F=>S(F.target.value),maxLength:200,rows:3,placeholder:"一句话概括本节点内容(可选)",className:_m})]})]})}),i.jsxs(Tl,{title:`结构化信息(${os[Q.type]})`,children:[i.jsx("div",{className:"flex flex-col gap-3",children:K.map(F=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:F.label}),i.jsx(H3,{field:F,value:j?.[F.key],sceneOptions:A,onChange:Y=>I(F.key,Y)})]},F.key))}),N&&i.jsx("p",{className:"mt-3 text-sm text-destructive",children:N})]}),i.jsxs(Tl,{title:"变更记录",action:i.jsx(pe,{variant:"outline",size:"sm",type:"button",onClick:()=>oe(F=>!F),children:J?"收起":"+ 新建变更"}),children:[J&&i.jsx(A3,{nodeId:n,onCreated:()=>{oe(!1),te(F=>F+1)},onClose:()=>oe(!1)}),i.jsx(N3,{nodeId:n,reloadKey:ie})]}),i.jsx(Tl,{title:"伏笔标记",className:"border-dashed",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:"伏笔标记将在伏笔面板(S9)落地"})})]}),i.jsx("div",{className:"flex min-w-0 flex-col gap-4",children:i.jsxs(Tl,{title:"相关实体",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"本节点作为源的关系(1 跳)"}),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>M(!0),children:"+ 新增关联"})]}),i.jsx(pS,{scope:{type:"outline_node",id:n},reloadKey:L,onOpenCreate:()=>M(!0)})]})})]}),H&&Q!==null&&i.jsx(Fp,{source:{type:"outline_node",id:Q.id,name:Q.title},onCreated:()=>w(F=>F+1),onClose:()=>M(!1)})]})}function H3({field:n,value:o,sceneOptions:r,onChange:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:typeof o=="string"?o:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,rows:3,className:_m});case"checkbox-group":{const c=Array.isArray(o)?o:[];return i.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:(n.options??[]).map(d=>i.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-sm text-foreground",children:[i.jsx("input",{type:"checkbox",checked:c.includes(d),onChange:()=>l(L3(c,d)),className:"size-4 accent-primary"}),n.optionsLabels?.[d]??d]},d))})}case"scene-select":{const c=B3(o),d=c!==""&&!r.some(m=>m.id===c);return i.jsxs("select",{value:c,onChange:m=>l(m.target.value),className:Qe(_m,c===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"(未设置)"}),d&&i.jsxs("option",{value:c,children:[c,"(已删除)"]}),r.map(m=>i.jsxs("option",{value:m.id,children:[" ".repeat(m.depth),m.label]},m.id))]})}default:return i.jsx(Dt,{value:typeof o=="string"?o:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,className:"h-8 text-sm"})}}const hr={volume:248,chapter:208,scene:168},ks={volume:96,chapter:88,scene:76},Lo={padX:48,padY:48,colGap:304,rowGap:28,indentChapter:28,indentScene:56},xS=.5,bS=2,P3="ai-editor:canvas:";function Mm(n){return Math.min(bS,Math.max(xS,n))}function Y3(n){if(!n)return[];const o=[],r=(l,c,d)=>{for(const m of l)o.push({id:m.id,type:m.type,title:m.title,summary:m.summary,parentId:c,depth:d}),m.type!=="scene"&&m.children&&r(m.children,m.id,d+1)};return r(n.children,null,0),o}function Rv(n){const o={};let r=0;for(const l of n){if(l.depth!==0)continue;const c=Lo.padX+r*Lo.colGap;let d=Lo.padY;o[l.id]={x:c,y:d},d+=ks[l.type]+Lo.rowGap;for(const m of n)if(m.parentId===l.id){o[m.id]={x:c+Lo.indentChapter,y:d},d+=ks[m.type]+Lo.rowGap;for(const g of n)g.parentId===m.id&&(o[g.id]={x:c+Lo.indentScene,y:d},d+=ks.scene+Lo.rowGap)}r+=1}return o}function yS(n){return`${P3}${n}`}function V3(n){if(typeof n!="object"||n===null)return null;const o=n.nodes;if(typeof o!="object"||o===null||Array.isArray(o))return null;const r={};for(const[d,m]of Object.entries(o)){if(typeof m!="object"||m===null)return null;const g=m;if(typeof g.x!="number"||typeof g.y!="number"||!Number.isFinite(g.x)||!Number.isFinite(g.y))return null;r[d]={x:g.x,y:g.y}}const l=n.zoom,c=typeof l=="number"&&Number.isFinite(l)?Mm(l):1;return{nodes:r,zoom:c}}function F3(n){try{const o=localStorage.getItem(yS(n));return o===null?null:V3(JSON.parse(o))}catch{return null}}function sm(n,o){try{localStorage.setItem(yS(n),JSON.stringify(o))}catch{}}function Ov(n,o,r){const l={};for(const c of r)l[c.id]=n?.[c.id]??o[c.id];return l}function G3(n){const o=[];for(const r of n){if(r.relationType!==sj||r.sourceType!=="outline_node"||r.targetType!=="outline_node")continue;const l=r.metadata?.label,c=typeof l=="string"&&l.trim()!==""?l.trim():void 0;o.push({id:r.id,sourceId:r.sourceId,targetId:r.targetId,label:c})}return o.sort((r,l)=>r.id<l.id?-1:r.id>l.id?1:0),o}function q3(n){return n.filter(o=>o.type==="scene")}function $3(n,o){return n.filter(r=>o.has(r.sourceId)&&o.has(r.targetId))}function kv(n,o){const r=Math.max(32,Math.abs(o.x-n.x)*.5),l=n.x+r,c=o.x-r;return`M ${n.x} ${n.y} C ${l} ${n.y}, ${c} ${o.y}, ${o.x} ${o.y}`}function X3(n,o){const r=Math.max(32,Math.abs(o.x-n.x)*.5),l={x:n.x+r,y:n.y},c={x:o.x-r,y:o.y};return{x:(n.x+3*l.x+3*c.x+o.x)/8,y:(n.y+3*l.y+3*c.y+o.y)/8}}function om(n,o){return{x:n.x+hr[o]/2,y:n.y+ks[o]/2}}function _v(n,o,r,l){const c=o.x-n.x,d=o.y-n.y;if(c===0&&d===0)return n;const m=c===0?Number.POSITIVE_INFINITY:r/2/Math.abs(c),g=d===0?Number.POSITIVE_INFINITY:l/2/Math.abs(d),b=Math.min(m,g);return{x:n.x+b*c,y:n.y+b*d}}const js={highlight:"#a855f7",scene:"#f59e0b",chapter:"#3b82f6",volume:"#06b6d4",default:"#94a3b8"};function K3(n,o={}){if(o.onPath||o.selected)return js.highlight;switch(n){case"scene":return js.scene;case"chapter":return js.chapter;case"volume":return js.volume;default:return js.default}}function Q3(n={}){return n.onPath||n.selected?2.5:1.5}function Z3(n={}){return n.offPath?.2:1}const vS="canvas-edge-arrow";function J3(){return`url(#${vS})`}const Qc={w:180,h:120},_c=4,W3=1,eM=.02;function tM(n,o,r,l){let c=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY,b=0;for(const C of n){const H=o[C.id];H&&(c=Math.min(c,H.x),d=Math.min(d,H.y),m=Math.max(m,H.x+hr[C.type]),g=Math.max(g,H.y+ks[C.type]),b+=1)}if(b===0)return{nodeRects:[],viewportRect:null};const p=m-c,v=g-d,x=Qc.w-2*_c,S=Qc.h-2*_c,j=Math.min(x/p,S/v),E=Math.min(W3,Math.max(eM,j)),_=_c+(x-p*E)/2,O=_c+(S-v*E)/2,N=[];for(const C of n){const H=o[C.id];H&&N.push({id:C.id,x:_+(H.x-c)*E,y:O+(H.y-d)*E,w:hr[C.type]*E,h:ks[C.type]*E,type:C.type})}let T=null;const k=r>0?r:1;if(l!==null&&l.width>0&&l.height>0){const C={x:l.x/k,y:l.y/k,width:l.width/k,height:l.height/k};T={x:_+(C.x-c)*E,y:O+(C.y-d)*E,w:C.width*E,h:C.height*E}}return{nodeRects:N,viewportRect:T}}function nM(n,o){const r=new Set([n]),l=new Set,c=[n];for(;c.length>0;){const d=c.pop();for(const m of o)m.sourceId!==d||l.has(m.id)||(l.add(m.id),r.has(m.targetId)||(r.add(m.targetId),c.push(m.targetId)))}return{nodeIds:r,edgeIds:l}}function Mv(n){switch(n){case"RELATION_EXISTS":return"这条连线已经存在";case"VALIDATION_ERROR":return"连线参数有误";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return null}}function sM(){const n=ze(ne=>ne.outline),o=ze(ne=>ne.outlineLoading),r=ze(ne=>ne.config),l=ze(ne=>ne.configLoading),c=ze(ne=>ne.loadOutline),[d,m]=h.useState({}),[g,b]=h.useState(1),[p,v]=h.useState(!1),[x,S]=h.useState(!0),[j,E]=h.useState(!1),[_,O]=h.useState(null),[N,T]=h.useState(null),[k,C]=h.useState(null),[H,M]=h.useState(null),[L,w]=h.useState(null),[J,oe]=h.useState(null),[ie,te]=h.useState(null),[Q,G]=h.useState(null),[K,A]=h.useState(null),[D,B]=h.useState(null),[I,V]=h.useState(!1),z=h.useRef(null),Z=h.useRef(null),F=h.useRef(null),Y=h.useRef(d);Y.current=d;const q=h.useRef(0),P=r?.id??null,me=r===null&&!l,re=h.useCallback(async()=>{if(P===null)return;const be=++q.current;try{const Oe=await br({source_type:"outline_node",relation_type:"plot_edge",depth:1});if(be!==q.current)return;O(G3(Oe.relations)),T(null)}catch(Oe){if(be!==q.current)return;T(Oe instanceof _e?Oe.code:ut)}},[P]);Ms(()=>{c(),re()});const de=h.useMemo(()=>Y3(n),[n]),Le=h.useMemo(()=>new Map(de.map(ne=>[ne.id,ne])),[de]),[De,we]=h.useState(null);h.useEffect(()=>{if(P===null){we(null),m({}),b(1);return}const ne=F3(P);we(P),b(ne?.zoom??1),m(ne?.nodes??{})},[P]);const Be=De===P;h.useEffect(()=>{de.length===0||!Be||m(ne=>Ov(ne,Rv(de),de))},[de,Be]),h.useEffect(()=>{if(!(P===null||!Be))return F.current!==null&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{sm(P,{nodes:d,zoom:g})},300),()=>{F.current!==null&&(window.clearTimeout(F.current),F.current=null,Y.current===d&&P!==null&&Be&&sm(P,{nodes:d,zoom:g}))}},[d,P,g,Be]),h.useEffect(()=>{P===null||!Be||sm(P,{nodes:d,zoom:g})},[g,P,Be]),h.useEffect(()=>{n===null&&!o&&!j&&(E(!0),c())},[n,o,j,c]),h.useEffect(()=>{if(P===null){O(null),T(null);return}re()},[P,re]),h.useEffect(()=>{if(n===null){C(null);return}let ne=!1;return Promise.all(Bp.map(be=>br({source_type:"outline_node",relation_type:be,depth:1}).then(Oe=>Oe.relations).catch(()=>[]))).then(be=>{ne||C(cS(be.flat()))}),()=>{ne=!0}},[n]);const ge=h.useRef(null),le=h.useRef(null),Ye=h.useCallback(()=>{const ne=z.current,be=Z.current;if(ne===null||be===null)return;const Oe=ne.getBoundingClientRect(),Ze=be.getBoundingClientRect(),nt={x:Math.round(Oe.left-Ze.left),y:Math.round(Oe.top-Ze.top),width:Math.round(Oe.width),height:Math.round(Oe.height)};oe(at=>at!==null&&at.x===nt.x&&at.y===nt.y&&at.width===nt.width&&at.height===nt.height?at:nt)},[]),ke=h.useCallback(ne=>{if(z.current=ne,ge.current?.(),ge.current=null,le.current?.(),le.current=null,ne===null)return;const be=Ze=>{Ze.preventDefault(),b(nt=>Mm(Math.round((nt+(Ze.deltaY<0?.1:-.1))*10)/10))};ne.addEventListener("wheel",be,{passive:!1}),ge.current=()=>ne.removeEventListener("wheel",be),Ye();const Oe=new ResizeObserver(()=>Ye());Oe.observe(ne),le.current=()=>Oe.disconnect()},[Ye]);h.useEffect(()=>()=>{ge.current?.(),ge.current=null,le.current?.(),le.current=null},[]),h.useEffect(()=>{if(Q===null)return;const ne=be=>{be.key==="Escape"&&G(null)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[Q]);const Ae=p?q3(de):de,ve=h.useMemo(()=>new Set(Ae.map(ne=>ne.id)),[Ae]),Ue=h.useMemo(()=>$3(_??[],ve),[_,ve]);h.useEffect(()=>{L!==null&&!ve.has(L)&&w(null)},[L,ve]);const Pe=h.useMemo(()=>{const ne=[];for(const be of Ue){const Oe=d[be.sourceId],Ze=d[be.targetId],nt=Le.get(be.sourceId),at=Le.get(be.targetId);if(!Oe||!Ze||!nt||!at)continue;const ot=om(Oe,nt.type),qt=om(Ze,at.type),$n=_v(ot,qt,hr[nt.type],ks[nt.type]),Zt=_v(qt,ot,hr[at.type],ks[at.type]);ne.push({edge:be,d:kv($n,Zt),mid:X3($n,Zt),targetType:at.type})}return ne},[Ue,d,Le]),Ie=h.useMemo(()=>L!==null&&Q===null?nM(L,Ue):null,[L,Q,Ue]),ee=h.useMemo(()=>Pe.map(ne=>{const be=ne.edge.id===H,Oe=Ie?.edgeIds.has(ne.edge.id)??!1;return{...ne,stroke:K3(ne.targetType,{onPath:Oe,selected:be}),strokeWidth:Q3({onPath:Oe,selected:be}),opacity:Z3({offPath:Ie!==null&&!Oe}),dash:Oe||be}}),[Pe,Ie,H]),U=h.useMemo(()=>tM(Ae,d,g,J),[Ae,d,g,J]),$=h.useMemo(()=>{let ne=0,be=0;for(const Oe of de){const Ze=d[Oe.id];Ze&&(ne=Math.max(ne,Ze.x+hr[Oe.type]),be=Math.max(be,Ze.y+ks[Oe.type]))}return{w:ne+96,h:be+96}},[de,d]),je=h.useMemo(()=>Pe.find(ne=>ne.edge.id===H)??null,[Pe,H]),xe=h.useMemo(()=>{if(Q===null||K===null)return null;const ne=Le.get(Q),be=d[Q];return!ne||!be?null:kv(om(be,ne.type),K)},[Q,K,d,Le]);function ae(ne,be){const Oe=Z.current?.getBoundingClientRect();return Oe?{x:(ne-Oe.left)/g,y:(be-Oe.top)/g}:{x:0,y:0}}function Re(ne,be){if(ne.target.closest("[data-canvas-handle]")||ne.button!==0)return;ne.preventDefault();const Oe=d[be.id];Oe&&(ne.currentTarget.setPointerCapture(ne.pointerId),te({nodeId:be.id,startClientX:ne.clientX,startClientY:ne.clientY,origX:Oe.x,origY:Oe.y}))}function He(ne,be){if(ie===null||ie.nodeId!==be)return;const Oe=(ne.clientX-ie.startClientX)/g,Ze=(ne.clientY-ie.startClientY)/g;m(nt=>nt[be]?{...nt,[be]:{x:ie.origX+Oe,y:ie.origY+Ze}}:nt)}function We(){te(null)}function pt(ne,be){ne.stopPropagation(),ne.preventDefault(),ne.button===0&&(ne.currentTarget.setPointerCapture(ne.pointerId),M(null),G(be.id),A(ae(ne.clientX,ne.clientY)))}function _t(ne){Q!==null&&A(ae(ne.clientX,ne.clientY))}async function mt(ne){if(Q===null)return;const be=Q,nt=document.elementFromPoint(ne.clientX,ne.clientY)?.closest("[data-canvas-node-id]")?.getAttribute("data-canvas-node-id")??null;if(G(null),A(null),!(nt===null||nt===be))try{await yr({source_type:"outline_node",source_id:be,target_type:"outline_node",target_id:nt,relation_type:"plot_edge"}),Ce.getState().showToast("已建立连线"),await re()}catch(at){const ot=at instanceof _e?at.code:null,qt=Mv(ot);if(qt!==null){Ce.getState().showToast(qt,"error"),await re();return}Ce.getState().showToast(at instanceof _e?at.message:"创建失败,请重试","error")}}const Tt=h.useRef(!1);function Rt(ne){Tt.current=!1,B({edgeId:ne.id,draft:ne.label??""})}async function zt(ne,be){if(!I){V(!0),B(null);try{const Oe=be.trim();await Fw(ne,Oe===""?{}:{label:Oe}),Ce.getState().showToast("已保存标签"),await re()}catch(Oe){Ce.getState().showToast(Oe instanceof _e?Oe.message:"保存失败,请重试","error")}finally{V(!1)}}}function Te(ne){ne.key==="Enter"?(ne.preventDefault(),Tt.current=!0,D!==null&&zt(D.edgeId,D.draft)):ne.key==="Escape"&&(ne.preventDefault(),Tt.current=!0,B(null))}function Se(){Tt.current||D!==null&&zt(D.edgeId,D.draft)}async function Fe(){if(je===null)return;const ne=je.edge;if(await Ce.getState().confirm({title:"删除连线",description:`删除连线「${ne.label??"未命名"}」?物理删除不可恢复,可随时重建。`,danger:!0}))try{Tt.current=!0,B(null),await Wc(ne.id),Ce.getState().showToast("已删除连线"),M(null),await re()}catch(Oe){const Ze=Oe instanceof _e?Oe.code:null,nt=Mv(Ze);Ce.getState().showToast(nt??(Oe instanceof _e?Oe.message:"删除失败,请重试"),"error"),Ze==="RELATION_NOT_FOUND"&&(M(null),await re())}}function Ot(){m(ne=>Ov(ne,Rv(de),de))}function Pt(ne){b(be=>Mm(Math.round((be+ne)*10)/10))}return i.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx("h1",{className:"mr-auto font-serif text-xl font-medium",children:"画布"}),i.jsx(pe,{variant:"outline",type:"button",onClick:Ot,disabled:de.length===0,children:"重新布局"}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(pe,{variant:"outline",size:"icon-sm",type:"button","aria-label":"缩小",disabled:g<=xS,onClick:()=>Pt(-.1),children:i.jsx(Fj,{})}),i.jsxs("span",{className:"w-12 text-center text-sm tabular-nums text-muted-foreground",children:[Math.round(g*100),"%"]}),i.jsx(pe,{variant:"outline",size:"icon-sm",type:"button","aria-label":"放大",disabled:g>=bS,onClick:()=>Pt(.1),children:i.jsx(Zc,{})})]}),i.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-secondary/30 p-1",role:"group","aria-label":"显示模式",children:[!1,!0].map(ne=>i.jsx("button",{type:"button",onClick:()=>v(ne),"aria-pressed":p===ne,className:Qe("rounded-md border border-border px-2.5 py-1 text-xs transition-colors",p===ne?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:ne?"仅场景":"全部节点"},String(ne)))}),i.jsxs(pe,{variant:"outline",size:"sm",type:"button",onClick:()=>S(ne=>!ne),"aria-expanded":x,children:[i.jsx(Qv,{}),"画布说明"]})]}),x&&i.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["连线与坐标仅用于推演展示,不参与状态计算",i.jsx("button",{type:"button",className:"rounded p-0.5 hover:bg-muted hover:text-foreground","aria-label":"收起说明",onClick:()=>S(!1),children:i.jsx(fs,{className:"size-3"})})]}),N!==null&&i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[N===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"连线加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{re()},children:"重试"})]}),me?i.jsxs("div",{className:"rounded-md border border-dashed border-border px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"未打开项目,无法查看画布"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-muted-foreground underline hover:text-foreground",children:"回到首页打开或创建书籍"})]}):o&&n===null?i.jsx("div",{className:"flex-1 overflow-hidden rounded-md border border-border bg-muted/20 p-4",children:Array.from({length:3},(ne,be)=>i.jsxs("div",{className:"mb-4 flex gap-4",children:[i.jsx("div",{className:"h-24 w-60 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"mt-6 h-24 w-52 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"mt-12 h-20 w-44 animate-pulse rounded-lg bg-muted"})]},be))}):n===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>E(!1),children:"重试"})]}):n.children.length===0?i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"大纲还是空的,先去搭大纲"}),i.jsx(pe,{className:"mt-4",type:"button",onClick:()=>Tn("/outline"),children:"去大纲"})]}):Ae.length===0?i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"当前大纲还没有场景节点"}),i.jsx(pe,{variant:"outline",className:"mt-4",type:"button",onClick:()=>v(!1),children:"显示全部节点"})]}):i.jsxs("div",{ref:ke,className:"relative min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/20",onScroll:Ye,onClick:ne=>{ne.target===ne.currentTarget&&M(null)},children:[i.jsxs("div",{ref:Z,className:"relative",style:{width:$.w,height:$.h,transform:`scale(${g})`,transformOrigin:"0 0"},onClick:ne=>{ne.target===ne.currentTarget&&M(null)},children:[i.jsxs("svg",{className:"pointer-events-none absolute left-0 top-0",width:$.w,height:$.h,style:{overflow:"visible"},children:[i.jsx("defs",{children:i.jsx("marker",{id:vS,viewBox:"0 0 10 10",refX:10,refY:5,markerWidth:10,markerHeight:10,markerUnits:"userSpaceOnUse",orient:"auto",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"context-stroke"})})}),ee.map(({edge:ne,d:be,stroke:Oe,strokeWidth:Ze,opacity:nt,dash:at})=>{const ot=ne.id===H;return i.jsxs("g",{opacity:nt,children:[i.jsx("path",{d:be,fill:"none",stroke:Oe,strokeWidth:Ze,strokeDasharray:at?"6 4":void 0,vectorEffect:"non-scaling-stroke",markerEnd:J3(),className:at?"canvas-edge-flow":void 0}),i.jsx("path",{d:be,fill:"none",stroke:"transparent",strokeWidth:14,vectorEffect:"non-scaling-stroke",className:"pointer-events-auto cursor-pointer",onClick:()=>M(ot?null:ne.id)})]},ne.id)}),xe!==null&&i.jsx("path",{d:xe,fill:"none",stroke:"var(--primary)",strokeWidth:2,strokeDasharray:"6 4",vectorEffect:"non-scaling-stroke"})]}),ee.map(({edge:ne,mid:be,opacity:Oe})=>{const Ze=ne.id===H;return Ze&&D!==null&&D.edgeId===ne.id?i.jsx("div",{className:"absolute z-20 -translate-x-1/2 -translate-y-1/2",style:{left:be.x,top:be.y},children:i.jsx(Dt,{value:D.draft,onChange:at=>B({edgeId:ne.id,draft:at.target.value}),onKeyDown:Te,onBlur:Se,onFocus:at=>at.currentTarget.select(),maxLength:50,placeholder:"+ 标签",autoFocus:!0,"aria-label":"编辑连线标签",className:"h-7 w-44 rounded-md px-1.5 py-0.5 text-xs"})},`label-${ne.id}`):i.jsx("span",{className:Qe("pointer-events-none absolute max-w-44 -translate-x-1/2 -translate-y-1/2 truncate whitespace-nowrap rounded border bg-card px-1.5 py-0.5 text-[10px] text-muted-foreground",Ze&&"pointer-events-auto cursor-text"),style:{left:be.x,top:be.y,opacity:Oe,...Ze?{borderColor:js.highlight,color:js.highlight}:{}},title:Ze?ne.label===void 0?"添加标签":"编辑标签":void 0,onClick:at=>{at.stopPropagation(),Rt(ne)},children:ne.label??(Ze?"+ 标签":"未命名连线")},`label-${ne.id}`)}),je!==null&&i.jsxs("div",{className:"absolute z-10 flex -translate-x-1/2 items-center gap-1 rounded-lg border border-border bg-card p-1 shadow-sm",style:{left:je.mid.x,top:je.mid.y+26},children:[i.jsx("span",{className:"max-w-36 truncate px-1.5 text-xs text-muted-foreground",children:je.edge.label??"未命名连线"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>{Fe()},children:"删除连线"}),i.jsx("button",{type:"button","aria-label":"取消选择",className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>M(null),children:i.jsx(fs,{className:"size-3.5"})})]}),Ae.map(ne=>{const be=d[ne.id];if(!be)return null;const Oe=k?.get(ne.id)??[],Ze=Q===ne.id,nt=ie?.nodeId===ne.id,at=Ie?.nodeIds.has(ne.id)??!1;return i.jsxs("div",{"data-canvas-node-id":ne.id,className:Qe("group absolute cursor-grab touch-none select-none rounded-lg border bg-card p-2.5 transition-colors active:cursor-grabbing",Ze?"border-primary ring-2 ring-ring/40":"border-border",nt&&"opacity-80"),style:{left:be.x,top:be.y,width:hr[ne.type],height:ks[ne.type],...Ie!==null?{opacity:at?1:.2,boxShadow:at?`0 0 0 2px ${js.highlight}`:void 0}:{}},title:"拖动调整位置",onPointerDown:ot=>Re(ot,ne),onPointerMove:ot=>He(ot,ne.id),onPointerUp:We,onMouseEnter:()=>w(ne.id),onMouseLeave:()=>w(ot=>ot===ne.id?null:ot),children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:os[ne.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",title:ne.title,children:ne.title}),Oe.length>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:Oe.map(ot=>i.jsx(iS,{mark:ot},`${ot.relationType}-${ot.hookId}`))})]}),ne.summary&&i.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground",children:ne.summary}),i.jsx("span",{"data-canvas-handle":!0,className:Qe("absolute top-1/2 -right-2 h-4 w-4 -translate-y-1/2 cursor-crosshair rounded-full border bg-card transition-colors",Ze?"border-primary bg-primary/10":"border-border hover:border-primary hover:bg-accent"),title:"拖出连线","aria-label":"拖出连线",onPointerDown:ot=>pt(ot,ne),onPointerMove:_t,onPointerUp:mt})]},ne.id)})]}),i.jsx("div",{className:"pointer-events-none absolute right-2 bottom-2 z-10 overflow-hidden rounded-md border border-border bg-card/90 shadow-sm",children:i.jsxs("svg",{width:Qc.w,height:Qc.h,children:[U.nodeRects.map(ne=>i.jsx("rect",{x:ne.x,y:ne.y,width:ne.w,height:ne.h,rx:2,fill:js[ne.type],opacity:.85},ne.id)),U.viewportRect!==null&&i.jsx("rect",{x:U.viewportRect.x,y:U.viewportRect.y,width:U.viewportRect.w,height:U.viewportRect.h,fill:"none",stroke:js.highlight,strokeWidth:1})]})})]})]})}const va={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},Av=[{value:"updated_at:desc",label:"更新时间(新→旧)",sort:"updated_at",order:"desc"},{value:"updated_at:asc",label:"更新时间(旧→新)",sort:"updated_at",order:"asc"},{value:"name:asc",label:"名称(A→Z)",sort:"name",order:"asc"},{value:"name:desc",label:"名称(Z→A)",sort:"name",order:"desc"},{value:"created_at:desc",label:"创建时间(新→旧)",sort:"created_at",order:"desc"},{value:"created_at:asc",label:"创建时间(旧→新)",sort:"created_at",order:"asc"}];function Dv({type:n}){const o=n==="relations",r=Ta.includes(n)?n:"character",[l,c]=h.useState(null),[d,m]=h.useState(0),[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(""),[j,E]=h.useState(""),[_,O]=h.useState(0),[N,T]=h.useState("updated_at"),[k,C]=h.useState("desc"),[H,M]=h.useState(0);Ms(()=>M(P=>P+1));const[L,w]=h.useState(!1),[J,oe]=h.useState(""),[ie,te]=h.useState(""),[Q,G]=h.useState(null),[K,A]=h.useState(!1),D=h3[r],B=Sv[r],I=p3(d,jl),V=Math.floor(_/jl)+1;h.useEffect(()=>{S(""),E(""),O(0),T("updated_at"),C("desc"),c(null),v(null),w(!1)},[n]),h.useEffect(()=>{const P=setTimeout(()=>{E(x.trim()),O(0)},300);return()=>clearTimeout(P)},[x]),h.useEffect(()=>{if(o)return;let P=!1;return b(!0),v(null),ls(r,{q:j||void 0,offset:_,limit:jl,sort:N,order:k}).then(me=>{P||(c(me.items),m(me.total))}).catch(me=>{P||(c(null),v(me instanceof _e?me.code:ut))}).finally(()=>{P||b(!1)}),()=>{P=!0}},[r,j,_,N,k,H,o]);function z(P){const me=Av.find(re=>re.value===P);me&&(T(me.sort),C(me.order),O(0))}function Z(){oe(""),te(""),G(null),w(!0)}function F(){w(!1),G(null)}async function Y(P){P.preventDefault();const me=J.trim();if(!me){G("请输入名称");return}A(!0),G(null);try{const re=Sv[r],de={};re.key!==""&&ie.trim()&&(de[re.key]=ie.trim());const Le=await Uc(r,{name:me,data:de});Ce.getState().showToast(`已创建${va[r]}《${me}》`),w(!1),Tn(`/entities/${r}/${Le.id}`)}catch(re){G(re instanceof _e?re.message:"创建失败,请重试")}finally{A(!1)}}function q(){S(""),E(""),O(0)}return i.jsxs("section",{children:[i.jsx("h1",{className:"mb-4 text-xl font-semibold",children:"实体"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-zinc-200 pb-3",children:[i.jsxs("div",{className:"flex gap-1",children:[Ta.map(P=>i.jsx("button",{type:"button",onClick:()=>Tn(`/entities/${P}`),className:Qe("rounded-md border border-border px-3 py-1.5 text-sm",!o&&r===P?"bg-zinc-900 text-white":"text-zinc-500 hover:bg-zinc-100 hover:text-zinc-800"),children:va[P]},P)),i.jsx("button",{type:"button",onClick:()=>Tn("/entities/relations"),className:Qe("rounded-md border border-border px-3 py-1.5 text-sm",o?"bg-foreground font-medium text-background":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:"关联"})]}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[!o&&i.jsx(Dt,{value:x,onChange:P=>S(P.target.value),placeholder:`搜索${va[r]}名称…`,className:"w-52"}),i.jsx(pe,{type:"button",onClick:o?()=>w(!0):Z,children:o?"+ 建立关联":"+ 新建"})]})]}),o?i.jsx(pS,{reloadKey:H,onOpenCreate:()=>w(!0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-2 mt-3 flex items-center gap-3",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm text-zinc-500",children:["排序:",i.jsx("select",{value:`${N}:${k}`,onChange:P=>z(P.target.value),className:"rounded-md border border-zinc-300 bg-white px-2 py-1 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:Av.map(P=>i.jsx("option",{value:P.value,children:P.label},P.value))})]}),i.jsxs("span",{className:"ml-auto text-sm text-zinc-400",children:["共 ",d," 个"]})]}),L&&i.jsxs("form",{id:"create-entity-row",onSubmit:Y,className:"mb-3 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2",children:[i.jsx(Dt,{value:J,onChange:P=>oe(P.target.value),onKeyDown:P=>{P.key==="Escape"&&F()},placeholder:`名称(如:${r==="character"?"张三":"示例名称"})`,maxLength:100,disabled:K,autoFocus:!0,"aria-label":"名称",className:"w-48"}),B.key!==""&&(B.input==="select"?i.jsxs("select",{value:ie,onChange:P=>te(P.target.value),disabled:K,"aria-label":B.label,className:"rounded-md border border-input bg-background px-2 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[i.jsxs("option",{value:"",children:[B.label,"(选填)"]}),B.options?.map(P=>i.jsx("option",{value:P,children:em(r,B.key,P)},P))]}):i.jsx(Dt,{value:ie,onChange:P=>te(P.target.value),placeholder:`${B.label}(选填)`,disabled:K,"aria-label":B.label,className:"w-40"})),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",size:"sm",onClick:F,disabled:K,children:"取消"}),i.jsx(pe,{type:"submit",size:"sm",disabled:K,children:K?"创建中…":"创建"})]}),Q&&i.jsx("p",{className:"w-full text-sm text-destructive",children:Q})]}),p!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:[p===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"列表加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>M(P=>P+1),children:"重试"})]}),g&&l===null&&p===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-zinc-200",children:Array.from({length:6},(P,me)=>i.jsxs("div",{className:"flex items-center gap-3 border-b border-zinc-100 px-3 py-3 last:border-0",children:[i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-zinc-100"}),i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-zinc-100"}),D.key2&&i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-zinc-100"}),i.jsx("div",{className:"ml-auto h-4 w-16 animate-pulse rounded bg-zinc-100"})]},me))}),!g&&l!==null&&l.length===0&&i.jsx("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:j?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm text-zinc-600",children:["没有匹配「",j,"」的",va[r]]}),i.jsx(pe,{variant:"outline",className:"mt-4",type:"button",onClick:q,children:"清空搜索"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm text-zinc-600",children:["还没有",va[r],",新建一个"]}),i.jsxs(pe,{className:"mt-4",type:"button",onClick:Z,children:["+ 新建",va[r]]})]})}),!g&&l!==null&&l.length>0&&i.jsx("div",{className:"overflow-hidden rounded-md border border-zinc-200",children:i.jsxs("table",{className:"w-full text-left text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-zinc-200 bg-zinc-50 text-xs text-zinc-400",children:[i.jsx("th",{className:"px-3 py-2 font-normal",children:"名称"}),i.jsx("th",{className:"px-3 py-2 font-normal",children:D.label1}),D.key2&&i.jsx("th",{className:"px-3 py-2 font-normal",children:D.label2}),i.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"更新时间"})]})}),i.jsx("tbody",{children:l.map(P=>i.jsxs("tr",{className:"cursor-pointer border-b border-zinc-100 transition-colors last:border-0 hover:bg-zinc-50",onClick:()=>Tn(`/entities/${r}/${P.id}`),title:`打开《${P.name}》`,children:[i.jsx("td",{className:"max-w-64 truncate px-3 py-2 font-medium text-zinc-800",children:P.name}),i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:em(r,D.key1,P.summary[D.key1])}),D.key2&&i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:em(r,D.key2,P.summary[D.key2])}),i.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-right text-xs text-zinc-400",children:is(P.updatedAt)})]},P.id))})]})}),!g&&l!==null&&l.length>0&&i.jsxs("div",{className:"mt-4 flex items-center justify-center gap-3 text-sm",children:[i.jsx("button",{type:"button",disabled:V<=1||g,className:"rounded-md border border-zinc-300 px-3 py-1 text-zinc-600 hover:bg-zinc-100 disabled:opacity-40",onClick:()=>O((V-2)*jl),children:"‹ 上一页"}),i.jsxs("span",{className:"text-zinc-500",children:["第 ",V," / ",I," 页"]}),i.jsx("button",{type:"button",disabled:V>=I||g,className:"rounded-md border border-zinc-300 px-3 py-1 text-zinc-600 hover:bg-zinc-100 disabled:opacity-40",onClick:()=>O(V*jl),children:"下一页 ›"})]})]}),o&&L&&i.jsx(Fp,{source:null,onCreated:()=>M(P=>P+1),onClose:()=>w(!1)})]})}function oM({type:n,id:o,currentData:r,deltaCount:l}){const c=ze(T=>T.outline),d=ze(T=>T.config),m=ze(T=>T.loadOutline),[g,b]=h.useState(()=>{const T=ze.getState().config?.currentPosition??"",k=ze.getState().outline?.children??[];return T!==""&&oo(k).some(C=>C.id===T)?T:""}),[p,v]=h.useState(!1),[x,S]=h.useState(null),[j,E]=h.useState(null);h.useEffect(()=>{b(T=>{if(T!=="")return T;const k=d?.currentPosition??"";return k!==""&&oo(c?.children??[]).some(C=>C.id===k)?k:""})},[d?.currentPosition,c]);const _=oo(c?.children??[]),O=new Map(_.map(T=>[T.id,T.label]));async function N(){if(!(!g||p)){v(!0),E(null);try{const T=await qw({target_type:n,target_id:o,at_node_id:g});S(T)}catch(T){S(null),T instanceof _e&&T.code==="OUTLINE_NODE_NOT_FOUND"?E("该节点已不存在,请重新选择计算节点"):E(T instanceof _e?T.message:"无法连接服务,请确认 ai-editor 服务已启动")}finally{v(!1)}}}return i.jsxs("div",{className:"mb-4 rounded-md border border-border p-4",children:[i.jsxs("h2",{className:"mb-2 text-sm font-semibold text-foreground",children:["变更记录 · 状态预览",i.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[l," 条"]})]}),l===0?i.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无变更记录——实体当前状态即初始状态"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"计算节点(到达该节点时的累积状态)"}),c===null?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"大纲未加载"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>{m()},children:"加载大纲"})]}):i.jsxs("select",{value:g,onChange:T=>b(T.target.value),"aria-label":"计算节点",className:Qe("min-w-56 rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",g===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"请选择大纲节点"}),_.map(T=>i.jsxs("option",{value:T.id,children:[" ".repeat(T.depth),T.label]},T.id))]})]}),i.jsx(pe,{variant:"outline",size:"sm",type:"button",disabled:!g||p,onClick:()=>{N()},children:p?"计算中…":"计算"})]}),d?.currentPosition==null&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"未设置当前位置,请手动选择计算节点"}),j!==null&&i.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:j}),p&&i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-16 animate-pulse rounded bg-muted/60"})]}),!p&&x!==null&&i.jsx(rM,{result:x,currentData:r,nodeTitles:O})]})]})}function rM({result:n,currentData:o,nodeTitles:r}){const l=E3(o,n.state),c=r.get(n.atNodeId)??n.atNodeId;return i.jsxs("div",{className:"mt-3 space-y-3",children:[n.conflicts.length>0&&i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-destructive",children:[i.jsx(Vm,{className:"size-3.5 shrink-0"}),"发现 ",n.conflicts.length," 处状态冲突"]}),i.jsx("p",{className:"mt-0.5 text-xs text-destructive/90",children:"手动编辑的数据与变更记录不一致,以下变更未应用(可直接修改当前数据,或调整变更记录):"}),i.jsx("ul",{className:"mt-1 space-y-0.5",children:n.conflicts.map((d,m)=>i.jsxs("li",{className:"text-xs text-destructive",children:[d.field,":记录应为 ",rs(d.expected),",实际为 ",rs(d.actual)]},m))})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:["状态差异(相对当前数据 · 到达《",c,"》",l.length>0?`,${l.length} 处`:"",")"]}),l.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"计算状态与当前数据一致"}):i.jsx("ul",{className:"space-y-1",children:l.map(d=>i.jsxs("li",{className:"flex items-baseline gap-2 text-xs",children:[i.jsx("span",{className:"shrink-0 font-medium text-foreground",children:d.field}),i.jsxs("span",{className:"text-muted-foreground",children:[d.from===void 0?"(无)":rs(d.from)," →"," ",d.to===void 0?"(已移除)":rs(d.to)]})]},d.field))})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:["应用的变更记录(",n.appliedDeltas.length,")"]}),n.appliedDeltas.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"到达该节点前没有变更被应用"}):i.jsx("ul",{className:"divide-y divide-border/70 rounded-md border border-border",children:n.appliedDeltas.map((d,m)=>i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:d.description,children:d.description}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["《",r.get(d.nodeId)??d.nodeId,"》"]})]}),d.skipped!==void 0&&d.skipped.length>0&&i.jsx("ul",{className:"mt-1 space-y-0.5",children:d.skipped.map(g=>i.jsxs("li",{className:"text-xs text-destructive",children:[g.field,":记录应为 ",rs(g.expected),",实际 ",rs(g.actual),"(已跳过)"]},g.index))}),i.jsx("div",{className:"mt-1.5",children:i.jsx(hS,{changes:d.changes,skipped:d.skipped?.map(g=>g.index)})})]},m))})]})]})}const aM={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"};function wl(n,o){const r=n[o];return r==null?"":String(r)}function lM({values:n,onChange:o,placeholder:r}){return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.map((l,c)=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Dt,{value:l,onChange:d=>{const m=[...n];m[c]=d.target.value,o(m)},placeholder:r,className:"h-8 flex-1 text-sm"}),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>o(n.filter((d,m)=>m!==c)),children:"删除"})]},c)),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>o([...n,""]),children:"+ 添加"})]})}function iM({value:n,onChange:o}){const[r,l]=h.useState(()=>Object.entries(n??{}).map(([d,m])=>({key:d,value:String(m??"")})));h.useEffect(()=>{l(Object.entries(n??{}).map(([d,m])=>({key:d,value:String(m??"")})))},[n]);function c(d){l(d);const m={};for(const g of d)g.key.trim()&&(m[g.key.trim()]=g.value);o(m)}return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.map((d,m)=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Dt,{value:d.key,onChange:g=>c(r.map((b,p)=>p===m?{...b,key:g.target.value}:b)),placeholder:"键",className:"h-8 w-28 text-sm"}),i.jsx(Dt,{value:d.value,onChange:g=>c(r.map((b,p)=>p===m?{...b,value:g.target.value}:b)),placeholder:"值",className:"h-8 flex-1 text-sm"}),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>c(r.filter((g,b)=>b!==m)),children:"删除"})]},m)),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>c([...r,{key:"",value:""}]),children:"+ 添加字段"})]})}function cM({type:n,id:o}){const r=n,[l,c]=h.useState(null),[d,m]=h.useState(!1),[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(null),[j,E]=h.useState(!1),[_,O]=h.useState(null),[N,T]=h.useState(!1),[k,C]=h.useState(null),[H,M]=h.useState(!1),L=Yp(r);async function w(){m(!0),v(null),b(!1);try{const G=await fr(r,o);c(G),S(JSON.parse(JSON.stringify(G.data)))}catch(G){c(null),S(null),G instanceof _e&&G.code==="ENTITY_NOT_FOUND"?b(!0):v(G instanceof _e?G.code:ut)}finally{m(!1)}}h.useEffect(()=>{w()},[r,o]),Ms(()=>{w()});async function J(){if(!l||!x||j)return;const G=Vp(l.data,x);if(!G){Ce.getState().showToast("没有变更");return}E(!0),O(null);try{await xr(r,o,{data:G}),Ce.getState().showToast("已保存"),await w()}catch(K){if(K instanceof _e&&K.code==="ENTITY_NOT_FOUND"){b(!0);return}O(K instanceof _e?K.message:"保存失败,请重试")}finally{E(!1)}}function oe(G,K){S(A=>A&&{...A,[G]:K})}async function ie(){if(l)try{const G=await Jc(r,o),K=[];G.cascaded.relations>0&&K.push(`${G.cascaded.relations} 条关联`),G.cascaded.deltas>0&&K.push(`${G.cascaded.deltas} 条变更记录`),Ce.getState().showToast(`已移入回收站,可随时还原${K.length>0?`(含 ${K.join("、")})`:""}`),Tn(`/entities/${r}`)}catch(G){Ce.getState().showToast(G instanceof _e?G.message:"删除失败,请重试","error")}}async function te(){if(k)try{await Wc(k.id),Ce.getState().showToast("已删除关系"),C(null),await w()}catch(G){throw G}}function Q(G,K){return(K==="source"?G.sourceId:G.targetId)===o?l?.name??"本实体":(K==="source"?G.sourceName:G.targetName)??(K==="source"?G.sourceId:G.targetId)}return g?i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"该实体不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-zinc-300 px-4 py-1.5 text-sm text-zinc-600 hover:bg-zinc-100",children:"去回收站"}),i.jsx(pe,{variant:"outline",type:"button",onClick:()=>Tn(`/entities/${r}`),children:"返回列表"})]})]})}):i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(qp,{items:[{label:"实体",href:"/entities/character"},{label:aM[r],href:`/entities/${r}`},{label:l?.name??"…"}]}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:l?.name??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>{J()},disabled:!l||j,children:j?"保存中…":"保存"}),i.jsx(pe,{variant:"outline",type:"button",disabled:!l,className:"text-red-600 hover:bg-red-50",onClick:()=>{ie()},children:"移入回收站"})]})]}),l&&i.jsxs("p",{className:"mb-4 text-xs text-muted-foreground",children:["创建于 ",is(l.createdAt)," · 更新于 ",is(l.updatedAt)," ·"," ",i.jsxs("button",{type:"button",onClick:()=>M(G=>!G),title:"展开状态预览:计算该实体在任意大纲节点处的累积状态",className:"rounded-md border border-border px-1.5 py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:["变更记录 ",l.deltaCount," 条"]})]}),l&&H&&i.jsx(oM,{type:r,id:o,currentData:l.data,deltaCount:l.deltaCount}),d&&!l&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx("div",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:Array.from({length:5},(G,K)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},K))}),i.jsx("div",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:Array.from({length:3},(G,K)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},K))})]}),!d&&!l&&p!==null&&i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:[p===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{w()},children:"重试"})]}),l&&x&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4",children:[i.jsx("h2",{className:"mb-3 text-sm font-semibold text-zinc-700",children:"基础信息"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[L.map(G=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-zinc-700",children:G.label}),i.jsx(uM,{field:G,value:x[G.key],onChange:K=>oe(G.key,K)})]},G.key)),"custom_fields"in l.data&&i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-zinc-700",children:"自定义字段"}),i.jsx(iM,{value:x.custom_fields,onChange:G=>oe("custom_fields",G)})]})]}),_&&i.jsx("p",{className:"mt-3 text-sm text-red-600",children:_})]}),i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-zinc-700",children:"关联(1 跳)"}),i.jsx(pe,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>T(!0),children:"+ 新增关联"})]}),l.relations.length===0?i.jsx("p",{className:"py-6 text-center text-sm text-zinc-400",children:"暂无关联,新增一个"}):i.jsx("ul",{className:"divide-y divide-zinc-100",children:l.relations.map(G=>{const K=G.sourceId===o,A=Q(G,"source"),D=Q(G,"target");return i.jsxs("li",{className:"flex items-center gap-2 py-2 text-sm",children:[i.jsx("span",{className:"min-w-0 max-w-28 truncate text-zinc-700",children:A}),i.jsxs("span",{className:"shrink-0 rounded bg-zinc-100 px-1.5 py-0.5 text-xs text-zinc-500",children:[pr(G.relationType)," ",K?"→":"←"]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-zinc-700",children:D}),i.jsx(pe,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-red-600 hover:bg-red-50",onClick:()=>C(G),children:"删除"})]},G.id)})})]})]}),N&&i.jsx(Fp,{source:{type:r,id:o,name:l?.name??""},onCreated:w,onClose:()=>T(!1)}),k&&i.jsx(Oa,{title:"删除关系",description:`删除关系「${Q(k,"source")} ${pr(k.relationType)} ${Q(k,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:te,onClose:()=>C(null)})]})}function uM({field:n,value:o,onChange:r}){switch(n.control){case"textarea":return i.jsx("textarea",{value:wl({[n.key]:o},n.key),onChange:l=>r(l.target.value),rows:3,className:"w-full rounded-md border border-zinc-300 px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400"});case"number":return i.jsx(Dt,{type:"number",value:wl({[n.key]:o},n.key),onChange:l=>r(l.target.value===""?void 0:Number(l.target.value)),className:"h-8 text-sm"});case"tags":return i.jsx(lM,{values:Array.isArray(o)?o:[],onChange:r,placeholder:"输入后回车添加下一项"});case"select":return i.jsx("select",{value:wl({[n.key]:o},n.key),onChange:l=>r(l.target.value),className:"w-full rounded-md border border-zinc-300 bg-white px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:n.options?.map(l=>i.jsx("option",{value:l,children:n.optionsLabels?.[l]??l},l))});case"toggle":return i.jsx("input",{type:"checkbox",checked:o===!0,onChange:l=>r(l.target.checked),className:"h-4 w-4 accent-zinc-900"});case"outline-node":return i.jsx(dM,{value:wl({[n.key]:o},n.key),onChange:r});default:return i.jsx(Dt,{value:wl({[n.key]:o},n.key),onChange:l=>r(l.target.value),className:"h-8 text-sm"})}}function dM({value:n,onChange:o}){const r=ze(c=>c.outline),l=oo(r?.children??[]);return i.jsxs("select",{value:n,onChange:c=>o(c.target.value===""?null:c.target.value),className:Qe("w-full rounded-md border border-zinc-300 bg-white px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",n===""&&"text-zinc-400"),children:[i.jsx("option",{value:"",children:"未设置"}),l.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function fM(n){return n==="resolved"?"resolved":n==="abandoned"?"abandoned":"active"}function mM(n){const o={active:[],resolved:[],abandoned:[]};for(const r of n)o[fM(r.summary.status)].push(r);return o}function Uo(n,o){return n.filter(r=>r.relationType===o)}function SS(n,o){return Uo(n,"depends_on").filter(r=>r.sourceId===o).map(r=>r.targetName??r.targetId)}function pM(n,o){return Uo(n,"depends_on").filter(r=>r.targetId===o).map(r=>r.sourceName??r.sourceId)}function zv(n,o){return pM(n,o).length}function hM(n,o){return Uo(n,"involves").map(r=>r.sourceId===o?r.targetName??r.targetId:r.sourceName??r.sourceId)}const gM=3;function xM(n){const o=n.maxDepth??gM,r=[],l=new Set([n.startHookId]),c=[{hookId:n.startHookId,depth:0}];for(;c.length>0;){const{hookId:d,depth:m}=c.shift();if(r.push({hookId:d,name:n.names.get(d)??d,depth:m}),!(m>=o))for(const g of n.depsOf.get(d)??[])g.relationType!=="depends_on"||g.sourceId!==d||l.has(g.targetId)||(l.add(g.targetId),c.push({hookId:g.targetId,depth:m+1}))}return r}function ES(n,o){if(!n)return!1;const r=[...n.children];for(;r.length>0;){const l=r.pop();if(l.id===o)return l.deleted!==!0;l.type!=="scene"&&l.children&&r.push(...l.children)}return!1}function bM(n){if(!n)return null;let o=null;const r=l=>{if(l.deleted!==!0&&(o=l.id,l.type!=="scene"&&l.children))for(const c of l.children)r(c)};for(const l of n.children)r(l);return o}function yM(n,o){const r=n?.currentPosition;return r!=null&&r!==""&&ES(o,r)?r:bM(o)}const NS={advance:"progressing",resolve:"resolved",abandon:"abandoned"},vM={advance:"advances",resolve:"resolves"};function Lv(n){const o=n.status;return typeof o=="string"&&o!==""?o:"planted"}function jS(n,o){return{field:"status",op:"update",from:n,to:o}}function SM(n,o,r){return{source_type:"outline_node",source_id:r,target_type:"hook",target_id:o,relation_type:vM[n]}}function EM(n,o){return{source_type:"outline_node",source_id:o,target_type:"hook",target_id:n,relation_type:"plants"}}function TS(n){return{status:n}}async function NM(n){const o=NS[n.kind];await Qm({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[jS(n.fromStatus,o)],description:n.description});try{await yr(SM(n.kind,n.hookId,n.nodeId))}catch(r){if(!(r instanceof _e&&r.code==="RELATION_EXISTS"))throw r}await xr("hook",n.hookId,{data:TS(o)})}async function jM(n){await Qm({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[jS(n.fromStatus,"abandoned")],description:n.description}),await xr("hook",n.hookId,{data:TS("abandoned")})}const rm={advance:"推进",resolve:"回收",abandon:"废弃"};function TM(n){return n==="resolved"||n==="abandoned"}function Cl(n,o){const r=n[o];return r==null?"":String(r)}function wM(){const[n,o]=h.useState(null),[r,l]=h.useState(!1),[c,d]=h.useState(null),[m,g]=h.useState(0);Ms(()=>g(ae=>ae+1));const[b,p]=h.useState([]),[v,x]=h.useState(!1),[S,j]=h.useState(null),[E,_]=h.useState(!1),[O,N]=h.useState(null),[T,k]=h.useState(null),[C,H]=h.useState("advance"),[M,L]=h.useState(""),[w,J]=h.useState(""),[oe,ie]=h.useState(null),[te,Q]=h.useState(!1),[G,K]=h.useState(null),[A,D]=h.useState(null),[B,I]=h.useState(null),[V,z]=h.useState(!1),[Z,F]=h.useState(!1),[Y,q]=h.useState(""),[P,me]=h.useState({}),[re,de]=h.useState(""),[Le,De]=h.useState(null),[we,Be]=h.useState(!1),[ge,le]=h.useState({}),Ye=ze(ae=>ae.config),ke=ze(ae=>ae.outline),Ae=oo(ke?.children??[]),ve=n===null?null:mM(n);h.useEffect(()=>{let ae=!1;return l(!0),d(null),x(!1),le({}),ls("hook",{}).then(Re=>{ae||o(Re.items)}).catch(Re=>{ae||(o(null),d(Re instanceof _e?Re.code:ut))}),br({source_type:"hook",relation_type:"depends_on",depth:1}).then(Re=>{ae||p(Re.relations)}).catch(()=>{ae||x(!0)}).finally(()=>{ae||l(!1)}),()=>{ae=!0}},[m]),h.useEffect(()=>{ze.getState().outline===null&&ze.getState().config!==null&&ze.getState().loadOutline()},[]);async function Ue(ae){j(null),_(!0),N(null);try{j(await fr("hook",ae.id))}catch(Re){N(Re instanceof _e?Re.message:"详情加载失败,请重试")}finally{_(!1)}}async function Pe(ae,Re){k(null),ie(null),J("");try{const He=await fr("hook",Re.id),We=ze.getState().config?.currentPosition,pt=We!=null&&We!==""&&ES(ke,We)?We:"";L(pt),H(ae),k(He)}catch{Ce.getState().showToast("无法读取伏笔状态,请重试","error")}}async function Ie(){const ae=T;if(!ae||te)return;const Re=C;Q(!0),ie(null);try{if(Re==="abandon"){const He=yM(Ye,ke);if(He===null){ie("大纲为空,无法记录废弃变更");return}await jM({hookId:ae.id,fromStatus:Lv(ae.data),nodeId:He,description:w.trim()})}else{if(M===""){ie("请选择大纲节点");return}await NM({kind:Re,hookId:ae.id,fromStatus:Lv(ae.data),nodeId:M,description:w.trim()})}Ce.getState().showToast(`已${rm[Re]}`),k(null),g(He=>He+1)}catch(He){ie(He instanceof _e?He.message:"操作失败,请重试")}finally{Q(!1)}}async function ee(ae){K(null),I(null);try{const Re=await fr("hook",ae.id);K(Re),D(JSON.parse(JSON.stringify(Re.data)))}catch{Ce.getState().showToast("无法读取伏笔数据,请重试","error")}}async function U(){if(!G||!A||V)return;const ae=Vp(G.data,A);if(!ae){Ce.getState().showToast("没有变更"),K(null);return}z(!0),I(null);try{await xr("hook",G.id,{data:ae}),Ce.getState().showToast("已保存"),K(null),g(Re=>Re+1)}catch(Re){I(Re instanceof _e?Re.message:"保存失败,请重试")}finally{z(!1)}}async function $(ae){ae.preventDefault();const Re=Y.trim();if(!Re){De("请输入名称");return}Be(!0),De(null);try{const He=await Uc("hook",{name:Re,data:P});if(re!=="")try{await yr(EM(He.id,re))}catch(We){Ce.getState().showToast(`已创建伏笔《${Re}》,但埋点关联失败:${We instanceof _e?We.message:"未知错误"}`,"error"),F(!1),g(pt=>pt+1);return}Ce.getState().showToast(`已创建伏笔《${Re}》`),F(!1),q(""),me({}),de(""),g(We=>We+1)}catch(He){De(He instanceof _e?He.message:"创建失败,请重试")}finally{Be(!1)}}async function je(ae){try{const Re=await Jc("hook",ae.id),He=[];Re.cascaded.relations>0&&He.push(`${Re.cascaded.relations} 条关联`),Re.cascaded.deltas>0&&He.push(`${Re.cascaded.deltas} 条变更记录`),Ce.getState().showToast(`已移入回收站,可随时还原${He.length>0?`(含 ${He.join("、")})`:""}`),g(We=>We+1)}catch(Re){Ce.getState().showToast(Re instanceof _e?Re.message:"删除失败,请重试","error")}}async function xe(ae){if(ge[ae.id]){le(Re=>{const He={...Re};return delete He[ae.id],He});return}le(Re=>({...Re,[ae.id]:{status:"loading",nodes:[]}}));try{const Re=new Map,He=new Map,We=[{id:ae.id,depth:0}],pt=new Set;for(;We.length>0;){const{id:mt,depth:Tt}=We.shift();if(pt.has(mt))continue;pt.add(mt);const Rt=await fr("hook",mt);He.set(mt,Rt.name);const zt=Uo(Rt.relations,"depends_on").filter(Te=>Te.sourceId===mt);if(Re.set(mt,zt),!(Tt>=2))for(const Te of zt)He.has(Te.targetId)||He.set(Te.targetId,Te.targetName??Te.targetId),We.push({id:Te.targetId,depth:Tt+1})}const _t=xM({startHookId:ae.id,depsOf:Re,names:He});le(mt=>({...mt,[ae.id]:{status:"ready",nodes:_t}}))}catch{le(Re=>({...Re,[ae.id]:{status:"error",nodes:[]}}))}}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"伏笔池"}),i.jsx(pe,{type:"button",className:"ml-auto",onClick:()=>F(!0),children:"+ 新建伏笔"})]}),c!==null&&i.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[c===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"伏笔池加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>g(ae=>ae+1),children:"重试"})]}),r&&ve===null&&c===null&&i.jsx("div",{className:"space-y-4",children:Array.from({length:3},(ae,Re)=>i.jsxs("div",{className:"rounded-md border border-border",children:[i.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-muted px-3 py-1.5"}),Array.from({length:Re===0?3:1},(He,We)=>i.jsxs("div",{className:"flex items-center gap-3 border-t border-border/70 px-3 py-2.5",children:[i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-6 w-6 animate-pulse rounded bg-muted"})]},We))]},Re))}),!r&&ve!==null&&n?.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有伏笔。好伏笔要趁早埋下——先新建一个,或在聊天里让 AI 帮你规划。"}),i.jsx(pe,{className:"mt-4",type:"button",onClick:()=>F(!0),children:"+ 新建伏笔"})]}),ve!==null&&n&&n.length>0&&i.jsxs("div",{className:"space-y-4",children:[i.jsx(am,{title:"活跃",icon:i.jsx("span",{className:"size-2 shrink-0 rounded-full bg-primary"}),hooks:ve.active,depEdges:b,depEdgesFailed:v,chains:ge,onToggleChain:xe,onDetail:Ue,onLifecycle:Pe,onEdit:ee,onDelete:ae=>{je(ae)}}),i.jsx(am,{title:"已回收",icon:i.jsx(Pm,{className:"size-3.5 shrink-0 text-primary"}),hooks:ve.resolved,depEdges:b,depEdgesFailed:v,chains:ge,onToggleChain:xe,onDetail:Ue,onLifecycle:Pe,onEdit:ee,onDelete:ae=>{je(ae)}}),i.jsx(am,{title:"已废弃",icon:i.jsx(wj,{className:"size-3.5 shrink-0 text-muted-foreground"}),hooks:ve.abandoned,depEdges:b,depEdgesFailed:v,chains:ge,onToggleChain:xe,onDetail:Ue,onLifecycle:Pe,onEdit:ee,onDelete:ae=>{je(ae)}})]}),i.jsx(Ts,{open:Z,onOpenChange:ae=>!ae&&F(!1),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsx(Os,{children:"新建伏笔"})}),i.jsxs("form",{id:"create-hook-form",onSubmit:$,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:Y,onChange:ae=>q(ae.target.value),placeholder:"如:身世之谜",maxLength:100})]}),i.jsx(Iv,{fields:RM,data:P,onChange:me,nodeOptions:Ae}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"埋点节点(选填,可空)"}),i.jsx(Am,{value:re,onChange:de,nodeOptions:Ae})]}),Le&&i.jsx("p",{className:"text-sm text-destructive",children:Le})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>F(!1),disabled:we,children:"取消"}),i.jsx(pe,{type:"submit",form:"create-hook-form",disabled:we,children:"创建"})]})]})}),i.jsx(Ts,{open:S!==null||E,onOpenChange:ae=>!ae&&j(null),children:i.jsxs(ws,{className:"sm:max-w-lg",children:[i.jsx(Cs,{children:i.jsx(Os,{children:"伏笔详情"})}),E&&i.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"加载中…"}),O&&i.jsx("p",{className:"py-4 text-sm text-destructive",children:O}),S&&i.jsx(CM,{detail:S}),i.jsx(Rs,{children:i.jsx(pe,{variant:"outline",type:"button",onClick:()=>j(null),children:"关闭"})})]})}),T&&i.jsx(Ts,{open:!0,onOpenChange:ae=>!ae&&!te&&k(null),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsxs(Os,{children:[rm[C],"伏笔《",T.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[C!=="abandon"&&i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"大纲节点(默认当前位置)"}),i.jsx(Am,{value:M,onChange:L,nodeOptions:Ae,placeholder:"请选择节点"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:w,onChange:ae=>J(ae.target.value),rows:2,placeholder:C==="abandon"?"说明废弃原因":"说明伏笔如何被推进/回收",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{className:"rounded-md border border-primary/25 bg-primary/5 px-3 py-2 text-sm",children:[i.jsx("p",{className:"font-medium text-foreground",children:"将写入:"}),i.jsxs("p",{className:"mt-1 text-muted-foreground",children:["status → ",NS[C],C==="advance"&&" + advances 关系",C==="resolve"&&" + resolves 关系"," + 同步 status"]}),C==="resolve"&&v&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:"依赖关系加载失败,无法确认依赖者"}),C==="resolve"&&!v&&zv(b,T.id)>0&&i.jsxs("p",{className:"mt-2 text-sm text-destructive",children:["有 ",zv(b,T.id)," 个伏笔依赖此伏笔"]})]}),oe&&i.jsx("p",{className:"text-sm text-destructive",children:oe})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>k(null),disabled:te,children:"取消"}),i.jsx(pe,{type:"button",onClick:()=>{Ie()},disabled:te,children:te?"提交中…":`确认${rm[C]}`})]})]})}),G&&A&&i.jsx(Ts,{open:!0,onOpenChange:ae=>!ae&&!V&&K(null),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsxs(Os,{children:["编辑伏笔《",G.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx(Iv,{fields:Yp("hook"),data:A,onChange:ae=>D(Re=>Re&&{...Re,...ae}),nodeOptions:Ae}),B&&i.jsx("p",{className:"text-sm text-destructive",children:B})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>K(null),disabled:V,children:"取消"}),i.jsx(pe,{type:"button",onClick:()=>{U()},disabled:V,children:V?"保存中…":"保存"})]})]})})]})}function am({title:n,icon:o,hooks:r,depEdges:l,depEdgesFailed:c,chains:d,onToggleChain:m,onDetail:g,onLifecycle:b,onEdit:p,onDelete:v}){return i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-muted/30 px-3 py-1.5 text-sm font-medium text-foreground",children:[o,i.jsx("span",{children:n}),i.jsxs("span",{className:"text-muted-foreground",children:["(",r.length,")"]})]}),r.length===0?i.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/70",children:"(空)"}):i.jsx("ul",{className:"divide-y divide-border/70",children:r.map(x=>{const S=TM(x.summary.status),j=c?[]:SS(l,x.id),E=d[x.id],_=typeof x.summary.category=="string"?x.summary.category:"";return i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:x.name,children:x.name}),_&&i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:_}),i.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground",title:"详情","aria-label":`${x.name} 详情`,onClick:()=>g(x),children:i.jsx(Ll,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",disabled:S,className:"text-muted-foreground",title:"推进","aria-label":`${x.name} 推进`,onClick:()=>b("advance",x),children:i.jsx(hj,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",disabled:S,className:"text-muted-foreground",title:"回收","aria-label":`${x.name} 回收`,onClick:()=>b("resolve",x),children:i.jsx(Kv,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",disabled:S,className:"text-muted-foreground",title:"废弃","aria-label":`${x.name} 废弃`,onClick:()=>b("abandon",x),children:i.jsx(fs,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground",title:"编辑","aria-label":`${x.name} 编辑`,onClick:()=>p(x),children:i.jsx(Kl,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",title:"移入回收站","aria-label":`${x.name} 移入回收站`,onClick:()=>v(x),children:i.jsx(Ql,{className:"size-3.5"})})]})]}),j.length>0&&i.jsxs("button",{type:"button",onClick:()=>m(x),className:"mt-0.5 flex items-center gap-1 rounded-md border border-border px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",children:["依赖: ",j.join("、")]}),E?.status==="loading"&&i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"依赖链展开中…"}),E?.status==="error"&&i.jsx("p",{className:"mt-0.5 text-xs text-destructive",children:"依赖链加载失败"}),E?.status==="ready"&&E.nodes.length>1&&i.jsx("ul",{className:"mt-1 space-y-0.5 border-l border-border pl-2",children:E.nodes.slice(1).map(O=>i.jsxs("li",{className:"text-xs text-muted-foreground",children:[" ".repeat(O.depth-1),O.name]},`${O.depth}-${O.hookId}`))})]},x.id)})})]})}function CM({detail:n}){const o=n.id,r=typeof n.data.status=="string"?n.data.status:"",l=typeof n.data.category=="string"?n.data.category:"",c=Uo(n.relations,"plants"),d=Uo(n.relations,"advances"),m=Uo(n.relations,"resolves"),g=SS(n.relations,o),b=Uo(n.relations,"depends_on").filter(x=>x.targetId===o).map(x=>x.sourceName??x.sourceId),p=hM(n.relations,o),v=typeof n.data.expected_resolve_node_id=="string"?n.data.expected_resolve_node_id:"";return i.jsxs("div",{className:"flex flex-col gap-3 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium text-foreground",children:n.name}),l&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:l}),r&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:Hp[r]??r})]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["创建于 ",is(n.createdAt)," · 更新于 ",is(n.updatedAt)]}),i.jsx(dr,{title:"埋点节点(plants)",items:c.map(x=>x.sourceName??x.sourceId)}),i.jsx(dr,{title:"推进节点(advances)",items:d.map(x=>x.sourceName??x.sourceId)}),i.jsx(dr,{title:"回收节点(resolves)",items:m.map(x=>x.sourceName??x.sourceId)}),i.jsx(dr,{title:"预计回收节点",items:v?[v]:[]}),i.jsx(dr,{title:"依赖(depends_on)",items:g}),i.jsx(dr,{title:"被依赖(其他伏笔依赖本伏笔)",items:b}),i.jsx(dr,{title:"涉及(involves)",items:p})]})}function dr({title:n,items:o}){return i.jsxs("div",{children:[i.jsx("p",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:n}),o.length===0?i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"无"}):i.jsx("ul",{className:"flex flex-wrap gap-1",children:o.map((r,l)=>i.jsx("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:r},`${r}-${l}`))})]})}const RM=[{key:"category",label:"类别",control:"text"},{key:"expected_payoff",label:"预期回收",control:"textarea"},{key:"payoff_timing",label:"回收时机",control:"select",options:["immediate","near_term","mid_arc","slow_burn","endgame"],optionsLabels:Pp},{key:"half_life",label:"半衰期(章数)",control:"number"},{key:"is_core",label:"主线伏笔",control:"toggle"},{key:"notes",label:"备注",control:"textarea"},{key:"expected_resolve_node_id",label:"预计回收节点",control:"outline-node"}];function Iv({fields:n,data:o,onChange:r,nodeOptions:l}){return i.jsx(i.Fragment,{children:n.map(c=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:c.label}),i.jsx(OM,{field:c,value:o[c.key],nodeOptions:l,onValue:d=>r({...o,[c.key]:d})})]},c.key))})}function OM({field:n,value:o,nodeOptions:r,onValue:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:Cl({[n.key]:o},n.key),onChange:c=>l(c.target.value),rows:2,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"});case"number":return i.jsx(Dt,{type:"number",value:Cl({[n.key]:o},n.key),onChange:c=>l(c.target.value===""?void 0:Number(c.target.value)),className:"h-8 text-sm"});case"select":return i.jsxs("select",{value:Cl({[n.key]:o},n.key),onChange:c=>l(c.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[i.jsx("option",{value:"",children:"未设置"}),n.options?.map(c=>i.jsx("option",{value:c,children:n.optionsLabels?.[c]??c},c))]});case"toggle":return i.jsx("input",{type:"checkbox",checked:o===!0,onChange:c=>l(c.target.checked),className:"h-4 w-4 accent-primary"});case"outline-node":return i.jsx(Am,{value:Cl({[n.key]:o},n.key),onChange:l,nodeOptions:r});default:return i.jsx(Dt,{value:Cl({[n.key]:o},n.key),onChange:c=>l(c.target.value),placeholder:n.key==="category"?`如:${oj.join(" / ")}`:void 0,className:"h-8 text-sm"})}}function Am({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Qe("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function Dm(n,o,r){const l=r===void 0?n:n.filter(d=>d!==r);if(o.kind==="end")return l.length;const c=l.indexOf(o.id);return c===-1?l.length:o.kind==="before"?c:c+1}function Bv(n,o,r){const l=n.map(g=>({timepoint:g,events:[]})),c=new Map(l.map(g=>[g.timepoint.id,g])),d=new Map;for(const g of r)g.relationType!=="occurs_at"||g.sourceType!=="timepoint"||d.has(g.targetId)||d.set(g.targetId,g.sourceId);const m=[];for(const g of o){const b=d.get(g.id),p=b===void 0?void 0:c.get(b);p===void 0?m.push(g):p.events.push(g)}return{groups:l,ungrouped:m}}function kM(n,o,r,l,c){const d=[...n.flatMap(b=>b.events.map(p=>p.id)),...o.map(b=>b.id)];let m;if(r===-1)m=l==="before"?o[0]:o[o.length-1];else{const b=n[r];if(b!==void 0){if(l==="before"){if(m=b.events[0],m===void 0)for(let p=r+1;p<n.length;p++){const v=n[p].events[0];if(v!==void 0){m=v;break}}}else if(m=b.events[b.events.length-1],m===void 0)for(let p=r-1;p>=0;p--){const v=n[p].events[n[p].events.length-1];if(v!==void 0){m=v;break}}}}if(m!==void 0)return Dm(d,{kind:l,id:m.id},c);const g=d.find(b=>b!==c);return g===void 0?0:Dm(d,{kind:"before",id:g},c)}function $p(n){const o=n.summary.tags;return Array.isArray(o)?o.filter(r=>typeof r=="string"):[]}function _M(n){const o=n.summary.description;return typeof o=="string"?o:""}function zm(n,o,r=5){const l=n.split(/[,,、\n]/),c=l[l.length-1].trim();if(c==="")return[];const d=new Set(l.slice(0,-1).map(p=>p.trim()).filter(p=>p!=="")),m=c.toLowerCase(),g=[],b=new Set;for(const p of o){if(g.length>=r)break;d.has(p)||b.has(p)||p.toLowerCase().includes(m)&&(b.add(p),g.push(p))}return g}function Lm(n,o){const r=n.split(/[,,、\n]/);return r[r.length-1]=o,r.join(",")+","}function Ic(n){const o=new Set,r=[];for(const l of n)for(const c of $p(l))c!==""&&!o.has(c)&&(o.add(c),r.push(c));return r}function MM(n,o){return o===null||o===""?n:n.filter(r=>$p(r).includes(o))}function wS(n){const o=[],r=new Set;for(const l of n.split(/[,,、\n]/)){const c=l.trim();c!==""&&!r.has(c)&&(r.add(c),o.push(c))}return o}function CS(n){return Array.isArray(n)?n.filter(o=>typeof o=="string").join(","):""}function AM(n){const o=n.data;return{name:n.name,description:typeof o.description=="string"?o.description:"",tagsInput:CS(o.tags)}}function RS(n,o){const r={};o.name.trim()!==n.name&&(r.name=o.name.trim());const l={};(o.description.trim()!==""||n.data.description!==void 0)&&(l.description=o.description.trim());const c=wS(o.tagsInput);(c.length>0||n.data.tags!==void 0)&&(l.tags=c);const d={};for(const m of["description","tags"])JSON.stringify(l[m])!==JSON.stringify(n.data[m])&&(d[m]=l[m]);return Object.keys(d).length>0&&(r.data=d),r.name===void 0&&r.data===void 0?null:r}const OS="occurs_in",kS="occurs_at";function DM(n,o){return n.filter(r=>r.relationType===OS&&r.sourceId===o)}function zM(n,o){return{source_type:"event",source_id:n,target_type:"outline_node",target_id:o,relation_type:OS}}function lm(n,o){const r=n.find(l=>l.relationType===kS&&l.sourceType==="timepoint"&&l.targetId===o);return r===void 0?null:r.sourceId}function LM(n,o){return{source_type:"timepoint",source_id:n,target_type:"event",target_id:o,relation_type:kS}}function IM({ev:n,occursCount:o,hasOccursData:r,dragging:l,busy:c,showInsertBefore:d,showInsertAfter:m,eventDrag:g,onDetail:b,onEdit:p,onDelete:v}){const x=$p(n),S=_M(n),j=o(n.id),[E,_]=h.useState(!1),O=h.useRef(null),[N,T]=h.useState(!1);return h.useLayoutEffect(()=>{const k=O.current;if(k===null)return;const C=()=>{E||T(k.scrollHeight>k.clientHeight+1)};return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[S,E]),i.jsxs("div",{draggable:!c,onDragStart:k=>g.onDragStart(k,n),onDragEnd:g.onDragEnd,onDragOver:k=>g.onDragOver(k,n),onDrop:k=>g.onDrop(k,n),className:Qe("relative flex items-start",l&&"opacity-50"),children:[d&&i.jsx("div",{className:"absolute inset-x-0 -top-px h-0.5 bg-primary"}),m&&i.jsx("div",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"}),i.jsx("div",{className:"w-[22px] shrink-0",children:i.jsx("span",{"aria-hidden":"true",className:"mx-auto mt-[16px] block size-2 rounded-full bg-primary/60"})}),i.jsxs("div",{className:"min-w-0 flex-1 rounded-md border border-border bg-card px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"shrink-0 cursor-grab text-muted-foreground/60 active:cursor-grabbing",title:"拖拽调整事件顺序/挂载","aria-hidden":"true",children:i.jsx(Ym,{className:"size-4"})}),i.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:n.name,children:n.name}),x.map(k=>i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:k},k)),i.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1",children:[r&&i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[j," 节点"]}),i.jsx(pe,{variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground",title:"详情","aria-label":`${n.name} 详情`,onClick:()=>b(n),children:i.jsx(kj,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground",title:"编辑","aria-label":`${n.name} 编辑`,onClick:()=>p(n),children:i.jsx(Kl,{className:"size-3.5"})}),i.jsx(pe,{variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground hover:text-destructive",title:"移入回收站","aria-label":`${n.name} 移入回收站`,onClick:()=>v(n),children:i.jsx(Ql,{className:"size-3.5"})})]})]}),S.trim()!==""&&i.jsxs("div",{className:"mt-1.5",children:[i.jsx("p",{ref:O,className:Qe("text-sm leading-relaxed text-muted-foreground",!E&&"line-clamp-2"),children:S}),(E||N)&&i.jsx("button",{type:"button",draggable:!1,onClick:()=>_(k=>!k),className:"mt-1 rounded-md border border-border px-1.5 py-0.5 text-xs text-primary hover:bg-muted","aria-expanded":E,children:E?"收起":"展开"})]})]})]})}function BM({timepoint:n,groupId:o,events:r,collapsed:l,dragSource:c,busy:d,occursCount:m,hasOccursData:g,showInsertBefore:b,showInsertAfter:p,onToggleCollapse:v,onRename:x,onDeleteTimepoint:S,onAddEventAt:j,onDragStart:E,onDragEnd:_,onDragOver:O,onDrop:N,eventDrag:T,eventInsertLines:k,onDetail:C,onEdit:H,onDelete:M}){const[L,w]=h.useState(!1),[J,oe]=h.useState(""),ie=n===null,te=ie?"未挂载":n.name,Q=c!==null&&c.kind==="timepoint"&&c.id===o;function G(){n!==null&&(oe(n.name),w(!0))}async function K(){if(n===null)return;const A=J.trim();w(!1),!(A===""||A===n.name)&&await x(n.id,A)}return i.jsxs("div",{className:"relative flex flex-col gap-2",children:[b&&i.jsx("div",{className:"absolute inset-x-0 -top-px h-0.5 bg-primary"}),p&&i.jsx("div",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"}),i.jsxs("div",{draggable:!ie&&!d&&!L,onDragStart:E,onDragEnd:_,onDragOver:O,onDrop:N,className:Qe("flex items-start",!ie&&Q&&"opacity-50"),children:[i.jsx("div",{className:"w-[22px] shrink-0",children:i.jsx("span",{"aria-hidden":"true",className:Qe("relative z-10 mx-auto mt-[6px] block size-4 rounded-full border-2 bg-background",ie?"border-dashed border-border":"border-primary")})}),i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 py-1",children:[!ie&&i.jsx("span",{className:"shrink-0 cursor-grab text-muted-foreground/60 active:cursor-grabbing",title:"拖拽调整时间点顺序(组内事件不动)","aria-hidden":"true",children:i.jsx(Ym,{className:"size-4"})}),L?i.jsx("input",{autoFocus:!0,value:J,onChange:A=>oe(A.target.value),onKeyDown:A=>{A.key==="Enter"?K():A.key==="Escape"&&w(!1)},onBlur:()=>w(!1),maxLength:100,"aria-label":"时间点名称",className:"w-40 rounded-md border border-border bg-background px-2 py-0.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}):i.jsx("span",{className:Qe("min-w-0 truncate text-sm font-medium",ie?"italic text-muted-foreground":"text-foreground"),title:te,children:te}),i.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[r.length," 个事件"]}),n!==null&&!L&&i.jsx(pe,{type:"button",variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground",title:"重命名","aria-label":`重命名「${n.name}」`,onClick:G,children:i.jsx(Kl,{className:"size-3.5"})}),n!==null&&!L&&i.jsx(pe,{type:"button",variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground",title:"在此时间点新建事件","aria-label":"在此时间点新建事件",onClick:()=>j(o),children:i.jsx(Zc,{className:"size-3.5"})}),n!==null&&!L&&i.jsx(pe,{type:"button",variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground hover:text-destructive",title:"移入回收站","aria-label":`移入回收站「${n.name}」`,onClick:()=>S(n),children:i.jsx(Ql,{className:"size-3.5"})}),i.jsx(pe,{type:"button",variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground","aria-expanded":!l,"aria-label":`${l?"展开":"折叠"}「${te}」组`,onClick:v,children:i.jsx(Um,{className:Qe("size-4 transition-transform duration-200",!l&&"rotate-90")})})]})]})]}),!l&&i.jsx("div",{className:"flex flex-col gap-2",children:r.map(A=>{const D=k(A.id);return i.jsx(IM,{ev:A,occursCount:m,hasOccursData:g,dragging:c!==null&&c.kind==="event"&&c.id===A.id,busy:d,showInsertBefore:D.before,showInsertAfter:D.after,eventDrag:T,onDetail:C,onEdit:H,onDelete:M},A.id)})})]})}function UM({timepoints:n,events:o,allEvents:r,occursAtEdges:l,occursCount:c,hasOccursData:d,onMoveTimepoint:m,onMoveEvent:g,onMoveEventTo:b,onRenameTimepoint:p,onDeleteTimepoint:v,onAddEventAt:x,onDetail:S,onEdit:j,onDelete:E}){const _=h.useMemo(()=>Bv(n,o,l),[n,o,l]),O=h.useMemo(()=>Bv(n,r,l),[n,r,l]),N=h.useMemo(()=>[..._.groups.map(Y=>({timepoint:Y.timepoint,groupId:Y.timepoint.id,events:Y.events})),..._.ungrouped.length>0?[{timepoint:null,groupId:"",events:_.ungrouped}]:[]],[_]),T=h.useMemo(()=>{const Y=new Map;for(const q of _.groups)for(const P of q.events)Y.set(P.id,q.timepoint.id);for(const q of _.ungrouped)Y.set(q.id,"");return Y},[_]),k=h.useMemo(()=>n.map(Y=>Y.id),[n]),[C,H]=h.useState(new Set),[M,L]=h.useState(null),[w,J]=h.useState(null),[oe,ie]=h.useState(!1);function te(Y){const q=Y.currentTarget.getBoundingClientRect();return Y.clientY<q.top+q.height/2?"before":"after"}function Q(Y){return Y===""?-1:O.groups.findIndex(q=>q.timepoint.id===Y)}function G(Y,q,P){Y.preventDefault(),Y.dataTransfer.dropEffect="move";const me=te(Y);J(re=>re!==null&&re.kind==="event"&&re.at===P.at&&re.side===me&&re.groupId===q&&re.anchorId===P.anchorId?re:{kind:"event",at:P.at,side:me,groupId:q,anchorId:P.anchorId})}function K(Y,q){q.timepoint!==null&&(Y.dataTransfer.setData("text/plain",q.timepoint.id),Y.dataTransfer.effectAllowed="move",L({kind:"timepoint",id:q.timepoint.id}),J(null))}function A(Y,q){Y.dataTransfer.setData("text/plain",q.id),Y.dataTransfer.effectAllowed="move",L({kind:"event",id:q.id}),J(null)}function D(){L(null),J(null)}function B(Y,q){const P=M;if(P===null||P.kind==="timepoint"&&q.timepoint===null)return;Y.preventDefault(),Y.dataTransfer.dropEffect="move";const me=te(Y);if(P.kind==="timepoint"){J(de=>de!==null&&de.kind==="timepoint"&&de.side===me&&de.groupId===q.groupId?de:{kind:"timepoint",side:me,groupId:q.groupId});return}const re=q.events.length===0?null:me==="before"?q.events[0].id:q.events[q.events.length-1].id;G(Y,q.groupId,{at:"group",anchorId:re})}function I(Y,q,P){const me=M;if(me!==null&&!(me.kind==="timepoint"&&P.timepoint===null)){if(Y.preventDefault(),Y.dataTransfer.dropEffect="move",me.kind==="timepoint"){const re=te(Y);J(de=>de!==null&&de.kind==="timepoint"&&de.side===re&&de.groupId===P.groupId?de:{kind:"timepoint",side:re,groupId:P.groupId});return}G(Y,P.groupId,{at:"row",anchorId:q.id})}}async function V(Y,q,P){const me=M;if(me===null||me.kind!=="event"||oe)return;if(Y.preventDefault(),P===me.id){D();return}const re=te(Y),de=kM(O.groups,O.ungrouped,Q(q.groupId),re,me.id),Le=T.get(me.id)??"";ie(!0);try{q.groupId===Le?await g(me.id,de):await b(me.id,q.groupId===""?null:q.groupId,de)}finally{ie(!1),D()}}function z(Y,q){const P=M;if(P===null||oe)return;if(Y.preventDefault(),P.kind==="timepoint"){if(q.timepoint===null)return;if(q.groupId===P.id){D();return}const de=te(Y),Le=Dm(k,{kind:de,id:q.groupId},P.id);ie(!0),m(P.id,Le).finally(()=>{ie(!1),D()});return}const me=te(Y),re=q.events.length===0?null:me==="before"?q.events[0].id:q.events[q.events.length-1].id;V(Y,q,re)}function Z(Y,q,P){const me=M;if(me!==null&&me.kind==="timepoint"){z(Y,P);return}V(Y,P,q.id)}function F(Y){H(q=>{const P=new Set(q);return P.has(Y)?P.delete(Y):P.add(Y),P})}return i.jsxs("div",{className:"relative flex flex-col gap-2",children:[i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 left-[11px] top-0 w-0.5 bg-border"}),N.map(Y=>{const q=w!==null&&(w.kind==="timepoint"&&w.groupId===Y.groupId||w.kind==="event"&&w.at==="group"&&w.groupId===Y.groupId),P=q&&w!==null&&w.side==="before",me=q&&w!==null&&w.side==="after",re=w!==null&&w.kind==="event"&&w.at==="row"&&w.side==="before",de=w!==null&&w.kind==="event"&&w.at==="row"&&w.side==="after",Le={onDragStart:A,onDragEnd:D,onDragOver:(De,we)=>I(De,we,Y),onDrop:(De,we)=>Z(De,we,Y)};return i.jsx(BM,{timepoint:Y.timepoint,groupId:Y.groupId,events:Y.events,collapsed:C.has(Y.groupId),dragSource:M,busy:oe,occursCount:c,hasOccursData:d,showInsertBefore:P,showInsertAfter:me,onToggleCollapse:()=>F(Y.groupId),onRename:p,onDeleteTimepoint:v,onAddEventAt:x,onDragStart:De=>K(De,Y),onDragEnd:D,onDragOver:De=>B(De,Y),onDrop:De=>z(De,Y),eventDrag:Le,eventInsertLines:De=>({before:re&&w!==null&&w.kind==="event"&&w.anchorId===De,after:de&&w!==null&&w.kind==="event"&&w.anchorId===De}),onDetail:S,onEdit:j,onDelete:E},Y.groupId===""?"__ungrouped__":Y.groupId)})]})}function Im({suggestions:n,visible:o,onPick:r}){return!o||n.length===0?null:i.jsx("div",{className:"mt-1 overflow-hidden rounded-md border border-border bg-card",children:n.map(l=>i.jsx("button",{type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>r(l),className:"block w-full cursor-pointer px-2.5 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l},l))})}const Sa={name:"",description:"",tagsInput:""};function HM(){const[n,o]=h.useState(null),[r,l]=h.useState(null),[c,d]=h.useState(!1),[m,g]=h.useState(null),[b,p]=h.useState(0);Ms(()=>p(Te=>Te+1));const[v,x]=h.useState([]),[S,j]=h.useState(!1),[E,_]=h.useState([]),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,H]=h.useState([]),[M,L]=h.useState(!1),[w,J]=h.useState(Sa),[oe,ie]=h.useState(null),[te,Q]=h.useState(""),[G,K]=h.useState(null),[A,D]=h.useState(!1),[B,I]=h.useState(!1),[V,z]=h.useState(""),[Z,F]=h.useState(null),[Y,q]=h.useState(!1),[P,me]=h.useState(null),[re,de]=h.useState(null),[Le,De]=h.useState(null),[we,Be]=h.useState(!1),ge=ze(Te=>Te.config),le=ze(Te=>Te.outline),Ye=oo(le?.children??[]),ke=St(Te=>Te.sendMessage);h.useEffect(()=>{let Te=!1;return d(!0),g(null),j(!1),N(!1),Promise.allSettled([ls("timepoint",{}).then(Se=>{Te||o(Se.items)}).catch(Se=>{Te||(o(null),g(Se instanceof _e?Se.code:ut))}),ls("event",{}).then(Se=>{Te||(l(Se.items),H(Ic(Se.items)),Se.items.length>=Se.limit&&ls("event",{limit:200}).then(Fe=>{Te||H(Ic(Fe.items))}).catch(()=>{}))}).catch(Se=>{Te||(l(null),g(Se instanceof _e?Se.code:ut))}),br({source_type:"timepoint",relation_type:"occurs_at",depth:1}).then(Se=>{Te||x(Se.relations)}).catch(()=>{Te||j(!0)}),br({source_type:"event",relation_type:"occurs_in",depth:1}).then(Se=>{Te||_(Se.relations)}).catch(()=>{Te||N(!0)})]).finally(()=>{Te||d(!1)}),()=>{Te=!0}},[b]),h.useEffect(()=>{ze.getState().outline===null&&ze.getState().config!==null&&ze.getState().loadOutline()},[]);async function Ae(Te){Te.preventDefault();const Se=V.trim();if(!Se){F("请输入名称");return}q(!0),F(null);try{await Uc("timepoint",{name:Se}),Ce.getState().showToast(`已创建时间点《${Se}》`),I(!1),z(""),p(Fe=>Fe+1)}catch(Fe){F(Fe instanceof _e?Fe.message:"创建失败,请重试")}finally{q(!1)}}async function ve(Te){Te.preventDefault();const Se=w.name.trim();if(!Se){K("请输入名称");return}D(!0),K(null);try{const Fe={};w.description.trim()!==""&&(Fe.description=w.description.trim());const Ot=wS(w.tagsInput);Ot.length>0&&(Fe.tags=Ot);const Pt=await Uc("event",{name:Se,data:Fe});if(oe!==null)try{await yr(LM(oe,Pt.id))}catch(ne){Ce.getState().showToast(`已创建事件《${Se}》,但挂载到时间点失败:${ne instanceof _e?ne.message:"未知错误"}`,"error"),L(!1),J(Sa),ie(null),Q(""),p(be=>be+1);return}if(te!=="")try{await yr({source_type:"event",source_id:Pt.id,target_type:"outline_node",target_id:te,relation_type:"occurs_in"})}catch(ne){Ce.getState().showToast(`已创建事件《${Se}》,但节点关联失败:${ne instanceof _e?ne.message:"未知错误"}`,"error"),L(!1),J(Sa),ie(null),Q(""),p(be=>be+1);return}Ce.getState().showToast(`已创建事件《${Se}》`),L(!1),J(Sa),ie(null),Q(""),p(ne=>ne+1)}catch(Fe){K(Fe instanceof _e?Fe.message:"创建失败,请重试")}finally{D(!1)}}function Ue(Te){const Se=Te.summary;me(Te),De(null),de({name:Te.name,description:typeof Se.description=="string"?Se.description:"",tagsInput:CS(Se.tags)})}async function Pe(){const Te=P,Se=re;if(!(!Te||!Se||we)){Be(!0),De(null);try{const Fe=RS({name:Te.name,data:Te.summary},Se);if(Fe===null){Ce.getState().showToast("没有变更"),me(null);return}await xr("event",Te.id,Fe),Ce.getState().showToast("已保存"),me(null),p(Ot=>Ot+1)}catch(Fe){De(Fe instanceof _e?Fe.message:"保存失败,请重试")}finally{Be(!1)}}}async function Ie(Te){try{const Se=await Jc(Te.kind,Te.entity.id),Fe=[];Se.cascaded.relations>0&&Fe.push(`${Se.cascaded.relations} 条关联`),Se.cascaded.deltas>0&&Fe.push(`${Se.cascaded.deltas} 条变更记录`),Ce.getState().showToast(`已移入回收站,可随时还原${Fe.length>0?`(含 ${Fe.join("、")})`:""}`),p(Ot=>Ot+1)}catch(Se){Ce.getState().showToast(Se instanceof _e?Se.message:"删除失败,请重试","error")}}async function ee(Te,Se){try{await Vw(Te,{order:Se}),Ce.getState().showToast("已调整时间点顺序")}catch(Fe){Ce.getState().showToast(Fe instanceof _e?`排序失败:${Fe.message}`:"排序失败,请重试","error")}finally{p(Fe=>Fe+1)}}async function U(Te,Se){try{await Yw(Te,{order:Se}),Ce.getState().showToast("已调整事件顺序")}catch(Fe){Ce.getState().showToast(Fe instanceof _e?`排序失败:${Fe.message}`:"排序失败,请重试","error")}finally{p(Fe=>Fe+1)}}async function $(Te,Se,Fe){try{await b0(Te,{timepoint_id:Se,order:Fe}),Ce.getState().showToast(Se===null?"已移至未挂载区":"已调整事件挂载与顺序")}catch(Ot){Ce.getState().showToast(Ot instanceof _e?`操作失败:${Ot.message}`:"操作失败,请重试","error")}finally{p(Ot=>Ot+1)}}async function je(Te,Se){try{await xr("timepoint",Te,{name:Se}),Ce.getState().showToast("已重命名"),p(Fe=>Fe+1)}catch(Fe){Ce.getState().showToast(Fe instanceof _e?`重命名失败:${Fe.message}`:"重命名失败,请重试","error")}}function xe(Te){J(Sa),Q(""),K(null),ie(Te),L(!0)}function ae(){J(Sa),Q(""),K(null),ie(null),L(!0)}function Re(){ge!==null&&ke("请按时间标签的语义先后顺序对时间轴时间点排序,并使用 propose_reorder_timepoints 工具生成排序提案。")}const He=r===null?[]:Ic(r),We=r===null?null:MM(r,T),pt=Te=>O?0:E.filter(Se=>Se.sourceId===Te).length,_t=!O,mt=zm(w.tagsInput,C),Tt=re===null?[]:zm(re.tagsInput,C);function Rt(Te){J(Se=>({...Se,tagsInput:Lm(Se.tagsInput,Te)}))}function zt(Te){de(Se=>Se&&{...Se,tagsInput:Lm(Se.tagsInput,Te)})}return i.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[i.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"时间轴"}),i.jsx("span",{className:Qe("ml-auto",!ge&&"cursor-not-allowed"),title:ge?void 0:"请先打开项目",children:i.jsxs(pe,{type:"button",variant:"outline",size:"sm",disabled:!ge,onClick:Re,"aria-label":"AI 排序",children:[i.jsx(Bj,{className:"size-3.5"}),"AI 排序"]})}),i.jsx(pe,{type:"button",variant:"outline",onClick:ae,children:"+ 新建事件"}),i.jsx(pe,{type:"button",onClick:()=>I(!0),children:"+ 新建时间点"})]}),r!==null&&r.length>0&&i.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>k(null),className:Qe("rounded-full border px-2.5 py-0.5 text-xs transition-colors",T===null?"border-primary bg-primary text-primary-foreground":"border-border bg-muted text-muted-foreground hover:text-foreground"),children:"全部"}),He.map(Te=>i.jsx("button",{type:"button",onClick:()=>k(Se=>Se===Te?null:Te),className:Qe("rounded-full border px-2.5 py-0.5 text-xs transition-colors",T===Te?"border-primary bg-primary text-primary-foreground":"border-border bg-muted text-muted-foreground hover:text-foreground"),children:Te},Te))]}),i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[m!==null&&i.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[m===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"时间轴加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>p(Te=>Te+1),children:"重试"})]}),c&&(n===null||r===null)&&m===null&&i.jsx("div",{className:"space-y-2",children:Array.from({length:4},(Te,Se)=>i.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2.5",children:[i.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-6 w-6 animate-pulse rounded bg-muted"})]},Se))}),!c&&n!==null&&r!==null&&n.length===0&&r.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有时间点。先定义一个时间标签点(如「第二天黄昏」),再在其中挂载事件。"}),i.jsx(pe,{className:"mt-4",type:"button",onClick:()=>I(!0),children:"+ 新建时间点"})]}),n!==null&&r!==null&&We!==null&&!(T!==null&&We.length===0)&&i.jsx(UM,{timepoints:n,events:We,allEvents:r,occursAtEdges:S?[]:v,occursCount:pt,hasOccursData:_t,onMoveTimepoint:ee,onMoveEvent:U,onMoveEventTo:$,onRenameTimepoint:je,onAddEventAt:xe,onDetail:Te=>Tn(`/timeline/${Te.id}`),onEdit:Ue,onDelete:Te=>{Ie({kind:"event",entity:Te})},onDeleteTimepoint:Te=>{Ie({kind:"timepoint",entity:Te})}}),!c&&r!==null&&r.length>0&&We!==null&&We.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-8 text-center text-sm text-muted-foreground",children:["没有匹配「",T,"」的事件"]})]}),i.jsx(Ts,{open:B,onOpenChange:Te=>!Te&&I(!1),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsx(Os,{children:"新建时间点"})}),i.jsxs("form",{id:"create-timepoint-form",onSubmit:Ae,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填,时间标签文本)"}),i.jsx(Dt,{value:V,onChange:Te=>z(Te.target.value),placeholder:"如:第二天黄昏",maxLength:100,autoFocus:!0})]}),Z&&i.jsx("p",{className:"text-sm text-destructive",children:Z})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>I(!1),disabled:Y,children:"取消"}),i.jsx(pe,{type:"submit",form:"create-timepoint-form",disabled:Y,children:"创建"})]})]})}),i.jsx(Ts,{open:M,onOpenChange:Te=>!Te&&L(!1),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsx(Os,{children:oe!==null?"在此时间点新建事件(自动挂载)":"新建事件(不挂载,入未挂载区)"})}),i.jsxs("form",{id:"create-event-form",onSubmit:ve,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:w.name,onChange:Te=>J(Se=>({...Se,name:Te.target.value})),placeholder:"如:主角踏入宗门",maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:w.description,onChange:Te=>J(Se=>({...Se,description:Te.target.value})),rows:2,placeholder:"事件发生了什么",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:w.tagsInput,onChange:Te=>J(Se=>({...Se,tagsInput:Te.target.value})),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Im,{suggestions:mt,visible:w.tagsInput.trim()!=="",onPick:Rt})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"关联大纲节点(选填,可空)"}),i.jsx(PM,{value:te,onChange:Q,nodeOptions:Ye})]}),G&&i.jsx("p",{className:"text-sm text-destructive",children:G})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>L(!1),disabled:A,children:"取消"}),i.jsx(pe,{type:"submit",form:"create-event-form",disabled:A,children:"创建"})]})]})}),P&&re&&i.jsx(Ts,{open:!0,onOpenChange:Te=>!Te&&!we&&me(null),children:i.jsxs(ws,{className:"sm:max-w-md",children:[i.jsx(Cs,{children:i.jsxs(Os,{children:["编辑事件《",P.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:re.name,onChange:Te=>de(Se=>Se&&{...Se,name:Te.target.value}),maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:re.description,onChange:Te=>de(Se=>Se&&{...Se,description:Te.target.value}),rows:2,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:re.tagsInput,onChange:Te=>de(Se=>Se&&{...Se,tagsInput:Te.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Im,{suggestions:Tt,visible:re.tagsInput.trim()!=="",onPick:zt})]}),Le&&i.jsx("p",{className:"text-sm text-destructive",children:Le})]}),i.jsxs(Rs,{children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>me(null),disabled:we,children:"取消"}),i.jsx(pe,{type:"button",onClick:()=>{Pe()},disabled:we,children:we?"保存中…":"保存"})]})]})})]})}function PM({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Qe("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}const _S=h.createContext(void 0);function ti(n){const o=h.useContext(_S);if(o===void 0&&!n)throw new Error(En(47));return o}function YM(){return{...Rp(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const VM={...kp,disabled:qe(n=>n.disabled),instantType:qe(n=>n.instantType),openMethod:qe(n=>n.openMethod),openChangeReason:qe(n=>n.openChangeReason),modal:qe(n=>n.modal),focusManagerModal:qe(n=>n.focusManagerModal),stickIfOpen:qe(n=>n.stickIfOpen),titleElementId:qe(n=>n.titleElementId),descriptionElementId:qe(n=>n.descriptionElementId),openOnHover:qe(n=>n.openOnHover),closeDelay:qe(n=>n.closeDelay),hasViewport:qe(n=>n.hasViewport)};class Xp extends pu{constructor(o,r,l=!1){const c={...YM(),...o},d=new ei;c.open&&o?.mounted===void 0&&(c.mounted=!0),c.floatingRootContext=D1(d,r,l),super(c,{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:h.createRef(),beforeContentFocusGuardRef:h.createRef(),stickIfOpenTimeout:new ms,triggerElements:d},VM)}setOpen=(o,r)=>{const l=r.reason===fn,c=r.reason===vr&&r.event.detail===0,d=!o&&(r.reason===ru||r.reason==null),m=k1(r),g=this.select("activeTriggerId");if(!o&&r.reason===z0&&r.trigger==null&&g!=null&&(r.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,r),r.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,r);const b=()=>{const p={open:o,openChangeReason:r.reason};jp(p,o,r.trigger,m()),this.update(p)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(o1,()=>{this.set("stickIfOpen",!1)}),ao.flushSync(b)):b(),c||d?this.set("instantType",c?"click":"dismiss"):r.reason===Sr?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(o,r){const{store:l,internalStore:c}=O1(o,(d,m)=>new Xp(r,d,m));return h.useEffect(()=>c?.disposeEffect(),[c]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function Uv({props:n}){const{children:o,open:r,defaultOpen:l=!1,onOpenChange:c,onOpenChangeComplete:d,modal:m=!1,handle:g,triggerId:b,defaultTriggerId:p=null}=n,v=Xp.useStore(g?.store,{modal:m,open:l,openProp:r,activeTriggerId:p,triggerIdProp:b});_1(v,r,l,p),v.useControlledProp("openProp",r),v.useControlledProp("triggerIdProp",b);const x=v.useState("open"),S=v.useState("mounted"),j=v.useState("payload"),E=co()!=null;v.useContextCallback("onOpenChange",c),v.useContextCallback("onOpenChangeComplete",d),A1(v,x),Tp(v);const{forceUnmount:_}=wp(x,v,()=>{v.update({stickIfOpen:!0,openChangeReason:null})});v.useSyncedValues({modal:m,nested:E}),h.useEffect(()=>{x||v.context.stickIfOpenTimeout.clear()},[v,x]);const O=h.useCallback(()=>{v.setOpen(!1,jt(ap))},[v]);h.useImperativeHandle(n.actionsRef,()=>({unmount:_,close:O}),[_,O]);const N=x||S,T=h.useMemo(()=>({store:v}),[v]);return i.jsxs(_S.Provider,{value:T,children:[N&&i.jsx(GM,{store:v,modal:m}),typeof o=="function"?o({payload:j}):o]})}function FM(n){return ti(!0)?i.jsx(Uv,{props:n}):i.jsx(m1,{children:i.jsx(Uv,{props:n})})}function GM({store:n,modal:o}){const r=n.useState("floatingRootContext"),l=Ep(r,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),c=l.reference??Vt,d=l.trigger??Vt,m=h.useMemo(()=>to(gu,l.floating),[l.floating]);return Cp(n,{activeTriggerProps:c,inactiveTriggerProps:d,popupProps:m}),null}const qM=300,$M=h.forwardRef(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,handle:b,payload:p,openOnHover:v=!1,delay:x=qM,closeDelay:S=0,id:j,...E}=o,_=ti(!0),O=b?.store??_?.store;if(!O)throw new Error(En(74));const N=Rr(j),T=O.useState("isTriggerActive",N),k=O.useState("floatingRootContext"),C=O.useState("isOpenedByTrigger",N),H=O.useState("triggerPopupId",N),M=h.useRef(null),{registerTrigger:L,isMountedByThisTrigger:w}=M1(N,M,O,{payload:p,disabled:m,openOnHover:v,closeDelay:S}),J=O.useState("openChangeReason"),oe=O.useState("stickIfOpen"),ie=O.useState("openMethod"),te=O.useState("focusManagerModal"),Q=U1(k,{enabled:!m&&k!=null&&v&&(ie!=="touch"||J!==vr),mouseOnly:!0,move:!1,handleClose:H1(),restMs:x,delay:{close:S},triggerElementRef:M,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),G=p1(k,{enabled:k!=null,stickIfOpen:oe}),K=Z1(()=>O.select("open"),q=>{O.set("openMethod",q)}),A=O.useState("triggerProps",w),{getButtonProps:D,buttonRef:B}=Zl({disabled:m,native:g}),I={open(q){return q&&J===vr?gm.open(q):eC.open(q)}},{preFocusGuardRef:V,handlePreFocusGuardFocus:z,handleFocusTargetFocus:Z}=W1(O,M),Y=mn("button",o,{state:{disabled:m,open:C},ref:[B,r,L,M],props:[G.reference,Q,A,K,{[r1]:"",id:N,"aria-haspopup":"dialog","aria-expanded":C,"aria-controls":H},E,D],stateAttributesMapping:I});return w&&!te?i.jsxs(h.Fragment,{children:[i.jsx(Ho,{ref:V,onFocus:z}),i.jsx(h.Fragment,{children:Y},N),i.jsx(Ho,{ref:O.context.triggerFocusTargetRef,onFocus:Z})]}):i.jsx(h.Fragment,{children:Y},N)}),MS=h.createContext(void 0);function XM(){const n=h.useContext(MS);if(n===void 0)throw new Error(En(45));return n}const KM=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=ti();return d.useState("mounted")||l?i.jsx(MS.Provider,{value:l,children:i.jsx(xp,{ref:r,...c})}):null}),AS=h.createContext(void 0);function QM(){const n=h.useContext(AS);if(!n)throw new Error(En(46));return n}const ZM=h.forwardRef(function(o,r){const{render:l,className:c,style:d,anchor:m,positionMethod:g="absolute",side:b="bottom",align:p="center",sideOffset:v=0,alignOffset:x=0,collisionBoundary:S="clipping-ancestors",collisionPadding:j=5,arrowPadding:E=5,sticky:_=!1,disableAnchorTracking:O=!1,collisionAvoidance:N=a1,...T}=o,{store:k}=ti(),C=XM(),H=yp(),M=k.useState("floatingRootContext"),L=k.useState("mounted"),w=k.useState("open"),J=k.useState("openChangeReason"),oe=k.useState("activeTriggerElement"),ie=k.useState("modal"),te=k.useState("openMethod"),Q=k.useState("positionerElement"),G=k.useState("instantType"),K=k.useState("transitionStatus"),A=k.useState("hasViewport"),D=h.useRef(null),B=up(Q,!1,!1),I=q1({anchor:m,floatingRootContext:M,positionMethod:g,mounted:L,side:b,sideOffset:v,align:p,alignOffset:x,arrowPadding:E,collisionBoundary:S,collisionPadding:j,sticky:_,disableAnchorTracking:O,keepMounted:C,nodeId:H,collisionAvoidance:N,adaptiveOrigin:A?F1:void 0}),V=M.useState("domReferenceElement");Ke(()=>{const Y=V,q=D.current;if(Y&&(D.current=Y),q&&Y&&Y!==q){k.set("instantType",void 0);const P=new AbortController;return B(()=>{k.set("instantType","trigger-change")},P.signal),()=>{P.abort()}}},[V,B,k]),K1(w&&ie===!0&&J!==fn,te==="touch",Q,oe);const z=h.useCallback(Y=>{k.set("positionerElement",Y)},[k]),Z={open:w,side:I.side,align:I.align,anchorHidden:I.anchorHidden,instant:G},F=$1(o,Z,{styles:I.positionerStyles,transitionStatus:K,props:T,refs:[r,z],hidden:!L,inert:!w});return i.jsxs(AS.Provider,{value:I,children:[L&&ie===!0&&J!==fn&&i.jsx(zp,{ref:k.context.internalBackdropRef,inert:Dp(!w),cutout:oe}),i.jsx(f1,{id:H,children:F})]})}),JM=h.createContext(void 0);function WM(){const[n,o]=h.useState(0),r=st(()=>(o(c=>c+1),()=>{o(c=>Math.max(0,c-1))}));return{context:h.useMemo(()=>({register:r}),[r]),hasClosePart:n>0}}function eA(n){const{value:o,children:r}=n;return i.jsx(JM.Provider,{value:o,children:r})}const tA={...Jl,...su},nA=h.forwardRef(function(o,r){const{render:l,className:c,style:d,initialFocus:m,finalFocus:g,...b}=o,{store:p}=ti(),v=QM(),x=P1()!=null,{context:S,hasClosePart:j}=WM(),E=p.useState("open"),_=p.useState("openMethod"),O=p.useState("instantType"),N=p.useState("transitionStatus"),T=p.useState("popupProps"),k=p.useState("titleElementId"),C=p.useState("descriptionElementId"),H=p.useState("modal"),M=p.useState("mounted"),L=p.useState("openChangeReason"),w=p.useState("activeTriggerElement"),J=p.useState("floatingRootContext"),oe=J.useState("floatingId"),ie=p.useState("disabled"),te=p.useState("openOnHover"),Q=p.useState("closeDelay"),G=b.id??oe;iu({open:E,ref:p.context.popupRef,onComplete(){E&&p.context.onOpenChangeComplete?.(!0)}}),B1(J,{enabled:te&&!ie,closeDelay:Q});const K=m===void 0?R1(p.context.popupRef):m,A=H!==!1&&j;p.useSyncedValue("focusManagerModal",A);const D=h.useCallback(V=>{p.set("popupElement",V)},[p]),B={open:E,side:v.side,align:v.align,instant:O,transitionStatus:N},I=mn("div",o,{state:B,ref:[r,p.context.popupRef,D],props:[T,{id:G,role:"dialog",...gu,"aria-labelledby":k,"aria-describedby":C,onKeyDown(V){x&&Mp.has(V.key)&&V.stopPropagation()}},Ap(N),b],stateAttributesMapping:tA});return i.jsx(Sp,{context:J,openInteractionType:_,modal:A,disabled:!M||L===fn,initialFocus:K,returnFocus:g,restoreFocus:"popup",previousFocusableElement:Yt(w)?w:void 0,nextFocusableElement:p.context.triggerFocusTargetRef,beforeContentFocusGuardRef:p.context.beforeContentFocusGuardRef,children:i.jsx(eA,{value:S,children:I})})});function sA({...n}){return i.jsx(FM,{"data-slot":"popover",...n})}function oA({...n}){return i.jsx($M,{"data-slot":"popover-trigger",...n})}function rA({align:n="start",alignOffset:o=0,side:r="bottom",sideOffset:l=8,className:c,...d}){return i.jsx(KM,{children:i.jsx(ZM,{className:"isolate z-50 outline-none",align:n,alignOffset:o,side:r,sideOffset:l,children:i.jsx(nA,{"data-slot":"popover-content",className:Qe("z-50 min-w-64 origin-(--transform-origin) rounded-lg bg-popover p-3 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",c),...d})})})}function aA({id:n}){const[o,r]=h.useState(null),[l,c]=h.useState(!1),[d,m]=h.useState(!1),[g,b]=h.useState(null),[p,v]=h.useState(null),[x,S]=h.useState(!1),[j,E]=h.useState(null),[_,O]=h.useState(!1),[N,T]=h.useState(""),[k,C]=h.useState(null),[H,M]=h.useState(!1),[L,w]=h.useState(null),[J,oe]=h.useState([]),[ie,te]=h.useState(null),[Q,G]=h.useState(null),[K,A]=h.useState(!1),[D,B]=h.useState(!1),[I,V]=h.useState(null);async function z(){try{const ge=await ls("event",{limit:200});oe(Ic(ge.items))}catch{}}async function Z(){A(!1);try{const[ge,le]=await Promise.all([ls("timepoint",{}),ls("event",{limit:200})]);te(ge.items),G(le.items)}catch{te(null),G(null),A(!0)}}h.useEffect(()=>{z(),Z()},[]);const F=ze(ge=>ge.outline),Y=oo(F?.children??[]);async function q(){c(!0),b(null),m(!1);try{const ge=await fr("event",n);r(ge),v(AM(ge))}catch(ge){r(null),v(null),ge instanceof _e&&ge.code==="ENTITY_NOT_FOUND"?m(!0):b(ge instanceof _e?ge.code:ut)}finally{c(!1)}}h.useEffect(()=>{q()},[n]),Ms(()=>{q(),z(),Z()}),h.useEffect(()=>{ze.getState().outline===null&&ze.getState().config!==null&&ze.getState().loadOutline()},[]);async function P(){if(!o||!p||x)return;const ge=RS({name:o.name,data:o.data},p);if(ge===null){Ce.getState().showToast("没有变更");return}S(!0),E(null);try{await xr("event",n,ge),Ce.getState().showToast("已保存"),await q()}catch(le){if(le instanceof _e&&le.code==="ENTITY_NOT_FOUND"){m(!0);return}E(le instanceof _e?le.message:"保存失败,请重试")}finally{S(!1)}}async function me(ge){if(!o||D||!ie||!Q)return;const le=lm(o.relations,n);if(ge===(le??""))return;const Ye=Q.findIndex(Ae=>Ae.id===n),ke=Ye===-1?Q.length:Ye;B(!0),V(null);try{await b0(n,{timepoint_id:ge===""?null:ge,order:ke}),Ce.getState().showToast(ge===""?"已移出挂载":"已更新挂载时间点"),await q()}catch(Ae){if(Ae instanceof _e&&Ae.code==="ENTITY_NOT_FOUND"){m(!0);return}V(Ae instanceof _e?Ae.message:"挂载保存失败,请重试")}finally{B(!1)}}async function re(){if(!(N===""||H)){M(!0),C(null);try{await yr(zM(n,N)),Ce.getState().showToast("已关联大纲节点"),O(!1),await q()}catch(ge){if(ge instanceof _e&&ge.code==="RELATION_EXISTS"){C("这条关系已经存在");return}C(ge instanceof _e?ge.message:"关联失败,请重试")}finally{M(!1)}}}async function de(){if(L)try{await Wc(L.id),Ce.getState().showToast("已取消关联"),w(null),await q()}catch(ge){throw ge}}async function Le(){if(o)try{const ge=await Jc("event",n),le=[];ge.cascaded.relations>0&&le.push(`${ge.cascaded.relations} 条关联`),ge.cascaded.deltas>0&&le.push(`${ge.cascaded.deltas} 条变更记录`),Ce.getState().showToast(`已移入回收站,可随时还原${le.length>0?`(含 ${le.join("、")})`:""}`),Tn("/timeline")}catch(ge){Ce.getState().showToast(ge instanceof _e?ge.message:"删除失败,请重试","error")}}if(d)return i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"该事件不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-border px-4 py-1.5 text-sm text-muted-foreground hover:bg-muted",children:"去回收站"}),i.jsx(pe,{variant:"outline",type:"button",onClick:()=>Tn("/timeline"),children:"返回列表"})]})]})});const De=o===null?[]:DM(o.relations,n),we=p===null?[]:zm(p.tagsInput,J);function Be(ge){v(le=>le&&{...le,tagsInput:Lm(le.tagsInput,ge)})}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(qp,{items:[{label:"时间轴",href:"/timeline"},{label:o?.name??"…"}]}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:o?.name??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",onClick:()=>{P()},disabled:!o||x,children:x?"保存中…":"保存"}),i.jsx(pe,{variant:"outline",type:"button",disabled:!o,className:"text-destructive hover:bg-destructive/10",onClick:()=>{Le()},children:"移入回收站"})]})]}),o&&i.jsxs("p",{className:"mb-4 text-xs text-muted-foreground",children:["创建于 ",is(o.createdAt)," · 更新于 ",is(o.updatedAt)]}),l&&!o&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx("div",{className:"space-y-3 rounded-md border border-border p-4",children:Array.from({length:5},(ge,le)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},le))}),i.jsx("div",{className:"space-y-3 rounded-md border border-border p-4",children:Array.from({length:3},(ge,le)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},le))})]}),!l&&!o&&g!==null&&i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:[g===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{q()},children:"重试"})]}),o&&p&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"rounded-md border border-border p-4",children:[i.jsx("h2",{className:"mb-3 text-sm font-semibold text-foreground",children:"基础信息"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:p.name,onChange:ge=>v(le=>le&&{...le,name:ge.target.value}),maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:p.description,onChange:ge=>v(le=>le&&{...le,description:ge.target.value}),rows:3,placeholder:"事件发生了什么",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"挂载时间点"}),ie===null?K?i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:["挂载数据加载失败",i.jsx(pe,{variant:"outline",size:"sm",type:"button",className:"h-6 px-2 text-xs",onClick:()=>{Z()},children:"重试"})]}):i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"}):i.jsxs("select",{value:lm(o.relations,n)??"",onChange:ge=>{me(ge.target.value)},disabled:D,className:Qe("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",lm(o.relations,n)===null&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"未挂载"}),ie.map(ge=>i.jsx("option",{value:ge.id,children:ge.name},ge.id))]}),D&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"保存中…"}),I&&i.jsx("p",{className:"mt-1 text-sm text-destructive",children:I})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:p.tagsInput,onChange:ge=>v(le=>le&&{...le,tagsInput:ge.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Im,{suggestions:we,visible:p.tagsInput.trim()!=="",onPick:Be})]}),j&&i.jsx("p",{className:"text-sm text-destructive",children:j})]})]}),i.jsxs("div",{className:"rounded-md border border-border p-4",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"关联节点(occurs_in)"}),i.jsxs(sA,{open:_,onOpenChange:ge=>{ge?(T(""),C(null),O(!0)):H||O(!1)},children:[i.jsx(oA,{render:i.jsx(pe,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",children:"+ 关联场景/章节"})}),i.jsxs(rA,{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"大纲节点"}),i.jsx(lA,{value:N,onChange:T,nodeOptions:Y,placeholder:"请选择节点"})]}),k&&i.jsx("p",{className:"text-sm text-destructive",children:k}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(pe,{variant:"outline",type:"button",size:"sm",onClick:()=>O(!1),disabled:H,children:"取消"}),i.jsx(pe,{type:"button",size:"sm",onClick:()=>{re()},disabled:H||N==="",children:H?"关联中…":"关联"})]})]})]})]}),De.length===0?i.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"暂无关联节点,新增一个"}):i.jsx("ul",{className:"divide-y divide-border/70",children:De.map(ge=>i.jsxs("li",{className:"flex items-center gap-2 py-2 text-sm",children:[i.jsx("button",{type:"button",onClick:()=>Tn(`/outline/${ge.targetId}`),title:"跳转大纲定位",className:"min-w-0 flex-1 truncate rounded-md border border-border px-1.5 py-0.5 text-left text-foreground hover:bg-muted hover:text-foreground",children:ge.targetName??ge.targetId}),i.jsx(pe,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>w(ge),children:"取消关联"})]},ge.id))})]})]}),L&&i.jsx(Oa,{title:"取消关联",description:`取消《${L.targetName??L.targetId}》与事件的关联?物理删除不可恢复,可重新建立。`,confirmLabel:"取消关联",danger:!0,onConfirm:de,onClose:()=>w(null)})]})}function lA({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Qe("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function iA(n,o){const r=[];return n>0&&r.push(`${n} 条关系`),o>0&&r.push(`${o} 条变更记录`),r.length>0?`已还原,连带恢复 ${r.join("、")}`:"已还原"}function cA(n){return n>0?`已还原(含 ${n} 个子节点)`:"已还原"}function uA(n){return/软删祖先\s+([^\s,,]+)/.exec(n)?.[1]??null}const Hv={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},dA={volume:"卷",chapter:"章",scene:"场"};function Pv({label:n}){return i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:n})}function fA(){const[n,o]=h.useState(null),[r,l]=h.useState(!1),[c,d]=h.useState(null),[m,g]=h.useState(0);Ms(()=>g(C=>C+1));const[b,p]=h.useState(null),[v,x]=h.useState(null);h.useEffect(()=>{let C=!1;return l(!0),d(null),Bw().then(H=>{C||o(H)}).catch(H=>{C||d(H instanceof _e?H.code:ut)}).finally(()=>{C||l(!1)}),()=>{C=!0}},[m]);async function S(){g(C=>C+1)}function j(C){return C instanceof _e&&(C.code==="ENTITY_NOT_FOUND"||C.code==="OUTLINE_NODE_NOT_FOUND")}function E(C){Ce.getState().showError(C instanceof _e?C.code:ut,C instanceof _e?C.message:"操作失败,请重试")}async function _(C){try{const H=await Uw(C.type,C.id);Ce.getState().showToast(iA(H.restoredRelations,H.restoredDeltas)),await S()}catch(H){if(j(H)){Ce.getState().showToast("该对象已不存在","error"),await S();return}E(H)}}async function O(C){x(null);try{const H=await uy(C.id);Ce.getState().showToast(cA(H.restoredChildren)),await S(),ze.getState().loadOutline()}catch(H){if(H instanceof _e&&H.code==="OUTLINE_ANCESTOR_DELETED"){const M=uA(H.message);if(M===null){Ce.getState().showError("OUTLINE_ANCESTOR_DELETED","上级节点也在回收站,请先还原上级");return}x({node:C,ancestorId:M,ancestorName:n?.nodes.find(L=>L.id===M)?.title??M});return}if(j(H)){Ce.getState().showToast("该对象已不存在","error"),await S();return}E(H)}}async function N(){const C=v;if(C)try{await uy(C.ancestorId),ze.getState().loadOutline(),await O(C.node)}catch(H){if(j(H)){Ce.getState().showToast("该对象已不存在","error"),x(null),await S();return}E(H)}}async function T(){if(b)try{b.kind==="entity"?await Hw(b.item.type,b.item.id):(await Pw(b.item.id),ze.getState().loadOutline()),Ce.getState().showToast("已彻底删除"),await S()}catch(C){if(j(C)){Ce.getState().showToast("该对象已不存在","error"),await S();return}throw C}}const k=n!==null&&n.entities.length===0&&n.nodes.length===0;return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"回收站"}),i.jsx(pe,{variant:"outline",type:"button",className:"ml-auto",onClick:()=>{S()},disabled:r,children:"刷新"})]}),i.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"软删对象会保留一段时间,可在此还原,或彻底删除(不可恢复)。"}),c!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[c===ut?"无法连接服务,请确认 ai-editor 服务已启动。":"回收站加载失败,请重试。",i.jsx(pe,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{S()},children:"重试"})]}),r&&n===null&&c===null&&i.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:[0,1].map(C=>i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsx("div",{className:"h-9 animate-pulse bg-muted/60"}),Array.from({length:3},(H,M)=>i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2.5 last:border-0",children:[i.jsx("div",{className:"h-4 w-10 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 flex-1 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-16 animate-pulse rounded bg-muted"})]},M))]},C))}),!r&&k&&i.jsx("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground",children:"回收站是空的"}),n!==null&&!k&&i.jsxs("div",{className:"grid items-start gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"border-b border-border bg-muted/40 px-3 py-2 text-sm font-medium text-foreground",children:["实体 (",n.entities.length,")"]}),n.entities.length===0?i.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无实体"}):i.jsx("ul",{className:"divide-y divide-border/70",children:n.entities.map(C=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2",children:[i.jsx(Pv,{label:Hv[C.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:C.name,children:C.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:gr(C.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>{_(C)},children:"还原"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>p({kind:"entity",item:C}),children:"彻底删除"})]})]},C.id))})]}),i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"border-b border-border bg-muted/40 px-3 py-2 text-sm font-medium text-foreground",children:["大纲节点 (",n.nodes.length,")"]}),n.nodes.length===0?i.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无节点"}):i.jsx("ul",{className:"divide-y divide-border/70",children:n.nodes.map(C=>i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Pv,{label:dA[C.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:C.title,children:C.title}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:gr(C.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(pe,{variant:"outline",size:"xs",type:"button",onClick:()=>{O(C)},children:"还原"}),i.jsx(pe,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>p({kind:"node",item:C}),children:"彻底删除"})]})]}),v?.node.id===C.id&&i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm",children:[i.jsxs("span",{className:"text-destructive",children:["上级节点《",v.ancestorName,"》也在回收站,请先还原上级"]}),i.jsxs(pe,{variant:"outline",size:"xs",type:"button",className:"border-destructive/40 text-destructive hover:bg-destructive/10",onClick:()=>{N()},children:["还原上级《",v.ancestorName,"》"]})]})]},C.id))})]})]}),b&&i.jsx(Oa,{title:"彻底删除",description:b.kind==="entity"?`将彻底删除《${b.item.name}》(${Hv[b.item.type]})及其关联关系、变更记录,不可恢复。`:`将彻底删除《${b.item.title}》及整棵子树、关联关系、变更记录,不可恢复。`,confirmLabel:"确认彻底删除",danger:!0,onConfirm:T,onClose:()=>p(null)})]})}function im(n,o=new Date){const r=new Date(n);if(Number.isNaN(r.getTime()))return n;const l=m=>String(m).padStart(2,"0"),c=`${l(r.getHours())}:${l(r.getMinutes())}:${l(r.getSeconds())}`;return r.getFullYear()===o.getFullYear()?`${l(r.getMonth()+1)}-${l(r.getDate())} ${c}`:`${String(r.getFullYear()).slice(-2)}-${l(r.getMonth()+1)}-${l(r.getDate())} ${c}`}function Yv(n){return!Number.isFinite(n)||n<0?"0 B":n<1024?`${n} B`:n<1024*1024?`${Math.round(n/1024)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}const Vv=[{value:null,label:"关闭"},...rj.map(n=>({value:n,label:`每 ${n} 分钟`}))],Fv={auto:"自动",manual:"手动"};let Rl=0;function mA(){const n=Ce(D=>D.showToast),o=Ce(D=>D.showError),r=Ce(D=>D.notifyDataChanged),l=ze(D=>D.config),c=ze(D=>D.configLoading),d=ze(D=>D.updateConfig),m=ze(D=>D.loadConfig),g=ze(D=>D.loadOutline),[b,p]=h.useState(!1),[v,x]=h.useState(null),[S,j]=h.useState(!1),[E,_]=h.useState(null),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,H]=h.useState(""),[M,L]=h.useState(null),w=h.useRef(M);w.current=M;async function J(){if(ze.getState().config===null)return;const D=++Rl;j(!0),_(null);try{const B=await e2();if(D!==Rl)return;x(B.backups)}catch(B){if(D!==Rl)return;const I=B instanceof _e?B.code:ut;_(I)}finally{D===Rl&&j(!1)}}const oe=l?.id??null,ie=h.useRef(null);h.useEffect(()=>{if(oe===null){Rl++,x(null),_(null),k(null),L(null),ie.current=null;return}ie.current!==oe&&(ie.current=oe,J())},[oe]);async function te(D){if(l===null)return;const B=D==="null"?null:Number(D);if(B!==l.backupFrequencyMinutes){p(!0);try{await d({backup_frequency_minutes:B}),n(B===null?"已关闭自动备份":`自动备份频率已设为每 ${B} 分钟`)}catch(I){I instanceof _e&&I.code===ut?o("CLIENT_NETWORK_ERROR","无法连接服务,频率未保存"):n("频率保存失败,请重试","error")}finally{p(!1)}}}async function Q(){if(!(l===null||O)){N(!0);try{const D=C.trim();await t2(D.length>0?D:void 0),H(""),n(D.length>0?`已备份「${D}」`:"已备份"),await J()}catch(D){n(D instanceof _e&&D.code!==ut?D.message:"无法连接服务,备份失败","error")}finally{N(!1)}}}async function G(){if(T===null)return;const D=await n2(T.fileName);n(`已恢复备份,覆盖前状态已自动快照(${D.snapshot.fileName})`),await Promise.all([m(),g()]),r(),St.getState().clearSessions(),St.getState().loadSessions(),J()}async function K(){if(M===null||M.saving)return;const D=v?.find(I=>I.fileName===M.fileName)?.name??"",B=M.value.trim();if(B===D){L(null);return}L({...M,saving:!0,error:null});try{await s2(M.fileName,M.value),L(null),n(B.length>0?`已重命名「${B}」`:"已清除备份名称"),await J()}catch(I){const V=I instanceof _e&&I.code!==ut?I.message:"无法连接服务,重命名失败";if(w.current===null){n(V,"error");return}L(z=>z===null?z:{...z,saving:!1,error:V})}}const A=l===null?"":Vv.some(D=>String(D.value)===String(l.backupFrequencyMinutes))?String(l.backupFrequencyMinutes):"null";return i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-foreground",children:"自动备份"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"跟随书籍:备份与频率均为本项目独立;服务运行期间按频率自动备份,有变更才生成新备份;每项目保留最近 20 份"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("select",{value:A,onChange:D=>{te(D.target.value)},disabled:l===null||b,"aria-label":"自动备份频率",className:"rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",children:Vv.map(D=>i.jsx("option",{value:String(D.value),children:D.label},String(D.value)))}),i.jsx("input",{value:C,onChange:D=>H(D.target.value),maxLength:Kb,placeholder:"备份名称(可选)","aria-label":"备份名称(可选)",disabled:l===null,className:"w-36 rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs(pe,{onClick:()=>{Q()},disabled:l===null||O,type:"button",children:[O?i.jsx(Il,{className:"size-4 animate-spin"}):null,"立即备份"]})]}),l===null&&!c&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground/70",children:"打开项目后可用"}),l!==null&&i.jsxs("div",{className:"mt-3",children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"历史备份"}),i.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:S&&v===null?i.jsxs("div",{className:"space-y-1 p-2",children:[i.jsx("div",{className:"h-7 animate-pulse rounded-md bg-muted"}),i.jsx("div",{className:"h-7 animate-pulse rounded-md bg-muted"})]}):E!==null?i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:E===ut?"无法连接服务":"备份列表加载失败"}),i.jsx(pe,{variant:"outline",size:"xs",onClick:()=>{J()},children:"重试"})]}):v!==null&&v.length===0?i.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground/70",children:"暂无备份,自动备份将在数据变更后按频率生成"}):v!==null?i.jsx("ul",{className:"divide-y divide-border",children:v.map(D=>{const B=M!==null&&M.fileName===D.fileName;return i.jsxs("li",{className:"px-2 py-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"min-w-0 flex-1 text-sm",title:D.fileName,children:[i.jsx("span",{className:"text-muted-foreground",children:im(D.createdAt)}),i.jsx("span",{className:D.kind==="manual"?"ml-1.5 rounded border border-primary/40 px-1 text-[10px] leading-4 text-primary":"ml-1.5 rounded border border-border px-1 text-[10px] leading-4 text-muted-foreground",children:Fv[D.kind]}),!B&&D.name!==void 0?i.jsx("span",{className:"ml-1.5 font-medium text-foreground",children:D.name}):null]}),B?null:i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Yv(D.size)}),B?i.jsxs(i.Fragment,{children:[i.jsx("input",{value:M.value,onChange:I=>L(V=>V===null?V:{...V,value:I.target.value,error:null}),onKeyDown:I=>{I.key==="Enter"?K():I.key==="Escape"&&L(null)},onBlur:()=>{w.current?.saving||L(null)},maxLength:Kb,disabled:M.saving,autoFocus:!0,"aria-label":"备份新名称",className:"w-36 shrink-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-sm outline-none placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsx(pe,{size:"icon-xs",variant:"ghost",onClick:()=>{K()},disabled:M.saving,onMouseDown:I=>I.preventDefault(),"aria-label":"确认重命名",title:"确认(Enter)",children:M.saving?i.jsx(Il,{className:"size-3 animate-spin"}):i.jsx(Kv,{className:"size-3"})}),i.jsx(pe,{size:"icon-xs",variant:"ghost",onClick:()=>L(null),disabled:M.saving,onMouseDown:I=>I.preventDefault(),"aria-label":"取消重命名",title:"取消(Esc)",children:i.jsx(fs,{className:"size-3"})})]}):i.jsxs(i.Fragment,{children:[i.jsx(pe,{size:"icon-xs",variant:"ghost",onClick:()=>L({fileName:D.fileName,value:D.name??"",saving:!1,error:null}),"aria-label":`重命名备份 ${im(D.createdAt)}`,title:"重命名",children:i.jsx(Kl,{className:"size-3"})}),i.jsx(pe,{variant:"outline",size:"xs",onClick:()=>k(D),children:"加载"})]})]}),B&&M.error!==null?i.jsx("p",{className:"mt-1 text-xs text-destructive",children:M.error}):null]},D.fileName)})}):null})]}),T!==null&&i.jsx(Oa,{title:"加载备份",description:`${im(T.createdAt)} · ${Fv[T.kind]}${T.name!==void 0?` · ${T.name}`:""} · ${Yv(T.size)}。将覆盖当前项目数据;覆盖前会自动备份当前状态(可回退)`,confirmLabel:"确认加载",danger:!0,onConfirm:G,onClose:()=>k(null)})]})}function Ol(n){return n instanceof _e?n.code:ut}function pA(){const n=Ce(I=>I.showToast),o=Ce(I=>I.showError),r=Ce(I=>I.notifyDataChanged),l=ze(I=>I.config),c=ze(I=>I.configLoading),d=ze(I=>I.updateConfig),[m,g]=h.useState(!0),[b,p]=h.useState(""),[v,x]=h.useState(!1),[S,j]=h.useState(void 0),[E,_]=h.useState(""),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,H]=h.useState(null),[M,L]=h.useState(""),[w,J]=h.useState(null),[oe,ie]=h.useState(!1),[te,Q]=h.useState(null);async function G(){try{const I=await r2();p(I.model),x(I.apiKeySet),j(I.apiKeyMasked)}catch(I){o(Ol(I),"读取 LLM 配置失败")}finally{g(!1)}}h.useEffect(()=>{G()},[]),h.useEffect(()=>{const I=ze.getState();I.config===null&&!I.configLoading&&I.loadConfig()},[]),h.useEffect(()=>{if(l===null){J(null);return}l.id!==w&&(L(l.prompt),J(l.id))},[l,w]);async function K(){Q(null),ie(!0);try{const I=M.trim();await d({prompt:I}),L(I),n("提示词已保存,仅影响新请求"),r()}catch(I){Ol(I)===ut?o("CLIENT_NETWORK_ERROR","无法连接服务,提示词未保存"):Q("保存失败,请重试")}finally{ie(!1)}}async function A(){if(!b.trim()){k("模型名不能为空");return}k(null),N(!0);try{await Lf({model:b.trim()}),n("已保存,仅影响新请求"),p(b.trim())}catch(I){Ol(I)===ut?o("CLIENT_NETWORK_ERROR","无法连接服务,模型配置未保存"):k("保存失败,请重试")}finally{N(!1)}}async function D(){if(!E.trim()){H("请输入新 key");return}H(null),N(!0);try{await Lf({api_key:E.trim()}),_(""),n("Key 已保存,仅影响新请求"),await G()}catch(I){Ol(I)===ut?o("CLIENT_NETWORK_ERROR","无法连接服务,Key 未保存"):H("保存失败,请重试")}finally{N(!1)}}async function B(){H(null),N(!0);try{await Lf({api_key:""}),_(""),n("Key 已清除"),await G()}catch(I){Ol(I)===ut?o("CLIENT_NETWORK_ERROR","无法连接服务,Key 未清除"):H("清除失败,请重试")}finally{N(!1)}}return i.jsxs("section",{className:"max-w-lg",children:[i.jsx("h1",{className:"mb-4 text-xl font-semibold",children:"设置"}),m?i.jsx("p",{className:"text-sm text-zinc-500",children:"加载中…"}):i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-zinc-700",children:"AI 模型"}),i.jsx("p",{className:"mb-2 text-xs text-zinc-500",children:"默认 deepseek-v4-flash(可在服务端设置页或环境变量覆盖)"}),i.jsxs("div",{className:"flex max-w-sm gap-2",children:[i.jsx(Dt,{value:b,onChange:I=>p(I.target.value),placeholder:"deepseek-v4-flash"}),i.jsx(pe,{onClick:()=>{A()},disabled:O,type:"button",children:"保存设置"})]}),T&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:T})]}),i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-zinc-700",children:"API Key"}),i.jsxs("p",{className:"mb-2 text-xs text-zinc-500",children:["状态:",v?`已配置(${S??""})`:"未配置"]}),i.jsxs("div",{className:"flex max-w-sm gap-2",children:[i.jsx(Dt,{value:E,onChange:I=>_(I.target.value),placeholder:"输入新 key(覆盖旧 key)"}),i.jsx(pe,{onClick:()=>{D()},disabled:O,type:"button",children:"保存 Key"}),i.jsx(pe,{variant:"outline",onClick:()=>{B()},disabled:O,type:"button",children:"清除 Key"})]}),C&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:C})]}),i.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3 text-xs leading-relaxed text-zinc-600",children:[i.jsx("p",{children:"· key 保存在用户目录配置文件(~/.ai-editor/config.json),不写入项目文件(决策 17)"}),i.jsx("p",{children:"· 环境变量 DEEPSEEK_API_KEY 优先于此处配置;保存的 key 仅影响新请求"})]}),i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-foreground",children:"项目提示词"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"注入 AI 上下文「## 项目设定」段(每轮有效);承载项目级规则/行业要求;空 = 整段跳过"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground/70",children:"建议用 ### 及以下层级的小标题组织内容(如「### 写作规则」);避免使用 ## 顶层标题(与系统分段标题冲突)"}),i.jsx("textarea",{value:M,onChange:I=>L(I.target.value),rows:6,disabled:l===null||l.id!==w,placeholder:"输入项目级规则/行业要求…",className:"w-full resize-y rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[i.jsx(pe,{onClick:()=>{K()},disabled:oe||l===null||l.id!==w,type:"button",children:"保存提示词"}),l===null&&!c&&i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"打开项目后可用"})]}),te&&i.jsx("p",{className:"mt-1 text-sm text-destructive",children:te})]}),i.jsx(mA,{})]})]})}function hA(n){const[o,r,l]=n.segments;switch(o){case void 0:return i.jsx(fv,{});case"outline":return r!==void 0?i.jsx(U3,{nodeId:r},r):i.jsx(m3,{});case"canvas":return i.jsx(sM,{});case"entities":{if(r==="relations")return i.jsx(Dv,{type:"relations"});const c=r!==void 0&&Ta.includes(r)?r:"character";return l!==void 0?i.jsx(cM,{type:c,id:l},`${c}:${l}`):i.jsx(Dv,{type:c})}case"hooks":return i.jsx(wM,{});case"timeline":return r!==void 0?i.jsx(aA,{id:r},r):i.jsx(HM,{});case"trash":return i.jsx(fA,{});case"settings":return i.jsx(pA,{});default:return i.jsx(fv,{})}}function gA(){const n=lj();return i.jsx(r3,{route:n,children:hA(n)})}const DS=document.getElementById("root");if(!DS)throw new Error("#root 元素缺失(index.html)");nj.createRoot(DS).render(i.jsx(h.StrictMode,{children:i.jsx(a3,{children:i.jsx(gA,{})})}));