morpheus-cli 0.2.6 → 0.2.7
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.
|
@@ -16,7 +16,7 @@ Please change the parent <Route path="${O}"> to <Route path="${O==="/"?"*":`${O}
|
|
|
16
16
|
${M}px !important;
|
|
17
17
|
${O}px !important;
|
|
18
18
|
}
|
|
19
|
-
`),()=>{j.contains(R)&&j.removeChild(R)}},[t]),v.jsx(OO,{isPresent:t,childRef:u,sizeRef:d,children:z.cloneElement(e,{ref:g})})}const RO=({children:e,initial:t,isPresent:a,onExitComplete:i,custom:s,presenceAffectsLayout:c,mode:u,anchorX:d,anchorY:m,root:p})=>{const g=fm(MO),y=z.useId();let x=!0,_=z.useMemo(()=>(x=!1,{id:y,initial:t,isPresent:a,custom:s,onExitComplete:E=>{g.set(E,!0);for(const T of g.values())if(!T)return;i&&i()},register:E=>(g.set(E,!1),()=>g.delete(E))}),[a,g,i]);return c&&x&&(_={..._}),z.useMemo(()=>{g.forEach((E,T)=>g.set(T,!1))},[a]),z.useEffect(()=>{!a&&!g.size&&i&&i()},[a]),u==="popLayout"&&(e=v.jsx(NO,{isPresent:a,anchorX:d,anchorY:m,root:p,children:e})),v.jsx(Fu.Provider,{value:_,children:e})};function MO(){return new Map}function FS(e=!0){const t=z.useContext(Fu);if(t===null)return[!0,null];const{isPresent:a,onExitComplete:i,register:s}=t,c=z.useId();z.useEffect(()=>{if(e)return s(c)},[e]);const u=z.useCallback(()=>e&&i&&i(c),[c,i,e]);return!a&&i?[!1,u]:[!0]}const lu=e=>e.key||"";function Zb(e){const t=[];return z.Children.forEach(e,a=>{z.isValidElement(a)&&t.push(a)}),t}const DO=({children:e,custom:t,initial:a=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:c="sync",propagate:u=!1,anchorX:d="left",anchorY:m="top",root:p})=>{const[g,y]=FS(u),x=z.useMemo(()=>Zb(e),[e]),_=u&&!g?[]:x.map(lu),E=z.useRef(!0),T=z.useRef(x),C=fm(()=>new Map),M=z.useRef(new Set),[O,R]=z.useState(x),[j,L]=z.useState(x);E1(()=>{E.current=!1,T.current=x;for(let B=0;B<j.length;B++){const Q=lu(j[B]);_.includes(Q)?(C.delete(Q),M.current.delete(Q)):C.get(Q)!==!0&&C.set(Q,!1)}},[j,_.length,_.join("-")]);const W=[];if(x!==O){let B=[...x];for(let Q=0;Q<j.length;Q++){const te=j[Q],de=lu(te);_.includes(de)||(B.splice(Q,0,te),W.push(te))}return c==="wait"&&W.length&&(B=W),L(Zb(B)),R(x),null}const{forceRender:K}=z.useContext(cm);return v.jsx(v.Fragment,{children:j.map(B=>{const Q=lu(B),te=u&&!g?!1:x===j||_.includes(Q),de=()=>{if(M.current.has(Q))return;if(M.current.add(Q),C.has(Q))C.set(Q,!0);else return;let xe=!0;C.forEach(Fe=>{Fe||(xe=!1)}),xe&&(K?.(),L(T.current),u&&y?.(),i&&i())};return v.jsx(RO,{isPresent:te,initial:!E.current||a?void 0:!1,custom:t,presenceAffectsLayout:s,mode:c,root:p,onExitComplete:te?void 0:de,anchorX:d,anchorY:m,children:B},Q)})})},KS=z.createContext({strict:!1}),Lb={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Ub=!1;function $O(){if(Ub)return;const e={};for(const t in Lb)e[t]={isEnabled:a=>Lb[t].some(i=>!!a[i])};kS(e),Ub=!0}function JS(){return $O(),Sj()}function ZO(e){const t=JS();for(const a in e)t[a]={...t[a],...e[a]};kS(t)}const LO=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function $u(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||LO.has(e)}let QS=e=>!$u(e);function UO(e){typeof e=="function"&&(QS=t=>t.startsWith("on")?!$u(t):e(t))}try{UO(require("@emotion/is-prop-valid").default)}catch{}function VO(e,t,a){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||(QS(s)||a===!0&&$u(s)||!t&&!$u(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const Qu=z.createContext({});function BO(e,t){if(Ju(e)){const{initial:a,animate:i}=e;return{initial:a===!1||ks(a)?a:void 0,animate:ks(i)?i:void 0}}return e.inherit!==!1?t:{}}function PO(e){const{initial:t,animate:a}=BO(e,z.useContext(Qu));return z.useMemo(()=>({initial:t,animate:a}),[Vb(t),Vb(a)])}function Vb(e){return Array.isArray(e)?e.join(" "):e}const Vm=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function WS(e,t,a){for(const i in t)!Vt(t[i])&&!NS(i,a)&&(e[i]=t[i])}function HO({transformTemplate:e},t){return z.useMemo(()=>{const a=Vm();return Zm(a,t,e),Object.assign({},a.vars,a.style)},[t])}function GO(e,t){const a=e.style||{},i={};return WS(i,a,e),Object.assign(i,HO(e,t)),i}function qO(e,t){const a={},i=GO(e,t);return e.drag&&e.dragListener!==!1&&(a.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(a.tabIndex=0),a.style=i,a}const e_=()=>({...Vm(),attrs:{}});function YO(e,t,a,i){const s=z.useMemo(()=>{const c=e_();return RS(c,t,DS(i),e.transformTemplate,e.style),{...c.attrs,style:{...c.style}}},[t]);if(e.style){const c={};WS(c,e.style,e),s.style={...c,...s.style}}return s}const IO=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Bm(e){return typeof e!="string"||e.includes("-")?!1:!!(IO.indexOf(e)>-1||/[A-Z]/u.test(e))}function XO(e,t,a,{latestValues:i},s,c=!1,u){const m=(u??Bm(e)?YO:qO)(t,i,s,e),p=VO(t,typeof e=="string",c),g=e!==z.Fragment?{...p,...m,ref:a}:{},{children:y}=t,x=z.useMemo(()=>Vt(y)?y.get():y,[y]);return z.createElement(e,{...g,children:x})}function FO({scrapeMotionValuesFromProps:e,createRenderState:t},a,i,s){return{latestValues:KO(a,i,s,e),renderState:t()}}function KO(e,t,a,i){const s={},c=i(e,{});for(const x in c)s[x]=Tu(c[x]);let{initial:u,animate:d}=e;const m=Ju(e),p=wS(e);t&&p&&!m&&e.inherit!==!1&&(u===void 0&&(u=t.initial),d===void 0&&(d=t.animate));let g=a?a.initial===!1:!1;g=g||u===!1;const y=g?d:u;if(y&&typeof y!="boolean"&&!Ku(y)){const x=Array.isArray(y)?y:[y];for(let _=0;_<x.length;_++){const E=jm(e,x[_]);if(E){const{transitionEnd:T,transition:C,...M}=E;for(const O in M){let R=M[O];if(Array.isArray(R)){const j=g?R.length-1:0;R=R[j]}R!==null&&(s[O]=R)}for(const O in T)s[O]=T[O]}}}return s}const t_=e=>(t,a)=>{const i=z.useContext(Qu),s=z.useContext(Fu),c=()=>FO(e,t,i,s);return a?c():fm(c)},JO=t_({scrapeMotionValuesFromProps:Lm,createRenderState:Vm}),QO=t_({scrapeMotionValuesFromProps:$S,createRenderState:e_}),WO=Symbol.for("motionComponentSymbol");function eN(e,t,a){const i=z.useRef(a);z.useInsertionEffect(()=>{i.current=a});const s=z.useRef(null);return z.useCallback(c=>{c&&e.onMount?.(c),t&&(c?t.mount(c):t.unmount());const u=i.current;if(typeof u=="function")if(c){const d=u(c);typeof d=="function"&&(s.current=d)}else s.current?(s.current(),s.current=null):u(c);else u&&(u.current=c)},[t])}const n_=z.createContext({});function ds(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function tN(e,t,a,i,s,c){const{visualElement:u}=z.useContext(Qu),d=z.useContext(KS),m=z.useContext(Fu),p=z.useContext(Um).reducedMotion,g=z.useRef(null),y=z.useRef(!1);i=i||d.renderer,!g.current&&i&&(g.current=i(e,{visualState:t,parent:u,props:a,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:p,isSVG:c}),y.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const x=g.current,_=z.useContext(n_);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&nN(g.current,a,s,_);const E=z.useRef(!1);z.useInsertionEffect(()=>{x&&E.current&&x.update(a,m)});const T=a[cS],C=z.useRef(!!T&&!window.MotionHandoffIsComplete?.(T)&&window.MotionHasOptimisedAnimation?.(T));return E1(()=>{y.current=!0,x&&(E.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),C.current&&x.animationState&&x.animationState.animateChanges())}),z.useEffect(()=>{x&&(!C.current&&x.animationState&&x.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(T)}),C.current=!1),x.enteringChildren=void 0)}),x}function nN(e,t,a,i){const{layoutId:s,layout:c,drag:u,dragConstraints:d,layoutScroll:m,layoutRoot:p,layoutCrossfade:g}=t;e.projection=new a(e.latestValues,t["data-framer-portal-id"]?void 0:r_(e.parent)),e.projection.setOptions({layoutId:s,layout:c,alwaysMeasureLayout:!!u||d&&ds(d),visualElement:e,animationType:typeof c=="string"?c:"both",initialPromotionConfig:i,crossfade:g,layoutScroll:m,layoutRoot:p})}function r_(e){if(e)return e.options.allowProjection!==!1?e.projection:r_(e.parent)}function Fd(e,{forwardMotionProps:t=!1,type:a}={},i,s){i&&ZO(i);const c=a?a==="svg":Bm(e),u=c?QO:JO;function d(p,g){let y;const x={...z.useContext(Um),...p,layoutId:rN(p)},{isStatic:_}=x,E=PO(p),T=u(p,_);if(!_&&T1){aN();const C=iN(x);y=C.MeasureLayout,E.visualElement=tN(e,T,x,s,C.ProjectionNode,c)}return v.jsxs(Qu.Provider,{value:E,children:[y&&E.visualElement?v.jsx(y,{visualElement:E.visualElement,...x}):null,XO(e,p,eN(T,E.visualElement,g),T,_,t,c)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const m=z.forwardRef(d);return m[WO]=e,m}function rN({layoutId:e}){const t=z.useContext(cm).id;return t&&e!==void 0?t+"-"+e:e}function aN(e,t){z.useContext(KS).strict}function iN(e){const t=JS(),{drag:a,layout:i}=t;if(!a&&!i)return{};const s={...a,...i};return{MeasureLayout:a?.isEnabled(e)||i?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function oN(e,t){if(typeof Proxy>"u")return Fd;const a=new Map,i=(c,u)=>Fd(c,u,e,t),s=(c,u)=>i(c,u);return new Proxy(s,{get:(c,u)=>u==="create"?i:(a.has(u)||a.set(u,Fd(u,void 0,e,t)),a.get(u))})}const sN=(e,t)=>t.isSVG??Bm(e)?new Lj(t):new Nj(t,{allowProjection:e!==z.Fragment});class lN extends oa{constructor(t){super(t),t.animationState||(t.animationState=Hj(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ku(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:a}=this.node.prevProps||{};t!==a&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let uN=0;class cN extends oa{constructor(){super(...arguments),this.id=uN++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:a}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const s=this.node.animationState.setActive("exit",!t);a&&!t&&s.then(()=>{a(this.id)})}mount(){const{register:t,onExitComplete:a}=this.node.presenceContext||{};a&&a(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const fN={animation:{Feature:lN},exit:{Feature:cN}};function Ls(e){return{point:{x:e.pageX,y:e.pageY}}}const dN=e=>t=>Mm(t)&&e(t,Ls(t));function bs(e,t,a,i){return Ts(e,t,dN(a),i)}const a_=({current:e})=>e?e.ownerDocument.defaultView:null,Bb=(e,t)=>Math.abs(e-t);function hN(e,t){const a=Bb(e.x,t.x),i=Bb(e.y,t.y);return Math.sqrt(a**2+i**2)}const Pb=new Set(["auto","scroll"]);class i_{constructor(t,a,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:c=!1,distanceThreshold:u=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=Jd(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,T=hN(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!T)return;const{point:C}=_,{timestamp:M}=$t;this.history.push({...C,timestamp:M});const{onStart:O,onMove:R}=this.handlers;E||(O&&O(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),R&&R(this.lastMoveEvent,_)},this.handlePointerMove=(_,E)=>{this.lastMoveEvent=_,this.lastMoveEventInfo=Kd(E,this.transformPagePoint),Xe.update(this.updatePoint,!0)},this.handlePointerUp=(_,E)=>{this.end();const{onEnd:T,onSessionEnd:C,resumeAnimation:M}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const O=Jd(_.type==="pointercancel"?this.lastMoveEventInfo:Kd(E,this.transformPagePoint),this.history);this.startEvent&&T&&T(_,O),C&&C(_,O)},!Mm(t))return;this.dragSnapToOrigin=c,this.handlers=a,this.transformPagePoint=i,this.distanceThreshold=u,this.contextWindow=s||window;const m=Ls(t),p=Kd(m,this.transformPagePoint),{point:g}=p,{timestamp:y}=$t;this.history=[{...g,timestamp:y}];const{onSessionStart:x}=a;x&&x(t,Jd(p,this.history)),this.removeListeners=Ds(bs(this.contextWindow,"pointermove",this.handlePointerMove),bs(this.contextWindow,"pointerup",this.handlePointerUp),bs(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(t){let a=t.parentElement;for(;a;){const i=getComputedStyle(a);(Pb.has(i.overflowX)||Pb.has(i.overflowY))&&this.scrollPositions.set(a,{x:a.scrollLeft,y:a.scrollTop}),a=a.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const a=this.scrollPositions.get(t);if(!a)return;const i=t===window,s=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},c={x:s.x-a.x,y:s.y-a.y};c.x===0&&c.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=c.x,this.lastMoveEventInfo.point.y+=c.y):this.history.length>0&&(this.history[0].x-=c.x,this.history[0].y-=c.y),this.scrollPositions.set(t,s),Xe.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),na(this.updatePoint)}}function Kd(e,t){return t?{point:t(e.point)}:e}function Hb(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Jd({point:e},t){return{point:e,delta:Hb(e,o_(t)),offset:Hb(e,mN(t)),velocity:pN(t,.1)}}function mN(e){return e[0]}function o_(e){return e[e.length-1]}function pN(e,t){if(e.length<2)return{x:0,y:0};let a=e.length-1,i=null;const s=o_(e);for(;a>=0&&(i=e[a],!(s.timestamp-i.timestamp>zr(t)));)a--;if(!i)return{x:0,y:0};const c=En(s.timestamp-i.timestamp);if(c===0)return{x:0,y:0};const u={x:(s.x-i.x)/c,y:(s.y-i.y)/c};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function gN(e,{min:t,max:a},i){return t!==void 0&&e<t?e=i?at(t,e,i.min):Math.max(e,t):a!==void 0&&e>a&&(e=i?at(a,e,i.max):Math.min(e,a)),e}function Gb(e,t,a){return{min:t!==void 0?e.min+t:void 0,max:a!==void 0?e.max+a-(e.max-e.min):void 0}}function yN(e,{top:t,left:a,bottom:i,right:s}){return{x:Gb(e.x,a,s),y:Gb(e.y,t,i)}}function qb(e,t){let a=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([a,i]=[i,a]),{min:a,max:i}}function vN(e,t){return{x:qb(e.x,t.x),y:qb(e.y,t.y)}}function bN(e,t){let a=.5;const i=Yt(e),s=Yt(t);return s>i?a=_s(t.min,t.max-i,e.min):i>s&&(a=_s(e.min,e.max-s,t.min)),Qn(0,1,a)}function xN(e,t){const a={};return t.min!==void 0&&(a.min=t.min-e.min),t.max!==void 0&&(a.max=t.max-e.min),a}const Ph=.35;function SN(e=Ph){return e===!1?e=0:e===!0&&(e=Ph),{x:Yb(e,"left","right"),y:Yb(e,"top","bottom")}}function Yb(e,t,a){return{min:Ib(e,t),max:Ib(e,a)}}function Ib(e,t){return typeof e=="number"?e:e[t]||0}const _N=new WeakMap;class zN{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Tt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:a=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const c=y=>{a?(this.stopAnimation(),this.snapToCursor(Ls(y).point)):this.pauseAnimation()},u=(y,x)=>{this.stopAnimation();const{drag:_,dragPropagation:E,onDragStart:T}=this.getProps();if(_&&!E&&(this.openDragLock&&this.openDragLock(),this.openDragLock=uj(_),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kn(M=>{let O=this.getAxisMotionValue(M).get()||0;if(Jn.test(O)){const{projection:R}=this.visualElement;if(R&&R.layout){const j=R.layout.layoutBox[M];j&&(O=Yt(j)*(parseFloat(O)/100))}}this.originPoint[M]=O}),T&&Xe.postRender(()=>T(y,x)),Mh(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},d=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x;const{dragPropagation:_,dragDirectionLock:E,onDirectionLock:T,onDrag:C}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:M}=x;if(E&&this.currentDirection===null){this.currentDirection=wN(M),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",x.point,M),this.updateAxis("y",x.point,M),this.visualElement.render(),C&&C(y,x)},m=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x,this.stop(y,x),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>kn(y=>this.getAnimationState(y)==="paused"&&this.getAxisMotionValue(y).animation?.play()),{dragSnapToOrigin:g}=this.getProps();this.panSession=new i_(t,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:i,contextWindow:a_(this.visualElement),element:this.visualElement.current})}stop(t,a){const i=t||this.latestPointerEvent,s=a||this.latestPanInfo,c=this.isDragging;if(this.cancel(),!c||!s||!i)return;const{velocity:u}=s;this.startAnimation(u);const{onDragEnd:d}=this.getProps();d&&Xe.postRender(()=>d(i,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:a}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),a&&a.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,a,i){const{drag:s}=this.getProps();if(!i||!uu(t,s,this.currentDirection))return;const c=this.getAxisMotionValue(t);let u=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(u=gN(u,this.constraints[t],this.elastic[t])),c.set(u)}resolveConstraints(){const{dragConstraints:t,dragElastic:a}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,s=this.constraints;t&&ds(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=yN(i.layoutBox,t):this.constraints=!1,this.elastic=SN(a),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&kn(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=xN(i.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:a}=this.getProps();if(!t||!ds(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const c=Tj(i,s.root,this.visualElement.getTransformPagePoint());let u=vN(s.layout.layoutBox,c);if(a){const d=a(zj(u));this.hasMutatedConstraints=!!d,d&&(u=ES(d))}return u}startAnimation(t){const{drag:a,dragMomentum:i,dragElastic:s,dragTransition:c,dragSnapToOrigin:u,onDragTransitionEnd:d}=this.getProps(),m=this.constraints||{},p=kn(g=>{if(!uu(g,a,this.currentDirection))return;let y=m&&m[g]||{};u&&(y={min:0,max:0});const x=s?200:1e6,_=s?40:1e7,E={type:"inertia",velocity:i?t[g]:0,bounceStiffness:x,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...c,...y};return this.startAxisValueAnimation(g,E)});return Promise.all(p).then(d)}startAxisValueAnimation(t,a){const i=this.getAxisMotionValue(t);return Mh(this.visualElement,t),i.start(Cm(t,i,0,a,this.visualElement,!1))}stopAnimation(){kn(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){kn(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const a=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),s=i[a];return s||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){kn(a=>{const{drag:i}=this.getProps();if(!uu(a,i,this.currentDirection))return;const{projection:s}=this.visualElement,c=this.getAxisMotionValue(a);if(s&&s.layout){const{min:u,max:d}=s.layout.layoutBox[a],m=c.get()||0;c.set(t[a]-at(u,d,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:a}=this.getProps(),{projection:i}=this.visualElement;if(!ds(a)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};kn(u=>{const d=this.getAxisMotionValue(u);if(d&&this.constraints!==!1){const m=d.get();s[u]=bN({min:m,max:m},this.constraints[u])}});const{transformTemplate:c}=this.visualElement.getProps();this.visualElement.current.style.transform=c?c({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),kn(u=>{if(!uu(u,t,null))return;const d=this.getAxisMotionValue(u),{min:m,max:p}=this.constraints[u];d.set(at(m,p,s[u]))})}addListeners(){if(!this.visualElement.current)return;_N.set(this.visualElement,this);const t=this.visualElement.current,a=bs(t,"pointerdown",m=>{const{drag:p,dragListener:g=!0}=this.getProps(),y=m.target,x=y!==t&&SS(y);p&&g&&!x&&this.start(m)}),i=()=>{const{dragConstraints:m}=this.getProps();ds(m)&&m.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,c=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Xe.read(i);const u=Ts(window,"resize",()=>this.scalePositionWithinConstraints()),d=s.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:p})=>{this.isDragging&&p&&(kn(g=>{const y=this.getAxisMotionValue(g);y&&(this.originPoint[g]+=m[g].translate,y.set(y.get()+m[g].translate))}),this.visualElement.render())}));return()=>{u(),a(),c(),d&&d()}}getProps(){const t=this.visualElement.getProps(),{drag:a=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:c=!1,dragElastic:u=Ph,dragMomentum:d=!0}=t;return{...t,drag:a,dragDirectionLock:i,dragPropagation:s,dragConstraints:c,dragElastic:u,dragMomentum:d}}}function uu(e,t,a){return(t===!0||t===e)&&(a===null||a===e)}function wN(e,t=10){let a=null;return Math.abs(e.y)>t?a="y":Math.abs(e.x)>t&&(a="x"),a}class kN extends oa{constructor(t){super(t),this.removeGroupControls=An,this.removeListeners=An,this.controls=new zN(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||An}update(){const{dragControls:t}=this.node.getProps(),{dragControls:a}=this.node.prevProps||{};t!==a&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Xb=e=>(t,a)=>{e&&Xe.postRender(()=>e(t,a))};class TN extends oa{constructor(){super(...arguments),this.removePointerDownListener=An}onPointerDown(t){this.session=new i_(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:a_(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:a,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:Xb(t),onStart:Xb(a),onMove:i,onEnd:(c,u)=>{delete this.session,s&&Xe.postRender(()=>s(c,u))}}}mount(){this.removePointerDownListener=bs(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Qd=!1;class EN extends z.Component{componentDidMount(){const{visualElement:t,layoutGroup:a,switchLayoutGroup:i,layoutId:s}=this.props,{projection:c}=t;c&&(a.group&&a.group.add(c),i&&i.register&&s&&i.register(c),Qd&&c.root.didUpdate(),c.addEventListener("animationComplete",()=>{this.safeToRemove()}),c.setOptions({...c.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Eu.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:a,visualElement:i,drag:s,isPresent:c}=this.props,{projection:u}=i;return u&&(u.isPresent=c,t.layoutDependency!==a&&u.setOptions({...u.options,layoutDependency:a}),Qd=!0,s||t.layoutDependency!==a||a===void 0||t.isPresent!==c?u.willUpdate():this.safeToRemove(),t.isPresent!==c&&(c?u.promote():u.relegate()||Xe.postRender(()=>{const d=u.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Rm.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:a,switchLayoutGroup:i}=this.props,{projection:s}=t;Qd=!0,s&&(s.scheduleCheckAfterUnmount(),a&&a.group&&a.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function s_(e){const[t,a]=FS(),i=z.useContext(cm);return v.jsx(EN,{...e,layoutGroup:i,switchLayoutGroup:z.useContext(n_),isPresent:t,safeToRemove:a})}const AN={pan:{Feature:TN},drag:{Feature:kN,ProjectionNode:XS,MeasureLayout:s_}};function Fb(e,t,a){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",a==="Start");const s="onHover"+a,c=i[s];c&&Xe.postRender(()=>c(t,Ls(t)))}class CN extends oa{mount(){const{current:t}=this.node;t&&(this.unmount=cj(t,(a,i)=>(Fb(this.node,i,"Start"),s=>Fb(this.node,s,"End"))))}unmount(){}}class jN extends oa{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ds(Ts(this.node.current,"focus",()=>this.onFocus()),Ts(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Kb(e,t,a){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",a==="Start");const s="onTap"+(a==="End"?"":a),c=i[s];c&&Xe.postRender(()=>c(t,Ls(t)))}class ON extends oa{mount(){const{current:t}=this.node;t&&(this.unmount=hj(t,(a,i)=>(Kb(this.node,i,"Start"),(s,{success:c})=>Kb(this.node,s,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Hh=new WeakMap,Wd=new WeakMap,NN=e=>{const t=Hh.get(e.target);t&&t(e)},RN=e=>{e.forEach(NN)};function MN({root:e,...t}){const a=e||document;Wd.has(a)||Wd.set(a,{});const i=Wd.get(a),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(RN,{root:e,...t})),i[s]}function DN(e,t,a){const i=MN(t);return Hh.set(e,a),i.observe(e),()=>{Hh.delete(e),i.unobserve(e)}}const $N={some:0,all:1};class ZN extends oa{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:a,margin:i,amount:s="some",once:c}=t,u={root:a?a.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:$N[s]},d=m=>{const{isIntersecting:p}=m;if(this.isInView===p||(this.isInView=p,c&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:g,onViewportLeave:y}=this.node.getProps(),x=p?g:y;x&&x(m)};return DN(this.node.current,u,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:a}=this.node;["amount","margin","root"].some(LN(t,a))&&this.startObserver()}unmount(){}}function LN({viewport:e={}},{viewport:t={}}={}){return a=>e[a]!==t[a]}const UN={inView:{Feature:ZN},tap:{Feature:ON},focus:{Feature:jN},hover:{Feature:CN}},VN={layout:{ProjectionNode:XS,MeasureLayout:s_}},BN={...fN,...UN,...AN,...VN},Kn=oN(BN,sN),l_=()=>{const[e,t]=z.useState(!!localStorage.getItem("morpheus.auth.token"));return z.useEffect(()=>{const s=()=>{t(!!localStorage.getItem("morpheus.auth.token"))};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),{isAuthenticated:e,login:s=>{localStorage.setItem("morpheus.auth.token",s),t(!0)},logout:()=>{localStorage.removeItem("morpheus.auth.token"),t(!1),window.location.href="/login"}}};function PN({onMenuClick:e,isDark:t,toggleTheme:a}){return v.jsxs("header",{className:"lg:hidden fixed top-0 left-0 right-0 z-50 bg-azure-surface dark:bg-zinc-950 border-b border-azure-border dark:border-matrix-primary p-4 flex items-center justify-between",children:[v.jsxs("h1",{className:"text-lg font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight","aria-label":t?"Modo claro":"Modo escuro",children:t?v.jsx(g1,{className:"w-5 h-5"}):v.jsx(p1,{className:"w-5 h-5"})}),v.jsx("button",{onClick:e,className:"p-2 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-secondary","aria-label":"Abrir menu",children:v.jsx(lE,{className:"w-6 h-6"})})]})]})}const Pm=({open:e,onOpenChange:t,children:a})=>e?v.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[v.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>t(!1)}),v.jsx("div",{className:"relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full max-w-md max-h-[90vh] overflow-hidden flex flex-col",children:a})]}):null,Hm=({className:e,children:t})=>v.jsx("div",{className:`relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full max-w-md max-h-[90vh] overflow-hidden flex flex-col ${e}`,children:v.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:t})}),Gm=({children:e})=>v.jsx("div",{className:"flex flex-col space-y-1.5 text-center sm:text-left border-b border-azure-border dark:border-matrix-primary p-6",children:e}),qm=({className:e,children:t})=>v.jsx("h3",{className:`text-lg font-semibold leading-none tracking-tight ${e}`,children:t}),Fn=({className:e,variant:t="default",size:a="default",...i})=>{const d=`inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-zinc-950 dark:focus-visible:ring-zinc-300 ${t==="destructive"?"bg-red-500 text-zinc-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-zinc-50 dark:hover:bg-red-900/90":t==="outline"?"border border-azure-border dark:border-matrix-primary bg-transparent hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-primary dark:text-matrix-secondary":t==="secondary"?"bg-azure-surface dark:bg-zinc-800 hover:bg-azure-hover dark:hover:bg-zinc-700/80 text-azure-text-primary dark:text-matrix-secondary":t==="ghost"?"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-primary dark:text-matrix-secondary":t==="link"?"text-azure-primary dark:text-matrix-highlight underline-offset-4 hover:underline":"bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black hover:bg-azure-primary/90 dark:hover:bg-matrix-highlight/90"} ${a==="sm"?"h-9 px-3 rounded-md":a==="lg"?"h-11 px-8 rounded-md":a==="icon"?"h-10 w-10":"h-10 px-4 py-2"} ${e||""}`;return v.jsx("button",{className:d,...i})};function HN({isOpen:e,onClose:t,onConfirm:a}){return v.jsx(Pm,{open:e,onOpenChange:t,children:v.jsxs(Hm,{className:"sm:max-w-md bg-azure-surface dark:bg-zinc-900 border-azure-border dark:border-matrix-primary",children:[v.jsx(Gm,{children:v.jsx(qm,{className:"text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:"Confirm Restart"})}),v.jsxs("div",{children:[v.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary mb-6",children:"Are you sure you want to restart the Morpheus agent? This will temporarily disconnect all services and channels."}),v.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-end",children:[v.jsx(Fn,{variant:"outline",onClick:t,children:"Cancel"}),v.jsx(Fn,{variant:"destructive",onClick:()=>{a(),t()},children:"Confirm Restart"})]})]})]})})}function GN({children:e}){const t=Ln(),[a,i]=z.useState(()=>{const x=localStorage.getItem("theme");return x?x==="dark":!0}),[s,c]=z.useState(!1),[u,d]=z.useState(!1),{logout:m}=l_(),p=async()=>{try{await dn.post("/restart",{}),alert("Restart initiated successfully. The agent will restart shortly.")}catch(x){console.error("Failed to restart:",x),alert("Failed to restart the agent. Please try again.")}};z.useEffect(()=>{a?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))},[a]),z.useEffect(()=>{c(!1)},[t.pathname]);const g=[{icon:x0,label:"Dashboard",path:"/"},{icon:w0,label:"Configuration",path:"/config"},{icon:_0,label:"MCP Servers",path:"/mcp-servers"},{icon:fh,label:"Usage Stats",path:"/stats"},{icon:Mi,label:"Sati Memories",path:"/sati-memories"}],y=[{icon:x0,label:"Dashboard",path:"/"},{icon:w0,label:"Configuration",path:"/config"},{icon:_0,label:"MCP Servers",path:"/mcp-servers"},{icon:fh,label:"Usage Stats",path:"/stats"},{icon:Mi,label:"Sati Memories",path:"/sati-memories"}];return v.jsxs("div",{className:"flex flex-col h-screen bg-azure-bg dark:bg-black text-azure-text-primary dark:text-matrix-secondary font-mono overflow-hidden transition-colors duration-300",children:[v.jsx(PN,{onMenuClick:()=>c(!0),isDark:a,toggleTheme:()=>i(!a)}),v.jsxs("div",{className:"flex flex-1 overflow-hidden pt-16 lg:pt-0",children:[" ",v.jsxs("div",{className:"hidden lg:flex w-64 border-r border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-950 flex-col shrink-0 transition-colors duration-300",children:[v.jsxs("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary flex justify-between items-center",children:[v.jsxs("h1",{className:"text-xl font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsx("button",{onClick:()=>i(!a),className:"p-1 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors",children:a?v.jsx(g1,{className:"w-4 h-4"}):v.jsx(p1,{className:"w-4 h-4"})})]}),v.jsxs("nav",{className:"flex-1 p-4 space-y-2",children:[g.map(x=>{const _=t.pathname===x.path;return v.jsxs(Ri,{to:x.path,className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${_?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,children:[v.jsx(x.icon,{className:"w-5 h-5"}),v.jsx("span",{children:x.label})]},x.path)}),v.jsxs(Ri,{to:"/logs",className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${t.pathname==="/logs"?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,children:[v.jsx(k0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logs"})]},"/logs")]}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>d(!0),className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:[v.jsx(z0,{className:"w-5 h-5"}),v.jsx("span",{children:"Restart"})]})}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:m,className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 transition-colors",children:[v.jsx(S0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logout"})]})})]}),v.jsx(DO,{children:s&&v.jsxs(Kn.div,{className:"fixed inset-0 z-50 lg:hidden",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>c(!1),children:[v.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),v.jsxs(Kn.div,{className:"absolute left-0 top-0 bottom-0 w-64 bg-azure-surface dark:bg-zinc-950 flex flex-col shadow-xl",initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:200},onClick:x=>x.stopPropagation(),children:[v.jsxs("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary flex justify-between items-center",children:[v.jsxs("h1",{className:"text-xl font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsx("button",{onClick:()=>c(!1),className:"p-2 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors","aria-label":"Fechar menu",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),v.jsxs("nav",{className:"flex-1 p-4 space-y-2 overflow-y-auto",children:[y.map(x=>{const _=t.pathname===x.path;return v.jsxs(Ri,{to:x.path,className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${_?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,onClick:()=>c(!1),children:[v.jsx(x.icon,{className:"w-5 h-5"}),v.jsx("span",{children:x.label})]},x.path)}),v.jsxs(Ri,{to:"/logs",className:"flex items-center gap-3 px-4 py-3 rounded transition-colors hidden lg:flex hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary",onClick:()=>c(!1),children:[v.jsx(k0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logs"})]})]}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>{d(!0),c(!1)},className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:[v.jsx(z0,{className:"w-5 h-5"}),v.jsx("span",{children:"Restart"})]})}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>{m(),c(!1)},className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 transition-colors",children:[v.jsx(S0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logout"})]})})]})]})}),v.jsxs("main",{className:"flex-1 overflow-auto p-4 md:p-8 relative flex flex-col",children:[v.jsx("div",{className:"max-w-6xl w-full mx-auto flex-1",children:e}),v.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(18,16,16,0)_50%,rgba(0,0,0,0.1)_50%),linear-gradient(90deg,rgba(0,255,0,0.03),rgba(0,255,0,0.01))] bg-[length:100%_2px,3px_100%] opacity-0 dark:opacity-20 transition-opacity duration-300"})]})]}),v.jsx(iA,{}),v.jsx(HN,{isOpen:u,onClose:()=>d(!1),onConfirm:p})]})}const qN={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},Ma=({title:e,value:t,icon:a,subValue:i})=>v.jsxs(Kn.div,{variants:qN,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[v.jsxs("div",{className:"flex justify-between items-start mb-4",children:[v.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:e}),v.jsx(a,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),v.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:t}),i&&v.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:i})]}),Gh={fetchUsageStats:async()=>dn.get("/stats/usage"),fetchGroupedUsageStats:async()=>dn.get("/stats/usage/grouped")};function YN(){const{data:e}=Va("/api/stats/usage",Gh.fetchUsageStats,{refreshInterval:5e3});return v.jsxs(v.Fragment,{children:[v.jsx(Ma,{title:"Total Input",value:e?e.totalInputTokens.toLocaleString():"-",icon:L2,subValue:"Tokens processed"}),v.jsx(Ma,{title:"Total Output",value:e?e.totalOutputTokens.toLocaleString():"-",icon:V2,subValue:"Tokens generated"})]})}function IN(){const{data:e}=k1(),t={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},a={hidden:{opacity:0,y:20},show:{opacity:1,y:0}};return v.jsxs(Kn.div,{className:"space-y-8",variants:t,initial:"hidden",animate:"show",children:[v.jsxs(Kn.div,{variants:a,children:[v.jsx("h2",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight mb-2",children:"SYSTEM STATUS"}),v.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-80",children:"Overview of the Morpheus agent runtime."})]}),v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[v.jsx(Ma,{title:"Agent Status",value:e?.status.toUpperCase()||"CONNECTING...",icon:Mi,subValue:e?`PID: ${e.pid}`:""}),v.jsx(Ma,{title:"Uptime",value:e?`${Math.floor(e.uptimeSeconds/60)}m`:"-",icon:h1,subValue:e?`${e.uptimeSeconds.toFixed(0)} seconds`:""}),v.jsx(Ma,{title:"Version",value:e?.projectVersion||"-",icon:F2,subValue:`Node ${e?.nodeVersion||"-"}`}),v.jsx(Ma,{title:"Provider",value:e?.llmProvider?.toUpperCase()||"-",icon:G2,subValue:"LLM Inference Engine"}),v.jsx(Ma,{title:"Model",value:e?.llmModel||"-",icon:P2,subValue:"Active Model"}),v.jsx(YN,{})]})]})}function ja({title:e,description:t,children:a}){return v.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[v.jsxs("div",{className:"mb-4",children:[v.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&v.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),v.jsx("div",{className:"space-y-4",children:a})]})}const XN=(e,t)=>{const a=new Array(e.length+t.length);for(let i=0;i<e.length;i++)a[i]=e[i];for(let i=0;i<t.length;i++)a[e.length+i]=t[i];return a},FN=(e,t)=>({classGroupId:e,validator:t}),u_=(e=new Map,t=null,a)=>({nextPart:e,validators:t,classGroupId:a}),Zu="-",Jb=[],KN="arbitrary..",JN=e=>{const t=WN(e),{conflictingClassGroups:a,conflictingClassGroupModifiers:i}=e;return{getClassGroupId:u=>{if(u.startsWith("[")&&u.endsWith("]"))return QN(u);const d=u.split(Zu),m=d[0]===""&&d.length>1?1:0;return c_(d,m,t)},getConflictingClassGroupIds:(u,d)=>{if(d){const m=i[u],p=a[u];return m?p?XN(p,m):m:p||Jb}return a[u]||Jb}}},c_=(e,t,a)=>{if(e.length-t===0)return a.classGroupId;const s=e[t],c=a.nextPart.get(s);if(c){const p=c_(e,t+1,c);if(p)return p}const u=a.validators;if(u===null)return;const d=t===0?e.join(Zu):e.slice(t).join(Zu),m=u.length;for(let p=0;p<m;p++){const g=u[p];if(g.validator(d))return g.classGroupId}},QN=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),a=t.indexOf(":"),i=t.slice(0,a);return i?KN+i:void 0})(),WN=e=>{const{theme:t,classGroups:a}=e;return e4(a,t)},e4=(e,t)=>{const a=u_();for(const i in e){const s=e[i];Ym(s,a,i,t)}return a},Ym=(e,t,a,i)=>{const s=e.length;for(let c=0;c<s;c++){const u=e[c];t4(u,t,a,i)}},t4=(e,t,a,i)=>{if(typeof e=="string"){n4(e,t,a);return}if(typeof e=="function"){r4(e,t,a,i);return}a4(e,t,a,i)},n4=(e,t,a)=>{const i=e===""?t:f_(t,e);i.classGroupId=a},r4=(e,t,a,i)=>{if(i4(e)){Ym(e(i),t,a,i);return}t.validators===null&&(t.validators=[]),t.validators.push(FN(a,e))},a4=(e,t,a,i)=>{const s=Object.entries(e),c=s.length;for(let u=0;u<c;u++){const[d,m]=s[u];Ym(m,f_(t,d),a,i)}},f_=(e,t)=>{let a=e;const i=t.split(Zu),s=i.length;for(let c=0;c<s;c++){const u=i[c];let d=a.nextPart.get(u);d||(d=u_(),a.nextPart.set(u,d)),a=d}return a},i4=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,o4=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,a=Object.create(null),i=Object.create(null);const s=(c,u)=>{a[c]=u,t++,t>e&&(t=0,i=a,a=Object.create(null))};return{get(c){let u=a[c];if(u!==void 0)return u;if((u=i[c])!==void 0)return s(c,u),u},set(c,u){c in a?a[c]=u:s(c,u)}}},qh="!",Qb=":",s4=[],Wb=(e,t,a,i,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:a,maybePostfixModifierPosition:i,isExternal:s}),l4=e=>{const{prefix:t,experimentalParseClassName:a}=e;let i=s=>{const c=[];let u=0,d=0,m=0,p;const g=s.length;for(let T=0;T<g;T++){const C=s[T];if(u===0&&d===0){if(C===Qb){c.push(s.slice(m,T)),m=T+1;continue}if(C==="/"){p=T;continue}}C==="["?u++:C==="]"?u--:C==="("?d++:C===")"&&d--}const y=c.length===0?s:s.slice(m);let x=y,_=!1;y.endsWith(qh)?(x=y.slice(0,-1),_=!0):y.startsWith(qh)&&(x=y.slice(1),_=!0);const E=p&&p>m?p-m:void 0;return Wb(c,_,x,E)};if(t){const s=t+Qb,c=i;i=u=>u.startsWith(s)?c(u.slice(s.length)):Wb(s4,!1,u,void 0,!0)}if(a){const s=i;i=c=>a({className:c,parseClassName:s})}return i},u4=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((a,i)=>{t.set(a,1e6+i)}),a=>{const i=[];let s=[];for(let c=0;c<a.length;c++){const u=a[c],d=u[0]==="[",m=t.has(u);d||m?(s.length>0&&(s.sort(),i.push(...s),s=[]),i.push(u)):s.push(u)}return s.length>0&&(s.sort(),i.push(...s)),i}},c4=e=>({cache:o4(e.cacheSize),parseClassName:l4(e),sortModifiers:u4(e),...JN(e)}),f4=/\s+/,d4=(e,t)=>{const{parseClassName:a,getClassGroupId:i,getConflictingClassGroupIds:s,sortModifiers:c}=t,u=[],d=e.trim().split(f4);let m="";for(let p=d.length-1;p>=0;p-=1){const g=d[p],{isExternal:y,modifiers:x,hasImportantModifier:_,baseClassName:E,maybePostfixModifierPosition:T}=a(g);if(y){m=g+(m.length>0?" "+m:m);continue}let C=!!T,M=i(C?E.substring(0,T):E);if(!M){if(!C){m=g+(m.length>0?" "+m:m);continue}if(M=i(E),!M){m=g+(m.length>0?" "+m:m);continue}C=!1}const O=x.length===0?"":x.length===1?x[0]:c(x).join(":"),R=_?O+qh:O,j=R+M;if(u.indexOf(j)>-1)continue;u.push(j);const L=s(M,C);for(let W=0;W<L.length;++W){const K=L[W];u.push(R+K)}m=g+(m.length>0?" "+m:m)}return m},h4=(...e)=>{let t=0,a,i,s="";for(;t<e.length;)(a=e[t++])&&(i=d_(a))&&(s&&(s+=" "),s+=i);return s},d_=e=>{if(typeof e=="string")return e;let t,a="";for(let i=0;i<e.length;i++)e[i]&&(t=d_(e[i]))&&(a&&(a+=" "),a+=t);return a},m4=(e,...t)=>{let a,i,s,c;const u=m=>{const p=t.reduce((g,y)=>y(g),e());return a=c4(p),i=a.cache.get,s=a.cache.set,c=d,d(m)},d=m=>{const p=i(m);if(p)return p;const g=d4(m,a);return s(m,g),g};return c=u,(...m)=>c(h4(...m))},p4=[],kt=e=>{const t=a=>a[e]||p4;return t.isThemeGetter=!0,t},h_=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,m_=/^\((?:(\w[\w-]*):)?(.+)\)$/i,g4=/^\d+\/\d+$/,y4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,v4=/\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$/,b4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,x4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,S4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ji=e=>g4.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),Qr=e=>!!e&&Number.isInteger(Number(e)),eh=e=>e.endsWith("%")&&Se(e.slice(0,-1)),br=e=>y4.test(e),_4=()=>!0,z4=e=>v4.test(e)&&!b4.test(e),p_=()=>!1,w4=e=>x4.test(e),k4=e=>S4.test(e),T4=e=>!re(e)&&!ae(e),E4=e=>ro(e,v_,p_),re=e=>h_.test(e),Oa=e=>ro(e,b_,z4),th=e=>ro(e,N4,Se),ex=e=>ro(e,g_,p_),A4=e=>ro(e,y_,k4),cu=e=>ro(e,x_,w4),ae=e=>m_.test(e),ls=e=>ao(e,b_),C4=e=>ao(e,R4),tx=e=>ao(e,g_),j4=e=>ao(e,v_),O4=e=>ao(e,y_),fu=e=>ao(e,x_,!0),ro=(e,t,a)=>{const i=h_.exec(e);return i?i[1]?t(i[1]):a(i[2]):!1},ao=(e,t,a=!1)=>{const i=m_.exec(e);return i?i[1]?t(i[1]):a:!1},g_=e=>e==="position"||e==="percentage",y_=e=>e==="image"||e==="url",v_=e=>e==="length"||e==="size"||e==="bg-size",b_=e=>e==="length",N4=e=>e==="number",R4=e=>e==="family-name",x_=e=>e==="shadow",M4=()=>{const e=kt("color"),t=kt("font"),a=kt("text"),i=kt("font-weight"),s=kt("tracking"),c=kt("leading"),u=kt("breakpoint"),d=kt("container"),m=kt("spacing"),p=kt("radius"),g=kt("shadow"),y=kt("inset-shadow"),x=kt("text-shadow"),_=kt("drop-shadow"),E=kt("blur"),T=kt("perspective"),C=kt("aspect"),M=kt("ease"),O=kt("animate"),R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...j(),ae,re],W=()=>["auto","hidden","clip","visible","scroll"],K=()=>["auto","contain","none"],B=()=>[ae,re,m],Q=()=>[ji,"full","auto",...B()],te=()=>[Qr,"none","subgrid",ae,re],de=()=>["auto",{span:["full",Qr,ae,re]},Qr,ae,re],xe=()=>[Qr,"auto",ae,re],Fe=()=>["auto","min","max","fr",ae,re],Oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Ne=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...B()],F=()=>[ji,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],q=()=>[e,ae,re],he=()=>[...j(),tx,ex,{position:[ae,re]}],ye=()=>["no-repeat",{repeat:["","x","y","space","round"]}],w=()=>["auto","cover","contain",j4,E4,{size:[ae,re]}],P=()=>[eh,ls,Oa],J=()=>["","none","full",p,ae,re],ee=()=>["",Se,ls,Oa],ce=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],se=()=>[Se,eh,tx,ex],mt=()=>["","none",E,ae,re],Me=()=>["none",Se,ae,re],tn=()=>["none",Se,ae,re],Un=()=>[Se,ae,re],Vn=()=>[ji,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[br],breakpoint:[br],color:[_4],container:[br],"drop-shadow":[br],ease:["in","out","in-out"],font:[T4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[br],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[br],shadow:[br],spacing:["px",Se],text:[br],"text-shadow":[br],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ji,re,ae,C]}],container:["container"],columns:[{columns:[Se,re,ae,d]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:L()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Q()}],"inset-x":[{"inset-x":Q()}],"inset-y":[{"inset-y":Q()}],start:[{start:Q()}],end:[{end:Q()}],top:[{top:Q()}],right:[{right:Q()}],bottom:[{bottom:Q()}],left:[{left:Q()}],visibility:["visible","invisible","collapse"],z:[{z:[Qr,"auto",ae,re]}],basis:[{basis:[ji,"full","auto",d,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,ji,"auto","initial","none",re]}],grow:[{grow:["",Se,ae,re]}],shrink:[{shrink:["",Se,ae,re]}],order:[{order:[Qr,"first","last","none",ae,re]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":xe()}],"col-end":[{"col-end":xe()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":xe()}],"row-end":[{"row-end":xe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Fe()}],"auto-rows":[{"auto-rows":Fe()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...Oe(),"normal"]}],"justify-items":[{"justify-items":[...Ne(),"normal"]}],"justify-self":[{"justify-self":["auto",...Ne()]}],"align-content":[{content:["normal",...Oe()]}],"align-items":[{items:[...Ne(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Ne(),{baseline:["","last"]}]}],"place-content":[{"place-content":Oe()}],"place-items":[{"place-items":[...Ne(),"baseline"]}],"place-self":[{"place-self":["auto",...Ne()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[d,"screen",...F()]}],"min-w":[{"min-w":[d,"screen","none",...F()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[u]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",a,ls,Oa]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,ae,th]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",eh,re]}],"font-family":[{font:[C4,re,t]}],"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:[s,ae,re]}],"line-clamp":[{"line-clamp":[Se,"none",ae,th]}],leading:[{leading:[c,...B()]}],"list-image":[{"list-image":["none",ae,re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ae,re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ce(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",ae,Oa]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Se,"auto",ae,re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ae,re]}],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",ae,re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:he()}],"bg-repeat":[{bg:ye()}],"bg-size":[{bg:w()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qr,ae,re],radial:["",ae,re],conic:[Qr,ae,re]},O4,A4]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:P()}],"gradient-via-pos":[{via:P()}],"gradient-to-pos":[{to:P()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:J()}],"rounded-s":[{"rounded-s":J()}],"rounded-e":[{"rounded-e":J()}],"rounded-t":[{"rounded-t":J()}],"rounded-r":[{"rounded-r":J()}],"rounded-b":[{"rounded-b":J()}],"rounded-l":[{"rounded-l":J()}],"rounded-ss":[{"rounded-ss":J()}],"rounded-se":[{"rounded-se":J()}],"rounded-ee":[{"rounded-ee":J()}],"rounded-es":[{"rounded-es":J()}],"rounded-tl":[{"rounded-tl":J()}],"rounded-tr":[{"rounded-tr":J()}],"rounded-br":[{"rounded-br":J()}],"rounded-bl":[{"rounded-bl":J()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ce(),"hidden","none"]}],"divide-style":[{divide:[...ce(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...ce(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,ae,re]}],"outline-w":[{outline:["",Se,ls,Oa]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",g,fu,cu]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",y,fu,cu]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Se,Oa]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",x,fu,cu]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Se,ae,re]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"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":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":se()}],"mask-image-linear-to-pos":[{"mask-linear-to":se()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":se()}],"mask-image-t-to-pos":[{"mask-t-to":se()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":se()}],"mask-image-r-to-pos":[{"mask-r-to":se()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":se()}],"mask-image-b-to-pos":[{"mask-b-to":se()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":se()}],"mask-image-l-to-pos":[{"mask-l-to":se()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":se()}],"mask-image-x-to-pos":[{"mask-x-to":se()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":se()}],"mask-image-y-to-pos":[{"mask-y-to":se()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[ae,re]}],"mask-image-radial-from-pos":[{"mask-radial-from":se()}],"mask-image-radial-to-pos":[{"mask-radial-to":se()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":j()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":se()}],"mask-image-conic-to-pos":[{"mask-conic-to":se()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:he()}],"mask-repeat":[{mask:ye()}],"mask-size":[{mask:w()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ae,re]}],filter:[{filter:["","none",ae,re]}],blur:[{blur:mt()}],brightness:[{brightness:[Se,ae,re]}],contrast:[{contrast:[Se,ae,re]}],"drop-shadow":[{"drop-shadow":["","none",_,fu,cu]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Se,ae,re]}],"hue-rotate":[{"hue-rotate":[Se,ae,re]}],invert:[{invert:["",Se,ae,re]}],saturate:[{saturate:[Se,ae,re]}],sepia:[{sepia:["",Se,ae,re]}],"backdrop-filter":[{"backdrop-filter":["","none",ae,re]}],"backdrop-blur":[{"backdrop-blur":mt()}],"backdrop-brightness":[{"backdrop-brightness":[Se,ae,re]}],"backdrop-contrast":[{"backdrop-contrast":[Se,ae,re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,ae,re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,ae,re]}],"backdrop-invert":[{"backdrop-invert":["",Se,ae,re]}],"backdrop-opacity":[{"backdrop-opacity":[Se,ae,re]}],"backdrop-saturate":[{"backdrop-saturate":[Se,ae,re]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,ae,re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ae,re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",ae,re]}],ease:[{ease:["linear","initial",M,ae,re]}],delay:[{delay:[Se,ae,re]}],animate:[{animate:["none",O,ae,re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[T,ae,re]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:tn()}],"scale-x":[{"scale-x":tn()}],"scale-y":[{"scale-y":tn()}],"scale-z":[{"scale-z":tn()}],"scale-3d":["scale-3d"],skew:[{skew:Un()}],"skew-x":[{"skew-x":Un()}],"skew-y":[{"skew-y":Un()}],transform:[{transform:[ae,re,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Vn()}],"translate-x":[{"translate-x":Vn()}],"translate-y":[{"translate-y":Vn()}],"translate-z":[{"translate-z":Vn()}],"translate-none":["translate-none"],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",ae,re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"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",ae,re]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Se,ls,Oa,th]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Gi=m4(M4);function wn({label:e,error:t,helperText:a,className:i,...s}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("input",{className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",i),...s}),a&&!t&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),t&&v.jsx("p",{className:"text-xs text-red-500",children:t})]})}function du({label:e,options:t,error:a,helperText:i,className:s,...c}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("select",{className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors appearance-none",a&&"border-red-500 focus:border-red-500 focus:ring-red-500",s),...c,children:t.map(u=>v.jsx("option",{value:u.value,className:"bg-azure-bg dark:bg-matrix-base",children:u.label},u.value))}),i&&!a&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:i}),a&&v.jsx("p",{className:"text-xs text-red-500",children:a})]})}function Oi({label:e,error:t,helperText:a,className:i,...s}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("input",{type:"number",className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",i),...s}),a&&!t&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),t&&v.jsx("p",{className:"text-xs text-red-500",children:t})]})}function hu({label:e,checked:t,onChange:a,helperText:i,disabled:s}){return v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{className:"flex flex-col",children:[v.jsx("span",{className:Gi("text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",s&&"opacity-50"),children:e}),i&&v.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:i})]}),v.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>!s&&a(!t),className:Gi("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:ring-offset-2 focus:ring-offset-azure-bg dark:focus:ring-offset-black",t?"bg-azure-primary dark:bg-matrix-highlight":"bg-slate-300 dark:bg-matrix-primary",s&&"opacity-50 cursor-not-allowed"),children:v.jsx("span",{className:Gi("inline-block h-4 w-4 transform rounded-full bg-white dark:bg-black transition-transform",t?"translate-x-6":"translate-x-1")})})]})}const mu={fetchConfig:async()=>dn.get("/config"),updateConfig:async e=>dn.post("/config",e),getSatiConfig:async()=>dn.get("/config/sati"),updateSatiConfig:async e=>dn.post("/config/sati",e),deleteSatiConfig:async()=>dn.delete("/config/sati")};function G(e,t,a){function i(d,m){if(d._zod||Object.defineProperty(d,"_zod",{value:{def:m,constr:u,traits:new Set},enumerable:!1}),d._zod.traits.has(e))return;d._zod.traits.add(e),t(d,m);const p=u.prototype,g=Object.keys(p);for(let y=0;y<g.length;y++){const x=g[y];x in d||(d[x]=p[x].bind(d))}}const s=a?.Parent??Object;class c extends s{}Object.defineProperty(c,"name",{value:e});function u(d){var m;const p=a?.Parent?new c:this;i(p,d),(m=p._zod).deferred??(m.deferred=[]);for(const g of p._zod.deferred)g();return p}return Object.defineProperty(u,"init",{value:i}),Object.defineProperty(u,Symbol.hasInstance,{value:d=>a?.Parent&&d instanceof a.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}let qi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},S_=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};const __={};function aa(e){return __}function z_(e){const t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,s])=>t.indexOf(+i)===-1).map(([i,s])=>s)}function Yh(e,t){return typeof t=="bigint"?t.toString():t}function Wu(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Im(e){return e==null}function Xm(e){const t=e.startsWith("^")?1:0,a=e.endsWith("$")?e.length-1:e.length;return e.slice(t,a)}function D4(e,t){const a=(e.toString().split(".")[1]||"").length,i=t.toString();let s=(i.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(i)){const m=i.match(/\d?e-(\d?)/);m?.[1]&&(s=Number.parseInt(m[1]))}const c=a>s?a:s,u=Number.parseInt(e.toFixed(c).replace(".","")),d=Number.parseInt(t.toFixed(c).replace(".",""));return u%d/10**c}const nx=Symbol("evaluating");function Re(e,t,a){let i;Object.defineProperty(e,t,{get(){if(i!==nx)return i===void 0&&(i=nx,i=a()),i},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function Ha(e,t,a){Object.defineProperty(e,t,{value:a,writable:!0,enumerable:!0,configurable:!0})}function sa(...e){const t={};for(const a of e){const i=Object.getOwnPropertyDescriptors(a);Object.assign(t,i)}return Object.defineProperties({},t)}function rx(e){return JSON.stringify(e)}function $4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const w_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Z4=Wu(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Xi(e){if(Es(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const a=t.prototype;return!(Es(a)===!1||Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")===!1)}function k_(e){return Xi(e)?{...e}:Array.isArray(e)?[...e]:e}const L4=new Set(["string","number","symbol"]);function Fi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function la(e,t,a){const i=new e._zod.constr(t??e._zod.def);return(!t||a?.parent)&&(i._zod.parent=e),i}function le(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function U4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const V4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function B4(e,t){const a=e._zod.def,i=a.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const c=sa(e._zod.def,{get shape(){const u={};for(const d in t){if(!(d in a.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&(u[d]=a.shape[d])}return Ha(this,"shape",u),u},checks:[]});return la(e,c)}function P4(e,t){const a=e._zod.def,i=a.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const c=sa(e._zod.def,{get shape(){const u={...e._zod.def.shape};for(const d in t){if(!(d in a.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&delete u[d]}return Ha(this,"shape",u),u},checks:[]});return la(e,c)}function H4(e,t){if(!Xi(t))throw new Error("Invalid input to extend: expected a plain object");const a=e._zod.def.checks;if(a&&a.length>0){const c=e._zod.def.shape;for(const u in t)if(Object.getOwnPropertyDescriptor(c,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=sa(e._zod.def,{get shape(){const c={...e._zod.def.shape,...t};return Ha(this,"shape",c),c}});return la(e,s)}function G4(e,t){if(!Xi(t))throw new Error("Invalid input to safeExtend: expected a plain object");const a=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ha(this,"shape",i),i}});return la(e,a)}function q4(e,t){const a=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return Ha(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return la(e,a)}function Y4(e,t,a){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const u=sa(t._zod.def,{get shape(){const d=t._zod.def.shape,m={...d};if(a)for(const p in a){if(!(p in d))throw new Error(`Unrecognized key: "${p}"`);a[p]&&(m[p]=e?new e({type:"optional",innerType:d[p]}):d[p])}else for(const p in d)m[p]=e?new e({type:"optional",innerType:d[p]}):d[p];return Ha(this,"shape",m),m},checks:[]});return la(t,u)}function I4(e,t,a){const i=sa(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(a)for(const u in a){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);a[u]&&(c[u]=new e({type:"nonoptional",innerType:s[u]}))}else for(const u in s)c[u]=new e({type:"nonoptional",innerType:s[u]});return Ha(this,"shape",c),c}});return la(t,i)}function Ui(e,t=0){if(e.aborted===!0)return!0;for(let a=t;a<e.issues.length;a++)if(e.issues[a]?.continue!==!0)return!0;return!1}function Vi(e,t){return t.map(a=>{var i;return(i=a).path??(i.path=[]),a.path.unshift(e),a})}function pu(e){return typeof e=="string"?e:e?.message}function ia(e,t,a){const i={...e,path:e.path??[]};if(!e.message){const s=pu(e.inst?._zod.def?.error?.(e))??pu(t?.error?.(e))??pu(a.customError?.(e))??pu(a.localeError?.(e))??"Invalid input";i.message=s}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Fm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function As(...e){const[t,a,i]=e;return typeof t=="string"?{message:t,code:"custom",input:a,inst:i}:{...t}}const T_=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Yh,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},E_=G("$ZodError",T_),A_=G("$ZodError",T_,{Parent:Error});function X4(e,t=a=>a.message){const a={},i=[];for(const s of e.issues)s.path.length>0?(a[s.path[0]]=a[s.path[0]]||[],a[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:a}}function F4(e,t=a=>a.message){const a={_errors:[]},i=s=>{for(const c of s.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u}));else if(c.code==="invalid_key")i({issues:c.issues});else if(c.code==="invalid_element")i({issues:c.issues});else if(c.path.length===0)a._errors.push(t(c));else{let u=a,d=0;for(;d<c.path.length;){const m=c.path[d];d===c.path.length-1?(u[m]=u[m]||{_errors:[]},u[m]._errors.push(t(c))):u[m]=u[m]||{_errors:[]},u=u[m],d++}}};return i(e),a}const Km=e=>(t,a,i,s)=>{const c=i?Object.assign(i,{async:!1}):{async:!1},u=t._zod.run({value:a,issues:[]},c);if(u instanceof Promise)throw new qi;if(u.issues.length){const d=new(s?.Err??e)(u.issues.map(m=>ia(m,c,aa())));throw w_(d,s?.callee),d}return u.value},Jm=e=>async(t,a,i,s)=>{const c=i?Object.assign(i,{async:!0}):{async:!0};let u=t._zod.run({value:a,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const d=new(s?.Err??e)(u.issues.map(m=>ia(m,c,aa())));throw w_(d,s?.callee),d}return u.value},ec=e=>(t,a,i)=>{const s=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:a,issues:[]},s);if(c instanceof Promise)throw new qi;return c.issues.length?{success:!1,error:new(e??E_)(c.issues.map(u=>ia(u,s,aa())))}:{success:!0,data:c.value}},K4=ec(A_),tc=e=>async(t,a,i)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let c=t._zod.run({value:a,issues:[]},s);return c instanceof Promise&&(c=await c),c.issues.length?{success:!1,error:new e(c.issues.map(u=>ia(u,s,aa())))}:{success:!0,data:c.value}},J4=tc(A_),Q4=e=>(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Km(e)(t,a,s)},W4=e=>(t,a,i)=>Km(e)(t,a,i),eR=e=>async(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Jm(e)(t,a,s)},tR=e=>async(t,a,i)=>Jm(e)(t,a,i),nR=e=>(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ec(e)(t,a,s)},rR=e=>(t,a,i)=>ec(e)(t,a,i),aR=e=>async(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return tc(e)(t,a,s)},iR=e=>async(t,a,i)=>tc(e)(t,a,i),oR=/^[cC][^\s-]{8,}$/,sR=/^[0-9a-z]+$/,lR=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,uR=/^[0-9a-vA-V]{20}$/,cR=/^[A-Za-z0-9]{27}$/,fR=/^[a-zA-Z0-9_-]{21}$/,dR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hR=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ax=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,mR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function gR(){return new RegExp(pR,"u")}const yR=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,bR=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,SR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C_=/^[A-Za-z0-9_-]*$/,_R=/^\+[1-9]\d{6,14}$/,j_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",zR=new RegExp(`^${j_}$`);function O_(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wR(e){return new RegExp(`^${O_(e)}$`)}function kR(e){const t=O_({precision:e.precision}),a=["Z"];e.local&&a.push(""),e.offset&&a.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${a.join("|")})`;return new RegExp(`^${j_}T(?:${i})$`)}const TR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ER=/^-?\d+$/,N_=/^-?\d+(?:\.\d+)?$/,AR=/^(?:true|false)$/i,CR=/^[^A-Z]*$/,jR=/^[^a-z]*$/,en=G("$ZodCheck",(e,t)=>{var a;e._zod??(e._zod={}),e._zod.def=t,(a=e._zod).onattach??(a.onattach=[])}),R_={number:"number",bigint:"bigint",object:"date"},M_=G("$ZodCheckLessThan",(e,t)=>{en.init(e,t);const a=R_[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,c=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<c&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:a,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),D_=G("$ZodCheckGreaterThan",(e,t)=>{en.init(e,t);const a=R_[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,c=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>c&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:a,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),OR=G("$ZodCheckMultipleOf",(e,t)=>{en.init(e,t),e._zod.onattach.push(a=>{var i;(i=a._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=a=>{if(typeof a.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof a.value=="bigint"?a.value%t.value===BigInt(0):D4(a.value,t.value)===0)||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:t.value,input:a.value,inst:e,continue:!t.abort})}}),NR=G("$ZodCheckNumberFormat",(e,t)=>{en.init(e,t),t.format=t.format||"float64";const a=t.format?.includes("int"),i=a?"int":"number",[s,c]=V4[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=s,d.maximum=c,a&&(d.pattern=ER)}),e._zod.check=u=>{const d=u.value;if(a){if(!Number.isInteger(d)){u.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}d<s&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),d>c&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:c,inclusive:!0,inst:e,continue:!t.abort})}}),RR=G("$ZodCheckMaxLength",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{const s=i.value;if(s.length<=t.maximum)return;const u=Fm(s);i.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),MR=G("$ZodCheckMinLength",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{const s=i.value;if(s.length>=t.minimum)return;const u=Fm(s);i.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),DR=G("$ZodCheckLengthEquals",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=i=>{const s=i.value,c=s.length;if(c===t.length)return;const u=Fm(s),d=c>t.length;i.issues.push({origin:u,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),nc=G("$ZodCheckStringFormat",(e,t)=>{var a,i;en.init(e,t),e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,t.pattern&&(c.patterns??(c.patterns=new Set),c.patterns.add(t.pattern))}),t.pattern?(a=e._zod).check??(a.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),$R=G("$ZodCheckRegex",(e,t)=>{nc.init(e,t),e._zod.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ZR=G("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=CR),nc.init(e,t)}),LR=G("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=jR),nc.init(e,t)}),UR=G("$ZodCheckIncludes",(e,t)=>{en.init(e,t);const a=Fi(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${a}`:a);t.pattern=i,e._zod.onattach.push(s=>{const c=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(i)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),VR=G("$ZodCheckStartsWith",(e,t)=>{en.init(e,t);const a=new RegExp(`^${Fi(t.prefix)}.*`);t.pattern??(t.pattern=a),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),BR=G("$ZodCheckEndsWith",(e,t)=>{en.init(e,t);const a=new RegExp(`.*${Fi(t.suffix)}$`);t.pattern??(t.pattern=a),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),PR=G("$ZodCheckOverwrite",(e,t)=>{en.init(e,t),e._zod.check=a=>{a.value=t.tx(a.value)}});let HR=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const i=t.split(`
|
|
19
|
+
`),()=>{j.contains(R)&&j.removeChild(R)}},[t]),v.jsx(OO,{isPresent:t,childRef:u,sizeRef:d,children:z.cloneElement(e,{ref:g})})}const RO=({children:e,initial:t,isPresent:a,onExitComplete:i,custom:s,presenceAffectsLayout:c,mode:u,anchorX:d,anchorY:m,root:p})=>{const g=fm(MO),y=z.useId();let x=!0,_=z.useMemo(()=>(x=!1,{id:y,initial:t,isPresent:a,custom:s,onExitComplete:E=>{g.set(E,!0);for(const T of g.values())if(!T)return;i&&i()},register:E=>(g.set(E,!1),()=>g.delete(E))}),[a,g,i]);return c&&x&&(_={..._}),z.useMemo(()=>{g.forEach((E,T)=>g.set(T,!1))},[a]),z.useEffect(()=>{!a&&!g.size&&i&&i()},[a]),u==="popLayout"&&(e=v.jsx(NO,{isPresent:a,anchorX:d,anchorY:m,root:p,children:e})),v.jsx(Fu.Provider,{value:_,children:e})};function MO(){return new Map}function FS(e=!0){const t=z.useContext(Fu);if(t===null)return[!0,null];const{isPresent:a,onExitComplete:i,register:s}=t,c=z.useId();z.useEffect(()=>{if(e)return s(c)},[e]);const u=z.useCallback(()=>e&&i&&i(c),[c,i,e]);return!a&&i?[!1,u]:[!0]}const lu=e=>e.key||"";function Zb(e){const t=[];return z.Children.forEach(e,a=>{z.isValidElement(a)&&t.push(a)}),t}const DO=({children:e,custom:t,initial:a=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:c="sync",propagate:u=!1,anchorX:d="left",anchorY:m="top",root:p})=>{const[g,y]=FS(u),x=z.useMemo(()=>Zb(e),[e]),_=u&&!g?[]:x.map(lu),E=z.useRef(!0),T=z.useRef(x),C=fm(()=>new Map),M=z.useRef(new Set),[O,R]=z.useState(x),[j,L]=z.useState(x);E1(()=>{E.current=!1,T.current=x;for(let B=0;B<j.length;B++){const Q=lu(j[B]);_.includes(Q)?(C.delete(Q),M.current.delete(Q)):C.get(Q)!==!0&&C.set(Q,!1)}},[j,_.length,_.join("-")]);const W=[];if(x!==O){let B=[...x];for(let Q=0;Q<j.length;Q++){const te=j[Q],de=lu(te);_.includes(de)||(B.splice(Q,0,te),W.push(te))}return c==="wait"&&W.length&&(B=W),L(Zb(B)),R(x),null}const{forceRender:K}=z.useContext(cm);return v.jsx(v.Fragment,{children:j.map(B=>{const Q=lu(B),te=u&&!g?!1:x===j||_.includes(Q),de=()=>{if(M.current.has(Q))return;if(M.current.add(Q),C.has(Q))C.set(Q,!0);else return;let xe=!0;C.forEach(Fe=>{Fe||(xe=!1)}),xe&&(K?.(),L(T.current),u&&y?.(),i&&i())};return v.jsx(RO,{isPresent:te,initial:!E.current||a?void 0:!1,custom:t,presenceAffectsLayout:s,mode:c,root:p,onExitComplete:te?void 0:de,anchorX:d,anchorY:m,children:B},Q)})})},KS=z.createContext({strict:!1}),Lb={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Ub=!1;function $O(){if(Ub)return;const e={};for(const t in Lb)e[t]={isEnabled:a=>Lb[t].some(i=>!!a[i])};kS(e),Ub=!0}function JS(){return $O(),Sj()}function ZO(e){const t=JS();for(const a in e)t[a]={...t[a],...e[a]};kS(t)}const LO=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function $u(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||LO.has(e)}let QS=e=>!$u(e);function UO(e){typeof e=="function"&&(QS=t=>t.startsWith("on")?!$u(t):e(t))}try{UO(require("@emotion/is-prop-valid").default)}catch{}function VO(e,t,a){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||(QS(s)||a===!0&&$u(s)||!t&&!$u(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const Qu=z.createContext({});function BO(e,t){if(Ju(e)){const{initial:a,animate:i}=e;return{initial:a===!1||ks(a)?a:void 0,animate:ks(i)?i:void 0}}return e.inherit!==!1?t:{}}function PO(e){const{initial:t,animate:a}=BO(e,z.useContext(Qu));return z.useMemo(()=>({initial:t,animate:a}),[Vb(t),Vb(a)])}function Vb(e){return Array.isArray(e)?e.join(" "):e}const Vm=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function WS(e,t,a){for(const i in t)!Vt(t[i])&&!NS(i,a)&&(e[i]=t[i])}function HO({transformTemplate:e},t){return z.useMemo(()=>{const a=Vm();return Zm(a,t,e),Object.assign({},a.vars,a.style)},[t])}function GO(e,t){const a=e.style||{},i={};return WS(i,a,e),Object.assign(i,HO(e,t)),i}function qO(e,t){const a={},i=GO(e,t);return e.drag&&e.dragListener!==!1&&(a.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(a.tabIndex=0),a.style=i,a}const e_=()=>({...Vm(),attrs:{}});function YO(e,t,a,i){const s=z.useMemo(()=>{const c=e_();return RS(c,t,DS(i),e.transformTemplate,e.style),{...c.attrs,style:{...c.style}}},[t]);if(e.style){const c={};WS(c,e.style,e),s.style={...c,...s.style}}return s}const IO=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Bm(e){return typeof e!="string"||e.includes("-")?!1:!!(IO.indexOf(e)>-1||/[A-Z]/u.test(e))}function XO(e,t,a,{latestValues:i},s,c=!1,u){const m=(u??Bm(e)?YO:qO)(t,i,s,e),p=VO(t,typeof e=="string",c),g=e!==z.Fragment?{...p,...m,ref:a}:{},{children:y}=t,x=z.useMemo(()=>Vt(y)?y.get():y,[y]);return z.createElement(e,{...g,children:x})}function FO({scrapeMotionValuesFromProps:e,createRenderState:t},a,i,s){return{latestValues:KO(a,i,s,e),renderState:t()}}function KO(e,t,a,i){const s={},c=i(e,{});for(const x in c)s[x]=Tu(c[x]);let{initial:u,animate:d}=e;const m=Ju(e),p=wS(e);t&&p&&!m&&e.inherit!==!1&&(u===void 0&&(u=t.initial),d===void 0&&(d=t.animate));let g=a?a.initial===!1:!1;g=g||u===!1;const y=g?d:u;if(y&&typeof y!="boolean"&&!Ku(y)){const x=Array.isArray(y)?y:[y];for(let _=0;_<x.length;_++){const E=jm(e,x[_]);if(E){const{transitionEnd:T,transition:C,...M}=E;for(const O in M){let R=M[O];if(Array.isArray(R)){const j=g?R.length-1:0;R=R[j]}R!==null&&(s[O]=R)}for(const O in T)s[O]=T[O]}}}return s}const t_=e=>(t,a)=>{const i=z.useContext(Qu),s=z.useContext(Fu),c=()=>FO(e,t,i,s);return a?c():fm(c)},JO=t_({scrapeMotionValuesFromProps:Lm,createRenderState:Vm}),QO=t_({scrapeMotionValuesFromProps:$S,createRenderState:e_}),WO=Symbol.for("motionComponentSymbol");function eN(e,t,a){const i=z.useRef(a);z.useInsertionEffect(()=>{i.current=a});const s=z.useRef(null);return z.useCallback(c=>{c&&e.onMount?.(c),t&&(c?t.mount(c):t.unmount());const u=i.current;if(typeof u=="function")if(c){const d=u(c);typeof d=="function"&&(s.current=d)}else s.current?(s.current(),s.current=null):u(c);else u&&(u.current=c)},[t])}const n_=z.createContext({});function ds(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function tN(e,t,a,i,s,c){const{visualElement:u}=z.useContext(Qu),d=z.useContext(KS),m=z.useContext(Fu),p=z.useContext(Um).reducedMotion,g=z.useRef(null),y=z.useRef(!1);i=i||d.renderer,!g.current&&i&&(g.current=i(e,{visualState:t,parent:u,props:a,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:p,isSVG:c}),y.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const x=g.current,_=z.useContext(n_);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&nN(g.current,a,s,_);const E=z.useRef(!1);z.useInsertionEffect(()=>{x&&E.current&&x.update(a,m)});const T=a[cS],C=z.useRef(!!T&&!window.MotionHandoffIsComplete?.(T)&&window.MotionHasOptimisedAnimation?.(T));return E1(()=>{y.current=!0,x&&(E.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),C.current&&x.animationState&&x.animationState.animateChanges())}),z.useEffect(()=>{x&&(!C.current&&x.animationState&&x.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(T)}),C.current=!1),x.enteringChildren=void 0)}),x}function nN(e,t,a,i){const{layoutId:s,layout:c,drag:u,dragConstraints:d,layoutScroll:m,layoutRoot:p,layoutCrossfade:g}=t;e.projection=new a(e.latestValues,t["data-framer-portal-id"]?void 0:r_(e.parent)),e.projection.setOptions({layoutId:s,layout:c,alwaysMeasureLayout:!!u||d&&ds(d),visualElement:e,animationType:typeof c=="string"?c:"both",initialPromotionConfig:i,crossfade:g,layoutScroll:m,layoutRoot:p})}function r_(e){if(e)return e.options.allowProjection!==!1?e.projection:r_(e.parent)}function Fd(e,{forwardMotionProps:t=!1,type:a}={},i,s){i&&ZO(i);const c=a?a==="svg":Bm(e),u=c?QO:JO;function d(p,g){let y;const x={...z.useContext(Um),...p,layoutId:rN(p)},{isStatic:_}=x,E=PO(p),T=u(p,_);if(!_&&T1){aN();const C=iN(x);y=C.MeasureLayout,E.visualElement=tN(e,T,x,s,C.ProjectionNode,c)}return v.jsxs(Qu.Provider,{value:E,children:[y&&E.visualElement?v.jsx(y,{visualElement:E.visualElement,...x}):null,XO(e,p,eN(T,E.visualElement,g),T,_,t,c)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const m=z.forwardRef(d);return m[WO]=e,m}function rN({layoutId:e}){const t=z.useContext(cm).id;return t&&e!==void 0?t+"-"+e:e}function aN(e,t){z.useContext(KS).strict}function iN(e){const t=JS(),{drag:a,layout:i}=t;if(!a&&!i)return{};const s={...a,...i};return{MeasureLayout:a?.isEnabled(e)||i?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function oN(e,t){if(typeof Proxy>"u")return Fd;const a=new Map,i=(c,u)=>Fd(c,u,e,t),s=(c,u)=>i(c,u);return new Proxy(s,{get:(c,u)=>u==="create"?i:(a.has(u)||a.set(u,Fd(u,void 0,e,t)),a.get(u))})}const sN=(e,t)=>t.isSVG??Bm(e)?new Lj(t):new Nj(t,{allowProjection:e!==z.Fragment});class lN extends oa{constructor(t){super(t),t.animationState||(t.animationState=Hj(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ku(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:a}=this.node.prevProps||{};t!==a&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let uN=0;class cN extends oa{constructor(){super(...arguments),this.id=uN++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:a}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const s=this.node.animationState.setActive("exit",!t);a&&!t&&s.then(()=>{a(this.id)})}mount(){const{register:t,onExitComplete:a}=this.node.presenceContext||{};a&&a(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const fN={animation:{Feature:lN},exit:{Feature:cN}};function Ls(e){return{point:{x:e.pageX,y:e.pageY}}}const dN=e=>t=>Mm(t)&&e(t,Ls(t));function bs(e,t,a,i){return Ts(e,t,dN(a),i)}const a_=({current:e})=>e?e.ownerDocument.defaultView:null,Bb=(e,t)=>Math.abs(e-t);function hN(e,t){const a=Bb(e.x,t.x),i=Bb(e.y,t.y);return Math.sqrt(a**2+i**2)}const Pb=new Set(["auto","scroll"]);class i_{constructor(t,a,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:c=!1,distanceThreshold:u=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=Jd(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,T=hN(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!T)return;const{point:C}=_,{timestamp:M}=$t;this.history.push({...C,timestamp:M});const{onStart:O,onMove:R}=this.handlers;E||(O&&O(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),R&&R(this.lastMoveEvent,_)},this.handlePointerMove=(_,E)=>{this.lastMoveEvent=_,this.lastMoveEventInfo=Kd(E,this.transformPagePoint),Xe.update(this.updatePoint,!0)},this.handlePointerUp=(_,E)=>{this.end();const{onEnd:T,onSessionEnd:C,resumeAnimation:M}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const O=Jd(_.type==="pointercancel"?this.lastMoveEventInfo:Kd(E,this.transformPagePoint),this.history);this.startEvent&&T&&T(_,O),C&&C(_,O)},!Mm(t))return;this.dragSnapToOrigin=c,this.handlers=a,this.transformPagePoint=i,this.distanceThreshold=u,this.contextWindow=s||window;const m=Ls(t),p=Kd(m,this.transformPagePoint),{point:g}=p,{timestamp:y}=$t;this.history=[{...g,timestamp:y}];const{onSessionStart:x}=a;x&&x(t,Jd(p,this.history)),this.removeListeners=Ds(bs(this.contextWindow,"pointermove",this.handlePointerMove),bs(this.contextWindow,"pointerup",this.handlePointerUp),bs(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(t){let a=t.parentElement;for(;a;){const i=getComputedStyle(a);(Pb.has(i.overflowX)||Pb.has(i.overflowY))&&this.scrollPositions.set(a,{x:a.scrollLeft,y:a.scrollTop}),a=a.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const a=this.scrollPositions.get(t);if(!a)return;const i=t===window,s=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},c={x:s.x-a.x,y:s.y-a.y};c.x===0&&c.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=c.x,this.lastMoveEventInfo.point.y+=c.y):this.history.length>0&&(this.history[0].x-=c.x,this.history[0].y-=c.y),this.scrollPositions.set(t,s),Xe.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),na(this.updatePoint)}}function Kd(e,t){return t?{point:t(e.point)}:e}function Hb(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Jd({point:e},t){return{point:e,delta:Hb(e,o_(t)),offset:Hb(e,mN(t)),velocity:pN(t,.1)}}function mN(e){return e[0]}function o_(e){return e[e.length-1]}function pN(e,t){if(e.length<2)return{x:0,y:0};let a=e.length-1,i=null;const s=o_(e);for(;a>=0&&(i=e[a],!(s.timestamp-i.timestamp>zr(t)));)a--;if(!i)return{x:0,y:0};const c=En(s.timestamp-i.timestamp);if(c===0)return{x:0,y:0};const u={x:(s.x-i.x)/c,y:(s.y-i.y)/c};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function gN(e,{min:t,max:a},i){return t!==void 0&&e<t?e=i?at(t,e,i.min):Math.max(e,t):a!==void 0&&e>a&&(e=i?at(a,e,i.max):Math.min(e,a)),e}function Gb(e,t,a){return{min:t!==void 0?e.min+t:void 0,max:a!==void 0?e.max+a-(e.max-e.min):void 0}}function yN(e,{top:t,left:a,bottom:i,right:s}){return{x:Gb(e.x,a,s),y:Gb(e.y,t,i)}}function qb(e,t){let a=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([a,i]=[i,a]),{min:a,max:i}}function vN(e,t){return{x:qb(e.x,t.x),y:qb(e.y,t.y)}}function bN(e,t){let a=.5;const i=Yt(e),s=Yt(t);return s>i?a=_s(t.min,t.max-i,e.min):i>s&&(a=_s(e.min,e.max-s,t.min)),Qn(0,1,a)}function xN(e,t){const a={};return t.min!==void 0&&(a.min=t.min-e.min),t.max!==void 0&&(a.max=t.max-e.min),a}const Ph=.35;function SN(e=Ph){return e===!1?e=0:e===!0&&(e=Ph),{x:Yb(e,"left","right"),y:Yb(e,"top","bottom")}}function Yb(e,t,a){return{min:Ib(e,t),max:Ib(e,a)}}function Ib(e,t){return typeof e=="number"?e:e[t]||0}const _N=new WeakMap;class zN{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Tt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:a=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const c=y=>{a?(this.stopAnimation(),this.snapToCursor(Ls(y).point)):this.pauseAnimation()},u=(y,x)=>{this.stopAnimation();const{drag:_,dragPropagation:E,onDragStart:T}=this.getProps();if(_&&!E&&(this.openDragLock&&this.openDragLock(),this.openDragLock=uj(_),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kn(M=>{let O=this.getAxisMotionValue(M).get()||0;if(Jn.test(O)){const{projection:R}=this.visualElement;if(R&&R.layout){const j=R.layout.layoutBox[M];j&&(O=Yt(j)*(parseFloat(O)/100))}}this.originPoint[M]=O}),T&&Xe.postRender(()=>T(y,x)),Mh(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},d=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x;const{dragPropagation:_,dragDirectionLock:E,onDirectionLock:T,onDrag:C}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:M}=x;if(E&&this.currentDirection===null){this.currentDirection=wN(M),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",x.point,M),this.updateAxis("y",x.point,M),this.visualElement.render(),C&&C(y,x)},m=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x,this.stop(y,x),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>kn(y=>this.getAnimationState(y)==="paused"&&this.getAxisMotionValue(y).animation?.play()),{dragSnapToOrigin:g}=this.getProps();this.panSession=new i_(t,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:i,contextWindow:a_(this.visualElement),element:this.visualElement.current})}stop(t,a){const i=t||this.latestPointerEvent,s=a||this.latestPanInfo,c=this.isDragging;if(this.cancel(),!c||!s||!i)return;const{velocity:u}=s;this.startAnimation(u);const{onDragEnd:d}=this.getProps();d&&Xe.postRender(()=>d(i,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:a}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),a&&a.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,a,i){const{drag:s}=this.getProps();if(!i||!uu(t,s,this.currentDirection))return;const c=this.getAxisMotionValue(t);let u=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(u=gN(u,this.constraints[t],this.elastic[t])),c.set(u)}resolveConstraints(){const{dragConstraints:t,dragElastic:a}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,s=this.constraints;t&&ds(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=yN(i.layoutBox,t):this.constraints=!1,this.elastic=SN(a),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&kn(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=xN(i.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:a}=this.getProps();if(!t||!ds(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const c=Tj(i,s.root,this.visualElement.getTransformPagePoint());let u=vN(s.layout.layoutBox,c);if(a){const d=a(zj(u));this.hasMutatedConstraints=!!d,d&&(u=ES(d))}return u}startAnimation(t){const{drag:a,dragMomentum:i,dragElastic:s,dragTransition:c,dragSnapToOrigin:u,onDragTransitionEnd:d}=this.getProps(),m=this.constraints||{},p=kn(g=>{if(!uu(g,a,this.currentDirection))return;let y=m&&m[g]||{};u&&(y={min:0,max:0});const x=s?200:1e6,_=s?40:1e7,E={type:"inertia",velocity:i?t[g]:0,bounceStiffness:x,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...c,...y};return this.startAxisValueAnimation(g,E)});return Promise.all(p).then(d)}startAxisValueAnimation(t,a){const i=this.getAxisMotionValue(t);return Mh(this.visualElement,t),i.start(Cm(t,i,0,a,this.visualElement,!1))}stopAnimation(){kn(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){kn(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const a=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),s=i[a];return s||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){kn(a=>{const{drag:i}=this.getProps();if(!uu(a,i,this.currentDirection))return;const{projection:s}=this.visualElement,c=this.getAxisMotionValue(a);if(s&&s.layout){const{min:u,max:d}=s.layout.layoutBox[a],m=c.get()||0;c.set(t[a]-at(u,d,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:a}=this.getProps(),{projection:i}=this.visualElement;if(!ds(a)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};kn(u=>{const d=this.getAxisMotionValue(u);if(d&&this.constraints!==!1){const m=d.get();s[u]=bN({min:m,max:m},this.constraints[u])}});const{transformTemplate:c}=this.visualElement.getProps();this.visualElement.current.style.transform=c?c({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),kn(u=>{if(!uu(u,t,null))return;const d=this.getAxisMotionValue(u),{min:m,max:p}=this.constraints[u];d.set(at(m,p,s[u]))})}addListeners(){if(!this.visualElement.current)return;_N.set(this.visualElement,this);const t=this.visualElement.current,a=bs(t,"pointerdown",m=>{const{drag:p,dragListener:g=!0}=this.getProps(),y=m.target,x=y!==t&&SS(y);p&&g&&!x&&this.start(m)}),i=()=>{const{dragConstraints:m}=this.getProps();ds(m)&&m.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,c=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Xe.read(i);const u=Ts(window,"resize",()=>this.scalePositionWithinConstraints()),d=s.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:p})=>{this.isDragging&&p&&(kn(g=>{const y=this.getAxisMotionValue(g);y&&(this.originPoint[g]+=m[g].translate,y.set(y.get()+m[g].translate))}),this.visualElement.render())}));return()=>{u(),a(),c(),d&&d()}}getProps(){const t=this.visualElement.getProps(),{drag:a=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:c=!1,dragElastic:u=Ph,dragMomentum:d=!0}=t;return{...t,drag:a,dragDirectionLock:i,dragPropagation:s,dragConstraints:c,dragElastic:u,dragMomentum:d}}}function uu(e,t,a){return(t===!0||t===e)&&(a===null||a===e)}function wN(e,t=10){let a=null;return Math.abs(e.y)>t?a="y":Math.abs(e.x)>t&&(a="x"),a}class kN extends oa{constructor(t){super(t),this.removeGroupControls=An,this.removeListeners=An,this.controls=new zN(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||An}update(){const{dragControls:t}=this.node.getProps(),{dragControls:a}=this.node.prevProps||{};t!==a&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Xb=e=>(t,a)=>{e&&Xe.postRender(()=>e(t,a))};class TN extends oa{constructor(){super(...arguments),this.removePointerDownListener=An}onPointerDown(t){this.session=new i_(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:a_(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:a,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:Xb(t),onStart:Xb(a),onMove:i,onEnd:(c,u)=>{delete this.session,s&&Xe.postRender(()=>s(c,u))}}}mount(){this.removePointerDownListener=bs(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Qd=!1;class EN extends z.Component{componentDidMount(){const{visualElement:t,layoutGroup:a,switchLayoutGroup:i,layoutId:s}=this.props,{projection:c}=t;c&&(a.group&&a.group.add(c),i&&i.register&&s&&i.register(c),Qd&&c.root.didUpdate(),c.addEventListener("animationComplete",()=>{this.safeToRemove()}),c.setOptions({...c.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Eu.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:a,visualElement:i,drag:s,isPresent:c}=this.props,{projection:u}=i;return u&&(u.isPresent=c,t.layoutDependency!==a&&u.setOptions({...u.options,layoutDependency:a}),Qd=!0,s||t.layoutDependency!==a||a===void 0||t.isPresent!==c?u.willUpdate():this.safeToRemove(),t.isPresent!==c&&(c?u.promote():u.relegate()||Xe.postRender(()=>{const d=u.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Rm.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:a,switchLayoutGroup:i}=this.props,{projection:s}=t;Qd=!0,s&&(s.scheduleCheckAfterUnmount(),a&&a.group&&a.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function s_(e){const[t,a]=FS(),i=z.useContext(cm);return v.jsx(EN,{...e,layoutGroup:i,switchLayoutGroup:z.useContext(n_),isPresent:t,safeToRemove:a})}const AN={pan:{Feature:TN},drag:{Feature:kN,ProjectionNode:XS,MeasureLayout:s_}};function Fb(e,t,a){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",a==="Start");const s="onHover"+a,c=i[s];c&&Xe.postRender(()=>c(t,Ls(t)))}class CN extends oa{mount(){const{current:t}=this.node;t&&(this.unmount=cj(t,(a,i)=>(Fb(this.node,i,"Start"),s=>Fb(this.node,s,"End"))))}unmount(){}}class jN extends oa{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ds(Ts(this.node.current,"focus",()=>this.onFocus()),Ts(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Kb(e,t,a){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",a==="Start");const s="onTap"+(a==="End"?"":a),c=i[s];c&&Xe.postRender(()=>c(t,Ls(t)))}class ON extends oa{mount(){const{current:t}=this.node;t&&(this.unmount=hj(t,(a,i)=>(Kb(this.node,i,"Start"),(s,{success:c})=>Kb(this.node,s,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Hh=new WeakMap,Wd=new WeakMap,NN=e=>{const t=Hh.get(e.target);t&&t(e)},RN=e=>{e.forEach(NN)};function MN({root:e,...t}){const a=e||document;Wd.has(a)||Wd.set(a,{});const i=Wd.get(a),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(RN,{root:e,...t})),i[s]}function DN(e,t,a){const i=MN(t);return Hh.set(e,a),i.observe(e),()=>{Hh.delete(e),i.unobserve(e)}}const $N={some:0,all:1};class ZN extends oa{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:a,margin:i,amount:s="some",once:c}=t,u={root:a?a.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:$N[s]},d=m=>{const{isIntersecting:p}=m;if(this.isInView===p||(this.isInView=p,c&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:g,onViewportLeave:y}=this.node.getProps(),x=p?g:y;x&&x(m)};return DN(this.node.current,u,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:a}=this.node;["amount","margin","root"].some(LN(t,a))&&this.startObserver()}unmount(){}}function LN({viewport:e={}},{viewport:t={}}={}){return a=>e[a]!==t[a]}const UN={inView:{Feature:ZN},tap:{Feature:ON},focus:{Feature:jN},hover:{Feature:CN}},VN={layout:{ProjectionNode:XS,MeasureLayout:s_}},BN={...fN,...UN,...AN,...VN},Kn=oN(BN,sN),l_=()=>{const[e,t]=z.useState(!!localStorage.getItem("morpheus.auth.token"));return z.useEffect(()=>{const s=()=>{t(!!localStorage.getItem("morpheus.auth.token"))};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),{isAuthenticated:e,login:s=>{localStorage.setItem("morpheus.auth.token",s),t(!0)},logout:()=>{localStorage.removeItem("morpheus.auth.token"),t(!1),window.location.href="/login"}}};function PN({onMenuClick:e,isDark:t,toggleTheme:a}){return v.jsxs("header",{className:"lg:hidden fixed top-0 left-0 right-0 z-50 bg-azure-surface dark:bg-zinc-950 border-b border-azure-border dark:border-matrix-primary p-4 flex items-center justify-between",children:[v.jsxs("h1",{className:"text-lg font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight","aria-label":t?"Modo claro":"Modo escuro",children:t?v.jsx(g1,{className:"w-5 h-5"}):v.jsx(p1,{className:"w-5 h-5"})}),v.jsx("button",{onClick:e,className:"p-2 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-secondary","aria-label":"Abrir menu",children:v.jsx(lE,{className:"w-6 h-6"})})]})]})}const Pm=({open:e,onOpenChange:t,children:a})=>e?v.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[v.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>t(!1)}),v.jsx("div",{className:"relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full max-w-md md:max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:a})]}):null,Hm=({className:e,children:t})=>v.jsx("div",{className:`relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full max-w-md md:max-w-2xl max-h-[90vh] overflow-hidden flex flex-col ${e}`,children:v.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:t})}),Gm=({children:e})=>v.jsx("div",{className:"flex flex-col space-y-1.5 text-center sm:text-left border-b border-azure-border dark:border-matrix-primary p-6",children:e}),qm=({className:e,children:t})=>v.jsx("h3",{className:`text-lg font-semibold leading-none tracking-tight ${e}`,children:t}),Fn=({className:e,variant:t="default",size:a="default",...i})=>{const d=`inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-zinc-950 dark:focus-visible:ring-zinc-300 ${t==="destructive"?"bg-red-500 text-zinc-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-zinc-50 dark:hover:bg-red-900/90":t==="outline"?"border border-azure-border dark:border-matrix-primary bg-transparent hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-primary dark:text-matrix-secondary":t==="secondary"?"bg-azure-surface dark:bg-zinc-800 hover:bg-azure-hover dark:hover:bg-zinc-700/80 text-azure-text-primary dark:text-matrix-secondary":t==="ghost"?"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-primary dark:text-matrix-secondary":t==="link"?"text-azure-primary dark:text-matrix-highlight underline-offset-4 hover:underline":"bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black hover:bg-azure-primary/90 dark:hover:bg-matrix-highlight/90"} ${a==="sm"?"h-9 px-3 rounded-md":a==="lg"?"h-11 px-8 rounded-md":a==="icon"?"h-10 w-10":"h-10 px-4 py-2"} ${e||""}`;return v.jsx("button",{className:d,...i})};function HN({isOpen:e,onClose:t,onConfirm:a}){return v.jsx(Pm,{open:e,onOpenChange:t,children:v.jsxs(Hm,{className:"sm:max-w-md bg-azure-surface dark:bg-zinc-900 border-azure-border dark:border-matrix-primary",children:[v.jsx(Gm,{children:v.jsx(qm,{className:"text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:"Confirm Restart"})}),v.jsxs("div",{children:[v.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary mb-6",children:"Are you sure you want to restart the Morpheus agent? This will temporarily disconnect all services and channels."}),v.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-end",children:[v.jsx(Fn,{variant:"outline",onClick:t,children:"Cancel"}),v.jsx(Fn,{variant:"destructive",onClick:()=>{a(),t()},children:"Confirm Restart"})]})]})]})})}function GN({children:e}){const t=Ln(),[a,i]=z.useState(()=>{const x=localStorage.getItem("theme");return x?x==="dark":!0}),[s,c]=z.useState(!1),[u,d]=z.useState(!1),{logout:m}=l_(),p=async()=>{try{await dn.post("/restart",{}),alert("Restart initiated successfully. The agent will restart shortly.")}catch(x){console.error("Failed to restart:",x),alert("Failed to restart the agent. Please try again.")}};z.useEffect(()=>{a?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))},[a]),z.useEffect(()=>{c(!1)},[t.pathname]);const g=[{icon:x0,label:"Dashboard",path:"/"},{icon:w0,label:"Configuration",path:"/config"},{icon:_0,label:"MCP Servers",path:"/mcp-servers"},{icon:fh,label:"Usage Stats",path:"/stats"},{icon:Mi,label:"Sati Memories",path:"/sati-memories"}],y=[{icon:x0,label:"Dashboard",path:"/"},{icon:w0,label:"Configuration",path:"/config"},{icon:_0,label:"MCP Servers",path:"/mcp-servers"},{icon:fh,label:"Usage Stats",path:"/stats"},{icon:Mi,label:"Sati Memories",path:"/sati-memories"}];return v.jsxs("div",{className:"flex flex-col h-screen bg-azure-bg dark:bg-black text-azure-text-primary dark:text-matrix-secondary font-mono overflow-hidden transition-colors duration-300",children:[v.jsx(PN,{onMenuClick:()=>c(!0),isDark:a,toggleTheme:()=>i(!a)}),v.jsxs("div",{className:"flex flex-1 overflow-hidden pt-16 lg:pt-0",children:[" ",v.jsxs("div",{className:"hidden lg:flex w-64 border-r border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-950 flex-col shrink-0 transition-colors duration-300",children:[v.jsxs("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary flex justify-between items-center",children:[v.jsxs("h1",{className:"text-xl font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsx("button",{onClick:()=>i(!a),className:"p-1 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors",children:a?v.jsx(g1,{className:"w-4 h-4"}):v.jsx(p1,{className:"w-4 h-4"})})]}),v.jsxs("nav",{className:"flex-1 p-4 space-y-2",children:[g.map(x=>{const _=t.pathname===x.path;return v.jsxs(Ri,{to:x.path,className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${_?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,children:[v.jsx(x.icon,{className:"w-5 h-5"}),v.jsx("span",{children:x.label})]},x.path)}),v.jsxs(Ri,{to:"/logs",className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${t.pathname==="/logs"?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,children:[v.jsx(k0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logs"})]},"/logs")]}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>d(!0),className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:[v.jsx(z0,{className:"w-5 h-5"}),v.jsx("span",{children:"Restart"})]})}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:m,className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 transition-colors",children:[v.jsx(S0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logout"})]})})]}),v.jsx(DO,{children:s&&v.jsxs(Kn.div,{className:"fixed inset-0 z-50 lg:hidden",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>c(!1),children:[v.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),v.jsxs(Kn.div,{className:"absolute left-0 top-0 bottom-0 w-64 bg-azure-surface dark:bg-zinc-950 flex flex-col shadow-xl",initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:200},onClick:x=>x.stopPropagation(),children:[v.jsxs("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary flex justify-between items-center",children:[v.jsxs("h1",{className:"text-xl font-bold text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:[v.jsx(Mi,{className:"w-6 h-6"}),"MORPHEUS"]}),v.jsx("button",{onClick:()=>c(!1),className:"p-2 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-muted dark:text-matrix-secondary transition-colors","aria-label":"Fechar menu",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),v.jsxs("nav",{className:"flex-1 p-4 space-y-2 overflow-y-auto",children:[y.map(x=>{const _=t.pathname===x.path;return v.jsxs(Ri,{to:x.path,className:`flex items-center gap-3 px-4 py-3 rounded transition-colors ${_?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary"}`,onClick:()=>c(!1),children:[v.jsx(x.icon,{className:"w-5 h-5"}),v.jsx("span",{children:x.label})]},x.path)}),v.jsxs(Ri,{to:"/logs",className:"flex items-center gap-3 px-4 py-3 rounded transition-colors hidden lg:flex hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary",onClick:()=>c(!1),children:[v.jsx(k0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logs"})]})]}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>{d(!0),c(!1)},className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-azure-hover dark:hover:bg-matrix-primary/50 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:[v.jsx(z0,{className:"w-5 h-5"}),v.jsx("span",{children:"Restart"})]})}),v.jsx("div",{className:"p-2",children:v.jsxs("button",{onClick:()=>{m(),c(!1)},className:"flex items-center gap-3 px-4 py-3 rounded w-full text-left hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 transition-colors",children:[v.jsx(S0,{className:"w-5 h-5"}),v.jsx("span",{children:"Logout"})]})})]})]})}),v.jsxs("main",{className:"flex-1 overflow-auto p-4 md:p-8 relative flex flex-col",children:[v.jsx("div",{className:"max-w-6xl w-full mx-auto flex-1",children:e}),v.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(rgba(18,16,16,0)_50%,rgba(0,0,0,0.1)_50%),linear-gradient(90deg,rgba(0,255,0,0.03),rgba(0,255,0,0.01))] bg-[length:100%_2px,3px_100%] opacity-0 dark:opacity-20 transition-opacity duration-300"})]})]}),v.jsx(iA,{}),v.jsx(HN,{isOpen:u,onClose:()=>d(!1),onConfirm:p})]})}const qN={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},Ma=({title:e,value:t,icon:a,subValue:i})=>v.jsxs(Kn.div,{variants:qN,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[v.jsxs("div",{className:"flex justify-between items-start mb-4",children:[v.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:e}),v.jsx(a,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),v.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:t}),i&&v.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:i})]}),Gh={fetchUsageStats:async()=>dn.get("/stats/usage"),fetchGroupedUsageStats:async()=>dn.get("/stats/usage/grouped")};function YN(){const{data:e}=Va("/api/stats/usage",Gh.fetchUsageStats,{refreshInterval:5e3});return v.jsxs(v.Fragment,{children:[v.jsx(Ma,{title:"Total Input",value:e?e.totalInputTokens.toLocaleString():"-",icon:L2,subValue:"Tokens processed"}),v.jsx(Ma,{title:"Total Output",value:e?e.totalOutputTokens.toLocaleString():"-",icon:V2,subValue:"Tokens generated"})]})}function IN(){const{data:e}=k1(),t={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},a={hidden:{opacity:0,y:20},show:{opacity:1,y:0}};return v.jsxs(Kn.div,{className:"space-y-8",variants:t,initial:"hidden",animate:"show",children:[v.jsxs(Kn.div,{variants:a,children:[v.jsx("h2",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight mb-2",children:"SYSTEM STATUS"}),v.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-80",children:"Overview of the Morpheus agent runtime."})]}),v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[v.jsx(Ma,{title:"Agent Status",value:e?.status.toUpperCase()||"CONNECTING...",icon:Mi,subValue:e?`PID: ${e.pid}`:""}),v.jsx(Ma,{title:"Uptime",value:e?`${Math.floor(e.uptimeSeconds/60)}m`:"-",icon:h1,subValue:e?`${e.uptimeSeconds.toFixed(0)} seconds`:""}),v.jsx(Ma,{title:"Version",value:e?.projectVersion||"-",icon:F2,subValue:`Node ${e?.nodeVersion||"-"}`}),v.jsx(Ma,{title:"Provider",value:e?.llmProvider?.toUpperCase()||"-",icon:G2,subValue:"LLM Inference Engine"}),v.jsx(Ma,{title:"Model",value:e?.llmModel||"-",icon:P2,subValue:"Active Model"}),v.jsx(YN,{})]})]})}function ja({title:e,description:t,children:a}){return v.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[v.jsxs("div",{className:"mb-4",children:[v.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&v.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),v.jsx("div",{className:"space-y-4",children:a})]})}const XN=(e,t)=>{const a=new Array(e.length+t.length);for(let i=0;i<e.length;i++)a[i]=e[i];for(let i=0;i<t.length;i++)a[e.length+i]=t[i];return a},FN=(e,t)=>({classGroupId:e,validator:t}),u_=(e=new Map,t=null,a)=>({nextPart:e,validators:t,classGroupId:a}),Zu="-",Jb=[],KN="arbitrary..",JN=e=>{const t=WN(e),{conflictingClassGroups:a,conflictingClassGroupModifiers:i}=e;return{getClassGroupId:u=>{if(u.startsWith("[")&&u.endsWith("]"))return QN(u);const d=u.split(Zu),m=d[0]===""&&d.length>1?1:0;return c_(d,m,t)},getConflictingClassGroupIds:(u,d)=>{if(d){const m=i[u],p=a[u];return m?p?XN(p,m):m:p||Jb}return a[u]||Jb}}},c_=(e,t,a)=>{if(e.length-t===0)return a.classGroupId;const s=e[t],c=a.nextPart.get(s);if(c){const p=c_(e,t+1,c);if(p)return p}const u=a.validators;if(u===null)return;const d=t===0?e.join(Zu):e.slice(t).join(Zu),m=u.length;for(let p=0;p<m;p++){const g=u[p];if(g.validator(d))return g.classGroupId}},QN=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),a=t.indexOf(":"),i=t.slice(0,a);return i?KN+i:void 0})(),WN=e=>{const{theme:t,classGroups:a}=e;return e4(a,t)},e4=(e,t)=>{const a=u_();for(const i in e){const s=e[i];Ym(s,a,i,t)}return a},Ym=(e,t,a,i)=>{const s=e.length;for(let c=0;c<s;c++){const u=e[c];t4(u,t,a,i)}},t4=(e,t,a,i)=>{if(typeof e=="string"){n4(e,t,a);return}if(typeof e=="function"){r4(e,t,a,i);return}a4(e,t,a,i)},n4=(e,t,a)=>{const i=e===""?t:f_(t,e);i.classGroupId=a},r4=(e,t,a,i)=>{if(i4(e)){Ym(e(i),t,a,i);return}t.validators===null&&(t.validators=[]),t.validators.push(FN(a,e))},a4=(e,t,a,i)=>{const s=Object.entries(e),c=s.length;for(let u=0;u<c;u++){const[d,m]=s[u];Ym(m,f_(t,d),a,i)}},f_=(e,t)=>{let a=e;const i=t.split(Zu),s=i.length;for(let c=0;c<s;c++){const u=i[c];let d=a.nextPart.get(u);d||(d=u_(),a.nextPart.set(u,d)),a=d}return a},i4=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,o4=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,a=Object.create(null),i=Object.create(null);const s=(c,u)=>{a[c]=u,t++,t>e&&(t=0,i=a,a=Object.create(null))};return{get(c){let u=a[c];if(u!==void 0)return u;if((u=i[c])!==void 0)return s(c,u),u},set(c,u){c in a?a[c]=u:s(c,u)}}},qh="!",Qb=":",s4=[],Wb=(e,t,a,i,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:a,maybePostfixModifierPosition:i,isExternal:s}),l4=e=>{const{prefix:t,experimentalParseClassName:a}=e;let i=s=>{const c=[];let u=0,d=0,m=0,p;const g=s.length;for(let T=0;T<g;T++){const C=s[T];if(u===0&&d===0){if(C===Qb){c.push(s.slice(m,T)),m=T+1;continue}if(C==="/"){p=T;continue}}C==="["?u++:C==="]"?u--:C==="("?d++:C===")"&&d--}const y=c.length===0?s:s.slice(m);let x=y,_=!1;y.endsWith(qh)?(x=y.slice(0,-1),_=!0):y.startsWith(qh)&&(x=y.slice(1),_=!0);const E=p&&p>m?p-m:void 0;return Wb(c,_,x,E)};if(t){const s=t+Qb,c=i;i=u=>u.startsWith(s)?c(u.slice(s.length)):Wb(s4,!1,u,void 0,!0)}if(a){const s=i;i=c=>a({className:c,parseClassName:s})}return i},u4=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((a,i)=>{t.set(a,1e6+i)}),a=>{const i=[];let s=[];for(let c=0;c<a.length;c++){const u=a[c],d=u[0]==="[",m=t.has(u);d||m?(s.length>0&&(s.sort(),i.push(...s),s=[]),i.push(u)):s.push(u)}return s.length>0&&(s.sort(),i.push(...s)),i}},c4=e=>({cache:o4(e.cacheSize),parseClassName:l4(e),sortModifiers:u4(e),...JN(e)}),f4=/\s+/,d4=(e,t)=>{const{parseClassName:a,getClassGroupId:i,getConflictingClassGroupIds:s,sortModifiers:c}=t,u=[],d=e.trim().split(f4);let m="";for(let p=d.length-1;p>=0;p-=1){const g=d[p],{isExternal:y,modifiers:x,hasImportantModifier:_,baseClassName:E,maybePostfixModifierPosition:T}=a(g);if(y){m=g+(m.length>0?" "+m:m);continue}let C=!!T,M=i(C?E.substring(0,T):E);if(!M){if(!C){m=g+(m.length>0?" "+m:m);continue}if(M=i(E),!M){m=g+(m.length>0?" "+m:m);continue}C=!1}const O=x.length===0?"":x.length===1?x[0]:c(x).join(":"),R=_?O+qh:O,j=R+M;if(u.indexOf(j)>-1)continue;u.push(j);const L=s(M,C);for(let W=0;W<L.length;++W){const K=L[W];u.push(R+K)}m=g+(m.length>0?" "+m:m)}return m},h4=(...e)=>{let t=0,a,i,s="";for(;t<e.length;)(a=e[t++])&&(i=d_(a))&&(s&&(s+=" "),s+=i);return s},d_=e=>{if(typeof e=="string")return e;let t,a="";for(let i=0;i<e.length;i++)e[i]&&(t=d_(e[i]))&&(a&&(a+=" "),a+=t);return a},m4=(e,...t)=>{let a,i,s,c;const u=m=>{const p=t.reduce((g,y)=>y(g),e());return a=c4(p),i=a.cache.get,s=a.cache.set,c=d,d(m)},d=m=>{const p=i(m);if(p)return p;const g=d4(m,a);return s(m,g),g};return c=u,(...m)=>c(h4(...m))},p4=[],kt=e=>{const t=a=>a[e]||p4;return t.isThemeGetter=!0,t},h_=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,m_=/^\((?:(\w[\w-]*):)?(.+)\)$/i,g4=/^\d+\/\d+$/,y4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,v4=/\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$/,b4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,x4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,S4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ji=e=>g4.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),Qr=e=>!!e&&Number.isInteger(Number(e)),eh=e=>e.endsWith("%")&&Se(e.slice(0,-1)),br=e=>y4.test(e),_4=()=>!0,z4=e=>v4.test(e)&&!b4.test(e),p_=()=>!1,w4=e=>x4.test(e),k4=e=>S4.test(e),T4=e=>!re(e)&&!ae(e),E4=e=>ro(e,v_,p_),re=e=>h_.test(e),Oa=e=>ro(e,b_,z4),th=e=>ro(e,N4,Se),ex=e=>ro(e,g_,p_),A4=e=>ro(e,y_,k4),cu=e=>ro(e,x_,w4),ae=e=>m_.test(e),ls=e=>ao(e,b_),C4=e=>ao(e,R4),tx=e=>ao(e,g_),j4=e=>ao(e,v_),O4=e=>ao(e,y_),fu=e=>ao(e,x_,!0),ro=(e,t,a)=>{const i=h_.exec(e);return i?i[1]?t(i[1]):a(i[2]):!1},ao=(e,t,a=!1)=>{const i=m_.exec(e);return i?i[1]?t(i[1]):a:!1},g_=e=>e==="position"||e==="percentage",y_=e=>e==="image"||e==="url",v_=e=>e==="length"||e==="size"||e==="bg-size",b_=e=>e==="length",N4=e=>e==="number",R4=e=>e==="family-name",x_=e=>e==="shadow",M4=()=>{const e=kt("color"),t=kt("font"),a=kt("text"),i=kt("font-weight"),s=kt("tracking"),c=kt("leading"),u=kt("breakpoint"),d=kt("container"),m=kt("spacing"),p=kt("radius"),g=kt("shadow"),y=kt("inset-shadow"),x=kt("text-shadow"),_=kt("drop-shadow"),E=kt("blur"),T=kt("perspective"),C=kt("aspect"),M=kt("ease"),O=kt("animate"),R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...j(),ae,re],W=()=>["auto","hidden","clip","visible","scroll"],K=()=>["auto","contain","none"],B=()=>[ae,re,m],Q=()=>[ji,"full","auto",...B()],te=()=>[Qr,"none","subgrid",ae,re],de=()=>["auto",{span:["full",Qr,ae,re]},Qr,ae,re],xe=()=>[Qr,"auto",ae,re],Fe=()=>["auto","min","max","fr",ae,re],Oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Ne=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...B()],F=()=>[ji,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],q=()=>[e,ae,re],he=()=>[...j(),tx,ex,{position:[ae,re]}],ye=()=>["no-repeat",{repeat:["","x","y","space","round"]}],w=()=>["auto","cover","contain",j4,E4,{size:[ae,re]}],P=()=>[eh,ls,Oa],J=()=>["","none","full",p,ae,re],ee=()=>["",Se,ls,Oa],ce=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],se=()=>[Se,eh,tx,ex],mt=()=>["","none",E,ae,re],Me=()=>["none",Se,ae,re],tn=()=>["none",Se,ae,re],Un=()=>[Se,ae,re],Vn=()=>[ji,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[br],breakpoint:[br],color:[_4],container:[br],"drop-shadow":[br],ease:["in","out","in-out"],font:[T4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[br],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[br],shadow:[br],spacing:["px",Se],text:[br],"text-shadow":[br],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ji,re,ae,C]}],container:["container"],columns:[{columns:[Se,re,ae,d]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:L()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Q()}],"inset-x":[{"inset-x":Q()}],"inset-y":[{"inset-y":Q()}],start:[{start:Q()}],end:[{end:Q()}],top:[{top:Q()}],right:[{right:Q()}],bottom:[{bottom:Q()}],left:[{left:Q()}],visibility:["visible","invisible","collapse"],z:[{z:[Qr,"auto",ae,re]}],basis:[{basis:[ji,"full","auto",d,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,ji,"auto","initial","none",re]}],grow:[{grow:["",Se,ae,re]}],shrink:[{shrink:["",Se,ae,re]}],order:[{order:[Qr,"first","last","none",ae,re]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":xe()}],"col-end":[{"col-end":xe()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":xe()}],"row-end":[{"row-end":xe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Fe()}],"auto-rows":[{"auto-rows":Fe()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...Oe(),"normal"]}],"justify-items":[{"justify-items":[...Ne(),"normal"]}],"justify-self":[{"justify-self":["auto",...Ne()]}],"align-content":[{content:["normal",...Oe()]}],"align-items":[{items:[...Ne(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Ne(),{baseline:["","last"]}]}],"place-content":[{"place-content":Oe()}],"place-items":[{"place-items":[...Ne(),"baseline"]}],"place-self":[{"place-self":["auto",...Ne()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[d,"screen",...F()]}],"min-w":[{"min-w":[d,"screen","none",...F()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[u]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",a,ls,Oa]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,ae,th]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",eh,re]}],"font-family":[{font:[C4,re,t]}],"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:[s,ae,re]}],"line-clamp":[{"line-clamp":[Se,"none",ae,th]}],leading:[{leading:[c,...B()]}],"list-image":[{"list-image":["none",ae,re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ae,re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ce(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",ae,Oa]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Se,"auto",ae,re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ae,re]}],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",ae,re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:he()}],"bg-repeat":[{bg:ye()}],"bg-size":[{bg:w()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qr,ae,re],radial:["",ae,re],conic:[Qr,ae,re]},O4,A4]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:P()}],"gradient-via-pos":[{via:P()}],"gradient-to-pos":[{to:P()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:J()}],"rounded-s":[{"rounded-s":J()}],"rounded-e":[{"rounded-e":J()}],"rounded-t":[{"rounded-t":J()}],"rounded-r":[{"rounded-r":J()}],"rounded-b":[{"rounded-b":J()}],"rounded-l":[{"rounded-l":J()}],"rounded-ss":[{"rounded-ss":J()}],"rounded-se":[{"rounded-se":J()}],"rounded-ee":[{"rounded-ee":J()}],"rounded-es":[{"rounded-es":J()}],"rounded-tl":[{"rounded-tl":J()}],"rounded-tr":[{"rounded-tr":J()}],"rounded-br":[{"rounded-br":J()}],"rounded-bl":[{"rounded-bl":J()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ce(),"hidden","none"]}],"divide-style":[{divide:[...ce(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...ce(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,ae,re]}],"outline-w":[{outline:["",Se,ls,Oa]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",g,fu,cu]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",y,fu,cu]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Se,Oa]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",x,fu,cu]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Se,ae,re]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"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":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":se()}],"mask-image-linear-to-pos":[{"mask-linear-to":se()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":se()}],"mask-image-t-to-pos":[{"mask-t-to":se()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":se()}],"mask-image-r-to-pos":[{"mask-r-to":se()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":se()}],"mask-image-b-to-pos":[{"mask-b-to":se()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":se()}],"mask-image-l-to-pos":[{"mask-l-to":se()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":se()}],"mask-image-x-to-pos":[{"mask-x-to":se()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":se()}],"mask-image-y-to-pos":[{"mask-y-to":se()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[ae,re]}],"mask-image-radial-from-pos":[{"mask-radial-from":se()}],"mask-image-radial-to-pos":[{"mask-radial-to":se()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":j()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":se()}],"mask-image-conic-to-pos":[{"mask-conic-to":se()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:he()}],"mask-repeat":[{mask:ye()}],"mask-size":[{mask:w()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ae,re]}],filter:[{filter:["","none",ae,re]}],blur:[{blur:mt()}],brightness:[{brightness:[Se,ae,re]}],contrast:[{contrast:[Se,ae,re]}],"drop-shadow":[{"drop-shadow":["","none",_,fu,cu]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Se,ae,re]}],"hue-rotate":[{"hue-rotate":[Se,ae,re]}],invert:[{invert:["",Se,ae,re]}],saturate:[{saturate:[Se,ae,re]}],sepia:[{sepia:["",Se,ae,re]}],"backdrop-filter":[{"backdrop-filter":["","none",ae,re]}],"backdrop-blur":[{"backdrop-blur":mt()}],"backdrop-brightness":[{"backdrop-brightness":[Se,ae,re]}],"backdrop-contrast":[{"backdrop-contrast":[Se,ae,re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,ae,re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,ae,re]}],"backdrop-invert":[{"backdrop-invert":["",Se,ae,re]}],"backdrop-opacity":[{"backdrop-opacity":[Se,ae,re]}],"backdrop-saturate":[{"backdrop-saturate":[Se,ae,re]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,ae,re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ae,re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",ae,re]}],ease:[{ease:["linear","initial",M,ae,re]}],delay:[{delay:[Se,ae,re]}],animate:[{animate:["none",O,ae,re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[T,ae,re]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:tn()}],"scale-x":[{"scale-x":tn()}],"scale-y":[{"scale-y":tn()}],"scale-z":[{"scale-z":tn()}],"scale-3d":["scale-3d"],skew:[{skew:Un()}],"skew-x":[{"skew-x":Un()}],"skew-y":[{"skew-y":Un()}],transform:[{transform:[ae,re,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Vn()}],"translate-x":[{"translate-x":Vn()}],"translate-y":[{"translate-y":Vn()}],"translate-z":[{"translate-z":Vn()}],"translate-none":["translate-none"],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",ae,re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"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",ae,re]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Se,ls,Oa,th]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Gi=m4(M4);function wn({label:e,error:t,helperText:a,className:i,...s}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("input",{className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",i),...s}),a&&!t&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),t&&v.jsx("p",{className:"text-xs text-red-500",children:t})]})}function du({label:e,options:t,error:a,helperText:i,className:s,...c}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("select",{className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors appearance-none",a&&"border-red-500 focus:border-red-500 focus:ring-red-500",s),...c,children:t.map(u=>v.jsx("option",{value:u.value,className:"bg-azure-bg dark:bg-matrix-base",children:u.label},u.value))}),i&&!a&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:i}),a&&v.jsx("p",{className:"text-xs text-red-500",children:a})]})}function Oi({label:e,error:t,helperText:a,className:i,...s}){return v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",children:e}),v.jsx("input",{type:"number",className:Gi("bg-azure-bg dark:bg-matrix-base border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-highlight placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",i),...s}),a&&!t&&v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),t&&v.jsx("p",{className:"text-xs text-red-500",children:t})]})}function hu({label:e,checked:t,onChange:a,helperText:i,disabled:s}){return v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{className:"flex flex-col",children:[v.jsx("span",{className:Gi("text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",s&&"opacity-50"),children:e}),i&&v.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:i})]}),v.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>!s&&a(!t),className:Gi("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:ring-offset-2 focus:ring-offset-azure-bg dark:focus:ring-offset-black",t?"bg-azure-primary dark:bg-matrix-highlight":"bg-slate-300 dark:bg-matrix-primary",s&&"opacity-50 cursor-not-allowed"),children:v.jsx("span",{className:Gi("inline-block h-4 w-4 transform rounded-full bg-white dark:bg-black transition-transform",t?"translate-x-6":"translate-x-1")})})]})}const mu={fetchConfig:async()=>dn.get("/config"),updateConfig:async e=>dn.post("/config",e),getSatiConfig:async()=>dn.get("/config/sati"),updateSatiConfig:async e=>dn.post("/config/sati",e),deleteSatiConfig:async()=>dn.delete("/config/sati")};function G(e,t,a){function i(d,m){if(d._zod||Object.defineProperty(d,"_zod",{value:{def:m,constr:u,traits:new Set},enumerable:!1}),d._zod.traits.has(e))return;d._zod.traits.add(e),t(d,m);const p=u.prototype,g=Object.keys(p);for(let y=0;y<g.length;y++){const x=g[y];x in d||(d[x]=p[x].bind(d))}}const s=a?.Parent??Object;class c extends s{}Object.defineProperty(c,"name",{value:e});function u(d){var m;const p=a?.Parent?new c:this;i(p,d),(m=p._zod).deferred??(m.deferred=[]);for(const g of p._zod.deferred)g();return p}return Object.defineProperty(u,"init",{value:i}),Object.defineProperty(u,Symbol.hasInstance,{value:d=>a?.Parent&&d instanceof a.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}let qi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},S_=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};const __={};function aa(e){return __}function z_(e){const t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,s])=>t.indexOf(+i)===-1).map(([i,s])=>s)}function Yh(e,t){return typeof t=="bigint"?t.toString():t}function Wu(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Im(e){return e==null}function Xm(e){const t=e.startsWith("^")?1:0,a=e.endsWith("$")?e.length-1:e.length;return e.slice(t,a)}function D4(e,t){const a=(e.toString().split(".")[1]||"").length,i=t.toString();let s=(i.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(i)){const m=i.match(/\d?e-(\d?)/);m?.[1]&&(s=Number.parseInt(m[1]))}const c=a>s?a:s,u=Number.parseInt(e.toFixed(c).replace(".","")),d=Number.parseInt(t.toFixed(c).replace(".",""));return u%d/10**c}const nx=Symbol("evaluating");function Re(e,t,a){let i;Object.defineProperty(e,t,{get(){if(i!==nx)return i===void 0&&(i=nx,i=a()),i},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function Ha(e,t,a){Object.defineProperty(e,t,{value:a,writable:!0,enumerable:!0,configurable:!0})}function sa(...e){const t={};for(const a of e){const i=Object.getOwnPropertyDescriptors(a);Object.assign(t,i)}return Object.defineProperties({},t)}function rx(e){return JSON.stringify(e)}function $4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const w_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Z4=Wu(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Xi(e){if(Es(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const a=t.prototype;return!(Es(a)===!1||Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")===!1)}function k_(e){return Xi(e)?{...e}:Array.isArray(e)?[...e]:e}const L4=new Set(["string","number","symbol"]);function Fi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function la(e,t,a){const i=new e._zod.constr(t??e._zod.def);return(!t||a?.parent)&&(i._zod.parent=e),i}function le(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function U4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const V4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function B4(e,t){const a=e._zod.def,i=a.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const c=sa(e._zod.def,{get shape(){const u={};for(const d in t){if(!(d in a.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&(u[d]=a.shape[d])}return Ha(this,"shape",u),u},checks:[]});return la(e,c)}function P4(e,t){const a=e._zod.def,i=a.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const c=sa(e._zod.def,{get shape(){const u={...e._zod.def.shape};for(const d in t){if(!(d in a.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&delete u[d]}return Ha(this,"shape",u),u},checks:[]});return la(e,c)}function H4(e,t){if(!Xi(t))throw new Error("Invalid input to extend: expected a plain object");const a=e._zod.def.checks;if(a&&a.length>0){const c=e._zod.def.shape;for(const u in t)if(Object.getOwnPropertyDescriptor(c,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=sa(e._zod.def,{get shape(){const c={...e._zod.def.shape,...t};return Ha(this,"shape",c),c}});return la(e,s)}function G4(e,t){if(!Xi(t))throw new Error("Invalid input to safeExtend: expected a plain object");const a=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ha(this,"shape",i),i}});return la(e,a)}function q4(e,t){const a=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return Ha(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return la(e,a)}function Y4(e,t,a){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const u=sa(t._zod.def,{get shape(){const d=t._zod.def.shape,m={...d};if(a)for(const p in a){if(!(p in d))throw new Error(`Unrecognized key: "${p}"`);a[p]&&(m[p]=e?new e({type:"optional",innerType:d[p]}):d[p])}else for(const p in d)m[p]=e?new e({type:"optional",innerType:d[p]}):d[p];return Ha(this,"shape",m),m},checks:[]});return la(t,u)}function I4(e,t,a){const i=sa(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(a)for(const u in a){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);a[u]&&(c[u]=new e({type:"nonoptional",innerType:s[u]}))}else for(const u in s)c[u]=new e({type:"nonoptional",innerType:s[u]});return Ha(this,"shape",c),c}});return la(t,i)}function Ui(e,t=0){if(e.aborted===!0)return!0;for(let a=t;a<e.issues.length;a++)if(e.issues[a]?.continue!==!0)return!0;return!1}function Vi(e,t){return t.map(a=>{var i;return(i=a).path??(i.path=[]),a.path.unshift(e),a})}function pu(e){return typeof e=="string"?e:e?.message}function ia(e,t,a){const i={...e,path:e.path??[]};if(!e.message){const s=pu(e.inst?._zod.def?.error?.(e))??pu(t?.error?.(e))??pu(a.customError?.(e))??pu(a.localeError?.(e))??"Invalid input";i.message=s}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Fm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function As(...e){const[t,a,i]=e;return typeof t=="string"?{message:t,code:"custom",input:a,inst:i}:{...t}}const T_=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Yh,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},E_=G("$ZodError",T_),A_=G("$ZodError",T_,{Parent:Error});function X4(e,t=a=>a.message){const a={},i=[];for(const s of e.issues)s.path.length>0?(a[s.path[0]]=a[s.path[0]]||[],a[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:a}}function F4(e,t=a=>a.message){const a={_errors:[]},i=s=>{for(const c of s.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u}));else if(c.code==="invalid_key")i({issues:c.issues});else if(c.code==="invalid_element")i({issues:c.issues});else if(c.path.length===0)a._errors.push(t(c));else{let u=a,d=0;for(;d<c.path.length;){const m=c.path[d];d===c.path.length-1?(u[m]=u[m]||{_errors:[]},u[m]._errors.push(t(c))):u[m]=u[m]||{_errors:[]},u=u[m],d++}}};return i(e),a}const Km=e=>(t,a,i,s)=>{const c=i?Object.assign(i,{async:!1}):{async:!1},u=t._zod.run({value:a,issues:[]},c);if(u instanceof Promise)throw new qi;if(u.issues.length){const d=new(s?.Err??e)(u.issues.map(m=>ia(m,c,aa())));throw w_(d,s?.callee),d}return u.value},Jm=e=>async(t,a,i,s)=>{const c=i?Object.assign(i,{async:!0}):{async:!0};let u=t._zod.run({value:a,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const d=new(s?.Err??e)(u.issues.map(m=>ia(m,c,aa())));throw w_(d,s?.callee),d}return u.value},ec=e=>(t,a,i)=>{const s=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:a,issues:[]},s);if(c instanceof Promise)throw new qi;return c.issues.length?{success:!1,error:new(e??E_)(c.issues.map(u=>ia(u,s,aa())))}:{success:!0,data:c.value}},K4=ec(A_),tc=e=>async(t,a,i)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let c=t._zod.run({value:a,issues:[]},s);return c instanceof Promise&&(c=await c),c.issues.length?{success:!1,error:new e(c.issues.map(u=>ia(u,s,aa())))}:{success:!0,data:c.value}},J4=tc(A_),Q4=e=>(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Km(e)(t,a,s)},W4=e=>(t,a,i)=>Km(e)(t,a,i),eR=e=>async(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Jm(e)(t,a,s)},tR=e=>async(t,a,i)=>Jm(e)(t,a,i),nR=e=>(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ec(e)(t,a,s)},rR=e=>(t,a,i)=>ec(e)(t,a,i),aR=e=>async(t,a,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return tc(e)(t,a,s)},iR=e=>async(t,a,i)=>tc(e)(t,a,i),oR=/^[cC][^\s-]{8,}$/,sR=/^[0-9a-z]+$/,lR=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,uR=/^[0-9a-vA-V]{20}$/,cR=/^[A-Za-z0-9]{27}$/,fR=/^[a-zA-Z0-9_-]{21}$/,dR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hR=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ax=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,mR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function gR(){return new RegExp(pR,"u")}const yR=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,bR=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,SR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C_=/^[A-Za-z0-9_-]*$/,_R=/^\+[1-9]\d{6,14}$/,j_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",zR=new RegExp(`^${j_}$`);function O_(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wR(e){return new RegExp(`^${O_(e)}$`)}function kR(e){const t=O_({precision:e.precision}),a=["Z"];e.local&&a.push(""),e.offset&&a.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${a.join("|")})`;return new RegExp(`^${j_}T(?:${i})$`)}const TR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ER=/^-?\d+$/,N_=/^-?\d+(?:\.\d+)?$/,AR=/^(?:true|false)$/i,CR=/^[^A-Z]*$/,jR=/^[^a-z]*$/,en=G("$ZodCheck",(e,t)=>{var a;e._zod??(e._zod={}),e._zod.def=t,(a=e._zod).onattach??(a.onattach=[])}),R_={number:"number",bigint:"bigint",object:"date"},M_=G("$ZodCheckLessThan",(e,t)=>{en.init(e,t);const a=R_[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,c=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<c&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:a,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),D_=G("$ZodCheckGreaterThan",(e,t)=>{en.init(e,t);const a=R_[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,c=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>c&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:a,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),OR=G("$ZodCheckMultipleOf",(e,t)=>{en.init(e,t),e._zod.onattach.push(a=>{var i;(i=a._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=a=>{if(typeof a.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof a.value=="bigint"?a.value%t.value===BigInt(0):D4(a.value,t.value)===0)||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:t.value,input:a.value,inst:e,continue:!t.abort})}}),NR=G("$ZodCheckNumberFormat",(e,t)=>{en.init(e,t),t.format=t.format||"float64";const a=t.format?.includes("int"),i=a?"int":"number",[s,c]=V4[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=s,d.maximum=c,a&&(d.pattern=ER)}),e._zod.check=u=>{const d=u.value;if(a){if(!Number.isInteger(d)){u.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}d<s&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),d>c&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:c,inclusive:!0,inst:e,continue:!t.abort})}}),RR=G("$ZodCheckMaxLength",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{const s=i.value;if(s.length<=t.maximum)return;const u=Fm(s);i.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),MR=G("$ZodCheckMinLength",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{const s=i.value;if(s.length>=t.minimum)return;const u=Fm(s);i.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),DR=G("$ZodCheckLengthEquals",(e,t)=>{var a;en.init(e,t),(a=e._zod.def).when??(a.when=i=>{const s=i.value;return!Im(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=i=>{const s=i.value,c=s.length;if(c===t.length)return;const u=Fm(s),d=c>t.length;i.issues.push({origin:u,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),nc=G("$ZodCheckStringFormat",(e,t)=>{var a,i;en.init(e,t),e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,t.pattern&&(c.patterns??(c.patterns=new Set),c.patterns.add(t.pattern))}),t.pattern?(a=e._zod).check??(a.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),$R=G("$ZodCheckRegex",(e,t)=>{nc.init(e,t),e._zod.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ZR=G("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=CR),nc.init(e,t)}),LR=G("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=jR),nc.init(e,t)}),UR=G("$ZodCheckIncludes",(e,t)=>{en.init(e,t);const a=Fi(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${a}`:a);t.pattern=i,e._zod.onattach.push(s=>{const c=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(i)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),VR=G("$ZodCheckStartsWith",(e,t)=>{en.init(e,t);const a=new RegExp(`^${Fi(t.prefix)}.*`);t.pattern??(t.pattern=a),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),BR=G("$ZodCheckEndsWith",(e,t)=>{en.init(e,t);const a=new RegExp(`.*${Fi(t.suffix)}$`);t.pattern??(t.pattern=a),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),PR=G("$ZodCheckOverwrite",(e,t)=>{en.init(e,t),e._zod.check=a=>{a.value=t.tx(a.value)}});let HR=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const i=t.split(`
|
|
20
20
|
`).filter(u=>u),s=Math.min(...i.map(u=>u.length-u.trimStart().length)),c=i.map(u=>u.slice(s)).map(u=>" ".repeat(this.indent*2)+u);for(const u of c)this.content.push(u)}compile(){const t=Function,a=this?.args,s=[...(this?.content??[""]).map(c=>` ${c}`)];return new t(...a,s.join(`
|
|
21
21
|
`))}};const GR={major:4,minor:3,patch:6},it=G("$ZodType",(e,t)=>{var a;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=GR;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const s of i)for(const c of s._zod.onattach)c(e);if(i.length===0)(a=e._zod).deferred??(a.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(u,d,m)=>{let p=Ui(u),g;for(const y of d){if(y._zod.def.when){if(!y._zod.def.when(u))continue}else if(p)continue;const x=u.issues.length,_=y._zod.check(u);if(_ instanceof Promise&&m?.async===!1)throw new qi;if(g||_ instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await _,u.issues.length!==x&&(p||(p=Ui(u,x)))});else{if(u.issues.length===x)continue;p||(p=Ui(u,x))}}return g?g.then(()=>u):u},c=(u,d,m)=>{if(Ui(u))return u.aborted=!0,u;const p=s(d,i,m);if(p instanceof Promise){if(m.async===!1)throw new qi;return p.then(g=>e._zod.parse(g,m))}return e._zod.parse(p,m)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return p instanceof Promise?p.then(g=>c(g,u,d)):c(p,u,d)}const m=e._zod.parse(u,d);if(m instanceof Promise){if(d.async===!1)throw new qi;return m.then(p=>s(p,i,d))}return s(m,i,d)}}Re(e,"~standard",()=>({validate:s=>{try{const c=K4(e,s);return c.success?{value:c.data}:{issues:c.error?.issues}}catch{return J4(e,s).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),Qm=G("$ZodString",(e,t)=>{it.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??TR(e._zod.bag),e._zod.parse=(a,i)=>{if(t.coerce)try{a.value=String(a.value)}catch{}return typeof a.value=="string"||a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:e}),a}}),et=G("$ZodStringFormat",(e,t)=>{nc.init(e,t),Qm.init(e,t)}),qR=G("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=hR),et.init(e,t)}),YR=G("$ZodUUID",(e,t)=>{if(t.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ax(i))}else t.pattern??(t.pattern=ax());et.init(e,t)}),IR=G("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mR),et.init(e,t)}),XR=G("$ZodURL",(e,t)=>{et.init(e,t),e._zod.check=a=>{try{const i=a.value.trim(),s=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:a.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:a.value,inst:e,continue:!t.abort})),t.normalize?a.value=s.href:a.value=i;return}catch{a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:e,continue:!t.abort})}}}),FR=G("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=gR()),et.init(e,t)}),KR=G("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=fR),et.init(e,t)}),JR=G("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=oR),et.init(e,t)}),QR=G("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=sR),et.init(e,t)}),WR=G("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lR),et.init(e,t)}),eM=G("$ZodXID",(e,t)=>{t.pattern??(t.pattern=uR),et.init(e,t)}),tM=G("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cR),et.init(e,t)}),nM=G("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kR(t)),et.init(e,t)}),rM=G("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zR),et.init(e,t)}),aM=G("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wR(t)),et.init(e,t)}),iM=G("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dR),et.init(e,t)}),oM=G("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yR),et.init(e,t),e._zod.bag.format="ipv4"}),sM=G("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vR),et.init(e,t),e._zod.bag.format="ipv6",e._zod.check=a=>{try{new URL(`http://[${a.value}]`)}catch{a.issues.push({code:"invalid_format",format:"ipv6",input:a.value,inst:e,continue:!t.abort})}}}),lM=G("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=bR),et.init(e,t)}),uM=G("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xR),et.init(e,t),e._zod.check=a=>{const i=a.value.split("/");try{if(i.length!==2)throw new Error;const[s,c]=i;if(!c)throw new Error;const u=Number(c);if(`${u}`!==c)throw new Error;if(u<0||u>128)throw new Error;new URL(`http://[${s}]`)}catch{a.issues.push({code:"invalid_format",format:"cidrv6",input:a.value,inst:e,continue:!t.abort})}}});function $_(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const cM=G("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=SR),et.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=a=>{$_(a.value)||a.issues.push({code:"invalid_format",format:"base64",input:a.value,inst:e,continue:!t.abort})}});function fM(e){if(!C_.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),a=t.padEnd(Math.ceil(t.length/4)*4,"=");return $_(a)}const dM=G("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=C_),et.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=a=>{fM(a.value)||a.issues.push({code:"invalid_format",format:"base64url",input:a.value,inst:e,continue:!t.abort})}}),hM=G("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_R),et.init(e,t)});function mM(e,t=null){try{const a=e.split(".");if(a.length!==3)return!1;const[i]=a;if(!i)return!1;const s=JSON.parse(atob(i));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const pM=G("$ZodJWT",(e,t)=>{et.init(e,t),e._zod.check=a=>{mM(a.value,t.alg)||a.issues.push({code:"invalid_format",format:"jwt",input:a.value,inst:e,continue:!t.abort})}}),Z_=G("$ZodNumber",(e,t)=>{it.init(e,t),e._zod.pattern=e._zod.bag.pattern??N_,e._zod.parse=(a,i)=>{if(t.coerce)try{a.value=Number(a.value)}catch{}const s=a.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return a;const c=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return a.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...c?{received:c}:{}}),a}}),gM=G("$ZodNumberFormat",(e,t)=>{NR.init(e,t),Z_.init(e,t)}),yM=G("$ZodBoolean",(e,t)=>{it.init(e,t),e._zod.pattern=AR,e._zod.parse=(a,i)=>{if(t.coerce)try{a.value=!!a.value}catch{}const s=a.value;return typeof s=="boolean"||a.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),a}}),vM=G("$ZodUnknown",(e,t)=>{it.init(e,t),e._zod.parse=a=>a}),bM=G("$ZodNever",(e,t)=>{it.init(e,t),e._zod.parse=(a,i)=>(a.issues.push({expected:"never",code:"invalid_type",input:a.value,inst:e}),a)});function ix(e,t,a){e.issues.length&&t.issues.push(...Vi(a,e.issues)),t.value[a]=e.value}const xM=G("$ZodArray",(e,t)=>{it.init(e,t),e._zod.parse=(a,i)=>{const s=a.value;if(!Array.isArray(s))return a.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),a;a.value=Array(s.length);const c=[];for(let u=0;u<s.length;u++){const d=s[u],m=t.element._zod.run({value:d,issues:[]},i);m instanceof Promise?c.push(m.then(p=>ix(p,a,u))):ix(m,a,u)}return c.length?Promise.all(c).then(()=>a):a}});function Lu(e,t,a,i,s){if(e.issues.length){if(s&&!(a in i))return;t.issues.push(...Vi(a,e.issues))}e.value===void 0?a in i&&(t.value[a]=void 0):t.value[a]=e.value}function L_(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const a=U4(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function U_(e,t,a,i,s,c){const u=[],d=s.keySet,m=s.catchall._zod,p=m.def.type,g=m.optout==="optional";for(const y in t){if(d.has(y))continue;if(p==="never"){u.push(y);continue}const x=m.run({value:t[y],issues:[]},i);x instanceof Promise?e.push(x.then(_=>Lu(_,a,y,t,g))):Lu(x,a,y,t,g)}return u.length&&a.issues.push({code:"unrecognized_keys",keys:u,input:t,inst:c}),e.length?Promise.all(e).then(()=>a):a}const SM=G("$ZodObject",(e,t)=>{if(it.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const d=t.shape;Object.defineProperty(t,"shape",{get:()=>{const m={...d};return Object.defineProperty(t,"shape",{value:m}),m}})}const i=Wu(()=>L_(t));Re(e._zod,"propValues",()=>{const d=t.shape,m={};for(const p in d){const g=d[p]._zod;if(g.values){m[p]??(m[p]=new Set);for(const y of g.values)m[p].add(y)}}return m});const s=Es,c=t.catchall;let u;e._zod.parse=(d,m)=>{u??(u=i.value);const p=d.value;if(!s(p))return d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d;d.value={};const g=[],y=u.shape;for(const x of u.keys){const _=y[x],E=_._zod.optout==="optional",T=_._zod.run({value:p[x],issues:[]},m);T instanceof Promise?g.push(T.then(C=>Lu(C,d,x,p,E))):Lu(T,d,x,p,E)}return c?U_(g,p,d,m,i.value,e):g.length?Promise.all(g).then(()=>d):d}}),_M=G("$ZodObjectJIT",(e,t)=>{SM.init(e,t);const a=e._zod.parse,i=Wu(()=>L_(t)),s=x=>{const _=new HR(["shape","payload","ctx"]),E=i.value,T=R=>{const j=rx(R);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};_.write("const input = payload.value;");const C=Object.create(null);let M=0;for(const R of E.keys)C[R]=`key_${M++}`;_.write("const newResult = {};");for(const R of E.keys){const j=C[R],L=rx(R),K=x[R]?._zod?.optout==="optional";_.write(`const ${j} = ${T(R)};`),K?_.write(`
|
|
22
22
|
if (${j}.issues.length) {
|
|
@@ -93,4 +93,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
93
93
|
`)}_.write("payload.value = newResult;"),_.write("return payload;");const O=_.compile();return(R,j)=>O(x,R,j)};let c;const u=Bu,d=!nz.jitless,p=d&&_3.value,g=t.catchall;let y;e._zod.parse=(x,_)=>{y??(y=i.value);const E=x.value;return u(E)?d&&p&&_?.async===!1&&_.jitless!==!0?(c||(c=s(t.shape)),x=c(x,_),g?pz([],E,x,_,y,e):x):a(x,_):(x.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),x)}});function Cx(e,t,a,i){for(const c of e)if(c.issues.length===0)return t.value=c.value,t;const s=e.filter(c=>!Bi(c));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:a,errors:e.map(c=>c.issues.map(u=>Pa(u,i,Ba())))}),t)}const t5=X("$ZodUnion",(e,t)=>{St.init(e,t),Le(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Le(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Le(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),Le(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(c=>c._zod.pattern);return new RegExp(`^(${s.map(c=>tp(c.source)).join("|")})$`)}});const a=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(s,c)=>{if(a)return i(s,c);let u=!1;const d=[];for(const m of t.options){const p=m._zod.run({value:s.value,issues:[]},c);if(p instanceof Promise)d.push(p),u=!0;else{if(p.issues.length===0)return p;d.push(p)}}return u?Promise.all(d).then(m=>Cx(m,s,e,c)):Cx(d,s,e,c)}}),n5=X("$ZodIntersection",(e,t)=>{St.init(e,t),e._zod.parse=(a,i)=>{const s=a.value,c=t.left._zod.run({value:s,issues:[]},i),u=t.right._zod.run({value:s,issues:[]},i);return c instanceof Promise||u instanceof Promise?Promise.all([c,u]).then(([m,p])=>jx(a,m,p)):jx(a,c,u)}});function Kh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(js(e)&&js(t)){const a=Object.keys(t),i=Object.keys(e).filter(c=>a.indexOf(c)!==-1),s={...e,...t};for(const c of i){const u=Kh(e[c],t[c]);if(!u.valid)return{valid:!1,mergeErrorPath:[c,...u.mergeErrorPath]};s[c]=u.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const a=[];for(let i=0;i<e.length;i++){const s=e[i],c=t[i],u=Kh(s,c);if(!u.valid)return{valid:!1,mergeErrorPath:[i,...u.mergeErrorPath]};a.push(u.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function jx(e,t,a){const i=new Map;let s;for(const d of t.issues)if(d.code==="unrecognized_keys"){s??(s=d);for(const m of d.keys)i.has(m)||i.set(m,{}),i.get(m).l=!0}else e.issues.push(d);for(const d of a.issues)if(d.code==="unrecognized_keys")for(const m of d.keys)i.has(m)||i.set(m,{}),i.get(m).r=!0;else e.issues.push(d);const c=[...i].filter(([,d])=>d.l&&d.r).map(([d])=>d);if(c.length&&s&&e.issues.push({...s,keys:c}),Bi(e))return e;const u=Kh(t.value,a.value);if(!u.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`);return e.value=u.data,e}const r5=X("$ZodEnum",(e,t)=>{St.init(e,t);const a=rz(t.entries),i=new Set(a);e._zod.values=i,e._zod.pattern=new RegExp(`^(${a.filter(s=>z3.has(typeof s)).map(s=>typeof s=="string"?Ki(s):s.toString()).join("|")})$`),e._zod.parse=(s,c)=>{const u=s.value;return i.has(u)||s.issues.push({code:"invalid_value",values:a,input:u,inst:e}),s}}),a5=X("$ZodLiteral",(e,t)=>{if(St.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const a=new Set(t.values);e._zod.values=a,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Ki(i):i?Ki(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,s)=>{const c=i.value;return a.has(c)||i.issues.push({code:"invalid_value",values:t.values,input:c,inst:e}),i}}),i5=X("$ZodTransform",(e,t)=>{St.init(e,t),e._zod.parse=(a,i)=>{if(i.direction==="backward")throw new tz(e.constructor.name);const s=t.transform(a.value,a);if(i.async)return(s instanceof Promise?s:Promise.resolve(s)).then(u=>(a.value=u,a));if(s instanceof Promise)throw new Yi;return a.value=s,a}});function Ox(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const gz=X("$ZodOptional",(e,t)=>{St.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Le(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Le(e._zod,"pattern",()=>{const a=t.innerType._zod.pattern;return a?new RegExp(`^(${tp(a.source)})?$`):void 0}),e._zod.parse=(a,i)=>{if(t.innerType._zod.optin==="optional"){const s=t.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>Ox(c,a.value)):Ox(s,a.value)}return a.value===void 0?a:t.innerType._zod.run(a,i)}}),o5=X("$ZodExactOptional",(e,t)=>{gz.init(e,t),Le(e._zod,"values",()=>t.innerType._zod.values),Le(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(a,i)=>t.innerType._zod.run(a,i)}),s5=X("$ZodNullable",(e,t)=>{St.init(e,t),Le(e._zod,"optin",()=>t.innerType._zod.optin),Le(e._zod,"optout",()=>t.innerType._zod.optout),Le(e._zod,"pattern",()=>{const a=t.innerType._zod.pattern;return a?new RegExp(`^(${tp(a.source)}|null)$`):void 0}),Le(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(a,i)=>a.value===null?a:t.innerType._zod.run(a,i)}),l5=X("$ZodDefault",(e,t)=>{St.init(e,t),e._zod.optin="optional",Le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(a,i)=>{if(i.direction==="backward")return t.innerType._zod.run(a,i);if(a.value===void 0)return a.value=t.defaultValue,a;const s=t.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>Nx(c,t)):Nx(s,t)}});function Nx(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const u5=X("$ZodPrefault",(e,t)=>{St.init(e,t),e._zod.optin="optional",Le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(a,i)=>(i.direction==="backward"||a.value===void 0&&(a.value=t.defaultValue),t.innerType._zod.run(a,i))}),c5=X("$ZodNonOptional",(e,t)=>{St.init(e,t),Le(e._zod,"values",()=>{const a=t.innerType._zod.values;return a?new Set([...a].filter(i=>i!==void 0)):void 0}),e._zod.parse=(a,i)=>{const s=t.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>Rx(c,e)):Rx(s,e)}});function Rx(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const f5=X("$ZodCatch",(e,t)=>{St.init(e,t),Le(e._zod,"optin",()=>t.innerType._zod.optin),Le(e._zod,"optout",()=>t.innerType._zod.optout),Le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(a,i)=>{if(i.direction==="backward")return t.innerType._zod.run(a,i);const s=t.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>(a.value=c.value,c.issues.length&&(a.value=t.catchValue({...a,error:{issues:c.issues.map(u=>Pa(u,i,Ba()))},input:a.value}),a.issues=[]),a)):(a.value=s.value,s.issues.length&&(a.value=t.catchValue({...a,error:{issues:s.issues.map(c=>Pa(c,i,Ba()))},input:a.value}),a.issues=[]),a)}}),d5=X("$ZodPipe",(e,t)=>{St.init(e,t),Le(e._zod,"values",()=>t.in._zod.values),Le(e._zod,"optin",()=>t.in._zod.optin),Le(e._zod,"optout",()=>t.out._zod.optout),Le(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(a,i)=>{if(i.direction==="backward"){const c=t.out._zod.run(a,i);return c instanceof Promise?c.then(u=>bu(u,t.in,i)):bu(c,t.in,i)}const s=t.in._zod.run(a,i);return s instanceof Promise?s.then(c=>bu(c,t.out,i)):bu(s,t.out,i)}});function bu(e,t,a){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},a)}const h5=X("$ZodReadonly",(e,t)=>{St.init(e,t),Le(e._zod,"propValues",()=>t.innerType._zod.propValues),Le(e._zod,"values",()=>t.innerType._zod.values),Le(e._zod,"optin",()=>t.innerType?._zod?.optin),Le(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(a,i)=>{if(i.direction==="backward")return t.innerType._zod.run(a,i);const s=t.innerType._zod.run(a,i);return s instanceof Promise?s.then(Mx):Mx(s)}});function Mx(e){return e.value=Object.freeze(e.value),e}const m5=X("$ZodCustom",(e,t)=>{er.init(e,t),St.init(e,t),e._zod.parse=(a,i)=>a,e._zod.check=a=>{const i=a.value,s=t.fn(i);if(s instanceof Promise)return s.then(c=>Dx(c,a,i,e));Dx(s,a,i,e)}});function Dx(e,t,a,i){if(!e){const s={code:"custom",input:a,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(s.params=i._zod.def.params),t.issues.push(Os(s))}}var $x;class p5{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...a){const i=a[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const a=this._map.get(t);return a&&typeof a=="object"&&"id"in a&&this._idmap.delete(a.id),this._map.delete(t),this}get(t){const a=t._zod.parent;if(a){const i={...this.get(a)??{}};delete i.id;const s={...i,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function g5(){return new p5}($x=globalThis).__zod_globalRegistry??($x.__zod_globalRegistry=g5());const ps=globalThis.__zod_globalRegistry;function y5(e,t){return new e({type:"string",...me(t)})}function v5(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...me(t)})}function Zx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...me(t)})}function b5(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...me(t)})}function x5(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...me(t)})}function S5(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...me(t)})}function _5(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...me(t)})}function z5(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...me(t)})}function w5(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...me(t)})}function k5(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...me(t)})}function T5(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...me(t)})}function E5(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...me(t)})}function A5(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...me(t)})}function C5(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...me(t)})}function j5(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...me(t)})}function O5(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...me(t)})}function N5(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...me(t)})}function R5(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...me(t)})}function M5(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...me(t)})}function D5(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...me(t)})}function $5(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...me(t)})}function Z5(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...me(t)})}function L5(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...me(t)})}function U5(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...me(t)})}function V5(e,t){return new e({type:"string",format:"date",check:"string_format",...me(t)})}function B5(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...me(t)})}function P5(e,t){return new e({type:"string",format:"duration",check:"string_format",...me(t)})}function H5(e){return new e({type:"unknown"})}function G5(e,t){return new e({type:"never",...me(t)})}function yz(e,t){return new h6({check:"max_length",...me(t),maximum:e})}function Hu(e,t){return new m6({check:"min_length",...me(t),minimum:e})}function vz(e,t){return new p6({check:"length_equals",...me(t),length:e})}function q5(e,t){return new g6({check:"string_format",format:"regex",...me(t),pattern:e})}function Y5(e){return new y6({check:"string_format",format:"lowercase",...me(e)})}function I5(e){return new v6({check:"string_format",format:"uppercase",...me(e)})}function X5(e,t){return new b6({check:"string_format",format:"includes",...me(t),includes:e})}function F5(e,t){return new x6({check:"string_format",format:"starts_with",...me(t),prefix:e})}function K5(e,t){return new S6({check:"string_format",format:"ends_with",...me(t),suffix:e})}function oo(e){return new _6({check:"overwrite",tx:e})}function J5(e){return oo(t=>t.normalize(e))}function Q5(){return oo(e=>e.trim())}function W5(){return oo(e=>e.toLowerCase())}function e9(){return oo(e=>e.toUpperCase())}function t9(){return oo(e=>S3(e))}function n9(e,t,a){return new e({type:"array",element:t,...me(a)})}function r9(e,t,a){return new e({type:"custom",check:"custom",fn:t,...me(a)})}function a9(e){const t=i9(a=>(a.addIssue=i=>{if(typeof i=="string")a.issues.push(Os(i,a.value,t._zod.def));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=a.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),a.issues.push(Os(s))}},e(a.value,a)));return t}function i9(e,t){const a=new er({check:"custom",...me(t)});return a._zod.check=e,a}function bz(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ps,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Zt(e,t,a={path:[],schemaPath:[]}){var i;const s=e._zod.def,c=t.seen.get(e);if(c)return c.count++,a.schemaPath.includes(e)&&(c.cycle=a.path),c.schema;const u={schema:{},count:1,cycle:void 0,path:a.path};t.seen.set(e,u);const d=e._zod.toJSONSchema?.();if(d)u.schema=d;else{const g={...a,schemaPath:[...a.schemaPath,e],path:a.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,u.schema,g);else{const x=u.schema,_=t.processors[s.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);_(e,t,x,g)}const y=e._zod.parent;y&&(u.ref||(u.ref=y),Zt(y,t,g),t.seen.get(y).isParent=!0)}const m=t.metadataRegistry.get(e);return m&&Object.assign(u.schema,m),t.io==="input"&&Gt(e)&&(delete u.schema.examples,delete u.schema.default),t.io==="input"&&u.schema._prefault&&((i=u.schema).default??(i.default=u.schema._prefault)),delete u.schema._prefault,t.seen.get(e).schema}function xz(e,t){const a=e.seen.get(t);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const u of e.seen.entries()){const d=e.metadataRegistry.get(u[0])?.id;if(d){const m=i.get(d);if(m&&m!==u[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(d,u[0])}}const s=u=>{const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const y=e.external.registry.get(u[0])?.id,x=e.external.uri??(E=>E);if(y)return{ref:x(y)};const _=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=_,{defId:_,ref:`${x("__shared")}#/${d}/${_}`}}if(u[1]===a)return{ref:"#"};const p=`#/${d}/`,g=u[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:p+g}},c=u=>{if(u[1].schema.$ref)return;const d=u[1],{ref:m,defId:p}=s(u);d.def={...d.schema},p&&(d.defId=p);const g=d.schema;for(const y in g)delete g[y];g.$ref=m};if(e.cycles==="throw")for(const u of e.seen.entries()){const d=u[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
94
94
|
|
|
95
95
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const d=u[1];if(t===u[0]){c(u);continue}if(e.external){const p=e.external.registry.get(u[0])?.id;if(t!==u[0]&&p){c(u);continue}}if(e.metadataRegistry.get(u[0])?.id){c(u);continue}if(d.cycle){c(u);continue}if(d.count>1&&e.reused==="ref"){c(u);continue}}}function Sz(e,t){const a=e.seen.get(t);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=u=>{const d=e.seen.get(u);if(d.ref===null)return;const m=d.def??d.schema,p={...m},g=d.ref;if(d.ref=null,g){i(g);const x=e.seen.get(g),_=x.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(_)):Object.assign(m,_),Object.assign(m,p),u._zod.parent===g)for(const T in m)T==="$ref"||T==="allOf"||T in p||delete m[T];if(_.$ref&&x.def)for(const T in m)T==="$ref"||T==="allOf"||T in x.def&&JSON.stringify(m[T])===JSON.stringify(x.def[T])&&delete m[T]}const y=u._zod.parent;if(y&&y!==g){i(y);const x=e.seen.get(y);if(x?.schema.$ref&&(m.$ref=x.schema.$ref,x.def))for(const _ in m)_==="$ref"||_==="allOf"||_ in x.def&&JSON.stringify(m[_])===JSON.stringify(x.def[_])&&delete m[_]}e.override({zodSchema:u,jsonSchema:m,path:d.path??[]})};for(const u of[...e.seen.entries()].reverse())i(u[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const u=e.external.registry.get(t)?.id;if(!u)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(u)}Object.assign(s,a.def??a.schema);const c=e.external?.defs??{};for(const u of e.seen.entries()){const d=u[1];d.def&&d.defId&&(c[d.defId]=d.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const u=JSON.parse(JSON.stringify(s));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Gu(t,"input",e.processors),output:Gu(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Gt(e,t){const a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Gt(i.element,a);if(i.type==="set")return Gt(i.valueType,a);if(i.type==="lazy")return Gt(i.getter(),a);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Gt(i.innerType,a);if(i.type==="intersection")return Gt(i.left,a)||Gt(i.right,a);if(i.type==="record"||i.type==="map")return Gt(i.keyType,a)||Gt(i.valueType,a);if(i.type==="pipe")return Gt(i.in,a)||Gt(i.out,a);if(i.type==="object"){for(const s in i.shape)if(Gt(i.shape[s],a))return!0;return!1}if(i.type==="union"){for(const s of i.options)if(Gt(s,a))return!0;return!1}if(i.type==="tuple"){for(const s of i.items)if(Gt(s,a))return!0;return!!(i.rest&&Gt(i.rest,a))}return!1}const o9=(e,t={})=>a=>{const i=bz({...a,processors:t});return Zt(e,i),xz(i,e),Sz(i,e)},Gu=(e,t,a={})=>i=>{const{libraryOptions:s,target:c}=i??{},u=bz({...s??{},target:c,io:t,processors:a});return Zt(e,u),xz(u,e),Sz(u,e)},s9={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},l9=(e,t,a,i)=>{const s=a;s.type="string";const{minimum:c,maximum:u,format:d,patterns:m,contentEncoding:p}=e._zod.bag;if(typeof c=="number"&&(s.minLength=c),typeof u=="number"&&(s.maxLength=u),d&&(s.format=s9[d]??d,s.format===""&&delete s.format,d==="time"&&delete s.format),p&&(s.contentEncoding=p),m&&m.size>0){const g=[...m];g.length===1?s.pattern=g[0].source:g.length>1&&(s.allOf=[...g.map(y=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:y.source}))])}},u9=(e,t,a,i)=>{a.not={}},c9=(e,t,a,i)=>{},f9=(e,t,a,i)=>{const s=e._zod.def,c=rz(s.entries);c.every(u=>typeof u=="number")&&(a.type="number"),c.every(u=>typeof u=="string")&&(a.type="string"),a.enum=c},d9=(e,t,a,i)=>{const s=e._zod.def,c=[];for(const u of s.values)if(u===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof u=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");c.push(Number(u))}else c.push(u);if(c.length!==0)if(c.length===1){const u=c[0];a.type=u===null?"null":typeof u,t.target==="draft-04"||t.target==="openapi-3.0"?a.enum=[u]:a.const=u}else c.every(u=>typeof u=="number")&&(a.type="number"),c.every(u=>typeof u=="string")&&(a.type="string"),c.every(u=>typeof u=="boolean")&&(a.type="boolean"),c.every(u=>u===null)&&(a.type="null"),a.enum=c},h9=(e,t,a,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},m9=(e,t,a,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},p9=(e,t,a,i)=>{const s=a,c=e._zod.def,{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(s.minItems=u),typeof d=="number"&&(s.maxItems=d),s.type="array",s.items=Zt(c.element,t,{...i,path:[...i.path,"items"]})},g9=(e,t,a,i)=>{const s=a,c=e._zod.def;s.type="object",s.properties={};const u=c.shape;for(const p in u)s.properties[p]=Zt(u[p],t,{...i,path:[...i.path,"properties",p]});const d=new Set(Object.keys(u)),m=new Set([...d].filter(p=>{const g=c.shape[p]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));m.size>0&&(s.required=Array.from(m)),c.catchall?._zod.def.type==="never"?s.additionalProperties=!1:c.catchall?c.catchall&&(s.additionalProperties=Zt(c.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},y9=(e,t,a,i)=>{const s=e._zod.def,c=s.inclusive===!1,u=s.options.map((d,m)=>Zt(d,t,{...i,path:[...i.path,c?"oneOf":"anyOf",m]}));c?a.oneOf=u:a.anyOf=u},v9=(e,t,a,i)=>{const s=e._zod.def,c=Zt(s.left,t,{...i,path:[...i.path,"allOf",0]}),u=Zt(s.right,t,{...i,path:[...i.path,"allOf",1]}),d=p=>"allOf"in p&&Object.keys(p).length===1,m=[...d(c)?c.allOf:[c],...d(u)?u.allOf:[u]];a.allOf=m},b9=(e,t,a,i)=>{const s=e._zod.def,c=Zt(s.innerType,t,i),u=t.seen.get(e);t.target==="openapi-3.0"?(u.ref=s.innerType,a.nullable=!0):a.anyOf=[c,{type:"null"}]},x9=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType},S9=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType,a.default=JSON.parse(JSON.stringify(s.defaultValue))},_9=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType,t.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},z9=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType;let u;try{u=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=u},w9=(e,t,a,i)=>{const s=e._zod.def,c=t.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;Zt(c,t,i);const u=t.seen.get(e);u.ref=c},k9=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType,a.readOnly=!0},_z=(e,t,a,i)=>{const s=e._zod.def;Zt(s.innerType,t,i);const c=t.seen.get(e);c.ref=s.innerType},T9=X("ZodISODateTime",(e,t)=>{$6.init(e,t),lt.init(e,t)});function E9(e){return U5(T9,e)}const A9=X("ZodISODate",(e,t)=>{Z6.init(e,t),lt.init(e,t)});function C9(e){return V5(A9,e)}const j9=X("ZodISOTime",(e,t)=>{L6.init(e,t),lt.init(e,t)});function O9(e){return B5(j9,e)}const N9=X("ZodISODuration",(e,t)=>{U6.init(e,t),lt.init(e,t)});function R9(e){return P5(N9,e)}const zz=(e,t)=>{lz.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a=>R3(e,a)},flatten:{value:a=>N3(e,a)},addIssue:{value:a=>{e.issues.push(a),e.message=JSON.stringify(e.issues,Fh,2)}},addIssues:{value:a=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,Fh,2)}},isEmpty:{get(){return e.issues.length===0}}})},M9=X("ZodError",zz),jn=X("ZodError",zz,{Parent:Error}),D9=rp(jn),$9=ap(jn),Z9=ac(jn),L9=ic(jn),U9=$3(jn),V9=Z3(jn),B9=L3(jn),P9=U3(jn),H9=V3(jn),G9=B3(jn),q9=P3(jn),Y9=H3(jn),_t=X("ZodType",(e,t)=>(St.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Gu(e,"input"),output:Gu(e,"output")}}),e.toJSONSchema=o9(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...a)=>e.clone(ua(t,{checks:[...t.checks??[],...a.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(a,i)=>ca(e,a,i),e.brand=()=>e,e.register=((a,i)=>(a.add(e,i),e)),e.parse=(a,i)=>D9(e,a,i,{callee:e.parse}),e.safeParse=(a,i)=>Z9(e,a,i),e.parseAsync=async(a,i)=>$9(e,a,i,{callee:e.parseAsync}),e.safeParseAsync=async(a,i)=>L9(e,a,i),e.spa=e.safeParseAsync,e.encode=(a,i)=>U9(e,a,i),e.decode=(a,i)=>V9(e,a,i),e.encodeAsync=async(a,i)=>B9(e,a,i),e.decodeAsync=async(a,i)=>P9(e,a,i),e.safeEncode=(a,i)=>H9(e,a,i),e.safeDecode=(a,i)=>G9(e,a,i),e.safeEncodeAsync=async(a,i)=>q9(e,a,i),e.safeDecodeAsync=async(a,i)=>Y9(e,a,i),e.refine=(a,i)=>e.check(UZ(a,i)),e.superRefine=a=>e.check(VZ(a)),e.overwrite=a=>e.check(oo(a)),e.optional=()=>Bx(e),e.exactOptional=()=>TZ(e),e.nullable=()=>Px(e),e.nullish=()=>Bx(Px(e)),e.nonoptional=a=>NZ(e,a),e.array=()=>pZ(e),e.or=a=>kz([e,a]),e.and=a=>xZ(e,a),e.transform=a=>Hx(e,wZ(a)),e.default=a=>CZ(e,a),e.prefault=a=>OZ(e,a),e.catch=a=>MZ(e,a),e.pipe=a=>Hx(e,a),e.readonly=()=>ZZ(e),e.describe=a=>{const i=e.clone();return ps.add(i,{description:a}),i},Object.defineProperty(e,"description",{get(){return ps.get(e)?.description},configurable:!0}),e.meta=(...a)=>{if(a.length===0)return ps.get(e);const i=e.clone();return ps.add(i,a[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=a=>a(e),e)),wz=X("_ZodString",(e,t)=>{ip.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(i,s,c)=>l9(e,i,s);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...i)=>e.check(q5(...i)),e.includes=(...i)=>e.check(X5(...i)),e.startsWith=(...i)=>e.check(F5(...i)),e.endsWith=(...i)=>e.check(K5(...i)),e.min=(...i)=>e.check(Hu(...i)),e.max=(...i)=>e.check(yz(...i)),e.length=(...i)=>e.check(vz(...i)),e.nonempty=(...i)=>e.check(Hu(1,...i)),e.lowercase=i=>e.check(Y5(i)),e.uppercase=i=>e.check(I5(i)),e.trim=()=>e.check(Q5()),e.normalize=(...i)=>e.check(J5(...i)),e.toLowerCase=()=>e.check(W5()),e.toUpperCase=()=>e.check(e9()),e.slugify=()=>e.check(t9())}),I9=X("ZodString",(e,t)=>{ip.init(e,t),wz.init(e,t),e.email=a=>e.check(v5(X9,a)),e.url=a=>e.check(z5(F9,a)),e.jwt=a=>e.check(L5(cZ,a)),e.emoji=a=>e.check(w5(K9,a)),e.guid=a=>e.check(Zx(Lx,a)),e.uuid=a=>e.check(b5(xu,a)),e.uuidv4=a=>e.check(x5(xu,a)),e.uuidv6=a=>e.check(S5(xu,a)),e.uuidv7=a=>e.check(_5(xu,a)),e.nanoid=a=>e.check(k5(J9,a)),e.guid=a=>e.check(Zx(Lx,a)),e.cuid=a=>e.check(T5(Q9,a)),e.cuid2=a=>e.check(E5(W9,a)),e.ulid=a=>e.check(A5(eZ,a)),e.base64=a=>e.check(D5(sZ,a)),e.base64url=a=>e.check($5(lZ,a)),e.xid=a=>e.check(C5(tZ,a)),e.ksuid=a=>e.check(j5(nZ,a)),e.ipv4=a=>e.check(O5(rZ,a)),e.ipv6=a=>e.check(N5(aZ,a)),e.cidrv4=a=>e.check(R5(iZ,a)),e.cidrv6=a=>e.check(M5(oZ,a)),e.e164=a=>e.check(Z5(uZ,a)),e.datetime=a=>e.check(E9(a)),e.date=a=>e.check(C9(a)),e.time=a=>e.check(O9(a)),e.duration=a=>e.check(R9(a))});function ah(e){return y5(I9,e)}const lt=X("ZodStringFormat",(e,t)=>{tt.init(e,t),wz.init(e,t)}),X9=X("ZodEmail",(e,t)=>{E6.init(e,t),lt.init(e,t)}),Lx=X("ZodGUID",(e,t)=>{k6.init(e,t),lt.init(e,t)}),xu=X("ZodUUID",(e,t)=>{T6.init(e,t),lt.init(e,t)}),F9=X("ZodURL",(e,t)=>{A6.init(e,t),lt.init(e,t)}),K9=X("ZodEmoji",(e,t)=>{C6.init(e,t),lt.init(e,t)}),J9=X("ZodNanoID",(e,t)=>{j6.init(e,t),lt.init(e,t)}),Q9=X("ZodCUID",(e,t)=>{O6.init(e,t),lt.init(e,t)}),W9=X("ZodCUID2",(e,t)=>{N6.init(e,t),lt.init(e,t)}),eZ=X("ZodULID",(e,t)=>{R6.init(e,t),lt.init(e,t)}),tZ=X("ZodXID",(e,t)=>{M6.init(e,t),lt.init(e,t)}),nZ=X("ZodKSUID",(e,t)=>{D6.init(e,t),lt.init(e,t)}),rZ=X("ZodIPv4",(e,t)=>{V6.init(e,t),lt.init(e,t)}),aZ=X("ZodIPv6",(e,t)=>{B6.init(e,t),lt.init(e,t)}),iZ=X("ZodCIDRv4",(e,t)=>{P6.init(e,t),lt.init(e,t)}),oZ=X("ZodCIDRv6",(e,t)=>{H6.init(e,t),lt.init(e,t)}),sZ=X("ZodBase64",(e,t)=>{G6.init(e,t),lt.init(e,t)}),lZ=X("ZodBase64URL",(e,t)=>{Y6.init(e,t),lt.init(e,t)}),uZ=X("ZodE164",(e,t)=>{I6.init(e,t),lt.init(e,t)}),cZ=X("ZodJWT",(e,t)=>{F6.init(e,t),lt.init(e,t)}),fZ=X("ZodUnknown",(e,t)=>{K6.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>c9()});function Ux(){return H5(fZ)}const dZ=X("ZodNever",(e,t)=>{J6.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>u9(e,a,i)});function hZ(e){return G5(dZ,e)}const mZ=X("ZodArray",(e,t)=>{Q6.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>p9(e,a,i,s),e.element=t.element,e.min=(a,i)=>e.check(Hu(a,i)),e.nonempty=a=>e.check(Hu(1,a)),e.max=(a,i)=>e.check(yz(a,i)),e.length=(a,i)=>e.check(vz(a,i)),e.unwrap=()=>e.element});function pZ(e,t){return n9(mZ,e,t)}const gZ=X("ZodObject",(e,t)=>{e5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>g9(e,a,i,s),Le(e,"shape",()=>t.shape),e.keyof=()=>SZ(Object.keys(e._zod.def.shape)),e.catchall=a=>e.clone({...e._zod.def,catchall:a}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ux()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ux()}),e.strict=()=>e.clone({...e._zod.def,catchall:hZ()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=a=>E3(e,a),e.safeExtend=a=>A3(e,a),e.merge=a=>C3(e,a),e.pick=a=>k3(e,a),e.omit=a=>T3(e,a),e.partial=(...a)=>j3(Tz,e,a[0]),e.required=(...a)=>O3(Ez,e,a[0])});function yZ(e,t){const a={type:"object",shape:e??{},...me(t)};return new gZ(a)}const vZ=X("ZodUnion",(e,t)=>{t5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>y9(e,a,i,s),e.options=t.options});function kz(e,t){return new vZ({type:"union",options:e,...me(t)})}const bZ=X("ZodIntersection",(e,t)=>{n5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>v9(e,a,i,s)});function xZ(e,t){return new bZ({type:"intersection",left:e,right:t})}const Jh=X("ZodEnum",(e,t)=>{r5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(i,s,c)=>f9(e,i,s),e.enum=t.entries,e.options=Object.values(t.entries);const a=new Set(Object.keys(t.entries));e.extract=(i,s)=>{const c={};for(const u of i)if(a.has(u))c[u]=t.entries[u];else throw new Error(`Key ${u} not found in enum`);return new Jh({...t,checks:[],...me(s),entries:c})},e.exclude=(i,s)=>{const c={...t.entries};for(const u of i)if(a.has(u))delete c[u];else throw new Error(`Key ${u} not found in enum`);return new Jh({...t,checks:[],...me(s),entries:c})}});function SZ(e,t){const a=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Jh({type:"enum",entries:a,...me(t)})}const _Z=X("ZodLiteral",(e,t)=>{a5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>d9(e,a,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Vx(e,t){return new _Z({type:"literal",values:Array.isArray(e)?e:[e],...me(t)})}const zZ=X("ZodTransform",(e,t)=>{i5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>m9(e,a),e._zod.parse=(a,i)=>{if(i.direction==="backward")throw new tz(e.constructor.name);a.addIssue=c=>{if(typeof c=="string")a.issues.push(Os(c,a.value,t));else{const u=c;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=a.value),u.inst??(u.inst=e),a.issues.push(Os(u))}};const s=t.transform(a.value,a);return s instanceof Promise?s.then(c=>(a.value=c,a)):(a.value=s,a)}});function wZ(e){return new zZ({type:"transform",transform:e})}const Tz=X("ZodOptional",(e,t)=>{gz.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>_z(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Bx(e){return new Tz({type:"optional",innerType:e})}const kZ=X("ZodExactOptional",(e,t)=>{o5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>_z(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function TZ(e){return new kZ({type:"optional",innerType:e})}const EZ=X("ZodNullable",(e,t)=>{s5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>b9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Px(e){return new EZ({type:"nullable",innerType:e})}const AZ=X("ZodDefault",(e,t)=>{l5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>S9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function CZ(e,t){return new AZ({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():iz(t)}})}const jZ=X("ZodPrefault",(e,t)=>{u5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>_9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function OZ(e,t){return new jZ({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():iz(t)}})}const Ez=X("ZodNonOptional",(e,t)=>{c5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>x9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function NZ(e,t){return new Ez({type:"nonoptional",innerType:e,...me(t)})}const RZ=X("ZodCatch",(e,t)=>{f5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>z9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function MZ(e,t){return new RZ({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const DZ=X("ZodPipe",(e,t)=>{d5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>w9(e,a,i,s),e.in=t.in,e.out=t.out});function Hx(e,t){return new DZ({type:"pipe",in:e,out:t})}const $Z=X("ZodReadonly",(e,t)=>{h5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>k9(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function ZZ(e){return new $Z({type:"readonly",innerType:e})}const LZ=X("ZodCustom",(e,t)=>{m5.init(e,t),_t.init(e,t),e._zod.processJSONSchema=(a,i,s)=>h9(e,a)});function UZ(e,t={}){return r9(LZ,e,t)}function VZ(e){return a9(e)}const BZ=[{id:"general",label:"General"},{id:"llm",label:"LLM"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"ui",label:"Interface"},{id:"logging",label:"Logging"}];function PZ(){const{data:e,error:t}=Va("/api/config",mu.fetchConfig),{data:a}=Va("/api/config/sati",mu.getSatiConfig),[i,s]=z.useState(null),[c,u]=z.useState(null),[d,m]=z.useState("general"),[p,g]=z.useState(!1),[y,x]=z.useState({}),[_,E]=z.useState(null);z.useEffect(()=>{e&&!i&&s(e)},[e]),z.useEffect(()=>{a&&!c&&u(a)},[a]);const T=JSON.stringify(e)!==JSON.stringify(i)||JSON.stringify(a)!==JSON.stringify(c),C=(j,L)=>{if(!i)return;const W=JSON.parse(JSON.stringify(i));let K=W;for(let B=0;B<j.length-1;B++)K=K[j[B]];K[j[j.length-1]]=L,s(W);try{b3.parse(W),x({})}catch(B){if(B instanceof M9){const Q={};B.errors.forEach(te=>{const de=te.path.join(".");Q[de]=te.message}),x(Q)}}},M=(j,L)=>{c&&u({...c,[j]:L})},O=()=>{!i||!c||u({...c,provider:i.llm.provider,model:i.llm.model,api_key:i.llm.api_key})},R=async()=>{if(i){g(!0),E(null);try{await mu.updateConfig(i),c&&await mu.updateSatiConfig(c),xh("/api/config"),xh("/api/config/sati"),E({type:"success",message:"Settings saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(j){if(E({type:"error",message:j.message}),j.details&&Array.isArray(j.details)){const L={};j.details.forEach(W=>{const K=W.path.join(".");L[K]=W.message}),x(L)}}finally{g(!1)}}};return t?v.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):i?v.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[v.jsxs("div",{className:"flex justify-between items-center",children:[v.jsx("h1",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight",children:"Settings"}),v.jsx("button",{onClick:R,disabled:!T||Object.keys(y).length>0||p,className:`px-4 py-2 rounded font-medium transition-colors ${T&&Object.keys(y).length===0?"bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90":"bg-azure-border text-azure-text-secondary cursor-not-allowed dark:bg-matrix-primary/50 dark:text-matrix-highlight/50"}`,children:p?"Saving...":"Save Changes"})]}),_&&v.jsx("div",{className:`p-4 rounded border ${_.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:_.message}),v.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:v.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:BZ.map(j=>v.jsx("button",{onClick:()=>m(j.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors flex-shrink-0 ${d===j.id?"bg-azure-surface/50 text-azure-primary border-t border-x border-azure-border dark:bg-matrix-primary/20 dark:text-matrix-highlight dark:border-t dark:border-x dark:border-matrix-primary":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:j.label},j.id))})}),v.jsxs("div",{className:"space-y-6",children:[d==="general"&&v.jsxs(ja,{title:"Agent Identity",children:[v.jsx(wn,{label:"Agent Name",value:i.agent.name,onChange:j=>C(["agent","name"],j.target.value),error:y["agent.name"]}),v.jsx(wn,{label:"Personality",value:i.agent.personality,onChange:j=>C(["agent","personality"],j.target.value),error:y["agent.personality"]})]}),d==="llm"&&v.jsxs(v.Fragment,{children:[v.jsxs(ja,{title:"Oracle Agent",children:[v.jsx(du,{label:"Provider",value:i.llm.provider,onChange:j=>C(["llm","provider"],j.target.value),options:[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}],error:y["llm.provider"]}),v.jsx(wn,{label:"Model Name",value:i.llm.model,onChange:j=>C(["llm","model"],j.target.value),error:y["llm.model"]}),v.jsx(Oi,{label:"Temperature",value:i.llm.temperature,onChange:j=>C(["llm","temperature"],parseFloat(j.target.value)),step:.1,min:0,max:1,error:y["llm.temperature"]}),v.jsx(Oi,{label:"Max Tokens",value:i.llm.max_tokens??"",onChange:j=>C(["llm","max_tokens"],j.target.value?parseInt(j.target.value):void 0),min:1,error:y["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default."}),v.jsx(Oi,{label:"Context Window (Messages)",value:i.llm.context_window??100,onChange:j=>C(["llm","context_window"],parseInt(j.target.value)),min:1,step:1,error:y["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100)."}),v.jsx(wn,{label:"API Key",type:"password",value:i.llm.api_key||"",onChange:j=>C(["llm","api_key"],j.target.value),placeholder:"sk-...",helperText:"Stored locally."}),i.llm.provider==="openrouter"&&v.jsx(wn,{label:"Base URL",value:i.llm.base_url||"https://openrouter.ai/api/v1",onChange:j=>C(["llm","base_url"],j.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),v.jsxs(ja,{title:"Sati Agent",children:[v.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Configure the LLM used for memory consolidation"}),v.jsxs("div",{className:"mb-4",children:[v.jsx("button",{type:"button",onClick:O,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),v.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),c&&v.jsxs(v.Fragment,{children:[v.jsx(du,{label:"Provider",value:c.provider,onChange:j=>M("provider",j.target.value),options:[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}]}),v.jsx(wn,{label:"Model Name",value:c.model,onChange:j=>M("model",j.target.value)}),v.jsx(wn,{label:"API Key",type:"password",value:c.api_key||"",onChange:j=>M("api_key",j.target.value),placeholder:"sk-...",helperText:"Stored locally."}),c.provider==="openrouter"&&v.jsx(wn,{label:"Base URL",value:c.base_url||"https://openrouter.ai/api/v1",onChange:j=>M("base_url",j.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),v.jsx(Oi,{label:"Memory Limit",value:c.memory_limit??10,onChange:j=>M("memory_limit",parseInt(j.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."})]})]})]}),d==="audio"&&v.jsxs(ja,{title:"Audio Transcription",children:[v.jsx(hu,{label:"Enable Audio",checked:i.audio.enabled,onChange:j=>C(["audio","enabled"],j)}),v.jsx(du,{label:"Provider",value:i.audio.provider||"google",onChange:j=>C(["audio","provider"],j.target.value),options:[{label:"Google Gemini",value:"google"}],error:y["audio.provider"]}),v.jsx(wn,{label:"API Key",type:"password",value:i.audio.apiKey||"",onChange:j=>C(["audio","apiKey"],j.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using same provider."}),v.jsx(Oi,{label:"Max Duration (Seconds)",value:i.audio.maxDurationSeconds,onChange:j=>C(["audio","maxDurationSeconds"],parseInt(j.target.value)),min:1}),v.jsx(wn,{label:"Supported Mime Types",value:i.audio.supportedMimeTypes.join(", "),onChange:j=>C(["audio","supportedMimeTypes"],j.target.value.split(",").map(L=>L.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),d==="channels"&&v.jsxs(ja,{title:"Telegram",children:[v.jsx(hu,{label:"Enable Telegram",checked:i.channels.telegram.enabled,onChange:j=>C(["channels","telegram","enabled"],j)}),i.channels.telegram.enabled&&v.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[v.jsx(wn,{label:"Bot Token",type:"password",value:i.channels.telegram.token||"",onChange:j=>C(["channels","telegram","token"],j.target.value)}),v.jsx(wn,{label:"Allowed Users (comma separated)",value:i.channels.telegram.allowedUsers.join(", "),onChange:j=>C(["channels","telegram","allowedUsers"],j.target.value.split(",").map(L=>L.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),d==="ui"&&v.jsxs(ja,{title:"Dashboard",children:[v.jsx(hu,{label:"Enable Web UI",checked:i.ui.enabled,onChange:j=>C(["ui","enabled"],j)}),v.jsx(Oi,{label:"Port",value:i.ui.port,onChange:j=>C(["ui","port"],parseInt(j.target.value)),disabled:!0,helperText:"Requires restart to change."})]}),d==="logging"&&v.jsxs(ja,{title:"Logging",children:[v.jsx(hu,{label:"Enable Logging",checked:i.logging.enabled,onChange:j=>C(["logging","enabled"],j)}),v.jsx(du,{label:"Log Level",value:i.logging.level,onChange:j=>C(["logging","level"],j.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]})]})]}):v.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}function HZ(){const{data:e}=rA(),[t,a]=z.useState(null),{data:i,mutate:s}=aA(t);return z.useEffect(()=>{!t&&e&&e.length>0&&a(e[0].name)},[e,t]),v.jsxs(Kn.div,{className:"h-full flex flex-col space-y-4 pt-16 md:pt-0",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{duration:.3},children:[v.jsxs("div",{children:[v.jsx("h2",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight",children:"SYSTEM LOGS"}),v.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-80",children:"View runtime logs."})]}),v.jsxs("div",{className:"flex-1 flex gap-4 overflow-hidden border border-azure-border dark:border-matrix-primary rounded bg-azure-surface dark:bg-zinc-950 p-4",children:[v.jsxs("div",{className:"w-64 flex flex-col gap-2 border-r border-azure-border dark:border-matrix-primary pr-4 overflow-y-auto shrink-0",children:[v.jsx("h3",{className:"font-bold text-azure-text-secondary dark:text-matrix-secondary mb-2 sticky top-0 bg-azure-surface dark:bg-zinc-950",children:"LOG FILES"}),e?.map(c=>v.jsxs("button",{onClick:()=>a(c.name),className:`text-left px-3 py-2 rounded text-sm truncate flex items-center gap-2 group transition-colors ${t===c.name?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-zinc-900 group-hover:text-azure-primary dark:group-hover:text-matrix-highlight"}`,children:[v.jsx(eE,{className:"w-4 h-4 shrink-0"}),v.jsxs("div",{className:"flex flex-col overflow-hidden",children:[v.jsx("span",{className:"truncate font-bold",children:c.name}),v.jsxs("span",{className:"text-xs opacity-70",children:[(c.size/1024).toFixed(1)," KB"]})]})]},c.name))]}),v.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary/50 rounded",children:[v.jsxs("div",{className:"flex justify-between items-center p-2 bg-azure-hover dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary/50",children:[v.jsx("span",{className:"text-azure-text-primary dark:text-matrix-highlight font-bold font-mono text-sm",children:t}),v.jsx("button",{onClick:()=>s(),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:v.jsx(mE,{className:"w-4 h-4"})})]}),v.jsx("div",{className:"flex-1 overflow-auto p-4 font-mono text-xs whitespace-pre-wrap text-azure-text-primary dark:text-white",children:i?i.lines.join(`
|
|
96
|
-
`):"Select a log file to view content..."})]})]})]})}function GZ(){const[e,t]=z.useState(null),[a,i]=z.useState([]),[s,c]=z.useState(!0),[u,d]=z.useState("");if(z.useEffect(()=>{async function g(){try{const[y,x]=await Promise.all([Gh.fetchUsageStats(),Gh.fetchGroupedUsageStats()]);t(y),i(x)}catch(y){d("Failed to load usage statistics"),console.error(y)}finally{c(!1)}}g()},[]),s)return v.jsx("div",{className:"flex items-center justify-center h-64 text-azure-accent dark:text-matrix-highlight font-mono animate-pulse",children:"LOADING_DATA_STREAM..."});if(u)return v.jsxs("div",{className:"p-4 bg-red-900/20 border border-red-500/50 text-red-500 font-mono rounded",children:["ERROR_ACCESSING_DATABASE: ",u]});const m={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},p={hidden:{y:20,opacity:0},show:{y:0,opacity:1}};return v.jsxs(Kn.div,{variants:m,initial:"hidden",animate:"show",className:"space-y-6",children:[v.jsx("div",{className:"flex items-center justify-between border-b border-azure-border dark:border-matrix-primary pb-4",children:v.jsxs("div",{children:[v.jsxs("h2",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight font-mono flex items-center gap-2",children:[v.jsx(fh,{className:"w-6 h-6"}),"USAGE_ANALYTICS"]}),v.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary mt-1 font-mono text-sm",children:"Resource consumption tracking and metrics"})]})}),v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[v.jsxs(Kn.div,{variants:p,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[v.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[v.jsx(cE,{className:"w-5 h-5"}),v.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Input Tokens"})]}),v.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:e?.totalInputTokens.toLocaleString()??0})]}),v.jsxs(Kn.div,{variants:p,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[v.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[v.jsx(J2,{className:"w-5 h-5"}),v.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Output Tokens"})]}),v.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:e?.totalOutputTokens.toLocaleString()??0})]})]}),v.jsxs(Kn.div,{variants:p,className:"bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden backdrop-blur-sm",children:[v.jsx("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary bg-azure-bg dark:bg-zinc-900/50",children:v.jsx("h3",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono uppercase",children:"Usage Breakdown by Model"})}),v.jsx("div",{className:"overflow-x-auto",children:v.jsxs("table",{className:"w-full text-left font-mono text-sm",children:[v.jsx("thead",{className:"bg-azure-bg dark:bg-zinc-900/50 text-azure-text-secondary dark:text-matrix-secondary border-b border-azure-border dark:border-matrix-primary",children:v.jsxs("tr",{children:[v.jsx("th",{className:"p-4",children:"Provider"}),v.jsx("th",{className:"p-4",children:"Model"}),v.jsx("th",{className:"p-4 text-right",children:"Messages"}),v.jsx("th",{className:"p-4 text-right",children:"Input Tokens"}),v.jsx("th",{className:"p-4 text-right",children:"Output Tokens"}),v.jsx("th",{className:"p-4 text-right",children:"Total Tokens"})]})}),v.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary/30",children:a.length===0?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"p-8 text-center text-azure-text-muted dark:text-matrix-secondary italic",children:"NO_DATA_AVAILABLE"})}):a.map((g,y)=>v.jsxs("tr",{className:"hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[v.jsx("td",{className:"p-4 font-bold text-azure-text-primary dark:text-matrix-highlight",children:g.provider}),v.jsx("td",{className:"p-4 text-azure-text-secondary dark:text-matrix-secondary",children:g.model}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.messageCount.toLocaleString()}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.totalInputTokens.toLocaleString()}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.totalOutputTokens.toLocaleString()}),v.jsx("td",{className:"p-4 text-right font-bold text-azure-text-primary dark:text-matrix-highlight",children:g.totalTokens.toLocaleString()})]},`${g.provider}-${g.model}-${y}`))})]})})]})]})}const qZ=()=>{const[e,t]=z.useState(""),[a,i]=z.useState(""),s=nm(),c=Ln(),u=d=>{d.preventDefault(),e&&(i(""),fetch("/api/config",{headers:{"x-architect-pass":e}}).then(async m=>{if(m.ok){localStorage.setItem("morpheus.auth.token",e);const p=c.state?.from?.pathname||"/";s(p,{replace:!0})}else i("Invalid architect password")}).catch(()=>{i("Connection failed")}))};return v.jsx("div",{className:"flex items-center justify-center min-h-screen bg-azure-bg dark:bg-black text-azure-primary dark:text-green-500 font-mono",children:v.jsxs("div",{className:"max-w-md w-full p-8 border border-azure-primary dark:border-green-500 shadow-xl dark:shadow-[0_0_15px_rgba(34,197,94,0.3)] bg-white dark:bg-black rounded-lg dark:rounded-none",children:[v.jsx("h1",{className:"text-2xl font-bold mb-6 text-center tracking-widest uppercase text-azure-primary dark:text-green-500",children:"> The Architect Login"}),v.jsxs("form",{onSubmit:u,className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm mb-2 opacity-70 text-azure-text-secondary dark:text-green-500",children:"ACCESS_PASS:"}),v.jsx("input",{type:"password",value:e,onChange:d=>t(d.target.value),className:"w-full bg-azure-bg dark:bg-black border border-azure-border dark:border-green-800 p-2 focus:outline-none focus:border-azure-primary dark:focus:border-green-500 text-azure-text-primary dark:text-green-500 placeholder-azure-text-secondary/50 dark:placeholder-green-900 rounded dark:rounded-none",placeholder:"••••••••",autoFocus:!0})]}),a&&v.jsxs("div",{className:"text-red-500 text-sm animate-pulse",children:["[!] ERROR: ",a]}),v.jsx("button",{type:"submit",className:"w-full bg-azure-primary hover:bg-azure-active dark:bg-green-900 dark:hover:bg-green-700 text-white dark:text-black font-bold py-2 transition-colors duration-200 uppercase tracking-wider rounded dark:rounded-none",children:"Authenticate"})]}),v.jsx("div",{className:"mt-8 text-[10px] opacity-30 text-center uppercase text-azure-text-secondary dark:text-green-500",children:"Morpheus OS v0.1.5 | Unauthorized access is logged."})]})})},YZ=({children:e})=>{const{isAuthenticated:t}=l_(),a=Ln();return t?v.jsx(v.Fragment,{children:e}):v.jsx(o1,{to:"/login",state:{from:a},replace:!0})},IZ=({className:e,...t})=>v.jsx("div",{className:"relative w-full overflow-auto",children:v.jsx("table",{className:`w-full caption-bottom text-sm ${e}`,...t})}),XZ=({...e})=>v.jsx("thead",{...e}),FZ=({...e})=>v.jsx("tbody",{...e}),ih=({...e})=>v.jsx("tr",{className:"border-b border-azure-border dark:border-matrix-primary transition-colors hover:bg-azure-hover/50 dark:hover:bg-matrix-primary/10",...e}),Ni=({className:e,...t})=>v.jsx("th",{className:`h-12 px-4 text-left align-middle font-medium text-azure-text-secondary dark:text-matrix-tertiary [&:has([role=checkbox])]:pr-0 ${e}`,...t}),Na=({className:e,...t})=>v.jsx("td",{className:`p-4 align-middle [&:has([role=checkbox])]:pr-0 ${e}`,...t}),Gx=({checked:e,onCheckedChange:t,className:a,...i})=>{const s=c=>{t&&t(c.target.checked),i.onChange&&i.onChange(c)};return v.jsx("input",{type:"checkbox",checked:e,onChange:s,className:`h-4 w-4 rounded border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 text-azure-primary dark:text-matrix-highlight focus:ring-azure-primary dark:focus:ring-matrix-highlight ${a||""}`,...i})},qu=({className:e,variant:t="default",...a})=>{const s=`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 dark:focus:ring-zinc-300 ${t==="destructive"?"border-transparent bg-red-500 text-zinc-50 dark:bg-red-900 dark:text-zinc-50":t==="secondary"?"border-transparent bg-azure-surface dark:bg-zinc-800 text-azure-text-secondary dark:text-matrix-secondary":t==="outline"?"text-azure-text-primary dark:text-matrix-secondary border-azure-border dark:border-matrix-primary":"border-transparent bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black"} ${e||""}`;return v.jsx("div",{className:s,...a})},oh=({className:e,...t})=>v.jsx("div",{className:`rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary shadow-sm ${e||""}`,...t}),qx=({className:e,...t})=>v.jsx("div",{className:`flex flex-col space-y-1.5 p-6 ${e||""}`,...t}),KZ=({className:e,...t})=>v.jsx("h3",{className:`text-2xl font-semibold leading-none tracking-tight ${e||""}`,...t}),sh=({className:e,...t})=>v.jsx("div",{className:`p-6 pt-0 ${e||""}`,...t}),JZ=({className:e,variant:t="default",...a})=>{const s=`relative w-full rounded-lg border p-4 ${t==="destructive"?"border-red-500/50 text-red-700 dark:border-red-900/50 dark:text-red-300":"border-azure-border dark:border-matrix-primary"} ${e||""}`;return v.jsx("div",{className:s,...a})},QZ=({className:e,...t})=>v.jsx("div",{className:`text-sm [&_p]:leading-relaxed ${e||""}`,...t}),Az=({isOpen:e,onClose:t,title:a,children:i,size:s="md"})=>{if(!e)return null;const c={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"};return v.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[v.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),v.jsxs("div",{className:`relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full ${c[s]} max-h-[90vh] overflow-hidden flex flex-col`,children:[a&&v.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-azure-border dark:border-matrix-primary",children:[a&&v.jsx("h3",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-secondary",children:a}),t&&v.jsx("button",{onClick:t,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-secondary",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:v.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),v.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:i})]})]})},WZ=({isOpen:e,onClose:t,memory:a})=>a?v.jsx(Az,{isOpen:e,onClose:t,title:"Memory Details",size:"lg",children:v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(SE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Category"})]}),v.jsx("div",{children:v.jsx(qu,{variant:"outline",children:a.category})}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(kE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Importance"})]}),v.jsx("div",{children:v.jsx(qu,{variant:a.importance==="critical"?"destructive":a.importance==="high"?"default":a.importance==="medium"?"secondary":"outline",children:a.importance})}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(d1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Created"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(a.created_at).toLocaleString()}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(h1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Updated"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(a.updated_at).toLocaleString()}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(m1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Access Count"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:a.access_count}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(nE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Hash"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary break-all text-sm",children:a.hash}),a.source&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(aE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Source"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:a.source})]})]}),v.jsxs("div",{children:[v.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Summary"}),v.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-800 p-3 rounded-md",children:a.summary})]}),a.details&&v.jsxs("div",{children:[v.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Details"}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-800 p-3 rounded-md whitespace-pre-wrap",children:a.details})]}),v.jsx("div",{className:"flex justify-end pt-4",children:v.jsx(Fn,{onClick:t,children:"Close"})})]})}):null,eL=({isOpen:e,onClose:t,onConfirm:a,title:i="Confirm Deletion",message:s="Are you sure you want to delete this item? This action cannot be undone.",confirmButtonText:c="Delete",cancelButtonText:u="Cancel"})=>v.jsx(Az,{isOpen:e,onClose:t,title:i,size:"md",children:v.jsxs("div",{className:"space-y-6",children:[v.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx(Fn,{variant:"outline",onClick:t,children:u}),v.jsx(Fn,{variant:"destructive",onClick:()=>{a(),t()},children:c})]})]})}),tL=()=>{const[e,t]=z.useState(!1),[a,i]=z.useState(null),s=z.useCallback(m=>(t(!0),i(null),dn.get(m).then(p=>p).catch(p=>{throw i(p.message||"An error occurred"),p}).finally(()=>{t(!1)})),[]),c=z.useCallback((m,p)=>(t(!0),i(null),dn.post(m,p).then(g=>g).catch(g=>{throw i(g.message||"An error occurred"),g}).finally(()=>{t(!1)})),[]),u=z.useCallback((m,p)=>(t(!0),i(null),dn.post(m,p).then(g=>g).catch(g=>{throw i(g.message||"An error occurred"),g}).finally(()=>{t(!1)})),[]),d=z.useCallback(m=>(t(!0),i(null),dn.delete(m).then(p=>p).catch(p=>{throw i(p.message||"An error occurred"),p}).finally(()=>{t(!1)})),[]);return{get:s,post:c,put:u,del:d,loading:e,error:a}},nL=()=>{const[e,t]=z.useState([]),[a,i]=z.useState(!0),[s,c]=z.useState([]),[u,d]=z.useState(""),[m,p]=z.useState("all"),[g,y]=z.useState("all"),[x,_]=z.useState(null),[E,T]=z.useState(!1),[C,M]=z.useState(null),[O,R]=z.useState(!1),[j,L]=z.useState(null),[W,K]=z.useState(!1),{get:B,del:Q,post:te}=tL();z.useEffect(()=>{de()},[]);const de=async()=>{try{i(!0);const w=await B("/sati/memories");t(w),_(null)}catch(w){_("Failed to load memories. Please try again."),console.error("Error fetching memories:",w)}finally{i(!1)}},xe=()=>{s.length===q.length?c([]):c(q.map(w=>w.id))},Fe=w=>{s.includes(w)?c(s.filter(P=>P!==w)):c([...s,w])},Oe=async()=>{if(s.length!==0)try{await te("/sati/memories/bulk-delete",{ids:s}),await de(),c([]),T(!1)}catch(w){_("Failed to delete memories. Please try again."),console.error("Error deleting memories:",w)}},Ne=w=>{L(w),K(!0)},U=async()=>{if(j)try{await Q(`/sati/memories/${j}`),await de()}catch(w){_("Failed to delete memory. Please try again."),console.error("Error deleting memory:",w)}finally{L(null),K(!1)}},F=w=>{M(w),R(!0)},q=e.filter(w=>{const P=w.summary.toLowerCase().includes(u.toLowerCase())||w.details?.toLowerCase().includes(u.toLowerCase())||w.category.toLowerCase().includes(u.toLowerCase()),J=m==="all"||w.category===m,ee=g==="all"||w.importance===g;return P&&J&&ee&&!w.archived}),he=Array.from(new Set(e.map(w=>w.category))),ye=Array.from(new Set(e.map(w=>w.importance)));return a?v.jsx(oh,{className:"w-full",children:v.jsx(sh,{className:"flex justify-center items-center h-64",children:v.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-azure-primary dark:border-matrix-highlight"})})}):v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight",children:"Sati Memories"}),v.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary mt-1",children:"View and manage your long-term memories stored by Sati"})]}),s.length>0&&v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("span",{className:"text-sm text-azure-text-muted dark:text-matrix-secondary",children:[s.length," selected"]}),v.jsxs(Fn,{variant:"destructive",size:"sm",onClick:()=>T(!0),disabled:s.length===0,children:[v.jsx(T0,{className:"w-4 h-4 mr-1"}),"Delete Selected"]})]})]}),x&&v.jsx(JZ,{variant:"destructive",children:v.jsx(QZ,{children:x})}),v.jsxs(oh,{children:[v.jsx(qx,{className:"border-b border-azure-border dark:border-matrix-primary",children:v.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[v.jsxs("div",{className:"flex flex-col relative w-full",children:[v.jsx(yE,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-azure-text-secondary dark:text-matrix-tertiary w-4 h-4"}),v.jsx("input",{type:"text",placeholder:"Search memories...",value:u,onChange:w=>d(w.target.value),className:"w-full pl-10 pr-4 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight"})]}),v.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[v.jsxs("select",{value:m,onChange:w=>p(w.target.value),className:"px-3 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[v.jsx("option",{value:"all",children:"All Categories"}),he.map(w=>v.jsx("option",{value:w,children:w},w))]}),v.jsxs("select",{value:g,onChange:w=>y(w.target.value),className:"px-3 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[v.jsx("option",{value:"all",children:"All Importance"}),ye.map(w=>v.jsx("option",{value:w,children:w},w))]})]})]})}),v.jsx(sh,{className:"p-0",children:v.jsxs(IZ,{children:[v.jsx(XZ,{children:v.jsxs(ih,{className:"hover:bg-transparent",children:[v.jsx(Ni,{className:"w-12",children:v.jsx(Gx,{checked:q.length>0&&s.length===q.length,onCheckedChange:xe})}),v.jsx(Ni,{children:"Summary"}),v.jsx(Ni,{children:"Category"}),v.jsx(Ni,{children:"Importance"}),v.jsx(Ni,{children:"Created"}),v.jsx(Ni,{className:"w-32",children:"Actions"})]})}),v.jsx(FZ,{children:q.length===0?v.jsx(ih,{children:v.jsx(Na,{colSpan:6,className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:a?"Loading memories...":"No memories found"})}):q.map(w=>v.jsxs(ih,{children:[v.jsx(Na,{children:v.jsx(Gx,{checked:s.includes(w.id),onCheckedChange:()=>Fe(w.id)})}),v.jsx(Na,{className:"font-medium max-w-xs truncate",children:w.summary}),v.jsx(Na,{children:v.jsx(qu,{variant:"outline",children:w.category})}),v.jsx(Na,{children:v.jsx(qu,{variant:w.importance==="critical"?"destructive":w.importance==="high"?"default":w.importance==="medium"?"secondary":"outline",children:w.importance})}),v.jsx(Na,{children:v.jsxs("div",{className:"flex items-center gap-1 text-azure-text-secondary dark:text-matrix-tertiary",children:[v.jsx(d1,{className:"w-4 h-4"}),new Date(w.created_at).toLocaleDateString()]})}),v.jsx(Na,{children:v.jsxs("div",{className:"flex gap-1",children:[v.jsx(Fn,{variant:"ghost",size:"sm",onClick:()=>F(w),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:v.jsx(m1,{className:"w-4 h-4"})}),v.jsx(Fn,{variant:"ghost",size:"sm",onClick:()=>Ne(w.id),className:"text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:v.jsx(T0,{className:"w-4 h-4"})})]})})]},w.id))})]})})]}),E&&v.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:v.jsxs(oh,{className:"w-full max-w-md mx-4",children:[v.jsx(qx,{children:v.jsx(KZ,{children:"Delete Memories"})}),v.jsxs(sh,{children:[v.jsxs("p",{className:"mb-4",children:["Are you sure you want to delete ",s.length," ","memory(ies)? This action cannot be undone."]}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx(Fn,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),v.jsx(Fn,{variant:"destructive",onClick:Oe,children:"Delete"})]})]})]})}),v.jsx(WZ,{isOpen:O,onClose:()=>R(!1),memory:C}),v.jsx(eL,{isOpen:W,onClose:()=>K(!1),onConfirm:U,title:"Confirm Memory Deletion",message:"Are you sure you want to delete this memory? This action cannot be undone.",confirmButtonText:"Delete Memory",cancelButtonText:"Cancel"})]})},us=Da.getInstance(),cs={fetchServers:async()=>us.get("/mcp/servers"),addServer:async(e,t)=>us.post("/mcp/servers",{name:e,config:t}),updateServer:async(e,t)=>us.put(`/mcp/servers/${encodeURIComponent(e)}`,{config:t}),deleteServer:async e=>us.delete(`/mcp/servers/${encodeURIComponent(e)}`),toggleServer:async(e,t)=>us.patch(`/mcp/servers/${encodeURIComponent(e)}/toggle`,{enabled:t})},rL=({label:e,values:t,onChange:a,placeholder:i})=>{const s=t.length>0?t:[""],c=(m,p)=>{const g=[...s];g[m]=p,a(g.filter(y=>y.trim().length>0))},u=()=>a([...s,""]),d=m=>{const p=s.filter((g,y)=>y!==m);a(p.filter(g=>g.trim().length>0))};return v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-highlight",children:e}),s.map((m,p)=>v.jsxs("div",{className:"flex gap-2",children:[v.jsx("input",{className:"flex-1 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:m,placeholder:i,onChange:g=>c(p,g.target.value)}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>d(p),children:"Remove"})]},`${e}-${p}`)),v.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:u,children:"Add argument"})]})},Yx=({label:e,values:t,onChange:a,keyPlaceholder:i,valuePlaceholder:s})=>{const c=z.useMemo(()=>t.length>0?t:[{key:"",value:""}],[t]),u=(p,g,y)=>{const x=[...c];x[p]={...x[p],[g]:y},a(x.filter(_=>_.key.trim().length>0||_.value.trim().length>0))},d=()=>a([...c,{key:"",value:""}]),m=p=>{const g=c.filter((y,x)=>x!==p);a(g.filter(y=>y.key.trim().length>0||y.value.trim().length>0))};return v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-highlight",children:e}),c.map((p,g)=>v.jsxs("div",{className:"grid gap-2 md:grid-cols-5",children:[v.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:p.key,placeholder:i,onChange:y=>u(g,"key",y.target.value)}),v.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:p.value,placeholder:s,onChange:y=>u(g,"value",y.target.value)}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>m(g),children:"Remove"})]},`${e}-${g}`)),v.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:d,children:"Add entry"})]})},aL=({transport:e,command:t,url:a,args:i,env:s,headers:c,onCommandChange:u,onUrlChange:d,onArgsChange:m,onEnvChange:p,onHeadersChange:g})=>v.jsxs("div",{className:"space-y-4",children:[e==="stdio"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Command",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:t,onChange:y=>u(y.target.value),placeholder:"npx"})]}),v.jsx(rL,{label:"Arguments",values:i,onChange:m,placeholder:"--flag"})]}),e==="http"&&v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["URL",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:a,onChange:y=>d(y.target.value),placeholder:"https://example.com/mcp"})]}),v.jsx(Yx,{label:"Environment Variables",values:s,onChange:p,keyPlaceholder:"KEY",valuePlaceholder:"value"}),e==="http"&&v.jsx(Yx,{label:"Headers",values:c,onChange:g,keyPlaceholder:"Header",valuePlaceholder:"value"})]}),iL=yZ({name:ah().min(1,"Name is required"),transport:kz([Vx("stdio"),Vx("http")]),command:ah().optional(),url:ah().optional()}),Su=e=>e?Object.entries(e).map(([t,a])=>({key:t,value:a})):[],lh=e=>e.reduce((t,a)=>(a.key.trim().length===0||(t[a.key]=a.value),t),{}),oL=({open:e,mode:t,initial:a,onClose:i,onSubmit:s})=>{const[c,u]=z.useState(a?.name??""),[d,m]=z.useState(a?.config.transport??"stdio"),[p,g]=z.useState(a?.config.transport==="stdio"?a.config.command:""),[y,x]=z.useState(a?.config.transport==="http"?a.config.url:""),[_,E]=z.useState(a?.config.args??[]),[T,C]=z.useState(Su(a?.config.env)),[M,O]=z.useState(a?.config.transport==="http"?Su(a.config.headers):[]),[R,j]=z.useState(null);z.useEffect(()=>{e&&(u(a?.name??""),m(a?.config.transport??"stdio"),g(a?.config.transport==="stdio"?a.config.command:""),x(a?.config.transport==="http"?a.config.url:""),E(a?.config.args??[]),C(Su(a?.config.env)),O(a?.config.transport==="http"?Su(a.config.headers):[]),j(null))},[e,a]);const L=t==="create",W=async()=>{const B=iL.safeParse({name:c,transport:d,command:p,url:y});if(!B.success){j(B.error.issues[0]?.message??"Invalid form");return}if(d==="stdio"&&(!p||p.trim().length===0)){j("Command is required for stdio transport.");return}if(d==="http"&&(!y||y.trim().length===0)){j("URL is required for http transport.");return}const Q=d==="stdio"?{transport:"stdio",command:p.trim(),args:_.length>0?_:void 0,env:T.length>0?lh(T):void 0}:{transport:"http",url:y.trim(),headers:M.length>0?lh(M):void 0,env:T.length>0?lh(T):void 0};j(null),await s(c.trim(),Q)},K=z.useMemo(()=>t==="create"?"Add MCP Server":"Edit MCP Server",[t]);return v.jsx(Pm,{open:e,onOpenChange:i,children:v.jsxs(Hm,{children:[v.jsx(Gm,{children:v.jsx(qm,{children:K})}),v.jsxs("div",{className:"space-y-4",children:[v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Name",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none disabled:bg-azure-border dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight dark:disabled:bg-matrix-primary/50",value:c,onChange:B=>u(B.target.value),placeholder:"coolify",disabled:!L})]}),v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Transport",v.jsxs("select",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:d,onChange:B=>m(B.target.value),children:[v.jsx("option",{value:"stdio",children:"stdio"}),v.jsx("option",{value:"http",children:"http"})]})]}),v.jsx(aL,{transport:d,command:p,url:y,args:_,env:T,headers:M,onCommandChange:g,onUrlChange:x,onArgsChange:E,onEnvChange:C,onHeadersChange:O}),R&&v.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-400",children:R}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:i,children:"Cancel"}),v.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:W,children:"Save"})]})]})]})})},sL=({server:e,onEdit:t,onDelete:a,onToggle:i})=>v.jsxs("div",{className:"rounded-2xl border border-azure-border bg-azure-surface/80 p-4 shadow-sm dark:border-matrix-primary dark:bg-zinc-950/70",children:[v.jsxs("div",{className:"flex items-start justify-between gap-3",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-highlight",children:e.name}),v.jsx("div",{className:"text-xs uppercase tracking-wide text-azure-text-muted dark:text-matrix-secondary",children:e.config.transport})]}),v.jsx("div",{className:"flex items-center gap-2",children:v.jsx("button",{type:"button",className:`rounded-full px-3 py-1 text-xs font-semibold ${e.enabled?"bg-matrix-highlight dark:text-matrix-primary":"bg-azure-border text-azure-text-secondary dark:bg-matrix-primary/50 dark:text-matrix-secondary"}`,onClick:()=>i(e,!e.enabled),children:e.enabled?"Enabled":"Disabled"})})]}),v.jsxs("div",{className:"mt-4 space-y-2 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:[e.config.transport==="stdio"&&v.jsxs("div",{children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"Command:"})," ",e.config.command]}),e.config.transport==="http"&&v.jsxs("div",{children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"URL:"})," ",e.config.url]}),e.config.args&&e.config.args.length>0&&v.jsxs("div",{children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"Args:"})," ",e.config.args.join(" ")]})]}),v.jsxs("div",{className:"mt-4 flex gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-3 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>t(e),children:"Edit"}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>a(e),children:"Delete"})]})]}),lL=()=>{const{data:e,error:t,mutate:a,isLoading:i}=Va("/api/mcp/servers",()=>cs.fetchServers()),[s,c]=z.useState(""),[u,d]=z.useState("all"),[m,p]=z.useState(!1),[g,y]=z.useState(null),[x,_]=z.useState(!1),[E,T]=z.useState(null),[C,M]=z.useState(null),O=e?.servers??[],R=z.useMemo(()=>O.filter(te=>{const de=te.name.toLowerCase().includes(s.toLowerCase()),xe=u==="all"||te.config.transport===u;return de&&xe}),[O,s,u]),j=()=>{y(null),p(!0)},L=te=>{y(te),p(!0)},W=async(te,de)=>{try{g?await cs.updateServer(g.name,de):await cs.addServer(te,de),p(!1),y(null),await a(),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(xe){M({type:"error",message:xe.message||"Failed to save MCP server."})}},K=async te=>{T(te),_(!0)},B=async()=>{if(E)try{await cs.deleteServer(E.name),await a(),_(!1),T(null),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(te){M({type:"error",message:te.message||"Failed to delete MCP server."})}},Q=async(te,de)=>{try{await cs.toggleServer(te.name,de),await a(),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(xe){M({type:"error",message:xe.message||"Failed to toggle MCP server."})}};return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-azure-primary dark:text-matrix-highlight",children:"MCP Servers"}),v.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Manage MCP servers stored in mcps.json."})]}),v.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:j,children:"Add Server"})]}),C&&v.jsx("div",{className:`p-4 rounded border ${C.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:C.message}),v.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center",children:[v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:s,onChange:te=>c(te.target.value),placeholder:"Search by name"}),v.jsxs("select",{className:"rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:u,onChange:te=>d(te.target.value),children:[v.jsx("option",{value:"all",children:"All"}),v.jsx("option",{value:"stdio",children:"stdio"}),v.jsx("option",{value:"http",children:"http"})]})]}),i&&v.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Loading MCP servers..."}),t&&v.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load MCP servers."}),!i&&R.length===0&&v.jsx("div",{className:"rounded-2xl border border-dashed border-azure-border bg-azure-surface/60 p-6 text-center text-sm text-azure-text-secondary dark:border-matrix-primary dark:bg-zinc-950/60 dark:text-matrix-secondary",children:"No MCP servers found. Add a server to get started."}),v.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:R.map(te=>v.jsx(sL,{server:te,onEdit:L,onDelete:K,onToggle:Q},`${te.name}-${te.enabled?"on":"off"}`))}),v.jsx(oL,{open:m,mode:g?"edit":"create",initial:g??void 0,onClose:()=>p(!1),onSubmit:W}),v.jsx(Pm,{open:x,onOpenChange:_,children:v.jsxs(Hm,{children:[v.jsx(Gm,{children:v.jsx(qm,{children:"Confirm Deletion"})}),v.jsxs("div",{className:"space-y-4",children:[v.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:["Are you sure you want to delete the MCP server ",v.jsxs("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:['"',E?.name,'"']}),"? This action cannot be undone."]}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>_(!1),children:"Cancel"}),v.jsx("button",{type:"button",className:"rounded-md bg-red-500 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-red-400 dark:bg-red-600 hover:dark:bg-red-500",onClick:B,children:"Delete"})]})]})]})})]})};function uL(){return v.jsx(S2,{children:v.jsxs(y0,{children:[v.jsx(In,{path:"/login",element:v.jsx(qZ,{})}),v.jsx(In,{path:"/*",element:v.jsx(YZ,{children:v.jsx(GN,{children:v.jsxs(y0,{children:[v.jsx(In,{path:"/",element:v.jsx(IN,{})}),v.jsx(In,{path:"/config",element:v.jsx(PZ,{})}),v.jsx(In,{path:"/logs",element:v.jsx(HZ,{})}),v.jsx(In,{path:"/stats",element:v.jsx(GZ,{})}),v.jsx(In,{path:"/sati-memories",element:v.jsx(nL,{})}),v.jsx(In,{path:"/mcp-servers",element:v.jsx(lL,{})}),v.jsx(In,{path:"*",element:v.jsx(o1,{to:"/",replace:!0})})]})})})})]})})}tT.createRoot(document.getElementById("root")).render(v.jsx(z.StrictMode,{children:v.jsx(uL,{})}));
|
|
96
|
+
`):"Select a log file to view content..."})]})]})]})}function GZ(){const[e,t]=z.useState(null),[a,i]=z.useState([]),[s,c]=z.useState(!0),[u,d]=z.useState("");if(z.useEffect(()=>{async function g(){try{const[y,x]=await Promise.all([Gh.fetchUsageStats(),Gh.fetchGroupedUsageStats()]);t(y),i(x)}catch(y){d("Failed to load usage statistics"),console.error(y)}finally{c(!1)}}g()},[]),s)return v.jsx("div",{className:"flex items-center justify-center h-64 text-azure-accent dark:text-matrix-highlight font-mono animate-pulse",children:"LOADING_DATA_STREAM..."});if(u)return v.jsxs("div",{className:"p-4 bg-red-900/20 border border-red-500/50 text-red-500 font-mono rounded",children:["ERROR_ACCESSING_DATABASE: ",u]});const m={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},p={hidden:{y:20,opacity:0},show:{y:0,opacity:1}};return v.jsxs(Kn.div,{variants:m,initial:"hidden",animate:"show",className:"space-y-6",children:[v.jsx("div",{className:"flex items-center justify-between border-b border-azure-border dark:border-matrix-primary pb-4",children:v.jsxs("div",{children:[v.jsxs("h2",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight font-mono flex items-center gap-2",children:[v.jsx(fh,{className:"w-6 h-6"}),"USAGE_ANALYTICS"]}),v.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary mt-1 font-mono text-sm",children:"Resource consumption tracking and metrics"})]})}),v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[v.jsxs(Kn.div,{variants:p,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[v.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[v.jsx(cE,{className:"w-5 h-5"}),v.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Input Tokens"})]}),v.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:e?.totalInputTokens.toLocaleString()??0})]}),v.jsxs(Kn.div,{variants:p,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[v.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[v.jsx(J2,{className:"w-5 h-5"}),v.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Output Tokens"})]}),v.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:e?.totalOutputTokens.toLocaleString()??0})]})]}),v.jsxs(Kn.div,{variants:p,className:"bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden backdrop-blur-sm",children:[v.jsx("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary bg-azure-bg dark:bg-zinc-900/50",children:v.jsx("h3",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono uppercase",children:"Usage Breakdown by Model"})}),v.jsx("div",{className:"overflow-x-auto",children:v.jsxs("table",{className:"w-full text-left font-mono text-sm",children:[v.jsx("thead",{className:"bg-azure-bg dark:bg-zinc-900/50 text-azure-text-secondary dark:text-matrix-secondary border-b border-azure-border dark:border-matrix-primary",children:v.jsxs("tr",{children:[v.jsx("th",{className:"p-4",children:"Provider"}),v.jsx("th",{className:"p-4",children:"Model"}),v.jsx("th",{className:"p-4 text-right",children:"Messages"}),v.jsx("th",{className:"p-4 text-right",children:"Input Tokens"}),v.jsx("th",{className:"p-4 text-right",children:"Output Tokens"}),v.jsx("th",{className:"p-4 text-right",children:"Total Tokens"})]})}),v.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary/30",children:a.length===0?v.jsx("tr",{children:v.jsx("td",{colSpan:6,className:"p-8 text-center text-azure-text-muted dark:text-matrix-secondary italic",children:"NO_DATA_AVAILABLE"})}):a.map((g,y)=>v.jsxs("tr",{className:"hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[v.jsx("td",{className:"p-4 font-bold text-azure-text-primary dark:text-matrix-highlight",children:g.provider}),v.jsx("td",{className:"p-4 text-azure-text-secondary dark:text-matrix-secondary",children:g.model}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.messageCount.toLocaleString()}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.totalInputTokens.toLocaleString()}),v.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:g.totalOutputTokens.toLocaleString()}),v.jsx("td",{className:"p-4 text-right font-bold text-azure-text-primary dark:text-matrix-highlight",children:g.totalTokens.toLocaleString()})]},`${g.provider}-${g.model}-${y}`))})]})})]})]})}const qZ=()=>{const[e,t]=z.useState(""),[a,i]=z.useState(""),s=nm(),c=Ln(),u=d=>{d.preventDefault(),e&&(i(""),fetch("/api/config",{headers:{"x-architect-pass":e}}).then(async m=>{if(m.ok){localStorage.setItem("morpheus.auth.token",e);const p=c.state?.from?.pathname||"/";s(p,{replace:!0})}else i("Invalid architect password")}).catch(()=>{i("Connection failed")}))};return v.jsx("div",{className:"flex items-center justify-center min-h-screen bg-azure-bg dark:bg-black text-azure-primary dark:text-green-500 font-mono",children:v.jsxs("div",{className:"max-w-md w-full p-8 border border-azure-primary dark:border-green-500 shadow-xl dark:shadow-[0_0_15px_rgba(34,197,94,0.3)] bg-white dark:bg-black rounded-lg dark:rounded-none",children:[v.jsx("h1",{className:"text-2xl font-bold mb-6 text-center tracking-widest uppercase text-azure-primary dark:text-green-500",children:"> The Architect Login"}),v.jsxs("form",{onSubmit:u,className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("label",{className:"block text-sm mb-2 opacity-70 text-azure-text-secondary dark:text-green-500",children:"ACCESS_PASS:"}),v.jsx("input",{type:"password",value:e,onChange:d=>t(d.target.value),className:"w-full bg-azure-bg dark:bg-black border border-azure-border dark:border-green-800 p-2 focus:outline-none focus:border-azure-primary dark:focus:border-green-500 text-azure-text-primary dark:text-green-500 placeholder-azure-text-secondary/50 dark:placeholder-green-900 rounded dark:rounded-none",placeholder:"••••••••",autoFocus:!0})]}),a&&v.jsxs("div",{className:"text-red-500 text-sm animate-pulse",children:["[!] ERROR: ",a]}),v.jsx("button",{type:"submit",className:"w-full bg-azure-primary hover:bg-azure-active dark:bg-green-900 dark:hover:bg-green-700 text-white dark:text-black font-bold py-2 transition-colors duration-200 uppercase tracking-wider rounded dark:rounded-none",children:"Authenticate"})]}),v.jsx("div",{className:"mt-8 text-[10px] opacity-30 text-center uppercase text-azure-text-secondary dark:text-green-500",children:"Morpheus OS v0.1.5 | Unauthorized access is logged."})]})})},YZ=({children:e})=>{const{isAuthenticated:t}=l_(),a=Ln();return t?v.jsx(v.Fragment,{children:e}):v.jsx(o1,{to:"/login",state:{from:a},replace:!0})},IZ=({className:e,...t})=>v.jsx("div",{className:"relative w-full overflow-auto",children:v.jsx("table",{className:`w-full caption-bottom text-sm ${e}`,...t})}),XZ=({...e})=>v.jsx("thead",{...e}),FZ=({...e})=>v.jsx("tbody",{...e}),ih=({...e})=>v.jsx("tr",{className:"border-b border-azure-border dark:border-matrix-primary transition-colors hover:bg-azure-hover/50 dark:hover:bg-matrix-primary/10",...e}),Ni=({className:e,...t})=>v.jsx("th",{className:`h-12 px-4 text-left align-middle font-medium text-azure-text-secondary dark:text-matrix-tertiary [&:has([role=checkbox])]:pr-0 ${e}`,...t}),Na=({className:e,...t})=>v.jsx("td",{className:`p-4 align-middle [&:has([role=checkbox])]:pr-0 ${e}`,...t}),Gx=({checked:e,onCheckedChange:t,className:a,...i})=>{const s=c=>{t&&t(c.target.checked),i.onChange&&i.onChange(c)};return v.jsx("input",{type:"checkbox",checked:e,onChange:s,className:`h-4 w-4 rounded border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 text-azure-primary dark:text-matrix-highlight focus:ring-azure-primary dark:focus:ring-matrix-highlight ${a||""}`,...i})},qu=({className:e,variant:t="default",...a})=>{const s=`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 dark:focus:ring-zinc-300 ${t==="destructive"?"border-transparent bg-red-500 text-zinc-50 dark:bg-red-900 dark:text-zinc-50":t==="secondary"?"border-transparent bg-azure-surface dark:bg-zinc-800 text-azure-text-secondary dark:text-matrix-secondary":t==="outline"?"text-azure-text-primary dark:text-matrix-secondary border-azure-border dark:border-matrix-primary":"border-transparent bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black"} ${e||""}`;return v.jsx("div",{className:s,...a})},oh=({className:e,...t})=>v.jsx("div",{className:`rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary shadow-sm ${e||""}`,...t}),qx=({className:e,...t})=>v.jsx("div",{className:`flex flex-col space-y-1.5 p-6 ${e||""}`,...t}),KZ=({className:e,...t})=>v.jsx("h3",{className:`text-2xl font-semibold leading-none tracking-tight ${e||""}`,...t}),sh=({className:e,...t})=>v.jsx("div",{className:`p-6 pt-0 ${e||""}`,...t}),JZ=({className:e,variant:t="default",...a})=>{const s=`relative w-full rounded-lg border p-4 ${t==="destructive"?"border-red-500/50 text-red-700 dark:border-red-900/50 dark:text-red-300":"border-azure-border dark:border-matrix-primary"} ${e||""}`;return v.jsx("div",{className:s,...a})},QZ=({className:e,...t})=>v.jsx("div",{className:`text-sm [&_p]:leading-relaxed ${e||""}`,...t}),Az=({isOpen:e,onClose:t,title:a,children:i,size:s="md"})=>{if(!e)return null;const c={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"};return v.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[v.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),v.jsxs("div",{className:`relative bg-azure-surface dark:bg-zinc-900 rounded-lg border border-azure-border dark:border-matrix-primary shadow-lg w-full ${c[s]} max-h-[90vh] overflow-hidden flex flex-col`,children:[a&&v.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-azure-border dark:border-matrix-primary",children:[a&&v.jsx("h3",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-secondary",children:a}),t&&v.jsx("button",{onClick:t,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-secondary",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:v.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),v.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:i})]})]})},WZ=({isOpen:e,onClose:t,memory:a})=>a?v.jsx(Az,{isOpen:e,onClose:t,title:"Memory Details",size:"lg",children:v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(SE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Category"})]}),v.jsx("div",{children:v.jsx(qu,{variant:"outline",children:a.category})}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(kE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Importance"})]}),v.jsx("div",{children:v.jsx(qu,{variant:a.importance==="critical"?"destructive":a.importance==="high"?"default":a.importance==="medium"?"secondary":"outline",children:a.importance})}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(d1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Created"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(a.created_at).toLocaleString()}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(h1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Updated"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(a.updated_at).toLocaleString()}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(m1,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Access Count"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:a.access_count}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(nE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Hash"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary break-all text-sm",children:a.hash}),a.source&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(aE,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),v.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Source"})]}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:a.source})]})]}),v.jsxs("div",{children:[v.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Summary"}),v.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-800 p-3 rounded-md",children:a.summary})]}),a.details&&v.jsxs("div",{children:[v.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Details"}),v.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-800 p-3 rounded-md whitespace-pre-wrap",children:a.details})]}),v.jsx("div",{className:"flex justify-end pt-4",children:v.jsx(Fn,{onClick:t,children:"Close"})})]})}):null,eL=({isOpen:e,onClose:t,onConfirm:a,title:i="Confirm Deletion",message:s="Are you sure you want to delete this item? This action cannot be undone.",confirmButtonText:c="Delete",cancelButtonText:u="Cancel"})=>v.jsx(Az,{isOpen:e,onClose:t,title:i,size:"md",children:v.jsxs("div",{className:"space-y-6",children:[v.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx(Fn,{variant:"outline",onClick:t,children:u}),v.jsx(Fn,{variant:"destructive",onClick:()=>{a(),t()},children:c})]})]})}),tL=()=>{const[e,t]=z.useState(!1),[a,i]=z.useState(null),s=z.useCallback(m=>(t(!0),i(null),dn.get(m).then(p=>p).catch(p=>{throw i(p.message||"An error occurred"),p}).finally(()=>{t(!1)})),[]),c=z.useCallback((m,p)=>(t(!0),i(null),dn.post(m,p).then(g=>g).catch(g=>{throw i(g.message||"An error occurred"),g}).finally(()=>{t(!1)})),[]),u=z.useCallback((m,p)=>(t(!0),i(null),dn.post(m,p).then(g=>g).catch(g=>{throw i(g.message||"An error occurred"),g}).finally(()=>{t(!1)})),[]),d=z.useCallback(m=>(t(!0),i(null),dn.delete(m).then(p=>p).catch(p=>{throw i(p.message||"An error occurred"),p}).finally(()=>{t(!1)})),[]);return{get:s,post:c,put:u,del:d,loading:e,error:a}},nL=()=>{const[e,t]=z.useState([]),[a,i]=z.useState(!0),[s,c]=z.useState([]),[u,d]=z.useState(""),[m,p]=z.useState("all"),[g,y]=z.useState("all"),[x,_]=z.useState(null),[E,T]=z.useState(!1),[C,M]=z.useState(null),[O,R]=z.useState(!1),[j,L]=z.useState(null),[W,K]=z.useState(!1),{get:B,del:Q,post:te}=tL();z.useEffect(()=>{de()},[]);const de=async()=>{try{i(!0);const w=await B("/sati/memories");t(w),_(null)}catch(w){_("Failed to load memories. Please try again."),console.error("Error fetching memories:",w)}finally{i(!1)}},xe=()=>{s.length===q.length?c([]):c(q.map(w=>w.id))},Fe=w=>{s.includes(w)?c(s.filter(P=>P!==w)):c([...s,w])},Oe=async()=>{if(s.length!==0)try{await te("/sati/memories/bulk-delete",{ids:s}),await de(),c([]),T(!1)}catch(w){_("Failed to delete memories. Please try again."),console.error("Error deleting memories:",w)}},Ne=w=>{L(w),K(!0)},U=async()=>{if(j)try{await Q(`/sati/memories/${j}`),await de()}catch(w){_("Failed to delete memory. Please try again."),console.error("Error deleting memory:",w)}finally{L(null),K(!1)}},F=w=>{M(w),R(!0)},q=e.filter(w=>{const P=w.summary.toLowerCase().includes(u.toLowerCase())||w.details?.toLowerCase().includes(u.toLowerCase())||w.category.toLowerCase().includes(u.toLowerCase()),J=m==="all"||w.category===m,ee=g==="all"||w.importance===g;return P&&J&&ee&&!w.archived}),he=Array.from(new Set(e.map(w=>w.category))),ye=Array.from(new Set(e.map(w=>w.importance)));return a?v.jsx(oh,{className:"w-full",children:v.jsx(sh,{className:"flex justify-center items-center h-64",children:v.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-azure-primary dark:border-matrix-highlight"})})}):v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-bold text-azure-primary dark:text-matrix-highlight",children:"Sati Memories"}),v.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary mt-1",children:"View and manage your long-term memories stored by Sati"})]}),s.length>0&&v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("span",{className:"text-sm text-azure-text-muted dark:text-matrix-secondary",children:[s.length," selected"]}),v.jsxs(Fn,{variant:"destructive",size:"sm",onClick:()=>T(!0),disabled:s.length===0,children:[v.jsx(T0,{className:"w-4 h-4 mr-1"}),"Delete Selected"]})]})]}),x&&v.jsx(JZ,{variant:"destructive",children:v.jsx(QZ,{children:x})}),v.jsxs(oh,{children:[v.jsx(qx,{className:"border-b border-azure-border dark:border-matrix-primary",children:v.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[v.jsxs("div",{className:"flex flex-col relative w-full",children:[v.jsx(yE,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-azure-text-secondary dark:text-matrix-tertiary w-4 h-4"}),v.jsx("input",{type:"text",placeholder:"Search memories...",value:u,onChange:w=>d(w.target.value),className:"w-full pl-10 pr-4 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight"})]}),v.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[v.jsxs("select",{value:m,onChange:w=>p(w.target.value),className:"px-3 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[v.jsx("option",{value:"all",children:"All Categories"}),he.map(w=>v.jsx("option",{value:w,children:w},w))]}),v.jsxs("select",{value:g,onChange:w=>y(w.target.value),className:"px-3 py-2 bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[v.jsx("option",{value:"all",children:"All Importance"}),ye.map(w=>v.jsx("option",{value:w,children:w},w))]})]})]})}),v.jsx(sh,{className:"p-0",children:v.jsxs(IZ,{children:[v.jsx(XZ,{children:v.jsxs(ih,{className:"hover:bg-transparent",children:[v.jsx(Ni,{className:"w-12",children:v.jsx(Gx,{checked:q.length>0&&s.length===q.length,onCheckedChange:xe})}),v.jsx(Ni,{children:"Summary"}),v.jsx(Ni,{children:"Category"}),v.jsx(Ni,{children:"Importance"}),v.jsx(Ni,{children:"Created"}),v.jsx(Ni,{className:"w-32",children:"Actions"})]})}),v.jsx(FZ,{children:q.length===0?v.jsx(ih,{children:v.jsx(Na,{colSpan:6,className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:a?"Loading memories...":"No memories found"})}):q.map(w=>v.jsxs(ih,{children:[v.jsx(Na,{children:v.jsx(Gx,{checked:s.includes(w.id),onCheckedChange:()=>Fe(w.id)})}),v.jsx(Na,{className:"font-medium max-w-xs truncate",children:w.summary}),v.jsx(Na,{children:v.jsx(qu,{variant:"outline",children:w.category})}),v.jsx(Na,{children:v.jsx(qu,{variant:w.importance==="critical"?"destructive":w.importance==="high"?"default":w.importance==="medium"?"secondary":"outline",children:w.importance})}),v.jsx(Na,{children:v.jsxs("div",{className:"flex items-center gap-1 text-azure-text-secondary dark:text-matrix-tertiary",children:[v.jsx(d1,{className:"w-4 h-4"}),new Date(w.created_at).toLocaleDateString()]})}),v.jsx(Na,{children:v.jsxs("div",{className:"flex gap-1",children:[v.jsx(Fn,{variant:"ghost",size:"sm",onClick:()=>F(w),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:v.jsx(m1,{className:"w-4 h-4"})}),v.jsx(Fn,{variant:"ghost",size:"sm",onClick:()=>Ne(w.id),className:"text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:v.jsx(T0,{className:"w-4 h-4"})})]})})]},w.id))})]})})]}),E&&v.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:v.jsxs(oh,{className:"w-full max-w-md mx-4",children:[v.jsx(qx,{children:v.jsx(KZ,{children:"Delete Memories"})}),v.jsxs(sh,{children:[v.jsxs("p",{className:"mb-4",children:["Are you sure you want to delete ",s.length," ","memory(ies)? This action cannot be undone."]}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx(Fn,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),v.jsx(Fn,{variant:"destructive",onClick:Oe,children:"Delete"})]})]})]})}),v.jsx(WZ,{isOpen:O,onClose:()=>R(!1),memory:C}),v.jsx(eL,{isOpen:W,onClose:()=>K(!1),onConfirm:U,title:"Confirm Memory Deletion",message:"Are you sure you want to delete this memory? This action cannot be undone.",confirmButtonText:"Delete Memory",cancelButtonText:"Cancel"})]})},us=Da.getInstance(),cs={fetchServers:async()=>us.get("/mcp/servers"),addServer:async(e,t)=>us.post("/mcp/servers",{name:e,config:t}),updateServer:async(e,t)=>us.put(`/mcp/servers/${encodeURIComponent(e)}`,{config:t}),deleteServer:async e=>us.delete(`/mcp/servers/${encodeURIComponent(e)}`),toggleServer:async(e,t)=>us.patch(`/mcp/servers/${encodeURIComponent(e)}/toggle`,{enabled:t})},rL=({label:e,values:t,onChange:a,placeholder:i})=>{const s=t.length>0?t:[""],c=(m,p)=>{const g=[...s];g[m]=p,a(g.filter(y=>y.trim().length>0))},u=()=>a([...s,""]),d=m=>{const p=s.filter((g,y)=>y!==m);a(p.filter(g=>g.trim().length>0))};return v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-highlight",children:e}),s.map((m,p)=>v.jsxs("div",{className:"flex gap-2",children:[v.jsx("input",{className:"flex-1 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:m,placeholder:i,onChange:g=>c(p,g.target.value)}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>d(p),children:"Remove"})]},`${e}-${p}`)),v.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:u,children:"Add argument"})]})},Yx=({label:e,values:t,onChange:a,keyPlaceholder:i,valuePlaceholder:s})=>{const c=z.useMemo(()=>t.length>0?t:[{key:"",value:""}],[t]),u=(p,g,y)=>{const x=[...c];x[p]={...x[p],[g]:y},a(x.filter(_=>_.key.trim().length>0||_.value.trim().length>0))},d=()=>a([...c,{key:"",value:""}]),m=p=>{const g=c.filter((y,x)=>x!==p);a(g.filter(y=>y.key.trim().length>0||y.value.trim().length>0))};return v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-highlight",children:e}),c.map((p,g)=>v.jsxs("div",{className:"grid gap-2 md:grid-cols-5",children:[v.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:p.key,placeholder:i,onChange:y=>u(g,"key",y.target.value)}),v.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:p.value,placeholder:s,onChange:y=>u(g,"value",y.target.value)}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>m(g),children:"Remove"})]},`${e}-${g}`)),v.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:d,children:"Add entry"})]})},aL=({transport:e,command:t,url:a,args:i,env:s,headers:c,onCommandChange:u,onUrlChange:d,onArgsChange:m,onEnvChange:p,onHeadersChange:g})=>v.jsxs("div",{className:"space-y-4",children:[e==="stdio"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Command",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:t,onChange:y=>u(y.target.value),placeholder:"npx"})]}),v.jsx(rL,{label:"Arguments",values:i,onChange:m,placeholder:"--flag"})]}),e==="http"&&v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["URL",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:a,onChange:y=>d(y.target.value),placeholder:"https://example.com/mcp"})]}),v.jsx(Yx,{label:"Environment Variables",values:s,onChange:p,keyPlaceholder:"KEY",valuePlaceholder:"value"}),e==="http"&&v.jsx(Yx,{label:"Headers",values:c,onChange:g,keyPlaceholder:"Header",valuePlaceholder:"value"})]}),iL=yZ({name:ah().min(1,"Name is required"),transport:kz([Vx("stdio"),Vx("http")]),command:ah().optional(),url:ah().optional()}),Su=e=>e?Object.entries(e).map(([t,a])=>({key:t,value:a})):[],lh=e=>e.reduce((t,a)=>(a.key.trim().length===0||(t[a.key]=a.value),t),{}),oL=({open:e,mode:t,initial:a,onClose:i,onSubmit:s})=>{const[c,u]=z.useState(a?.name??""),[d,m]=z.useState(a?.config.transport??"stdio"),[p,g]=z.useState(a?.config.transport==="stdio"?a.config.command:""),[y,x]=z.useState(a?.config.transport==="http"?a.config.url:""),[_,E]=z.useState(a?.config.args??[]),[T,C]=z.useState(Su(a?.config.env)),[M,O]=z.useState(a?.config.transport==="http"?Su(a.config.headers):[]),[R,j]=z.useState(null);z.useEffect(()=>{e&&(u(a?.name??""),m(a?.config.transport??"stdio"),g(a?.config.transport==="stdio"?a.config.command:""),x(a?.config.transport==="http"?a.config.url:""),E(a?.config.args??[]),C(Su(a?.config.env)),O(a?.config.transport==="http"?Su(a.config.headers):[]),j(null))},[e,a]);const L=t==="create",W=async()=>{const B=iL.safeParse({name:c,transport:d,command:p,url:y});if(!B.success){j(B.error.issues[0]?.message??"Invalid form");return}if(d==="stdio"&&(!p||p.trim().length===0)){j("Command is required for stdio transport.");return}if(d==="http"&&(!y||y.trim().length===0)){j("URL is required for http transport.");return}const Q=d==="stdio"?{transport:"stdio",command:p.trim(),args:_.length>0?_:void 0,env:T.length>0?lh(T):void 0}:{transport:"http",url:y.trim(),headers:M.length>0?lh(M):void 0,env:T.length>0?lh(T):void 0};j(null),await s(c.trim(),Q)},K=z.useMemo(()=>t==="create"?"Add MCP Server":"Edit MCP Server",[t]);return v.jsx(Pm,{open:e,onOpenChange:i,children:v.jsxs(Hm,{children:[v.jsx(Gm,{children:v.jsx(qm,{children:K})}),v.jsxs("div",{className:"space-y-4",children:[v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Name",v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none disabled:bg-azure-border dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight dark:disabled:bg-matrix-primary/50",value:c,onChange:B=>u(B.target.value),placeholder:"coolify",disabled:!L})]}),v.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-highlight",children:["Transport",v.jsxs("select",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:d,onChange:B=>m(B.target.value),children:[v.jsx("option",{value:"stdio",children:"stdio"}),v.jsx("option",{value:"http",children:"http"})]})]}),v.jsx(aL,{transport:d,command:p,url:y,args:_,env:T,headers:M,onCommandChange:g,onUrlChange:x,onArgsChange:E,onEnvChange:C,onHeadersChange:O}),R&&v.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-400",children:R}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:i,children:"Cancel"}),v.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:W,children:"Save"})]})]})]})})},sL=({server:e,onEdit:t,onDelete:a,onToggle:i})=>v.jsxs("div",{className:"rounded-2xl border border-azure-border bg-azure-surface/80 p-4 shadow-sm overflow-hidden dark:border-matrix-primary dark:bg-zinc-950/70",children:[v.jsxs("div",{className:"flex items-start justify-between gap-3",children:[v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsx("div",{className:"text-lg font-semibold text-azure-text-primary break-words dark:text-matrix-highlight",children:e.name}),v.jsx("div",{className:"text-xs uppercase tracking-wide text-azure-text-muted dark:text-matrix-secondary",children:e.config.transport})]}),v.jsx("div",{className:"flex items-center gap-2",children:v.jsx("button",{type:"button",className:`rounded-full px-3 py-1 text-xs font-semibold ${e.enabled?"bg-matrix-highlight dark:text-matrix-primary":"bg-azure-border text-azure-text-secondary dark:bg-matrix-primary/50 dark:text-matrix-secondary"}`,onClick:()=>i(e,!e.enabled),children:e.enabled?"Enabled":"Disabled"})})]}),v.jsxs("div",{className:"mt-4 space-y-2 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:[e.config.transport==="stdio"&&v.jsxs("div",{className:"break-all",children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"Command:"})," ",e.config.command]}),e.config.transport==="http"&&v.jsxs("div",{className:"break-all",children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"URL:"})," ",e.config.url]}),e.config.args&&e.config.args.length>0&&v.jsxs("div",{className:"break-all",children:[v.jsx("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:"Args:"})," ",e.config.args.join(" ")]})]}),v.jsxs("div",{className:"mt-4 flex gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-3 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>t(e),children:"Edit"}),v.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>a(e),children:"Delete"})]})]}),lL=()=>{const{data:e,error:t,mutate:a,isLoading:i}=Va("/api/mcp/servers",()=>cs.fetchServers()),[s,c]=z.useState(""),[u,d]=z.useState("all"),[m,p]=z.useState(!1),[g,y]=z.useState(null),[x,_]=z.useState(!1),[E,T]=z.useState(null),[C,M]=z.useState(null),O=e?.servers??[],R=z.useMemo(()=>O.filter(te=>{const de=te.name.toLowerCase().includes(s.toLowerCase()),xe=u==="all"||te.config.transport===u;return de&&xe}),[O,s,u]),j=()=>{y(null),p(!0)},L=te=>{y(te),p(!0)},W=async(te,de)=>{try{g?await cs.updateServer(g.name,de):await cs.addServer(te,de),p(!1),y(null),await a(),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(xe){M({type:"error",message:xe.message||"Failed to save MCP server."})}},K=async te=>{T(te),_(!0)},B=async()=>{if(E)try{await cs.deleteServer(E.name),await a(),_(!1),T(null),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(te){M({type:"error",message:te.message||"Failed to delete MCP server."})}},Q=async(te,de)=>{try{await cs.toggleServer(te.name,de),await a(),M({type:"success",message:"MCPs saved successfully. Restart Morpheus daemon for changes to take effect."})}catch(xe){M({type:"error",message:xe.message||"Failed to toggle MCP server."})}};return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-azure-primary dark:text-matrix-highlight",children:"MCP Servers"}),v.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Manage MCP servers stored in mcps.json."})]}),v.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:j,children:"Add Server"})]}),C&&v.jsx("div",{className:`p-4 rounded border ${C.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:C.message}),v.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center",children:[v.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:s,onChange:te=>c(te.target.value),placeholder:"Search by name"}),v.jsxs("select",{className:"rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-zinc-950 dark:text-matrix-highlight",value:u,onChange:te=>d(te.target.value),children:[v.jsx("option",{value:"all",children:"All"}),v.jsx("option",{value:"stdio",children:"stdio"}),v.jsx("option",{value:"http",children:"http"})]})]}),i&&v.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Loading MCP servers..."}),t&&v.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load MCP servers."}),!i&&R.length===0&&v.jsx("div",{className:"rounded-2xl border border-dashed border-azure-border bg-azure-surface/60 p-6 text-center text-sm text-azure-text-secondary dark:border-matrix-primary dark:bg-zinc-950/60 dark:text-matrix-secondary",children:"No MCP servers found. Add a server to get started."}),v.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:R.map(te=>v.jsx(sL,{server:te,onEdit:L,onDelete:K,onToggle:Q},`${te.name}-${te.enabled?"on":"off"}`))}),v.jsx(oL,{open:m,mode:g?"edit":"create",initial:g??void 0,onClose:()=>p(!1),onSubmit:W}),v.jsx(Pm,{open:x,onOpenChange:_,children:v.jsxs(Hm,{children:[v.jsx(Gm,{children:v.jsx(qm,{children:"Confirm Deletion"})}),v.jsxs("div",{className:"space-y-4",children:[v.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:["Are you sure you want to delete the MCP server ",v.jsxs("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:['"',E?.name,'"']}),"? This action cannot be undone."]}),v.jsxs("div",{className:"flex justify-end gap-2",children:[v.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>_(!1),children:"Cancel"}),v.jsx("button",{type:"button",className:"rounded-md bg-red-500 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-red-400 dark:bg-red-600 hover:dark:bg-red-500",onClick:B,children:"Delete"})]})]})]})})]})};function uL(){return v.jsx(S2,{children:v.jsxs(y0,{children:[v.jsx(In,{path:"/login",element:v.jsx(qZ,{})}),v.jsx(In,{path:"/*",element:v.jsx(YZ,{children:v.jsx(GN,{children:v.jsxs(y0,{children:[v.jsx(In,{path:"/",element:v.jsx(IN,{})}),v.jsx(In,{path:"/config",element:v.jsx(PZ,{})}),v.jsx(In,{path:"/logs",element:v.jsx(HZ,{})}),v.jsx(In,{path:"/stats",element:v.jsx(GZ,{})}),v.jsx(In,{path:"/sati-memories",element:v.jsx(nL,{})}),v.jsx(In,{path:"/mcp-servers",element:v.jsx(lL,{})}),v.jsx(In,{path:"*",element:v.jsx(o1,{to:"/",replace:!0})})]})})})})]})})}tT.createRoot(document.getElementById("root")).render(v.jsx(z.StrictMode,{children:v.jsx(uL,{})}));
|