@syncular/console 0.0.6-247 → 0.0.6-248
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/console",
|
|
3
|
-
"version": "0.0.6-
|
|
3
|
+
"version": "0.0.6-248",
|
|
4
4
|
"description": "Embeddable Syncular console UI",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"release": "bunx syncular-publish"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@syncular/observability-sentry": "0.0.6-
|
|
72
|
-
"@syncular/transport-http": "0.0.6-
|
|
73
|
-
"@syncular/ui": "0.0.6-
|
|
71
|
+
"@syncular/observability-sentry": "0.0.6-248",
|
|
72
|
+
"@syncular/transport-http": "0.0.6-248",
|
|
73
|
+
"@syncular/ui": "0.0.6-248",
|
|
74
74
|
"@tanstack/react-query": "^5.96.2",
|
|
75
75
|
"@tanstack/react-router": "^1.168.10",
|
|
76
76
|
"lucide-react": "^1.7.0"
|
|
@@ -27,4 +27,4 @@ Error generating stack: `+e.message+`
|
|
|
27
27
|
${e.right}px ${e.bottom}px,
|
|
28
28
|
${e.right}px ${e.top}px,
|
|
29
29
|
${e.left}px ${e.top}px
|
|
30
|
-
)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function kN(e,t){e&&Object.assign(e.style,t)}var AN={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},jN={position:`fixed`},MN=G.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=oC,..._}=e,{store:v,listRef:y,labelsRef:b,alignItemWithTriggerActiveRef:x,selectedItemTextRef:S,valuesRef:C,initialValueRef:w,popupRef:T,setValue:E}=UM(),D=WM(),O=wA(v,$M.open),k=wA(v,$M.mounted),A=wA(v,$M.modal),j=wA(v,$M.value),M=wA(v,$M.openMethod),N=wA(v,$M.positionerElement),P=wA(v,$M.triggerElement),F=wA(v,$M.isItemEqualToValue),I=wA(v,$M.transitionStatus),L=G.useRef(null),ee=G.useRef(null),[R,z]=G.useState(h),B=k&&R&&M!==`touch`;!k&&R!==h&&z(h),Z(()=>{k||($M.scrollUpArrowVisible(v.state)&&v.set(`scrollUpArrowVisible`,!1),$M.scrollDownArrowVisible(v.state)&&v.set(`scrollDownArrowVisible`,!1))},[v,k]),G.useImperativeHandle(x,()=>B),yN((B||A)&&O&&M!==`touch`,P);let V=$j({anchor:n,floatingRootContext:D,positionMethod:r,mounted:k,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??B,collisionAvoidance:g,keepMounted:!0}),H=B?`none`:V.side,U=B?jN:V.positionerStyles,W=G.useMemo(()=>{let e={};return O||(e.pointerEvents=`none`),{role:`presentation`,hidden:!k,style:{...U,...e}}},[O,k,U]),te={open:O,side:H,align:V.align,anchorHidden:V.anchorHidden},ne=lC(`div`,e,{ref:[t,X(e=>{v.set(`positionerElement`,e)})],state:te,stateAttributesMapping:Pj,props:[W,tM(I),_]}),re=G.useRef(0),ie=X(e=>{if(e.size===0&&re.current===0||C.current.length===0)return;let t=re.current;if(re.current=e.size,e.size===t)return;let n=Aw(vw);if(t!==0&&!v.state.multiple&&j!==null&&qM(C.current,j,F)===-1){let e=w.current,t=e!=null&&qM(C.current,e,F)!==-1?e:null;E(t,n),t===null&&(v.set(`selectedIndex`,null),S.current=null)}if(t!==0&&v.state.multiple&&Array.isArray(j)){let e=e=>qM(C.current,e,F)!==-1,t=j.filter(t=>e(t));(t.length!==j.length||t.some(e=>!KM(j,e,F)))&&(E(t,n),t.length===0&&(v.set(`selectedIndex`,null),S.current=null))}if(O&&B){v.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};kN(N,e),kN(T.current,e)}}),ae=G.useMemo(()=>({...V,side:H,alignItemWithTriggerActive:B,setControlledAlignItemWithTrigger:z,scrollUpArrowRef:L,scrollDownArrowRef:ee}),[V,H,B,z]);return(0,K.jsx)(SN,{elementsRef:y,labelsRef:b,onMapChange:ie,children:(0,K.jsxs)(EN.Provider,{value:ae,children:[k&&A&&(0,K.jsx)(ON,{inert:aM(!O),cutout:P}),ne]})})});function NN(e){let t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}var PN=`base-ui-disable-scrollbar`,FN={className:PN,getElement(e){return(0,K.jsx)(`style`,{nonce:e,href:PN,precedence:`base-ui:low`,children:`.${PN}{scrollbar-width:none}.${PN}::-webkit-scrollbar{display:none}`})}},IN=G.createContext(void 0);function LN(e){let t=G.useContext(IN);if(t===void 0&&!e)throw Error(zS(69));return t}var RN=`ArrowUp`,zN=`ArrowDown`,BN=`ArrowLeft`,VN=`ArrowRight`,HN=`Home`,UN=new Set([BN,VN]),WN=new Set([BN,VN,HN,`End`]),GN=new Set([RN,zN]),KN=new Set([RN,zN,HN,`End`]),qN=new Set([...UN,...GN]),JN=new Set([...qN,HN,`End`]),YN=new Set([RN,zN,BN,VN,HN,`End`]),XN=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function ZN(e){return EC(e)&&e.tagName===`INPUT`}function QN(e){return!!(ZN(e)&&e.selectionStart!=null||EC(e)&&e.tagName===`TEXTAREA`)}function $N(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=eP(e,t,`left`),a=tP(e),o=tP(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=eP(e,t,`top`),r=tP(e),i=tP(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function eP(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function tP(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function nP(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var rP=G.createContext(void 0),iP={disableStyleElements:!1};function aP(){return G.useContext(rP)??iP}var oP=1,sP={...Pj,...IA},cP=G.forwardRef(function(e,t){let{render:n,className:r,finalFocus:i,...a}=e,{store:o,popupRef:s,onOpenChangeComplete:c,setOpen:l,valueRef:u,selectedItemTextRef:d,keyboardActiveRef:f,multiple:p,handleScrollArrowVisibility:m,scrollHandlerRef:h,highlightItemOnHover:g}=UM(),{side:_,align:v,alignItemWithTriggerActive:y,setControlledAlignItemWithTrigger:b,scrollDownArrowRef:x,scrollUpArrowRef:S}=DN(),C=LN(!0)!=null,w=WM(),{nonce:T,disableStyleElements:E}=aP(),D=cE(),O=wA(o,$M.id),k=wA(o,$M.open),A=wA(o,$M.mounted),j=wA(o,$M.popupProps),M=wA(o,$M.transitionStatus),N=wA(o,$M.triggerElement),P=wA(o,$M.positionerElement),F=wA(o,$M.listElement),I=G.useRef(0),L=G.useRef(!1),ee=G.useRef(0),R=G.useRef(!1),z=G.useRef({}),B=SO(),V=X(e=>{if(!P||!s.current||!R.current)return;if(L.current||!y){m();return}let t=P.style.top===`0px`,n=P.style.bottom===`0px`,r=P.getBoundingClientRect().height,i=rO(P),a=getComputedStyle(P),o=parseFloat(a.marginTop),c=parseFloat(a.marginBottom),l=lP(getComputedStyle(s.current)),u=Math.min(i.documentElement.clientHeight-o-c,l),d=e.scrollTop,f=uP(e),p=0,h=null,g=!1,_=!1,v=e=>{P.style.height=`${e}px`},b=(t,n)=>{let i=nP(t,0,u-r);i>0&&v(r+i),e.scrollTop=n,u-(r+i)<=oP&&(L.current=!0),m()};if(t){let e=f-d,t=r+e,n=Math.min(t,u);if(p=n,e<=oP){b(e,f);return}u-n>oP?_=!0:g=!0}else if(n){let e=d,t=r+e,n=Math.min(t,u),i=t-u;if(p=n,e<=oP){b(e,0);return}u-n>oP?h=0:(g=!0,d<f&&(h=d-(e-i)))}if(p=Math.ceil(p),p!==0&&v(p),_||h!=null){let t=uP(e),n=_?t:nP(h,0,t);Math.abs(e.scrollTop-n)>oP&&(e.scrollTop=n)}(g||p>=u-oP)&&(L.current=!0),m()});G.useImperativeHandle(h,()=>V,[V]),RA({open:k,ref:s,onComplete(){k&&c?.(!0)}});let H={open:k,transitionStatus:M,side:_,align:v};Z(()=>{!P||!s.current||Object.keys(z.current).length||(z.current={top:P.style.top||`0`,left:P.style.left||`0`,right:P.style.right,height:P.style.height,bottom:P.style.bottom,minHeight:P.style.minHeight,maxHeight:P.style.maxHeight,marginTop:P.style.marginTop,marginBottom:P.style.marginBottom})},[s,P]),Z(()=>{k||y||(R.current=!1,L.current=!1,I.current=0,ee.current=0,kN(P,z.current))},[k,y,P,s]),Z(()=>{let e=s.current;if(!(!k||!N||!P||!e||o.state.transitionStatus===`ending`)){if(!y){R.current=!0,B.request(m),e.style.removeProperty(`--transform-origin`);return}queueMicrotask(()=>{let t=mP(e);e.style.removeProperty(`--transform-origin`);try{let t=getComputedStyle(P),n=getComputedStyle(e),r=rO(N),i=SC(P),a=dP(N),o=fP(N.getBoundingClientRect(),a),s=fP(P.getBoundingClientRect(),a),c=o.left,l=o.height,f=F||e,p=f.scrollHeight,h=parseFloat(n.borderBottomWidth),g=parseFloat(t.marginTop)||10,_=parseFloat(t.marginBottom)||10,v=parseFloat(t.minHeight)||100,y=lP(n),x=r.documentElement.clientHeight-g-_,S=r.documentElement.clientWidth,C=x-o.bottom+l,w=d.current,T=u.current,E,D=0,O=0;if(w&&T){let e=fP(T.getBoundingClientRect(),a);E=fP(w.getBoundingClientRect(),a);let t=e.left-c,n=E.left-s.left,r=e.top-o.top+e.height/2,i=E.top-s.top+E.height/2;D=t-n,O=i-r}let k=C+O+_+h,A=Math.min(x,k),j=x-g-_,M=k-A,ee=Math.max(5,c+D),B=S-5,V=Math.max(0,ee+s.width-B);P.style.left=`${ee-V}px`,P.style.height=`${A}px`,P.style.maxHeight=`auto`,P.style.marginTop=`${g}px`,P.style.marginBottom=`${_}px`,e.style.height=`100%`;let H=uP(f),U=M>=H-oP;U&&(A=Math.min(x,s.height)-(M-H));let W=o.top<20||o.bottom>x-20||Math.ceil(A)+oP<Math.min(p,v),te=(i.visualViewport?.scale??1)!==1&&pE;if(W||te){R.current=!0,kN(P,z.current),Ev.flushSync(()=>b(!1));return}if(U){let e=Math.max(0,x-k);P.style.top=s.height>=j?`0`:`${e}px`,P.style.height=`${A}px`,f.scrollTop=uP(f),I.current=Math.max(v,A)}else P.style.bottom=`0`,I.current=Math.max(v,A),f.scrollTop=M;if(E){let t=s.top,n=s.height,r=E.top+E.height/2,i=nP(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(I.current===x||A>=y)&&(L.current=!0),m(),setTimeout(()=>{R.current=!0})}finally{t()}})}},[o,k,P,N,u,d,s,m,y,b,B,x,S,F]),G.useEffect(()=>{if(!y||!P||!k)return;let e=SC(P);function t(e){l(!1,Aw(kw,e))}return e.addEventListener(`resize`,t),()=>{e.removeEventListener(`resize`,t)}},[l,y,P,k]);let U={...F?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":p||void 0,id:`${O}-list`},onKeyDown(e){f.current=!0,C&&YN.has(e.key)&&e.stopPropagation()},onMouseMove(){f.current=!1},onPointerLeave(e){if(!g||NN(e)||e.pointerType===`touch`)return;let t=e.currentTarget;D.start(0,()=>{o.set(`activeIndex`,null),t.focus({preventScroll:!0})})},onScroll(e){F||V(e.currentTarget)},...y&&{style:F?{height:`100%`}:AN}},W=lC(`div`,e,{ref:[t,s],state:H,stateAttributesMapping:sP,props:[j,U,tM(M),{className:!F&&y?FN.className:void 0},a]});return(0,K.jsxs)(G.Fragment,{children:[!E&&FN.getElement(T),(0,K.jsx)(ak,{context:w,modal:!1,disabled:!A,returnFocus:i,restoreFocus:!0,children:W})]})});function lP(e){let t=e.maxHeight||``;return t.endsWith(`px`)&&parseFloat(t)||1/0}function uP(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function dP(e){return $k.getScale(e)}function fP(e,t){return hD({x:e.x/t.x,y:e.y/t.y,width:e.width/t.x,height:e.height/t.y})}var pP=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function mP(e){let{style:t}=e,n={};for(let[e,r]of pP)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of pP){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var hP=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function gP(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:d}=xN(),f=G.useRef(-1),[p,m]=G.useState(a??(i===hP.GuessFromOrder?()=>{if(f.current===-1){let e=d.current;d.current+=1,f.current=e}return f.current}:-1)),h=G.useRef(null),g=G.useCallback(e=>{if(h.current=e,p!==-1&&e!==null&&(l.current[p]=e,u)){let n=t!==void 0;u.current[p]=n?t:r?.current?.textContent??e.textContent}},[p,l,u,t,r]);return Z(()=>{if(a!=null)return;let e=h.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),Z(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&m(t)})},[a,c,m]),G.useMemo(()=>({ref:g,index:p}),[p,g])}var _P=G.createContext(void 0),vP=G.memo(G.forwardRef(function(e,t){let{render:n,className:r,value:i=null,label:a,disabled:o=!1,nativeButton:s=!1,...c}=e,l=G.useRef(null),u=gP({label:a,textRef:l,indexGuessBehavior:hP.GuessFromOrder}),{store:d,getItemProps:f,setOpen:p,setValue:m,selectionRef:h,typingRef:g,valuesRef:_,keyboardActiveRef:v,multiple:y,highlightItemOnHover:b}=UM(),x=cE(),S=wA(d,$M.isActive,u.index),C=wA(d,$M.isSelected,u.index,i),w=wA(d,$M.isSelectedByFocus,u.index),T=wA(d,$M.isItemEqualToValue),E=u.index,D=E!==-1,O=G.useRef(null),k=_O(E);Z(()=>{if(!D)return;let e=_.current;return e[E]=i,()=>{delete e[E]}},[D,E,i,_]),Z(()=>{if(!D)return;let e=d.state.value,t=e;y&&Array.isArray(e)&&e.length>0&&(t=e[e.length-1]),t!==void 0&&GM(i,t,T)&&d.set(`selectedIndex`,E)},[D,E,y,T,d,i]);let A={disabled:o,selected:C,highlighted:S},j=f({active:S,selected:C});j.onFocus=void 0,j.id=void 0;let M=G.useRef(null),N=G.useRef(`mouse`),P=G.useRef(!1),{getButtonProps:F,buttonRef:I}=JC({disabled:o,focusableWhenDisabled:!0,native:s,composite:!0});function L(e){let t=d.state.value;if(y){let n=Array.isArray(t)?t:[];m(C?JM(n,i,T):[...n,i],Aw(Cw,e))}else m(i,Aw(Cw,e)),p(!1,Aw(Cw,e))}let ee={role:`option`,"aria-selected":C,tabIndex:S?0:-1,onFocus(){d.set(`activeIndex`,E)},onMouseEnter(){!v.current&&d.state.selectedIndex===null&&b&&d.set(`activeIndex`,E)},onMouseMove(){b&&d.set(`activeIndex`,E)},onMouseLeave(e){!b||v.current||NN(e)||x.start(0,()=>{d.state.activeIndex===E&&d.set(`activeIndex`,null)})},onTouchStart(){h.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(e){M.current=e.key,d.set(`activeIndex`,E),e.key===` `&&g.current&&e.preventDefault()},onClick(e){P.current=!1,!(e.type===`keydown`&&M.current===null)&&(o||e.type===`keydown`&&M.current===` `&&g.current||N.current!==`touch`&&!S||(M.current=null,L(e.nativeEvent)))},onPointerEnter(e){N.current=e.pointerType},onPointerDown(e){N.current=e.pointerType,P.current=!0},onMouseUp(){if(o)return;if(P.current){P.current=!1;return}let e=!h.current.allowSelectedMouseUp&&C,t=!h.current.allowUnselectedMouseUp&&!C;e||t||N.current!==`touch`&&!S||O.current?.click()}},R=lC(`div`,e,{ref:[I,t,u.ref,O],state:A,props:[j,ee,c,F]}),z=G.useMemo(()=>({selected:C,indexRef:k,textRef:l,selectedByFocus:w,hasRegistered:D}),[C,k,l,w,D]);return(0,K.jsx)(_P.Provider,{value:z,children:R})})),yP=(0,G.forwardRef)(({className:e,children:t,...n},r)=>(0,K.jsx)(cN,{ref:r,className:Y(`inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition`,e),...n,children:t}));yP.displayName=`SelectTrigger`;var bP=(0,G.forwardRef)(({className:e,portalProps:t,positionerProps:n,...r},i)=>(0,K.jsx)(uN,{...t,children:(0,K.jsx)(MN,{...n,children:(0,K.jsx)(cP,{ref:i,className:Y(`bg-panel border border-border rounded-md py-1 shadow-lg z-50`,e),...r})})}));bP.displayName=`SelectContent`;var xP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(vP,{ref:n,className:Y(`font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none`,e),...t}));xP.displayName=`SelectItem`;var SP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`textarea`,{ref:n,className:Y(`bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]`,e),...t}));SP.displayName=`Textarea`;var CP=G.createContext(void 0);function wP(e=!0){let t=G.useContext(CP);if(t===void 0&&!e)throw Error(zS(7));return t}function TP(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=KC(),{ref:i,index:a}=gP(e),o=n===a,s=G.useRef(null),c=ES(i,s);return{compositeProps:G.useMemo(()=>({tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}}),[o,r,a,t]),compositeRef:c,index:a}}function EP(e){let{render:t,className:n,state:r=LS,props:i=IS,refs:a=IS,metadata:o,stateAttributesMapping:s,tag:c=`div`,...l}=e,{compositeProps:u,compositeRef:d}=TP({metadata:o});return lC(c,e,{state:r,ref:[...a,d],props:[u,...i,l],stateAttributesMapping:s})}var DP=G.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,...f}=e,p=yC(u||void 0),m=wP(),h=m?.value??[],g=m?void 0:r,_=(i||m?.disabled)??!1,[v,y]=yS({controlled:m?p!==void 0&&h.indexOf(p)>-1:s,default:g,name:`Toggle`,state:`pressed`}),b=X((e,t)=>{p&&m?.setGroupValue?.(p,e,t),o?.(e,t)}),{getButtonProps:x,buttonRef:S}=JC({disabled:_,native:d}),C={disabled:_,pressed:v},w=[S,t],T=[{"aria-pressed":v,onClick(e){let t=!v,n=Aw(vw,e.nativeEvent);b(t,n),!n.isCanceled&&y(t)}},f,x],E=lC(`button`,e,{enabled:!m,state:C,ref:w,props:T});return m?(0,K.jsx)(EP,{tag:`button`,render:c,className:n,state:C,refs:w,props:T}):E}),OP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(DP,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]`,e),...t}));OP.displayName=`Toggle`;function kP(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var AP=`data-composite-item-active`,jP=[];function MP(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=jP}=e,[m,h]=G.useState(0),g=n>1,_=G.useRef(null),v=ES(_,l),y=G.useRef([]),b=G.useRef(!1),x=s??m,S=X((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];$N(_.current,t,o,a)}}),C=X(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),$N(_.current,n,o,a)}),w=G.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){!_.current||!QN(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?JN:qN;if(!s.has(e.key)||NP(e,p)||!_.current)return;let c=o===`rtl`,l=c?BN:VN,m={horizontal:l,vertical:zN,both:l}[a],h=c?VN:BN,v={horizontal:h,vertical:RN,both:h}[a];if(QN(e.target)&&!kP(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=vD(y,f),w=yD(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=SD(o,n,i),l=s.findIndex(e=>e!=null&&!TD(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!TD(y,t,f)?n:e,-1);b=s[xD({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:wD([...f||y.current.map((e,t)=>TD(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:CD(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[zN],both:[l,zN]}[a],E={horizontal:[h],vertical:[RN],both:[h,RN]}[a],D=g?s:{horizontal:u?WN:UN,vertical:u?KN:GN,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:bD(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!_D(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return G.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function NP(e,t){for(let n of XN.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function PP(e){let{render:t,className:n,refs:r=IS,props:i=IS,state:a=LS,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=MP({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:Gj(),disabledIndices:v,modifierKeys:y}),k=lC(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=G.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,K.jsx)(GC.Provider,{value:A,children:(0,K.jsx)(SN,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var FP=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),IP={multiple(e){return e?{[FP.multiple]:``}:null}},LP=G.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,...d}=e,f=LN(!0),p=G.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),m=G.useMemo(()=>c!==void 0||n!==void 0,[c,n]),h=(f?.disabled??!1)||r,[g,_]=yS({controlled:c,default:p,name:`ToggleGroup`,state:`value`}),v=X((e,t,n)=>{let r;if(s?(r=g.slice(),t?r.push(e):r.splice(g.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;_(r)}}),y={disabled:h,multiple:s,orientation:o},b=G.useMemo(()=>({disabled:h,orientation:o,setGroupValue:v,value:g,isValueInitialized:m}),[h,o,v,g,m]),x={role:`group`},S=lC(`div`,e,{enabled:!!f,state:y,ref:t,props:[x,d],stateAttributesMapping:IP});return(0,K.jsx)(CP.Provider,{value:b,children:f?S:(0,K.jsx)(PP,{render:u,className:l,state:y,refs:[t],props:[x,d],stateAttributesMapping:IP,loopFocus:i,enableHomeAndEndKeys:!0})})}),RP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(LP,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));RP.displayName=`ToggleGroup`;var zP=Y(Yw({variant:`secondary`,size:`sm`}),`h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline`);function BP({active:e,onClick:t,children:n,className:r}){return(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:Y(`font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors`,e?`text-white`:`text-neutral-500 hover:text-neutral-300`,r),children:[n,e&&(0,K.jsx)(`span`,{className:`absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]`})]})}function VP({items:e,activeId:t,onItemChange:n,renderItem:r,className:i}){return(0,K.jsx)(`div`,{className:Y(`flex items-center gap-0.5`,i),children:e.map(e=>{let i=e.id===t,a=()=>n?.(e.id);return r?(0,K.jsx)(`span`,{children:r(e,{active:i,onClick:a})},e.id):(0,K.jsx)(BP,{active:i,onClick:a,children:e.label},e.id)})})}var HP=gS(`rounded-full inline-block flex-shrink-0`,{variants:{color:{healthy:`bg-healthy`,syncing:`bg-syncing`,offline:`bg-offline`,flow:`bg-flow`,relay:`bg-relay`,encrypt:`bg-encrypt`,muted:`bg-neutral-500`},size:{sm:`w-1.5 h-1.5`,md:`w-2 h-2`,lg:`w-2.5 h-2.5`},glow:{true:``,false:``}},defaultVariants:{color:`healthy`,size:`sm`,glow:!1}}),UP={healthy:`0 0 6px #22c55e`,syncing:`0 0 6px #f59e0b`,offline:`0 0 6px #ef4444`,flow:`0 0 6px #3b82f6`,relay:`0 0 6px #8b5cf6`,encrypt:`0 0 6px #f472b6`,muted:`none`};function WP({color:e,size:t,glow:n,pulse:r,className:i}){return(0,K.jsx)(`span`,{className:Y(HP({color:e,size:t,glow:n}),r&&`dot-pulse`,i),style:n?{boxShadow:UP[e??`healthy`]}:void 0})}var GP={name:`@syncular/ui`,version:`0.0.6-247`,description:`Reusable Syncular UI components and styles`,license:`Apache-2.0`,author:`Benjamin Kniffler`,homepage:`https://syncular.dev`,repository:{type:`git`,url:`https://github.com/syncular/syncular.git`,directory:`packages/ui`},bugs:{url:`https://github.com/syncular/syncular/issues`},keywords:[`sync`,`offline-first`,`realtime`,`ui`,`react`],publishConfig:{access:`public`},type:`module`,exports:{".":{bun:`./src/index.ts`,browser:`./src/index.ts`,import:{types:`./dist/index.d.ts`,default:`./dist/index.js`}},"./charts":{bun:`./src/charts/index.ts`,browser:`./src/charts/index.ts`,import:{types:`./dist/charts/index.d.ts`,default:`./dist/charts/index.js`}},"./console":{bun:`./src/console/index.ts`,browser:`./src/console/index.ts`,import:{types:`./dist/console/index.d.ts`,default:`./dist/console/index.js`}},"./forms":{bun:`./src/forms/index.ts`,browser:`./src/forms/index.ts`,import:{types:`./dist/forms/index.d.ts`,default:`./dist/forms/index.js`}},"./primitives":{bun:`./src/primitives/index.ts`,browser:`./src/primitives/index.ts`,import:{types:`./dist/primitives/index.d.ts`,default:`./dist/primitives/index.js`}},"./observable-universe":{bun:`./src/observable-universe/index.ts`,browser:`./src/observable-universe/index.ts`,import:{types:`./dist/observable-universe/index.d.ts`,default:`./dist/observable-universe/index.js`}},"./demo":{bun:`./src/demo/index.ts`,browser:`./src/demo/index.ts`,import:{types:`./dist/demo/index.d.ts`,default:`./dist/demo/index.js`}},"./navigation":{bun:`./src/navigation/index.ts`,browser:`./src/navigation/index.ts`,import:{types:`./dist/navigation/index.d.ts`,default:`./dist/navigation/index.js`}},"./styles.css":`./dist/styles.css`,"./styles.source.css":`./src/styles/styles.css`,"./styles/tokens.css":`./src/styles/tokens.css`,"./package.json":`./package.json`},files:[`dist`,`src`],scripts:{tsgo:`tsgo --noEmit`,"build:css":`bunx @tailwindcss/cli -i src/styles/styles.css -o dist/styles.css`,build:`tsgo && bun run build:css`,release:`bunx syncular-publish`},peerDependencies:{react:`^19.0.0`,"react-dom":`^19.0.0`},dependencies:{"@base-ui/react":`^1.3.0`,"class-variance-authority":`^0.7.1`,clsx:`^2.1.1`,"lucide-react":`^1.7.0`,recharts:`^3.8.1`,"tailwind-merge":`^3.5.0`,tailwindcss:`^4.2.2`},devDependencies:{"@syncular/config":`workspace:*`,"@tailwindcss/cli":`^4.2.2`,"@types/react":`^19.2.14`}}.version;function KP({label:e,className:t}){return(0,K.jsxs)(`div`,{className:Y(`flex items-center gap-3`,t),children:[(0,K.jsx)(WP,{color:`healthy`,size:`md`,glow:!0}),(0,K.jsx)(`span`,{className:`font-display font-bold text-white text-sm tracking-tight`,children:`syncular`}),e&&(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-600 uppercase tracking-widest`,children:e}),(0,K.jsxs)(`span`,{className:`font-mono text-[9px] text-neutral-600 tracking-wider`,children:[`v`,GP]})]})}function qP({brand:e,center:t,right:n,className:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`h-[42px] shrink-0`}),(0,K.jsxs)(`nav`,{className:Y(`fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5`,r),children:[(0,K.jsx)(`div`,{className:`flex items-center gap-3`,children:e}),(0,K.jsx)(`div`,{className:`flex items-center gap-0.5`,children:t}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})]})}var JP=gS(`border rounded-lg p-3 font-mono text-[11px]`,{variants:{variant:{default:`border-border bg-panel`,destructive:`border-offline/20 bg-offline/5 text-offline`}},defaultVariants:{variant:`default`}}),YP=(0,G.forwardRef)(({className:e,variant:t,...n},r)=>(0,K.jsx)(`div`,{ref:r,role:`alert`,className:Y(JP({variant:t,className:e})),...n}));YP.displayName=`Alert`;var XP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`h5`,{ref:n,className:Y(`font-medium text-white mb-1`,e),...t}));XP.displayName=`AlertTitle`;var ZP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`text-neutral-400`,e),...t}));ZP.displayName=`AlertDescription`;var QP=G.createContext(void 0);function $P(e){let t=G.useContext(QP);if(e===!1&&t===void 0)throw Error(zS(27));return t}var eF={...Pj,...IA},tF=G.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=$P(),s=o.useState(`open`),c=o.useState(`nested`),l=o.useState(`mounted`);return lC(`div`,e,{state:{open:s,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:eF,props:[{role:`presentation`,hidden:!l,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!c})}),nF=G.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=$P(),s=yC(i);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),lC(`p`,e,{ref:t,props:[{id:s},a]})}),rF=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),iF=function(e){return e[e.open=Tj.open]=`open`,e[e.closed=Tj.closed]=`closed`,e[e.startingStyle=Tj.startingStyle]=`startingStyle`,e[e.endingStyle=Tj.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),aF=G.createContext(void 0);function oF(){let e=G.useContext(aF);if(e===void 0)throw Error(zS(26));return e}var sF={...Pj,...IA,nestedDialogOpen(e){return e?{[iF.nestedDialogOpen]:``}:null}},cF=G.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:s}=$P(),c=s.useState(`descriptionElementId`),l=s.useState(`disablePointerDismissal`),u=s.useState(`floatingRootContext`),d=s.useState(`popupProps`),f=s.useState(`modal`),p=s.useState(`mounted`),m=s.useState(`nested`),h=s.useState(`nestedOpenDialogCount`),g=s.useState(`open`),_=s.useState(`openMethod`),v=s.useState(`titleElementId`),y=s.useState(`transitionStatus`),b=s.useState(`role`);oF(),RA({open:g,ref:s.context.popupRef,onComplete(){g&&s.context.onOpenChangeComplete?.(!0)}});function x(e){return e===`touch`?s.context.popupRef.current:!0}let S=i===void 0?x:i,C=lC(`div`,e,{state:{open:g,nested:m,transitionStatus:y,nestedDialogOpen:h>0},props:[d,{"aria-labelledby":v??void 0,"aria-describedby":c??void 0,role:b,tabIndex:-1,hidden:!p,onKeyDown(e){YN.has(e.key)&&e.stopPropagation()},style:{[rF.nestedDialogs]:h}},o],ref:[t,s.context.popupRef,s.useStateSetter(`popupElement`)],stateAttributesMapping:sF});return(0,K.jsx)(ak,{context:u,openInteractionType:_,disabled:!p,closeOnFocusOut:!l,initialFocus:S,returnFocus:r,modal:f!==!1,restoreFocus:`popup`,children:C})}),lF=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=$P(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,K.jsx)(aF.Provider,{value:n,children:(0,K.jsxs)(UO,{ref:t,...r,children:[a&&o===!0&&(0,K.jsx)(ON,{ref:i.context.internalBackdropRef,inert:aM(!s)}),e.children]})}):null});function uF(e){let{store:t,parentContext:n,actionsRef:r}=e,i=t.useState(`open`),a=t.useState(`disablePointerDismissal`),o=t.useState(`modal`),s=t.useState(`popupElement`),{openMethod:c,triggerProps:l}=tN(i);VA(t);let{forceUnmount:u}=HA(i,t),d=X(e=>{let n=Aw(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),f=G.useCallback(()=>{t.setOpen(!1,d(Ow))},[t,d]);G.useImperativeHandle(r,()=>({unmount:u,close:f}),[u,f]);let p=XA({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[m,h]=G.useState(0),g=m===0,_=fj(p),v=fk(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=DE(e);if(g&&!a){let e=n;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||TE(e,s)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:g});yN(i&&o===!0,s);let{getReferenceProps:y,getFloatingProps:b,getTriggerProps:x}=cj([_,v]);t.useContextCallback(`onNestedDialogOpen`,e=>{h(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{h(0)}),G.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(m),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,m]);let S=G.useMemo(()=>y(l),[y,l]),C=G.useMemo(()=>x(l),[x,l]),w=G.useMemo(()=>b(),[b]);t.useSyncedValues({openMethod:c,activeTriggerProps:S,inactiveTriggerProps:C,popupProps:w,floatingRootContext:p,nestedOpenDialogCount:m})}var dF={...qA,modal:$(e=>e.modal),nested:$(e=>e.nested),nestedOpenDialogCount:$(e=>e.nestedOpenDialogCount),disablePointerDismissal:$(e=>e.disablePointerDismissal),openMethod:$(e=>e.openMethod),descriptionElementId:$(e=>e.descriptionElementId),titleElementId:$(e=>e.titleElementId),viewportElement:$(e=>e.viewportElement),role:$(e=>e.role)},fF=class extends kA{constructor(e){super(pF(e),{popupRef:G.createRef(),backdropRef:G.createRef(),internalBackdropRef:G.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new UA,onOpenChange:void 0,onOpenChangeComplete:void 0},dF)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function pF(e={}){return{...GA(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}function mF(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=$P(!0),p=!!f,m=xS(()=>l?.store??new fF({open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:p})).current;tE(()=>{n===void 0&&m.state.open===!1&&r===!0&&m.update({open:!0,activeTriggerId:d})}),m.useControlledProp(`openProp`,n),m.useControlledProp(`triggerIdProp`,u),m.useSyncedValues({disablePointerDismissal:o,nested:p,modal:s}),m.useContextCallback(`onOpenChange`,i),m.useContextCallback(`onOpenChangeComplete`,a);let h=m.useState(`payload`);uF({store:m,actionsRef:c,parentContext:f?.store.context,onOpenChange:i,triggerIdProp:u});let g=G.useMemo(()=>({store:m}),[m]);return(0,K.jsx)(QP.Provider,{value:g,children:typeof t==`function`?t({payload:h}):t})}var hF=G.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=$P(),s=yC(i);return o.useSyncedValueWithCleanup(`titleElementId`,s),lC(`h2`,e,{ref:t,props:[{id:s},a]})}),gF=mF,_F=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(tF,{ref:n,className:Y(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`,e),...t}));_F.displayName=`DialogOverlay`;var vF=(0,G.forwardRef)(({className:e,children:t,...n},r)=>(0,K.jsxs)(lF,{children:[(0,K.jsx)(tF,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(cF,{ref:r,className:Y(`fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0`,e),...n,children:t})]}));vF.displayName=`DialogContent`;var yF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));yF.displayName=`DialogHeader`;var bF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));bF.displayName=`DialogFooter`;var xF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(hF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));xF.displayName=`DialogTitle`;var SF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(nF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));SF.displayName=`DialogDescription`;var CF=(0,G.forwardRef)(({className:e,page:t,totalPages:n,totalItems:r,onPageChange:i,...a},o)=>(0,K.jsxs)(`div`,{ref:o,className:Y(`px-5 py-2.5 border-t border-border flex items-center justify-between`,e),...a,children:[(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-600`,children:[r,` items · Page `,t,` of `,n]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Q,{size:`sm`,variant:`default`,disabled:t<=1,onClick:()=>i(t-1),children:`Prev`}),(0,K.jsx)(Q,{size:`sm`,variant:`default`,disabled:t>=n,onClick:()=>i(t+1),children:`Next`})]})]}));CF.displayName=`Pagination`;var wF=(0,G.forwardRef)(({className:e,orientation:t=`horizontal`,...n},r)=>(0,K.jsx)(`hr`,{ref:r,"aria-orientation":t===`vertical`?`vertical`:void 0,className:Y(`border-none m-0`,t===`horizontal`?`h-px w-full bg-border`:`w-px h-4 bg-border`,e),...n}));wF.displayName=`Separator`;var TF=gS(`fixed z-50 bg-panel shadow-lg overflow-auto`,{variants:{side:{top:`top-0 left-0 w-full h-[400px] border-b border-border`,right:`right-0 top-0 h-full w-[400px] border-l border-border`,bottom:`bottom-0 left-0 w-full h-[400px] border-t border-border`,left:`left-0 top-0 h-full w-[400px] border-r border-border`}},defaultVariants:{side:`right`}}),EF=(0,G.forwardRef)(({className:e,side:t,children:n,...r},i)=>(0,K.jsxs)(lF,{children:[(0,K.jsx)(tF,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(cF,{ref:i,className:Y(TF({side:t,className:e})),...r,children:n})]}));EF.displayName=`SheetContent`;var DF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));DF.displayName=`SheetHeader`;var OF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));OF.displayName=`SheetFooter`;var kF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(hF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));kF.displayName=`SheetTitle`;var AF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(nF,{ref:n,className:Y(`text-sm text-neutral-400`,e),...t}));AF.displayName=`SheetDescription`;var jF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`rounded-md bg-neutral-800 animate-pulse`,e),...t}));jF.displayName=`Skeleton`;var MF=G.createContext(void 0);function NF(){let e=G.useContext(MF);if(e===void 0)throw Error(zS(64));return e}var PF=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),FF={tabActivationDirection:e=>({[PF.activationDirection]:e})},IF=G.createContext(void 0);function LF(){let e=G.useContext(IF);if(e===void 0)throw Error(zS(65));return e}var RF=G.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=NF(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=LF(),v=yC(o),{compositeProps:y,compositeRef:b,index:x}=TP({metadata:G.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a])}),S=a===l,C=G.useRef(!1),w=G.useRef(null);G.useEffect(()=>{let e=w.current;if(e)return h(e)},[h]),Z(()=>{if(C.current){C.current=!1;return}if(!(S&&x>-1&&p!==x))return;let e=_;if(e!=null){let t=wE(rO(e));if(t&&TE(e,t))return}r||g(x)},[S,x,p,g,r,_]);let{getButtonProps:T,buttonRef:E}=JC({disabled:r,native:s,focusableWhenDisabled:!0}),D=u(a),O=G.useRef(!1),k=G.useRef(!1);function A(e){S||r||m(a,Aw(vw,e.nativeEvent,void 0,{activationDirection:`none`}))}function j(e){S||(x>-1&&!r&&g(x),!r&&f&&(!O.current||O.current&&k.current)&&m(a,Aw(vw,e.nativeEvent,void 0,{activationDirection:`none`})))}function M(e){if(S||r)return;O.current=!0;function t(){O.current=!1,k.current=!1}(!e.button||e.button===0)&&(k.current=!0,rO(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return lC(`button`,e,{state:{disabled:r,active:S,orientation:d},ref:[t,E,b,w],props:[y,{role:`tab`,"aria-controls":D,"aria-selected":S,id:v,onClick:A,onFocus:j,onPointerDown:M,[AP]:S?``:void 0,onKeyDownCapture(){C.current=!0}},c,T]})}),zF=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=NA.startingStyle]=`startingStyle`,e[e.endingStyle=NA.endingStyle]=`endingStyle`,e}({}),BF={...FF,...IA},VF=G.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=NF(),p=yC(),{ref:m,index:h}=gP({metadata:G.useMemo(()=>({id:p,value:r}),[p,r])}),g=r===s,{mounted:_,transitionStatus:v,setMounted:y}=MA(g),b=!_,x=c(r),S={hidden:b,orientation:l,tabActivationDirection:u,transitionStatus:v},C=G.useRef(null),w=lC(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:aM(!g),[zF.index]:h},o],stateAttributesMapping:BF});return RA({open:g,ref:C,onComplete(){g||y(!1)}}),Z(()=>{if(!(b&&!a)&&p!=null)return d(r,p),()=>{f(r,p)}},[b,a,r,p,d,f]),a||_?w:null}),HF=G.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=NF(),[p,m]=G.useState(0),[h,g]=G.useState(null),_=G.useRef(new Set),v=G.useRef(new Set),y=G.useRef(null),b=X(()=>{_.current.forEach(e=>{e()})});G.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=X(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=X(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=WF(u,l,h,s),w=X((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=G.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,K.jsx)(IF.Provider,{value:D,children:(0,K.jsx)(PP,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:FF,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:IS})})});function UF(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function WF(e,t,n,r){let[i,a]=G.useState(null);return Z(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=UF(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),G.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=UF(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var GF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(HF,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));GF.displayName=`TabsList`;var KF=gS(`inline-flex items-center justify-center cursor-pointer transition-all outline-none`,{variants:{variant:{default:`font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]`,pills:`font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]`}},defaultVariants:{variant:`default`}}),qF=(0,G.forwardRef)(({className:e,variant:t,...n},r)=>(0,K.jsx)(RF,{ref:r,className:Y(KF({variant:t,className:e})),...n}));qF.displayName=`TabsTrigger`;var JF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(VF,{ref:n,className:Y(`outline-none`,e),...t}));JF.displayName=`TabsContent`;var YF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300`,e),...t}));YF.displayName=`Text`;var XF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));XF.displayName=`TextMuted`;var ZF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`code`,{ref:n,className:Y(`font-mono text-[11px] text-white`,e),...t}));ZF.displayName=`TextCode`;var QF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`span`,{ref:n,className:Y(`font-mono text-[9px] uppercase tracking-wider text-neutral-500`,e),...t}));QF.displayName=`TextLabel`;var $F=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`pre`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto`,e),...t}));$F.displayName=`CodeBlock`;function eI(e,t){let[n,r]=(0,G.useState)(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}});return(0,G.useEffect)(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,(0,G.useCallback)(e=>{r(t=>typeof e==`function`?e(t):e)},[])]}var tI=`console:instance-id`;function nI(){let[e,t]=eI(tI,``),n=e.trim();return(0,G.useMemo)(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t(``)}),[n,e,t])}var rI={stats:e=>[`console`,`stats`,e],timeseries:e=>[`console`,`stats`,`timeseries`,e],latency:e=>[`console`,`stats`,`latency`,e],commits:e=>[`console`,`commits`,e],commitDetail:(e,t,n)=>[`console`,`commit-detail`,e,t,n],timeline:e=>[`console`,`timeline`,e],clients:e=>[`console`,`clients`,e],eventDetail:(e,t,n)=>[`console`,`event-detail`,e,t,n],eventPayload:(e,t,n)=>[`console`,`event-payload`,e,t,n],handlers:e=>[`console`,`handlers`,e],prunePreview:e=>[`console`,`prune`,`preview`,e],operations:e=>[`console`,`operations`,e],apiKeys:e=>[`console`,`api-keys`,e],storage:e=>[`console`,`storage`,e]};function iI(e,t){return e===0?!1:e??t}function aI(e){let t=new URLSearchParams;if(!e)return t;for(let[n,r]of Object.entries(e))r!=null&&t.set(n,String(r));return t}function oI(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e,i=aI(n)?.toString();return`${r}${t}${i?`?${i}`:``}`}function sI(e,t){if(!t||!e)throw Error(`Not connected`);return e}async function cI(e){let t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t[`Content-Type`]=`application/json`);let n=await fetch(oI(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??`GET`,headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw Error(e.errorMessage);return n.json()}async function lI(e){let t=await fetch(oI(e.connectionConfig.serverUrl,e.path,e.query),{method:`GET`,headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw Error(e.errorMessage);return t.blob()}function uI(e){let{config:t,isConnected:n}=Ny();return ih({queryKey:e.queryKey,queryFn:()=>cI({connectionConfig:sI(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function dI(e){let{config:t,isConnected:n}=Ny();return ih({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw Error(e.requiredMessage);return cI({connectionConfig:sI(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function fI(e,t){for(let n of t)e.invalidateQueries({queryKey:n})}function pI(e){let{instanceId:t}=nI();return e??t}function mI(e){let{config:t,isConnected:n}=Ny(),{instanceId:r}=nI(),i=Um();return ah({mutationFn:i=>e.mutationFn({connectionConfig:sI(t,n),variables:i,selectedInstanceId:r}),onSuccess:()=>{e.invalidateQueryKeys&&fI(i,e.invalidateQueryKeys)}})}function hI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.stats({partitionId:e.partitionId,instanceId:t}),path:`/console/stats`,query:{partitionId:e.partitionId,instanceId:t},errorMessage:`Failed to fetch stats`,refetchInterval:iI(e.refetchIntervalMs,5e3)})}function gI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.timeseries({...e,instanceId:n}),path:`/console/stats/timeseries`,query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch timeseries stats`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,3e4)})}function _I(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.latency({...e,instanceId:n}),path:`/console/stats/latency`,query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch latency stats`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,3e4)})}function vI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.commits({...e,instanceId:n}),path:`/console/commits`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch commits`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function yI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.commitDetail(e,t.partitionId,n),id:e,requiredMessage:`Commit sequence is required`,path:e=>`/console/commits/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch commit detail`,enabled:t.enabled})}function bI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.timeline({...e,instanceId:n}),path:`/console/timeline`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to,instanceId:n},errorMessage:`Failed to fetch timeline`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function xI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.clients({...e,instanceId:n}),path:`/console/clients`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch clients`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function SI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.eventDetail(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event detail`,enabled:t.enabled})}function CI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.eventPayload(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event payload`,enabled:t.enabled})}function wI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.handlers(t),path:`/console/handlers`,query:{instanceId:t},errorMessage:`Failed to fetch handlers`})}function TI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.prunePreview(t),path:`/console/prune/preview`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to fetch prune preview`,enabled:e.enabled})}function EI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.operations({...e,instanceId:n}),path:`/console/operations`,query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch operations`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function DI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/events`,query:{instanceId:t},method:`DELETE`,errorMessage:`Failed to clear events`}),invalidateQueryKeys:[[`console`,`events`]]})}function OI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{let r=t.instanceId??n;return cI({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:r},method:`DELETE`,errorMessage:`Failed to evict client`})},invalidateQueryKeys:[[`console`,`clients`],[`console`,`stats`],[`console`,`operations`]]})}function kI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/prune`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to prune`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`prune`,`preview`],[`console`,`operations`]]})}function AI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/compact`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to compact`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`operations`]]})}function jI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/notify-data-change`,query:{instanceId:t.instanceId??n},method:`POST`,body:{tables:t.tables,partitionId:t.partitionId},errorMessage:`Failed to notify data change`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`operations`]]})}function MI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.apiKeys({...e,instanceId:t}),path:`/console/api-keys`,query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:`Failed to fetch API keys`})}function NI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to create API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function PI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:`DELETE`,errorMessage:`Failed to revoke API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function FI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/bulk-revoke`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to bulk revoke API keys`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function II(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function LI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to stage-rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function RI(e={}){return uI({queryKey:rI.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:`/console/storage`,query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:`Failed to list blobs`,refetchInterval:iI(e.refetchIntervalMs,3e4)})}function zI(){return mI({mutationFn:async({connectionConfig:e,variables:t})=>cI({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:`DELETE`,errorMessage:`Failed to delete blob`}),invalidateQueryKeys:[[`console`,`storage`]]})}function BI(){let{config:e,isConnected:t}=Ny();return async n=>{let r=await lI({connectionConfig:sI(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:`Failed to download blob`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.split(`/`).pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}var VI=`console:partition-id`;function HI(){let[e,t]=eI(VI,``),n=e.trim();return(0,G.useMemo)(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t(``)}),[n,e,t])}var UI={refreshInterval:5,timeFormat:`relative`,showSparklines:!0,pageSize:20};function WI(){let[e,t]=eI(`console:preferences`,UI);return{preferences:e,setPreferences:t,updatePreference:(e,n)=>{t(t=>({...t,[e]:n}))},resetPreferences:()=>{t(UI)}}}var GI=[{value:5,label:`5 seconds`},{value:10,label:`10 seconds`},{value:30,label:`30 seconds`},{value:60,label:`1 minute`},{value:0,label:`Manual only`}],KI=[{value:10,label:`10`},{value:20,label:`20`},{value:50,label:`50`},{value:100,label:`100`}],qI=`syncular-console-root`;function JI(e){e.classList.add(qI)}var YI=[{suffix:``,label:`Command`},{suffix:`/stream`,label:`Stream`},{suffix:`/fleet`,label:`Fleet`},{suffix:`/ops`,label:`Ops`},{suffix:`/storage`,label:`Storage`},{suffix:`/config`,label:`Config`}];function XI(e){let t=e?.trim()??``;return!t||t===`/`?``:(t.startsWith(`/`)?t:`/${t}`).replace(/\/+$/g,``)}function ZI(e,t){return e?t?`${e}${t}`:e:t||`/`}function QI({basePath:e,appHref:t,modeBadge:n}){let{connect:r,config:i,isConnected:a,isConnecting:o}=Ny(),{preferences:s}=WI(),{instanceId:c,rawInstanceId:l,setInstanceId:u,clearInstanceId:d}=nI(),{partitionId:f,rawPartitionId:p,setPartitionId:m,clearPartitionId:h}=HI(),g=sy({select:e=>e.location.pathname}),{data:_}=hI({refetchIntervalMs:s.refreshInterval*1e3,partitionId:f,instanceId:c}),v=XI(e),y=(0,G.useMemo)(()=>YI.map(e=>({...e,id:ZI(v,e.suffix)})),[v]),b=ZI(v,``),x=ZI(v,`/config`),S=o?`connecting`:a?`connected`:i?`disconnected`:`not-configured`,C=y.find(e=>e.suffix===``?g===b||g===`${b}/`:g.startsWith(e.id))?.id??b,w=_?[{label:`HEAD`,value:`#${_.maxCommitSeq}`},{label:`COMMITS`,value:`${_.commitCount}`},{label:`CHANGES`,value:`${_.changeCount}`},{label:`CLIENTS`,value:`${_.activeClientCount}/${_.clientCount}`}]:[];return(0,K.jsxs)(`div`,{className:`${qI} h-screen bg-background text-foreground flex flex-col`,children:[(0,K.jsx)(qP,{brand:(0,K.jsx)(Rv,{to:b,children:(0,K.jsx)(KP,{label:`console`})}),center:(0,K.jsx)(VP,{items:y,activeId:C,renderItem:(e,{active:t})=>(0,K.jsx)(Rv,{to:e.id,children:(0,K.jsx)(BP,{active:t,children:e.label})},e.id)}),right:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,K.jsx)(Rw,{variant:`flow`,className:`hidden md:inline-flex px-2 py-1 text-[10px]`,children:n}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Instance`}),(0,K.jsx)(vS,{variant:`mono`,value:l,onChange:e=>u(e.target.value),onBlur:e=>u(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),c?(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:d,children:`All`}):null]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Partition`}),(0,K.jsx)(vS,{variant:`mono`,value:p,onChange:e=>m(e.target.value),onBlur:e=>m(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),f?(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:h,children:`All`}):null]}),(0,K.jsx)($w,{state:S}),(0,K.jsx)(Rv,{to:x,children:(0,K.jsx)(Q,{variant:g===x?`secondary`:`ghost`,size:`icon`,children:(0,K.jsx)(wT,{className:`h-3 w-3`})})}),t?(0,K.jsxs)(`a`,{href:t,className:zP,children:[(0,K.jsx)(CT,{className:`h-3 w-3`}),`Go to app`]}):null]})}),(0,K.jsx)(`main`,{className:`flex-1 overflow-auto pb-[32px]`,children:(0,K.jsx)(`div`,{className:`min-h-full`,children:a||g===x?(0,K.jsx)(`div`,{style:{animation:`pageIn 0.3s ease-out`},children:(0,K.jsx)(Qv,{})},g):(0,K.jsx)($I,{configPath:x,hasSavedConfig:!!i,isConnecting:o,onConnect:()=>{r()}})})}),a&&(0,K.jsx)(qw,{isLive:a,metrics:w,uptime:`--`})]})}function $I({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,K.jsx)(`p`,{className:`mb-4 text-foreground-muted`,children:`Not connected to a @syncular server`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,K.jsx)(Q,{variant:`default`,onClick:r,disabled:n,children:n?`Connecting...`:`Connect`}),(0,K.jsx)(Rv,{to:e,children:(0,K.jsx)(Q,{variant:`link`,children:`Configure connection`})})]})]})}var eL=Uv({component:QI});function tL(e={}){let{maxEvents:t=100,enabled:n=!0,staleAfterMs:r=65e3,replayLimit:i=100,partitionId:a,instanceId:o}=e,{config:s,isConnected:c}=Ny(),{instanceId:l}=nI(),u=o??l,[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(`disconnected`),[_,v]=(0,G.useState)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(0),C=(0,G.useRef)(0),w=(0,G.useRef)(null),T=(0,G.useCallback)(()=>{f([]),w.current=null},[]);return(0,G.useEffect)(()=>{if(!n||!c||!s?.serverUrl||!s?.token)return;let e=!1,o=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>`u`)return;let l=()=>{b.current&&=(clearTimeout(b.current),null)},d=()=>{x.current&&=(clearInterval(x.current),null)},p=()=>{if(e||b.current)return;S.current+=1;let t=Math.min(3e4,1e3*2**Math.max(0,S.current-1)),n=t+Math.floor(t*.2*Math.random());b.current=setTimeout(()=>{b.current=null,e||_()},n)},h=()=>{C.current=Date.now(),m(!0),g(`connected`)},_=()=>{if(e)return;g(`connecting`),l();let n=(()=>{let e=new URL(s.serverUrl,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.pathname=`${e.pathname.endsWith(`/`)?e.pathname.slice(0,-1):e.pathname}/console/events/live`,e.search=``,w.current&&e.searchParams.set(`since`,w.current),e.searchParams.set(`replayLimit`,String(o)),a&&e.searchParams.set(`partitionId`,a),u&&e.searchParams.set(`instanceId`,u),e.toString()})(),i=new WebSocket(n);y.current=i,i.onopen=()=>{if(e){i.close();return}S.current=0,v(null),g(`connecting`),m(!1);try{i.send(JSON.stringify({type:`auth`,token:s.token}))}catch{i.close();return}d(),x.current=setInterval(()=>{let e=y.current;if(!e||e.readyState!==WebSocket.OPEN)return;let t=C.current;t&&(Date.now()-t<=r||(m(!1),g(`stale`),e.close()))},1e3)},i.onclose=()=>{e||(m(!1),g(`disconnected`),d(),p())},i.onerror=()=>{e||v(Error(`WebSocket connection failed`))},i.onmessage=e=>{try{let n=JSON.parse(e.data),r=n.type;if(h(),r===`connected`||r===`heartbeat`||r===`auth_required`)return;if(r===`error`){let e=typeof n.message==`string`?n.message:`Live events authentication failed`;v(Error(e));return}let i={type:r,timestamp:n.timestamp||new Date().toISOString(),data:n};if(a&&i.data.partitionId!==a||u&&i.data.instanceId!==u)return;let o=Date.parse(w.current??``),s=Date.parse(i.timestamp);Number.isFinite(s)&&(!Number.isFinite(o)||s>o)&&(w.current=i.timestamp),f(e=>[i,...e].slice(0,t))}catch{}}};return _(),()=>{e=!0,l(),d(),y.current&&=(y.current.close(),null),m(!1),g(`disconnected`)}},[n,c,s?.serverUrl,s?.token,t,a,u,i,r]),{events:d,isConnected:p,connectionState:h,error:_,clearEvents:T}}var nL=(0,G.createContext)(null);function rL(){let[e,t]=eI(`console:time-range`,`24h`);return{range:e,setRange:t}}var iL=[{hint:`ios`,type:`mobile`},{hint:`android`,type:`mobile`},{hint:`mobile`,type:`mobile`},{hint:`tablet`,type:`tablet`},{hint:`desktop`,type:`desktop`},{hint:`mac`,type:`desktop`},{hint:`windows`,type:`desktop`},{hint:`linux`,type:`desktop`},{hint:`browser`,type:`browser`},{hint:`web`,type:`browser`},{hint:`server`,type:`server`},{hint:`api`,type:`server`},{hint:`iot`,type:`iot`},{hint:`sensor`,type:`iot`}];function aL(e){let t=e.toLowerCase();for(let e of iL)if(t.includes(e.hint))return e.type;return`client`}function oL(e){let t=e.toLowerCase();return t.includes(`pglite`)?`PGlite`:t.includes(`sqlite`)||t.includes(`wa-sqlite`)?`SQLite`:t.includes(`postgres`)||t.includes(`pg`)?`PostgreSQL`:`unknown`}function sL(e,t){return typeof e.lagCommitCount==`number`?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function cL(e,t){return e.activityState===`stale`?`offline`:t>0?`syncing`:`online`}function lL(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function uL(e,t,n={}){let r=n.maxNodes??10;return e.slice(0,r).map((e,n)=>{let r=cL(e,sL(e,t));return{id:lL(e.clientId,n),type:aL(e.clientId),status:r,cursor:Math.max(0,e.cursor),actor:e.actorId,mode:e.connectionMode,dialect:oL(e.clientId),scopes:Object.keys(e.effectiveScopes||{}),lastSeen:e.updatedAt}})}var dL={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function fL(e,t=`relative`){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function pL(e){let t=e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e;return t===`/console`||t.startsWith(`/console/`)?`/console/stream`:`/stream`}function mL(){let e=wv(),t=(0,G.useMemo)(()=>typeof window>`u`?`/stream`:pL(window.location.pathname),[]),n=rL(),{range:r}=n,{preferences:i}=WI(),{partitionId:a}=HI(),o=i.refreshInterval*1e3,[s]=eI(`console:alert-config`,dL),[c,l]=(0,G.useState)(`1h`),{data:u}=hI({refetchIntervalMs:o,partitionId:a}),{data:d}=gI({range:r,partitionId:a},{refetchIntervalMs:o}),{data:f}=_I({range:r,partitionId:a},{refetchIntervalMs:o}),{data:p}=vI({limit:5,partitionId:a},{refetchIntervalMs:o}),{data:m}=xI({limit:12,offset:0,partitionId:a},{refetchIntervalMs:o}),{events:h,isConnected:g}=tL({maxEvents:8,partitionId:a}),_=(0,G.useMemo)(()=>{let e=d?.buckets??[],t=0,n=0;for(let r of e)t+=r.pushCount+r.pullCount,n+=r.errorCount;let r=t>0?n/t*100:0;return{totalEvents:t,errorRate:r}},[d?.buckets]),v=(0,G.useMemo)(()=>m?.items?uL(m.items,u,{maxNodes:12}):[],[m?.items,u]),y=v.filter(e=>e.status!==`offline`).length,b=v.filter(e=>e.status===`offline`).length,x=(0,G.useMemo)(()=>u?[{label:`Ops (Range)`,value:_.totalEvents,color:`flow`},{label:`P50 Latency`,value:f?.push?.p50??0,unit:`ms`,color:`healthy`},{label:`Error Rate`,value:`${_.errorRate.toFixed(1)}%`,color:_.errorRate>0?`offline`:`muted`},{label:`Active Clients`,value:u.activeClientCount,color:`syncing`},{label:`Pending`,value:u.maxActiveClientCursor!==null&&u.maxCommitSeq>0?u.maxCommitSeq-(u.minActiveClientCursor??0):0,color:`relay`}]:[],[u,f,_.errorRate,_.totalEvents]),S=(0,G.useMemo)(()=>h.map(e=>({type:e.type.toUpperCase(),actor:e.data?.actorId??``,table:(e.data?.tables??[])[0]??``,time:fL(e.timestamp,i.timeFormat)})),[h,i.timeFormat]),C=(0,G.useMemo)(()=>{let e=d?.buckets;if(!e?.length)return[];let t=Math.max(...e.map(e=>Math.max(e.pushCount,e.pullCount)),1);return e.map(e=>({pushPercent:t>0?e.pushCount/t*100:0,pullPercent:t>0?e.pullCount/t*100:0}))},[d?.buckets]),w=(0,G.useMemo)(()=>{if(!f)return[];let e=Math.max(f.push.p50,f.push.p90,f.push.p99,f.pull.p50,f.pull.p90,f.pull.p99,1);return[{label:`P50`,pushMs:f.push.p50,pullMs:f.pull.p50,pushBarPercent:f.push.p50/e*100,pullBarPercent:f.pull.p50/e*100},{label:`P90`,pushMs:f.push.p90,pullMs:f.pull.p90,pushBarPercent:f.push.p90/e*100,pullBarPercent:f.pull.p90/e*100},{label:`P99`,pushMs:f.push.p99,pullMs:f.pull.p99,pushBarPercent:f.push.p99/e*100,pullBarPercent:f.pull.p99/e*100}]},[f]),T=(0,G.useMemo)(()=>p?.items?p.items.map(e=>({seq:e.commitSeq,actor:e.actorId,changes:e.changeCount,tables:(e.affectedTables??[]).join(`, `),time:fL(e.createdAt,i.timeFormat)})):[],[p?.items,i.timeFormat]),E=(0,G.useMemo)(()=>Math.max(0,100-_.errorRate),[_.errorRate]),D=(0,G.useMemo)(()=>{if(!s.enabled||!u)return[];let e=[];return f?.push?.p90&&f.push.p90>s.thresholds.p90Latency&&e.push(`P90 push latency (${f.push.p90}ms) exceeds threshold (${s.thresholds.p90Latency}ms)`),u.minActiveClientCursor!==null&&u.maxCommitSeq-u.minActiveClientCursor>s.thresholds.clientLag&&e.push(`Client lag (${u.maxCommitSeq-u.minActiveClientCursor}) exceeds threshold (${s.thresholds.clientLag})`),_.errorRate>s.thresholds.errorRate&&e.push(`Error rate (${_.errorRate.toFixed(1)}%) exceeds threshold (${s.thresholds.errorRate}%)`),e},[s,u,f,_.errorRate]);return u?(0,K.jsx)(nL.Provider,{value:n,children:(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[D.length>0&&(0,K.jsx)(`div`,{className:`px-6 pb-4`,children:(0,K.jsxs)(YP,{variant:`destructive`,children:[(0,K.jsx)(XP,{children:`Threshold Exceeded`}),(0,K.jsx)(ZP,{children:D.map((e,t)=>(0,K.jsx)(`span`,{className:`block`,children:e},t))})]})}),(0,K.jsx)(cM,{clients:v,totalNodes:v.length+2,onlineCount:y,offlineCount:b,relayClientIds:[]}),(0,K.jsx)(jT,{items:x}),(0,K.jsxs)(`div`,{className:`flex`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:[(0,K.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,K.jsx)(pS,{bars:C,activeRange:c,onRangeChange:l})}),(0,K.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,K.jsx)(NT,{buckets:w,successRate:E})}),(0,K.jsx)(`div`,{className:`border-r border-border`,children:(0,K.jsx)(Jw,{commits:T,onViewAll:()=>e({href:t})})})]}),(0,K.jsx)(FT,{entries:S,isConnected:g,maxVisible:20,maxHeight:`calc(100vh - 200px)`})]})]})}):(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(Qw,{size:`lg`})})}function hL(){return(0,K.jsx)(mL,{})}var gL=OP;function _L({children:e}){return(0,K.jsxs)(`div`,{className:`space-y-4 px-5 py-5`,children:[(0,K.jsx)(vL,{}),(0,K.jsx)(TL,{}),(0,K.jsx)(EL,{}),e]})}function vL(){let{clearError:e,config:t,connect:n,disconnect:r,error:i,isConnected:a,isConnecting:o}=Ny(),[s,c]=(0,G.useState)(t?.serverUrl??`/api`),[l,u]=(0,G.useState)(t?.token??``),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),[_,v]=eI(`console:disconnect-clear-saved-config`,!1);return(0,G.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`server`),n=!1;if(t&&(c(t),e.delete(`server`),n=!0),e.has(`token`)&&(e.delete(`token`),n=!0),n){let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.replaceState({},``,n)}},[]),(0,G.useEffect)(()=>{t?.serverUrl&&c(t.serverUrl),t?.token&&u(t.token)},[t?.serverUrl,t?.token]),(0,G.useEffect)(()=>{g(null)},[]),(0,K.jsx)(Xw,{isConnected:a,isConnecting:o,isTestingConnection:p,serverUrl:s,onServerUrlChange:c,consoleToken:l,onConsoleTokenChange:u,onSaveAndConnect:async()=>{e(),f(null),g(await n({serverUrl:s.trim(),token:l.trim()},{persistOverride:!0})?`Connected successfully and configuration saved.`:`Failed to connect with the provided settings.`)},onDisconnect:()=>{r({clearSavedConfig:_}),_&&(c(`/api`),u(``)),g(_?`Disconnected and saved credentials cleared.`:`Disconnected.`),f(null)},onTestConnection:async()=>{m(!0),f(null),g(null);let e=performance.now();try{let t=s.trim(),n=l.trim();if(!t||!n)throw Error(`Missing server URL or token`);if(!(await fetch(`${t}/console/stats`,{headers:{Authorization:`Bearer ${n}`}})).ok)throw Error(`Failed to connect`);f(Math.round(performance.now()-e))}catch{f(-1)}finally{m(!1)}},statusMessage:i??h??(d===null?void 0:d<0?`Connection failed`:`Connection successful (${d}ms latency)`),children:(0,K.jsx)(`div`,{className:`px-5 pb-5 -mt-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-400`,children:`Clear saved credentials on disconnect`}),(0,K.jsx)(`p`,{className:`font-mono text-[9px] text-neutral-500`,children:`Removes stored server URL and token from this browser.`})]}),(0,K.jsx)(Pw,{checked:_,onCheckedChange:v})]})})})}var yL=1440*60*1e3;function bL(e){let t=e.trim();if(!t)return null;let n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function xL(e){if(!e)return`Never`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():`Invalid date`}function SL(e){return e.length===0?`all scopes`:e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function CL(e,t){if(e.revokedAt)return`revoked`;if(!e.expiresAt)return`active`;let n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return`active`;let r=Date.now();return n<=r?`expired`:n<=r+t*yL?`expiring`:`active`}function wL(e){return e===`revoked`?`destructive`:e===`expired`?`offline`:e===`expiring`?`syncing`:`healthy`}function TL(){let[e,t]=(0,G.useState)(`all`),[n,r]=(0,G.useState)(`all`),[i,a]=(0,G.useState)(`14`),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(`relay`),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)([]),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(null),[I,L]=(0,G.useState)(null),ee=(0,G.useMemo)(()=>bL(i),[i]),R=ee??14,z=(0,G.useMemo)(()=>bL(v),[v]),B=v.trim().length>0,V=!B||z!==null,{data:H,isLoading:U,error:W}=MI((0,G.useMemo)(()=>({type:e===`all`?void 0:e,status:n===`all`?void 0:n,expiresWithinDays:n===`expiring`?R:void 0}),[e,n,R])),te=NI(),ne=FI(),re=PI(),ie=II(),ae=LI();(0,G.useEffect)(()=>{let e=new Set((H?.items??[]).map(e=>e.keyId));C(t=>t.filter(t=>e.has(t)))},[H?.items]);let oe=async()=>{try{let e=g.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);x((await te.mutateAsync({name:u,keyType:f,actorId:m||void 0,scopeKeys:e.length>0?e:void 0,expiresInDays:B?z??void 0:void 0})).secretKey),d(``),h(``),_(``),y(``)}catch{}},se=e=>{navigator.clipboard.writeText(e),D(e),setTimeout(()=>D(null),2e3)},ce=async()=>{if(O)try{await re.mutateAsync(O)}finally{k(null)}},le=async()=>{if(S.length!==0)try{T(await ne.mutateAsync({keyIds:S})),C([])}catch{}},ue=async()=>{if(A)try{let e=await ae.mutateAsync(A.keyId);N({oldKeyId:A.keyId,oldKeyName:A.name,secretKey:e.secretKey})}catch{}},de=async()=>{if(M)try{await re.mutateAsync(M.oldKeyId)}finally{N(null),j(null)}},fe=async()=>{if(P)try{L((await ie.mutateAsync(P)).secretKey)}finally{F(null)}};if(U)return(0,K.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,K.jsx)(Qw,{size:`lg`})});if(W)return(0,K.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load API keys: `,W.message]})});let pe=(H?.items??[]).filter(e=>e.revokedAt===null).map(e=>e.keyId),me=pe.length>0&&pe.every(e=>S.includes(e)),he=S.length>0,ge=(H?.items??[]).filter(e=>S.includes(e.keyId)).map(e=>e.name);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(VT,{title:`API Keys`,description:`Issue, rotate, revoke, and audit key lifecycle state.`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Q,{size:`sm`,variant:`destructive`,onClick:()=>l(!0),disabled:S.length===0,children:[`Revoke Selected (`,S.length,`)`]}),(0,K.jsx)(Q,{size:`sm`,onClick:()=>s(!0),children:`Create Key`})]}),children:[(0,K.jsxs)(`div`,{className:`mb-4 grid gap-3 lg:grid-cols-3`,children:[(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Type filter`}),(0,K.jsxs)(RP,{value:[e],multiple:!1,onValueChange:e=>{let n=e.find(e=>typeof e==`string`);(n===`all`||n===`relay`||n===`proxy`||n===`admin`)&&t(n)},children:[(0,K.jsx)(gL,{value:`all`,children:`all`}),(0,K.jsx)(gL,{value:`relay`,children:`relay`}),(0,K.jsx)(gL,{value:`proxy`,children:`proxy`}),(0,K.jsx)(gL,{value:`admin`,children:`admin`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Status filter`}),(0,K.jsxs)(RP,{value:[n],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`all`||t===`active`||t===`revoked`||t===`expiring`)&&r(t)},children:[(0,K.jsx)(gL,{value:`all`,children:`all`}),(0,K.jsx)(gL,{value:`active`,children:`active`}),(0,K.jsx)(gL,{value:`revoked`,children:`revoked`}),(0,K.jsx)(gL,{value:`expiring`,children:`expiring`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-expiring-window`,children:`Expiring window (days)`}),(0,K.jsx)(RM,{children:`Used when status filter is set to expiring.`}),(0,K.jsx)(vS,{id:`api-key-expiring-window`,placeholder:`14`,value:i,inputMode:`numeric`,onChange:e=>a(e.target.value)}),ee===null&&i.trim().length>0?(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`}):null]})]}),H?.items.length===0?(0,K.jsx)(aT,{message:`No API keys match the current filters.`}):(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{className:`w-[28px]`,children:(0,K.jsx)(bM,{checked:me,indeterminate:!me&&he&&pe.length>0,onCheckedChange:e=>{C(e?pe:[])},"aria-label":`Select all active keys`})}),(0,K.jsx)(Uw,{className:`w-[100px]`,children:`NAME`}),(0,K.jsx)(Uw,{className:`w-[55px]`,children:`TYPE`}),(0,K.jsx)(Uw,{className:`w-[90px]`,children:`KEY PREFIX`}),(0,K.jsx)(Uw,{className:`w-[80px]`,children:`ACTOR`}),(0,K.jsx)(Uw,{className:`w-[100px]`,children:`SCOPES`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`CREATED`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`LAST USED`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`EXPIRES`}),(0,K.jsx)(Uw,{className:`flex-1`,children:`STATUS`})]})}),(0,K.jsx)(Vw,{children:(H?.items??[]).map(e=>{let t=CL(e,R);return(0,K.jsxs)(Hw,{className:`group relative`,children:[(0,K.jsx)(Ww,{className:`w-[28px]`,children:(0,K.jsx)(bM,{checked:S.includes(e.keyId),onCheckedChange:t=>{C(n=>t?[...new Set([...n,e.keyId])]:n.filter(t=>t!==e.keyId))},"aria-label":`Select ${e.name}`,disabled:e.revokedAt!==null})}),(0,K.jsx)(Ww,{className:`w-[100px] font-medium`,children:e.name}),(0,K.jsx)(Ww,{className:`w-[55px]`,children:(0,K.jsx)(Rw,{variant:e.keyType===`admin`?`flow`:e.keyType===`proxy`?`ghost`:`relay`,children:e.keyType})}),(0,K.jsx)(Ww,{className:`w-[90px]`,children:(0,K.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[e.keyPrefix,`...`]})}),(0,K.jsx)(Ww,{className:`w-[80px] text-neutral-500`,children:e.actorId??`-`}),(0,K.jsx)(Ww,{className:`w-[100px] text-neutral-500`,children:(0,K.jsx)(`code`,{className:`font-mono text-[10px]`,children:SL(e.scopeKeys)})}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.createdAt)}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.lastUsedAt)}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.expiresAt)}),(0,K.jsx)(Ww,{className:`flex-1`,children:(0,K.jsx)(Rw,{variant:wL(t),children:t})}),e.revokedAt===null&&(0,K.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors`,children:`stage`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>F(e.keyId),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors`,children:`rotate`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>k(e.keyId),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors`,children:`revoke`})]})]},e.keyId)})})]})]}),(0,K.jsx)(gF,{open:o,onOpenChange:s,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Create API Key`})}),b?(0,K.jsx)(DL,{copiedKeyId:E,onClose:()=>{x(null),s(!1)},onCopy:se,secretKey:b,warning:`Copy this key now. You will not be able to view it again.`}):(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-name`,children:`Name`}),(0,K.jsx)(vS,{id:`api-key-name`,placeholder:`Backend Relay Key`,value:u,onChange:e=>d(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Key type`}),(0,K.jsxs)(RP,{value:[f],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`relay`||t===`proxy`||t===`admin`)&&p(t)},children:[(0,K.jsx)(gL,{value:`relay`,children:`relay`}),(0,K.jsx)(gL,{value:`proxy`,children:`proxy`}),(0,K.jsx)(gL,{value:`admin`,children:`admin`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-actor-id`,children:`Actor ID (optional)`}),(0,K.jsx)(RM,{children:`Pin this key to a fixed actor ID`}),(0,K.jsx)(vS,{id:`api-key-actor-id`,placeholder:`actor-123`,value:m,onChange:e=>h(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-scope-keys`,children:`Scope keys (optional)`}),(0,K.jsx)(RM,{children:`Comma-separated list of allowed scope keys`}),(0,K.jsx)(vS,{id:`api-key-scope-keys`,placeholder:`scope-a, scope-b`,value:g,onChange:e=>_(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-expires-days`,children:`Expires in days (optional)`}),(0,K.jsx)(RM,{children:`Leave empty to keep the key non-expiring.`}),(0,K.jsx)(vS,{id:`api-key-expires-days`,placeholder:`30`,value:v,inputMode:`numeric`,onChange:e=>y(e.target.value)}),V?null:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>s(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:oe,disabled:te.isPending||!u||!V,children:te.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Creating...`]}):`Create`})]})]})]})}),(0,K.jsx)(gF,{open:c,onOpenChange:e=>{l(e),e||T(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Bulk Revoke API Keys`})}),w?(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsxs)(ZP,{children:[`Requested `,w.requestedCount,` keys. Revoked`,` `,w.revokedCount,`, already revoked`,` `,w.alreadyRevokedCount,`, not found`,` `,w.notFoundCount,`.`]})}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`primary`,onClick:()=>{l(!1),T(null)},children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:`This revokes selected keys immediately and cannot be undone.`})}),(0,K.jsxs)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:[`Selected keys: `,ge.slice(0,5).join(`, `),ge.length>5?` +${ge.length-5} more`:``]})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:le,disabled:ne.isPending||S.length===0,children:ne.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking...`]}):`Revoke Selected`})]})]})]})}),(0,K.jsx)(gF,{open:A!==null||M!==null,onOpenChange:()=>{j(null),N(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Stage Rotate API Key`})}),M?(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsxs)(ZP,{children:[`Replacement key created for `,M.oldKeyName,`. The old key is still active until you revoke it.`]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:M.secretKey}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>se(M.secretKey),children:E===M.secretKey?`Copied`:`Copy`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>{N(null),j(null)},children:`Keep Old Key Active`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:de,disabled:re.isPending,children:re.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking Old Key...`]}):`Finalize and Revoke Old Key`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it.`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>j(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:ue,disabled:ae.isPending||!A,children:ae.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Staging...`]}):`Create Replacement Key`})]})]})]})}),(0,K.jsx)(gF,{open:O!==null,onOpenChange:()=>k(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Revoke API Key`})}),(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:`Revoking a key immediately invalidates it for all requests.`})})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>k(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:ce,disabled:re.isPending,children:re.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking...`]}):`Revoke`})]})]})}),(0,K.jsx)(gF,{open:P!==null||I!==null,onOpenChange:()=>{F(null),L(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Rotate API Key`})}),I?(0,K.jsx)(DL,{copiedKeyId:E,onClose:()=>L(null),onCopy:se,secretKey:I,warning:`The previous key has been invalidated. Store this replacement securely.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Rotating a key invalidates the previous secret immediately.`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>F(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:fe,disabled:ie.isPending,children:ie.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Rotating...`]}):`Rotate`})]})]})]})})]})}function EL(){let{preferences:e,updatePreference:t,resetPreferences:n}=WI();return(0,K.jsx)(zT,{rows:[{type:`filter`,label:`Auto-refresh interval`,options:GI.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.refreshInterval}`,onActiveChange:e=>t(`refreshInterval`,Number.parseInt(e,10))},{type:`filter`,label:`Items per page`,options:KI.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.pageSize}`,onActiveChange:e=>t(`pageSize`,Number.parseInt(e,10))},{type:`filter`,label:`Time format`,options:[{id:`relative`,label:`Relative`},{id:`absolute`,label:`Absolute`}],activeId:e.timeFormat,onActiveChange:e=>t(`timeFormat`,e)},{type:`toggle`,label:`Show sparklines`,description:`Display mini trend charts in dashboard metric cards`,checked:e.showSparklines,onCheckedChange:e=>t(`showSparklines`,e)}],onResetDefaults:n})}function DL({copiedKeyId:e,onClose:t,onCopy:n,secretKey:r,warning:i}){return(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:i})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:r}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>n(r),children:e===r?`Copied`:`Copy`})]}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`primary`,onClick:t,children:`Done`})})]})}function OL(e){let t=e.toLowerCase();return t.includes(`mobile`)||t.includes(`ios`)||t.includes(`android`)?`mobile`:t.includes(`tablet`)?`tablet`:t.includes(`desktop`)||t.includes(`laptop`)?`desktop`:t.includes(`edge`)?`edge`:t.includes(`iot`)?`iot`:`desktop`}function kL(e){let t=e.toLowerCase();return t.includes(`pglite`)?`PGlite`:t.includes(`wa-sqlite`)||t.includes(`sqlite`)?`SQLite`:t.includes(`postgres`)||t.includes(`pg`)?`PostgreSQL`:`unknown`}function AL(e,t){if(t===`absolute`)return new Date(e).toLocaleString();try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}catch{return e}}function jL(e,t,n){return{id:e.clientId,type:OL(e.clientId),status:e.activityState===`stale`?`offline`:e.activityState===`idle`?`syncing`:`online`,cursor:e.cursor,actor:e.actorId,mode:e.connectionMode===`realtime`?`realtime`:`polling`,dialect:kL(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:AL(e.updatedAt,n)}}function ML({emptyState:e}={}){let[t,n]=(0,G.useState)(1),[r,i]=(0,G.useState)(null),{preferences:a}=WI(),{partitionId:o}=HI(),s=a.pageSize,c=a.refreshInterval*1e3,{data:l,isLoading:u}=hI({refetchIntervalMs:c,partitionId:o}),{data:d,isLoading:f,error:p}=xI({limit:s,offset:(t-1)*s,partitionId:o},{refetchIntervalMs:c}),m=OI(),h=Math.ceil((d?.total??0)/s),g=l?.maxCommitSeq??0;(0,G.useEffect)(()=>{n(1)},[]);let _=async()=>{if(r)try{await m.mutateAsync({clientId:r,partitionId:o})}finally{i(null)}};if(f||u)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})});if(p)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load clients: `,p.message]})});let v=(d?.items??[]).map(e=>jL(e,g,a.timeFormat));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 px-5 py-5`,children:[v.length>0&&(0,K.jsx)(qT,{clients:v,headSeq:g}),v.length===0?e??(0,K.jsx)(RT,{children:(0,K.jsx)(aT,{message:`No clients yet`})}):(0,K.jsx)(OT,{clients:v,headSeq:g,onEvict:e=>{let t=d?.items.find(t=>t.clientId===e);i(t?.clientId??e)}}),h>1&&(0,K.jsx)(CF,{page:t,totalPages:h,totalItems:d?.total??0,onPageChange:n}),(0,K.jsx)(gF,{open:r!==null,onOpenChange:()=>i(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Evict Client`})}),(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to evict client`,` `,(0,K.jsxs)(`span`,{className:`font-mono text-white`,children:[r?.slice(0,12),`...`]}),`?`]}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This will force the client to re-bootstrap on their next sync.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>i(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:_,disabled:m.isPending,children:m.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Evicting...`]}):`Evict`})]})]})})]})}var NL={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function PL(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function FL(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return Array.from(new Set(t))}function IL(e){switch(e){case`notify_data_change`:return`Notify`;case`evict_client`:return`Evict`;case`compact`:return`Compact`;default:return`Prune`}}function LL(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function RL(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function zL(e){let t=LL(e.requestPayload),n=LL(e.resultPayload);if(e.operationType===`notify_data_change`){let e=RL(t?.tables),r=n?.commitSeq;return`${e.length} table${e.length===1?``:`s`} -> commit #${typeof r==`number`?r:`?`}`}if(e.operationType===`evict_client`){let t=n?.evicted===!0?`evicted`:`not found`;return`client ${e.targetClientId??`?`} ${t}`}return e.operationType===`compact`?`${typeof n?.deletedChanges==`number`?n.deletedChanges:0} changes removed`:`${typeof n?.deletedCommits==`number`?n.deletedCommits:0} commits removed${typeof t?.watermarkCommitSeq==`number`?` at #${t.watermarkCommitSeq}`:``}`}function BL(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function VL(){let{partitionId:e}=HI();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,K.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,K.jsx)(HL,{}),(0,K.jsx)(qL,{})]}),(0,K.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,K.jsx)(UL,{partitionId:e}),(0,K.jsx)(WL,{partitionId:e}),(0,K.jsx)(GL,{partitionId:e})]}),(0,K.jsx)(KL,{partitionId:e})]})}function HL(){let{data:e,isLoading:t,error:n}=wI();return t?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):n?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load handlers: `,n.message]})}):(0,K.jsx)(kT,{handlers:(e?.items??[]).map(e=>({table:e.table,dependsOn:e.dependsOn?.join(`, `)??null,chunkTtl:e.snapshotChunkTtlMs?PL(e.snapshotChunkTtlMs):`default`})),tableCount:e?.items.length??0})}function UL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{data:a,isLoading:o}=hI({partitionId:e}),{data:s,isLoading:c,refetch:l}=TI({enabled:!1}),u=kI();return o?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Prune`,description:`Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.`,dotColor:`syncing`,stats:[{label:`Total commits`,value:a?.commitCount??0},{label:`Commit range`,value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:`Min active cursor`,value:a?.minActiveClientCursor??`N/A`,tone:`syncing`}],actionLabel:`Preview Prune`,actionVariant:`destructive`,onAction:async()=>{n(!0),i(null),await l()}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Prune Old Commits`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?c?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Qw,{size:`sm`})}):s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(YP,{variant:s.commitsToDelete>0?`destructive`:`default`,children:(0,K.jsx)(ZP,{children:s.commitsToDelete>0?(0,K.jsxs)(K.Fragment,{children:[`This will delete`,` `,(0,K.jsx)(`strong`,{children:s.commitsToDelete}),` commits up to sequence`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`#`,s.watermarkCommitSeq]}),`.`]}):`No commits are eligible for pruning.`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px]`,children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Watermark commit seq:`}),(0,K.jsxs)(`span`,{className:`text-white`,children:[`#`,s.watermarkCommitSeq]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px] items-center`,children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Commits to delete:`}),(0,K.jsx)(Rw,{variant:s.commitsToDelete>0?`offline`:`ghost`,children:s.commitsToDelete})]})]})]}):null:(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Pruning Complete`}),(0,K.jsxs)(ZP,{children:[`Successfully deleted `,(0,K.jsx)(`strong`,{children:r}),` commits.`]})]})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,K.jsx)(Q,{variant:`destructive`,onClick:async()=>{i((await u.mutateAsync()).deletedCommits)},disabled:u.isPending||c||(s?.commitsToDelete??0)===0,children:u.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Pruning...`]}):`Prune Now`})]})]})})]})}function WL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{data:a,isLoading:o}=hI({partitionId:e}),s=AI();return o?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Compact`,description:`Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.`,dotColor:`flow`,stats:[{label:`Total changes`,value:a?.changeCount??0},{label:`Total commits`,value:a?.commitCount??0}],actionLabel:`Run Compaction`,actionVariant:`primary`,onAction:()=>{n(!0),i(null)}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Compact Changes`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsx)(ZP,{children:`Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time.`})}):(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Compaction Complete`}),(0,K.jsxs)(ZP,{children:[`Successfully removed `,(0,K.jsx)(`strong`,{children:r}),` redundant changes.`]})]})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,K.jsx)(Q,{variant:`primary`,onClick:async()=>{i((await s.mutateAsync()).deletedChanges)},disabled:s.isPending,children:s.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Compacting...`]}):`Compact Now`})]})]})})]})}function GL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(`tasks`),[a,o]=(0,G.useState)(e??``),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=jI(),f=FL(r),p=[{label:`Next tables`,value:f.length,tone:`syncing`},{label:`Last commit seq`,value:s?`#${s.commitSeq}`:`—`,tone:`syncing`},{label:`Last chunks cleared`,value:s?.deletedChunks??`—`}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Notify Data Change`,description:`Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.`,dotColor:`healthy`,stats:p,actionLabel:`Notify Clients`,actionVariant:`primary`,onAction:()=>{n(!0),u(null)}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Notify External Data Change`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Notification Sent`}),(0,K.jsxs)(ZP,{children:[`Created synthetic commit`,` `,(0,K.jsxs)(`strong`,{children:[`#`,s.commitSeq]}),` for`,` `,(0,K.jsx)(`strong`,{children:s.tables.length}),` table`,s.tables.length===1?``:`s`,` and cleared`,` `,(0,K.jsx)(`strong`,{children:s.deletedChunks}),` cached chunk`,s.deletedChunks===1?``:`s`,`.`]})]}):(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsx)(ZP,{children:`Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data.`})}),l?(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:l})}):null,(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Tables (comma-separated)`}),(0,K.jsx)(vS,{value:r,onChange:e=>i(e.target.value),placeholder:`tasks, notes`,disabled:d.isPending}),(0,K.jsx)(RM,{children:`Enter one or more table names affected by the external change.`})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Partition ID (optional)`}),(0,K.jsx)(vS,{value:a,onChange:e=>o(e.target.value),placeholder:`default`,disabled:d.isPending})]})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:s?`Close`:`Cancel`}),s?null:(0,K.jsx)(Q,{variant:`primary`,onClick:async()=>{if(f.length===0){u(`Provide at least one table name.`);return}u(null),c(await d.mutateAsync({tables:f,partitionId:a.trim()||void 0}))},disabled:d.isPending,children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Notifying...`]}):`Notify Data Change`})]})]})})]})}function KL({partitionId:e}){let[t,n]=(0,G.useState)(`all`),{data:r,isLoading:i,error:a}=EI({limit:20,offset:0,operationType:t===`all`?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return(0,K.jsx)(VT,{title:`Operation Audit`,description:`Recent prune/compact/notify/evict actions with actor and result context.`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Q,{variant:t===`all`?`default`:`ghost`,size:`sm`,onClick:()=>n(`all`),children:`All`}),(0,K.jsx)(Q,{variant:t===`prune`?`default`:`ghost`,size:`sm`,onClick:()=>n(`prune`),children:`Prune`}),(0,K.jsx)(Q,{variant:t===`compact`?`default`:`ghost`,size:`sm`,onClick:()=>n(`compact`),children:`Compact`}),(0,K.jsx)(Q,{variant:t===`notify_data_change`?`default`:`ghost`,size:`sm`,onClick:()=>n(`notify_data_change`),children:`Notify`}),(0,K.jsx)(Q,{variant:t===`evict_client`?`default`:`ghost`,size:`sm`,onClick:()=>n(`evict_client`),children:`Evict`})]}),contentClassName:`pt-2`,children:i?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,K.jsx)(Qw,{size:`lg`})}):a?(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsxs)(ZP,{children:[`Failed to load operation audit events: `,a.message]})}):(r?.items.length??0)===0?(0,K.jsx)(`div`,{className:`px-2 py-8 text-sm text-neutral-500`,children:`No operation events found for this filter.`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{children:`Time`}),(0,K.jsx)(Uw,{children:`Type`}),(0,K.jsx)(Uw,{children:`User`}),(0,K.jsx)(Uw,{children:`Target`}),(0,K.jsx)(Uw,{children:`Result`})]})}),(0,K.jsx)(Vw,{children:(r?.items??[]).map((e,t)=>(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Ww,{className:`whitespace-nowrap text-xs text-neutral-400`,children:BL(e.createdAt)}),(0,K.jsx)(Ww,{children:(0,K.jsx)(Rw,{variant:`ghost`,children:IL(e.operationType)})}),(0,K.jsx)(Ww,{className:`font-mono text-xs`,children:e.consoleUserId??`system`}),(0,K.jsx)(Ww,{className:`font-mono text-xs`,children:e.targetClientId??e.partitionId??(e.operationType===`notify_data_change`?`partition default`:`global`)}),(0,K.jsx)(Ww,{className:`font-mono text-xs text-neutral-300`,children:zL(e)})]},`${e.operationId}:${e.createdAt}:${t}`))})]})})})}function qL(){let[e,t]=eI(`console:alert-config`,NL),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold};return(0,K.jsx)(Fw,{enabled:e.enabled,onEnabledChange:e=>{t(t=>({...t,enabled:e}))},thresholds:n,onThresholdsChange:e=>{t(t=>({...t,latencyThresholdMs:e.p90Latency,errorRateThreshold:e.errorRate,clientLagThreshold:e.clientLag}))}})}function JL(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function YL(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function XL(){let[e,t]=(0,G.useState)(``),[n,r]=(0,G.useState)(void 0),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(null),{data:u,isLoading:d,error:f}=RI({prefix:n,cursor:i,limit:100}),p=zI(),m=BI();function h(){let t=e.trim();r(t.length>0?t:void 0),a(void 0),s([])}function g(){t(``),r(void 0),a(void 0),s([])}function _(){u?.cursor&&(s(e=>[...e,i??``]),a(u.cursor))}function v(){s(e=>{let t=[...e],n=t.pop();return a(n&&n.length>0?n:void 0),t})}function y(){c&&p.mutate(c,{onSuccess:()=>l(null)})}if(d)return(0,K.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})})});if(f)return(0,K.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger font-mono text-[11px]`,children:[`Failed to load storage items: `,f.message]})})});let b=u?.items??[];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,K.jsx)(VT,{title:`Storage`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(vS,{placeholder:`Prefix filter...`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},className:`h-7 w-48 text-xs`}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:h,children:`Filter`}),n&&(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:g,children:`Clear`})]}),children:b.length===0?(0,K.jsx)(aT,{message:n?`No storage items matching prefix "${n}".`:`No storage items found.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{children:`Key`}),(0,K.jsx)(Uw,{children:`Size`}),(0,K.jsx)(Uw,{children:`Type`}),(0,K.jsx)(Uw,{children:`Uploaded`}),(0,K.jsx)(Uw,{children:`Actions`})]})}),(0,K.jsx)(Vw,{children:b.map(e=>(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Ww,{className:`font-mono text-xs max-w-[320px]`,title:e.key,children:e.key}),(0,K.jsx)(Ww,{className:`font-mono text-xs text-neutral-400 whitespace-nowrap`,children:JL(e.size)}),(0,K.jsx)(Ww,{children:e.httpMetadata?.contentType?(0,K.jsx)(Rw,{variant:`ghost`,children:e.httpMetadata.contentType}):(0,K.jsx)(`span`,{className:`text-neutral-500 text-xs`,children:`--`})}),(0,K.jsx)(Ww,{className:`whitespace-nowrap text-xs text-neutral-400`,children:YL(e.uploaded)}),(0,K.jsx)(Ww,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>void m(e.key),children:`Download`}),(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>l(e.key),children:`Delete`})]})})]},e.key))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2`,children:[(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:o.length===0,onClick:v,children:`Previous`}),(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!u?.truncated,onClick:_,children:`Next`})]})]})}),(0,K.jsx)(gF,{open:c!==null,onOpenChange:()=>l(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Delete Storage Item`})}),(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to delete`,` `,(0,K.jsx)(`span`,{className:`font-mono text-white`,children:c}),`?`]}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This action cannot be undone.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>l(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:y,disabled:p.isPending,children:p.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),` Deleting...`]}):`Delete`})]})]})})]})}function ZL(e,t){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}function QL(e){let t=e.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),n={},r=[];for(let e of t){let[t=``,...i]=e.split(`:`),a=i.join(`:`).trim(),o=t.toLowerCase();if(!a){r.push(e);continue}if(o===`actor`){n.actorId=a;continue}if(o===`client`){n.clientId=a;continue}if(o===`table`){n.table=a;continue}if(o===`request`){n.requestId=a;continue}if(o===`trace`){n.traceId=a;continue}r.push(e)}return r.length>0&&(n.search=r.join(` `)),n}function $L(e){return e===`1h`?3600*1e3:e===`6h`?360*60*1e3:e===`24h`?1440*60*1e3:e===`7d`?10080*60*1e3:720*60*60*1e3}function eR(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tR(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:`#?`}function nR(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:`E?`}function rR(e,t,n){return!e||!t?null:e.replaceAll(`{traceId}`,encodeURIComponent(t)).replaceAll(`{spanId}`,encodeURIComponent(n??``))}function iR({initialSelectedEntryId:e}={}){let{preferences:t}=WI(),{partitionId:n}=HI(),{range:r,setRange:i}=rL(),a=t.pageSize,o=t.refreshInterval*1e3,[s,c]=(0,G.useState)(()=>e?.startsWith(`#`)?`commits`:e?.startsWith(`E`)?`events`:`all`),[l,u]=(0,G.useState)(`all`),[d,f]=(0,G.useState)(`all`),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(e??null),x=(0,G.useRef)(!1),S=(0,G.useMemo)(()=>QL(p),[p]),C=(0,G.useMemo)(()=>new Date(Date.now()-$L(r)).toISOString(),[r]),{data:w,isLoading:T,refetch:E}=bI({limit:a,offset:(h-1)*a,...n?{partitionId:n}:{},view:s,...s!==`commits`&&l!==`all`?{eventType:l}:{},...s!==`commits`&&d!==`all`?{outcome:d}:{},...S.actorId?{actorId:S.actorId}:{},...S.clientId?{clientId:S.clientId}:{},...S.requestId?{requestId:S.requestId}:{},...S.traceId?{traceId:S.traceId}:{},...S.table?{table:S.table}:{},...S.search?{search:S.search}:{},from:C},{refetchIntervalMs:o}),D=DI(),O=y?.startsWith(`#`)?y.slice(1):void 0,k=y?.startsWith(`E`)?y.slice(1):void 0,A=O&&O!==`?`?O:void 0,j=k&&k!==`?`?k:void 0,{data:M,isLoading:N,error:P}=yI(A,{enabled:A!==void 0,partitionId:n}),{data:F,isLoading:I,error:L}=SI(j,{enabled:j!==void 0,partitionId:n}),{data:ee,isLoading:R,error:z}=CI(j,{enabled:j!==void 0&&!!F?.payloadRef,partitionId:n}),B=(0,G.useMemo)(()=>rR(void 0,F?.traceId??null,F?.spanId??null),[F?.spanId,F?.traceId,void 0]);(0,G.useEffect)(()=>{g(1)},[]),(0,G.useEffect)(()=>{g(1)},[]),(0,G.useEffect)(()=>{e&&b(e)},[e]),(0,G.useEffect)(()=>{if(!x.current){x.current=!0;return}b(null)},[]),(0,G.useEffect)(()=>{g(1),b(null)},[]);let V=(0,G.useMemo)(()=>(w?.items??[]).map(e=>{let n=e.instanceId??e.commit?.instanceId??e.event?.instanceId,r=n?`[${n}] `:``;if(e.type===`commit`&&e.commit){let i=e.commit;return{type:`commit`,id:tR(i,n),outcome:`--`,duration:`--`,actor:i.actorId,client:i.clientId,detail:`${r}${i.changeCount} chg | ${(i.affectedTables??[]).join(`, `)}`,time:ZL(e.timestamp,t.timeFormat)}}let i=e.event;return i?{type:i.eventType,id:nR(i,n),outcome:i.outcome,duration:`${i.durationMs}ms`,actor:i.actorId,client:i.clientId,detail:`${r}${(i.tables??[]).join(`, `)||`--`}`,time:ZL(e.timestamp,t.timeFormat)}:{type:`pull`,id:`E?`,outcome:`unknown`,duration:`--`,actor:``,client:``,detail:`--`,time:ZL(e.timestamp,t.timeFormat)}}),[t.timeFormat,w?.items]),H=w?.total??0,U=Math.max(1,Math.ceil(H/a)),W=T,te=[{label:``,options:[{id:`all`,label:`All`},{id:`commits`,label:`Commits`},{id:`events`,label:`Events`}],activeId:s,onActiveChange:e=>{c(e),e===`commits`&&(u(`all`),f(`all`)),g(1)}},{label:`Time`,options:[{id:`1h`,label:`1h`},{id:`6h`,label:`6h`},{id:`24h`,label:`24h`},{id:`7d`,label:`7d`},{id:`30d`,label:`30d`}],activeId:r,onActiveChange:e=>{i(e),g(1)}},{label:`Type`,options:[{id:`all`,label:`All`},{id:`push`,label:`Push`},{id:`pull`,label:`Pull`}],activeId:l,onActiveChange:e=>{u(e),g(1)}},{label:`Outcome`,options:[{id:`all`,label:`All`},{id:`applied`,label:`Applied`},{id:`error`,label:`Error`},{id:`rejected`,label:`Rejected`}],activeId:d,onActiveChange:e=>{f(e),g(1)}}];function ne(){D.mutate(void 0,{onSuccess:()=>{v(!1),E()}})}return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[W&&V.length===0?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsx)(WT,{entries:V,selectedEntryId:y,onEntryClick:e=>b(e.id),filterBar:(0,K.jsx)(oT,{groups:te,searchValue:p,searchPlaceholder:`Use actor:, client:, table:, request:, trace: or free text...`,onSearchChange:m,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>void E(),children:`Refresh`}),(0,K.jsx)(Q,{size:`sm`,variant:`ghost`,children:`Export`}),(0,K.jsx)(Q,{size:`sm`,variant:`destructive`,onClick:()=>v(!0),children:`Clear`})]})}),pagination:(0,K.jsx)(CF,{page:h,totalPages:U,totalItems:H,onPageChange:g})}),(0,K.jsx)(gF,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:A===void 0?j===void 0?`Entry details`:`Event E${j}`:`Commit #${A}`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto`,children:N||I?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Qw,{size:`sm`})}):P||L?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load details.`}):M?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.actorId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.clientId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.instanceId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:ZL(M.createdAt,t.timeFormat)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Changes`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.changeCount})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Affected Tables`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:M.affectedTables.join(`, `)||`--`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Changes`}),M.changes.length===0?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No changes recorded.`}):M.changes.map(e=>(0,K.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between font-mono text-[11px]`,children:[(0,K.jsxs)(`span`,{className:`text-neutral-300`,children:[e.table,` | `,e.op]}),(0,K.jsxs)(`span`,{className:`text-neutral-500`,children:[`#`,e.changeId]})]}),(0,K.jsxs)(`div`,{className:`font-mono text-[11px] text-neutral-400`,children:[`rowId: `,e.rowId,e.rowVersion===null?``:` | version: ${e.rowVersion}`]}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(e.rowJson)})]},e.changeId))]})]}):F?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Type`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.eventType})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Path`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.syncPath})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.instanceId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Outcome`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.outcome})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Response Status`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.responseStatus})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.actorId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.clientId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Status`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.statusCode})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Transport`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.transportPath})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Duration`}),(0,K.jsxs)(`div`,{className:`text-neutral-100`,children:[F.durationMs,`ms`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Request ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.requestId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Trace ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.traceId??`--`}),B&&(0,K.jsx)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`font-mono text-[10px] text-flow underline underline-offset-4`,children:`Open external trace`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Span ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.spanId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Commit Seq`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.commitSeq??`--`}),F.commitSeq!==null&&(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>b(`#${F.instanceId?`${F.instanceId}:`:``}${F.commitSeq}`),children:`Open linked commit`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Subscription Count`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.subscriptionCount??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Error Code`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.errorCode??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Payload Ref`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.payloadRef??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:ZL(F.createdAt,t.timeFormat)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Tables`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:F.tables.join(`, `)||`--`})]}),F.scopesSummary&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Scopes Summary`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(F.scopesSummary)})]}),F.payloadRef&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Payload Snapshot`}),R?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Qw,{size:`sm`}),(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`Loading payload snapshot...`})]}):z?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load payload snapshot.`}):ee?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Request`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(ee.requestPayload)}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Response`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(ee.responsePayload)})]}):(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No payload snapshot available.`})]}),F.errorMessage&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Error`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:F.errorMessage})]})]}):(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No details available for this row.`})}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>b(null),children:`Close`})})]})}),(0,K.jsx)(gF,{open:_,onOpenChange:e=>{e||v(!1)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Clear all events`})}),(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`This will permanently delete all request events. Commits are not affected. Are you sure?`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>v(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,size:`sm`,onClick:ne,disabled:D.isPending,children:D.isPending?`Clearing...`:`Clear all`})]})]})})]})}var aR=Vv({getParentRoute:()=>eL,path:`/config`,component:_L}),oR=Vv({getParentRoute:()=>eL,path:`/fleet`,component:ML}),sR=Vv({getParentRoute:()=>eL,path:`/`,component:hL});function cR(){let{seq:e}=lR.useParams();return(0,K.jsx)(iR,{initialSelectedEntryId:`#${e}`})}var lR=Vv({getParentRoute:()=>eL,path:`/investigate/commit/$seq`,component:cR});function uR(){let{id:e}=dR.useParams();return(0,K.jsx)(iR,{initialSelectedEntryId:`E${e}`})}var dR=Vv({getParentRoute:()=>eL,path:`/investigate/event/$id`,component:uR}),fR=Vv({getParentRoute:()=>eL,path:`/ops`,component:VL}),pR=Vv({getParentRoute:()=>eL,path:`/storage`,component:XL}),mR=Vv({getParentRoute:()=>eL,path:`/stream`,component:iR}),hR=eL.addChildren([sR,mR,lR,dR,oR,fR,pR,aR]),gR=`syncular-console-basepath`,_R=`syncular-console-server-url`,vR=`syncular-console-token`;function yR(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function bR(e){let t=globalThis.document;if(!t)return;let n=t.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return yR(n)}function xR(e){return!e||e===`/`?`/`:(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/g,``)||`/`}function SR(){return xR(bR(gR))}function CR(){let e=bR(_R),t=bR(vR);return!e||!t?null:{serverUrl:e,token:t}}function wR(){return new Bm({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function TR(e){return xR(e??SR())}function ER(e){let[t]=(0,G.useState)(()=>wR()),n=(0,G.useMemo)(()=>ry({routeTree:hR,basepath:TR(e.basePath)}),[e.basePath]);return(0,K.jsx)(Wm,{client:t,children:(0,K.jsx)(jy,{defaultConfig:e.defaultConfig===void 0?CR():e.defaultConfig,autoConnect:e.autoConnect??e.defaultConfig===void 0,storageMode:e.storageMode,children:(0,K.jsx)(oy,{router:n})})})}function DR(e){return(0,K.jsx)(`div`,{className:qI,children:(0,K.jsx)(ER,{...e})})}function OR(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Unable to mount console: ${e} not found`);return t}function kR(e,t={}){let n=OR(e);JI(n);let r=(0,Sy.createRoot)(n),i=(0,K.jsx)(DR,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(r.render(i),r):(r.render((0,K.jsx)(G.StrictMode,{children:i})),r)}var AR=`syncular-sentry-dsn`,jR=`syncular-sentry-environment`,MR=`syncular-sentry-release`;function NR(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function PR(e){if(typeof document>`u`)return;let t=document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return NR(t)}function FR(e){if(!(typeof process>`u`))return NR({}[e])}function IR(e){for(let t of e)if(t)return t}function LR(){let e=IR([NR(globalThis.__SYNCULAR_SENTRY_DSN__),PR(AR),FR(`SYNCULAR_SENTRY_DSN`)]);return e?{dsn:e,environment:IR([NR(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),PR(jR),FR(`SYNCULAR_SENTRY_ENVIRONMENT`)]),release:IR([NR(globalThis.__SYNCULAR_SENTRY_RELEASE__),PR(MR),FR(`SYNCULAR_SENTRY_RELEASE`)]),enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}:null}var RR=LR();RR&&wp(RR),kR(`#root`);
|
|
30
|
+
)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function kN(e,t){e&&Object.assign(e.style,t)}var AN={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},jN={position:`fixed`},MN=G.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=oC,..._}=e,{store:v,listRef:y,labelsRef:b,alignItemWithTriggerActiveRef:x,selectedItemTextRef:S,valuesRef:C,initialValueRef:w,popupRef:T,setValue:E}=UM(),D=WM(),O=wA(v,$M.open),k=wA(v,$M.mounted),A=wA(v,$M.modal),j=wA(v,$M.value),M=wA(v,$M.openMethod),N=wA(v,$M.positionerElement),P=wA(v,$M.triggerElement),F=wA(v,$M.isItemEqualToValue),I=wA(v,$M.transitionStatus),L=G.useRef(null),ee=G.useRef(null),[R,z]=G.useState(h),B=k&&R&&M!==`touch`;!k&&R!==h&&z(h),Z(()=>{k||($M.scrollUpArrowVisible(v.state)&&v.set(`scrollUpArrowVisible`,!1),$M.scrollDownArrowVisible(v.state)&&v.set(`scrollDownArrowVisible`,!1))},[v,k]),G.useImperativeHandle(x,()=>B),yN((B||A)&&O&&M!==`touch`,P);let V=$j({anchor:n,floatingRootContext:D,positionMethod:r,mounted:k,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??B,collisionAvoidance:g,keepMounted:!0}),H=B?`none`:V.side,U=B?jN:V.positionerStyles,W=G.useMemo(()=>{let e={};return O||(e.pointerEvents=`none`),{role:`presentation`,hidden:!k,style:{...U,...e}}},[O,k,U]),te={open:O,side:H,align:V.align,anchorHidden:V.anchorHidden},ne=lC(`div`,e,{ref:[t,X(e=>{v.set(`positionerElement`,e)})],state:te,stateAttributesMapping:Pj,props:[W,tM(I),_]}),re=G.useRef(0),ie=X(e=>{if(e.size===0&&re.current===0||C.current.length===0)return;let t=re.current;if(re.current=e.size,e.size===t)return;let n=Aw(vw);if(t!==0&&!v.state.multiple&&j!==null&&qM(C.current,j,F)===-1){let e=w.current,t=e!=null&&qM(C.current,e,F)!==-1?e:null;E(t,n),t===null&&(v.set(`selectedIndex`,null),S.current=null)}if(t!==0&&v.state.multiple&&Array.isArray(j)){let e=e=>qM(C.current,e,F)!==-1,t=j.filter(t=>e(t));(t.length!==j.length||t.some(e=>!KM(j,e,F)))&&(E(t,n),t.length===0&&(v.set(`selectedIndex`,null),S.current=null))}if(O&&B){v.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};kN(N,e),kN(T.current,e)}}),ae=G.useMemo(()=>({...V,side:H,alignItemWithTriggerActive:B,setControlledAlignItemWithTrigger:z,scrollUpArrowRef:L,scrollDownArrowRef:ee}),[V,H,B,z]);return(0,K.jsx)(SN,{elementsRef:y,labelsRef:b,onMapChange:ie,children:(0,K.jsxs)(EN.Provider,{value:ae,children:[k&&A&&(0,K.jsx)(ON,{inert:aM(!O),cutout:P}),ne]})})});function NN(e){let t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}var PN=`base-ui-disable-scrollbar`,FN={className:PN,getElement(e){return(0,K.jsx)(`style`,{nonce:e,href:PN,precedence:`base-ui:low`,children:`.${PN}{scrollbar-width:none}.${PN}::-webkit-scrollbar{display:none}`})}},IN=G.createContext(void 0);function LN(e){let t=G.useContext(IN);if(t===void 0&&!e)throw Error(zS(69));return t}var RN=`ArrowUp`,zN=`ArrowDown`,BN=`ArrowLeft`,VN=`ArrowRight`,HN=`Home`,UN=new Set([BN,VN]),WN=new Set([BN,VN,HN,`End`]),GN=new Set([RN,zN]),KN=new Set([RN,zN,HN,`End`]),qN=new Set([...UN,...GN]),JN=new Set([...qN,HN,`End`]),YN=new Set([RN,zN,BN,VN,HN,`End`]),XN=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function ZN(e){return EC(e)&&e.tagName===`INPUT`}function QN(e){return!!(ZN(e)&&e.selectionStart!=null||EC(e)&&e.tagName===`TEXTAREA`)}function $N(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=eP(e,t,`left`),a=tP(e),o=tP(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=eP(e,t,`top`),r=tP(e),i=tP(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function eP(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function tP(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function nP(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var rP=G.createContext(void 0),iP={disableStyleElements:!1};function aP(){return G.useContext(rP)??iP}var oP=1,sP={...Pj,...IA},cP=G.forwardRef(function(e,t){let{render:n,className:r,finalFocus:i,...a}=e,{store:o,popupRef:s,onOpenChangeComplete:c,setOpen:l,valueRef:u,selectedItemTextRef:d,keyboardActiveRef:f,multiple:p,handleScrollArrowVisibility:m,scrollHandlerRef:h,highlightItemOnHover:g}=UM(),{side:_,align:v,alignItemWithTriggerActive:y,setControlledAlignItemWithTrigger:b,scrollDownArrowRef:x,scrollUpArrowRef:S}=DN(),C=LN(!0)!=null,w=WM(),{nonce:T,disableStyleElements:E}=aP(),D=cE(),O=wA(o,$M.id),k=wA(o,$M.open),A=wA(o,$M.mounted),j=wA(o,$M.popupProps),M=wA(o,$M.transitionStatus),N=wA(o,$M.triggerElement),P=wA(o,$M.positionerElement),F=wA(o,$M.listElement),I=G.useRef(0),L=G.useRef(!1),ee=G.useRef(0),R=G.useRef(!1),z=G.useRef({}),B=SO(),V=X(e=>{if(!P||!s.current||!R.current)return;if(L.current||!y){m();return}let t=P.style.top===`0px`,n=P.style.bottom===`0px`,r=P.getBoundingClientRect().height,i=rO(P),a=getComputedStyle(P),o=parseFloat(a.marginTop),c=parseFloat(a.marginBottom),l=lP(getComputedStyle(s.current)),u=Math.min(i.documentElement.clientHeight-o-c,l),d=e.scrollTop,f=uP(e),p=0,h=null,g=!1,_=!1,v=e=>{P.style.height=`${e}px`},b=(t,n)=>{let i=nP(t,0,u-r);i>0&&v(r+i),e.scrollTop=n,u-(r+i)<=oP&&(L.current=!0),m()};if(t){let e=f-d,t=r+e,n=Math.min(t,u);if(p=n,e<=oP){b(e,f);return}u-n>oP?_=!0:g=!0}else if(n){let e=d,t=r+e,n=Math.min(t,u),i=t-u;if(p=n,e<=oP){b(e,0);return}u-n>oP?h=0:(g=!0,d<f&&(h=d-(e-i)))}if(p=Math.ceil(p),p!==0&&v(p),_||h!=null){let t=uP(e),n=_?t:nP(h,0,t);Math.abs(e.scrollTop-n)>oP&&(e.scrollTop=n)}(g||p>=u-oP)&&(L.current=!0),m()});G.useImperativeHandle(h,()=>V,[V]),RA({open:k,ref:s,onComplete(){k&&c?.(!0)}});let H={open:k,transitionStatus:M,side:_,align:v};Z(()=>{!P||!s.current||Object.keys(z.current).length||(z.current={top:P.style.top||`0`,left:P.style.left||`0`,right:P.style.right,height:P.style.height,bottom:P.style.bottom,minHeight:P.style.minHeight,maxHeight:P.style.maxHeight,marginTop:P.style.marginTop,marginBottom:P.style.marginBottom})},[s,P]),Z(()=>{k||y||(R.current=!1,L.current=!1,I.current=0,ee.current=0,kN(P,z.current))},[k,y,P,s]),Z(()=>{let e=s.current;if(!(!k||!N||!P||!e||o.state.transitionStatus===`ending`)){if(!y){R.current=!0,B.request(m),e.style.removeProperty(`--transform-origin`);return}queueMicrotask(()=>{let t=mP(e);e.style.removeProperty(`--transform-origin`);try{let t=getComputedStyle(P),n=getComputedStyle(e),r=rO(N),i=SC(P),a=dP(N),o=fP(N.getBoundingClientRect(),a),s=fP(P.getBoundingClientRect(),a),c=o.left,l=o.height,f=F||e,p=f.scrollHeight,h=parseFloat(n.borderBottomWidth),g=parseFloat(t.marginTop)||10,_=parseFloat(t.marginBottom)||10,v=parseFloat(t.minHeight)||100,y=lP(n),x=r.documentElement.clientHeight-g-_,S=r.documentElement.clientWidth,C=x-o.bottom+l,w=d.current,T=u.current,E,D=0,O=0;if(w&&T){let e=fP(T.getBoundingClientRect(),a);E=fP(w.getBoundingClientRect(),a);let t=e.left-c,n=E.left-s.left,r=e.top-o.top+e.height/2,i=E.top-s.top+E.height/2;D=t-n,O=i-r}let k=C+O+_+h,A=Math.min(x,k),j=x-g-_,M=k-A,ee=Math.max(5,c+D),B=S-5,V=Math.max(0,ee+s.width-B);P.style.left=`${ee-V}px`,P.style.height=`${A}px`,P.style.maxHeight=`auto`,P.style.marginTop=`${g}px`,P.style.marginBottom=`${_}px`,e.style.height=`100%`;let H=uP(f),U=M>=H-oP;U&&(A=Math.min(x,s.height)-(M-H));let W=o.top<20||o.bottom>x-20||Math.ceil(A)+oP<Math.min(p,v),te=(i.visualViewport?.scale??1)!==1&&pE;if(W||te){R.current=!0,kN(P,z.current),Ev.flushSync(()=>b(!1));return}if(U){let e=Math.max(0,x-k);P.style.top=s.height>=j?`0`:`${e}px`,P.style.height=`${A}px`,f.scrollTop=uP(f),I.current=Math.max(v,A)}else P.style.bottom=`0`,I.current=Math.max(v,A),f.scrollTop=M;if(E){let t=s.top,n=s.height,r=E.top+E.height/2,i=nP(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(I.current===x||A>=y)&&(L.current=!0),m(),setTimeout(()=>{R.current=!0})}finally{t()}})}},[o,k,P,N,u,d,s,m,y,b,B,x,S,F]),G.useEffect(()=>{if(!y||!P||!k)return;let e=SC(P);function t(e){l(!1,Aw(kw,e))}return e.addEventListener(`resize`,t),()=>{e.removeEventListener(`resize`,t)}},[l,y,P,k]);let U={...F?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":p||void 0,id:`${O}-list`},onKeyDown(e){f.current=!0,C&&YN.has(e.key)&&e.stopPropagation()},onMouseMove(){f.current=!1},onPointerLeave(e){if(!g||NN(e)||e.pointerType===`touch`)return;let t=e.currentTarget;D.start(0,()=>{o.set(`activeIndex`,null),t.focus({preventScroll:!0})})},onScroll(e){F||V(e.currentTarget)},...y&&{style:F?{height:`100%`}:AN}},W=lC(`div`,e,{ref:[t,s],state:H,stateAttributesMapping:sP,props:[j,U,tM(M),{className:!F&&y?FN.className:void 0},a]});return(0,K.jsxs)(G.Fragment,{children:[!E&&FN.getElement(T),(0,K.jsx)(ak,{context:w,modal:!1,disabled:!A,returnFocus:i,restoreFocus:!0,children:W})]})});function lP(e){let t=e.maxHeight||``;return t.endsWith(`px`)&&parseFloat(t)||1/0}function uP(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function dP(e){return $k.getScale(e)}function fP(e,t){return hD({x:e.x/t.x,y:e.y/t.y,width:e.width/t.x,height:e.height/t.y})}var pP=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function mP(e){let{style:t}=e,n={};for(let[e,r]of pP)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of pP){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var hP=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function gP(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:d}=xN(),f=G.useRef(-1),[p,m]=G.useState(a??(i===hP.GuessFromOrder?()=>{if(f.current===-1){let e=d.current;d.current+=1,f.current=e}return f.current}:-1)),h=G.useRef(null),g=G.useCallback(e=>{if(h.current=e,p!==-1&&e!==null&&(l.current[p]=e,u)){let n=t!==void 0;u.current[p]=n?t:r?.current?.textContent??e.textContent}},[p,l,u,t,r]);return Z(()=>{if(a!=null)return;let e=h.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),Z(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&m(t)})},[a,c,m]),G.useMemo(()=>({ref:g,index:p}),[p,g])}var _P=G.createContext(void 0),vP=G.memo(G.forwardRef(function(e,t){let{render:n,className:r,value:i=null,label:a,disabled:o=!1,nativeButton:s=!1,...c}=e,l=G.useRef(null),u=gP({label:a,textRef:l,indexGuessBehavior:hP.GuessFromOrder}),{store:d,getItemProps:f,setOpen:p,setValue:m,selectionRef:h,typingRef:g,valuesRef:_,keyboardActiveRef:v,multiple:y,highlightItemOnHover:b}=UM(),x=cE(),S=wA(d,$M.isActive,u.index),C=wA(d,$M.isSelected,u.index,i),w=wA(d,$M.isSelectedByFocus,u.index),T=wA(d,$M.isItemEqualToValue),E=u.index,D=E!==-1,O=G.useRef(null),k=_O(E);Z(()=>{if(!D)return;let e=_.current;return e[E]=i,()=>{delete e[E]}},[D,E,i,_]),Z(()=>{if(!D)return;let e=d.state.value,t=e;y&&Array.isArray(e)&&e.length>0&&(t=e[e.length-1]),t!==void 0&&GM(i,t,T)&&d.set(`selectedIndex`,E)},[D,E,y,T,d,i]);let A={disabled:o,selected:C,highlighted:S},j=f({active:S,selected:C});j.onFocus=void 0,j.id=void 0;let M=G.useRef(null),N=G.useRef(`mouse`),P=G.useRef(!1),{getButtonProps:F,buttonRef:I}=JC({disabled:o,focusableWhenDisabled:!0,native:s,composite:!0});function L(e){let t=d.state.value;if(y){let n=Array.isArray(t)?t:[];m(C?JM(n,i,T):[...n,i],Aw(Cw,e))}else m(i,Aw(Cw,e)),p(!1,Aw(Cw,e))}let ee={role:`option`,"aria-selected":C,tabIndex:S?0:-1,onFocus(){d.set(`activeIndex`,E)},onMouseEnter(){!v.current&&d.state.selectedIndex===null&&b&&d.set(`activeIndex`,E)},onMouseMove(){b&&d.set(`activeIndex`,E)},onMouseLeave(e){!b||v.current||NN(e)||x.start(0,()=>{d.state.activeIndex===E&&d.set(`activeIndex`,null)})},onTouchStart(){h.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(e){M.current=e.key,d.set(`activeIndex`,E),e.key===` `&&g.current&&e.preventDefault()},onClick(e){P.current=!1,!(e.type===`keydown`&&M.current===null)&&(o||e.type===`keydown`&&M.current===` `&&g.current||N.current!==`touch`&&!S||(M.current=null,L(e.nativeEvent)))},onPointerEnter(e){N.current=e.pointerType},onPointerDown(e){N.current=e.pointerType,P.current=!0},onMouseUp(){if(o)return;if(P.current){P.current=!1;return}let e=!h.current.allowSelectedMouseUp&&C,t=!h.current.allowUnselectedMouseUp&&!C;e||t||N.current!==`touch`&&!S||O.current?.click()}},R=lC(`div`,e,{ref:[I,t,u.ref,O],state:A,props:[j,ee,c,F]}),z=G.useMemo(()=>({selected:C,indexRef:k,textRef:l,selectedByFocus:w,hasRegistered:D}),[C,k,l,w,D]);return(0,K.jsx)(_P.Provider,{value:z,children:R})})),yP=(0,G.forwardRef)(({className:e,children:t,...n},r)=>(0,K.jsx)(cN,{ref:r,className:Y(`inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition`,e),...n,children:t}));yP.displayName=`SelectTrigger`;var bP=(0,G.forwardRef)(({className:e,portalProps:t,positionerProps:n,...r},i)=>(0,K.jsx)(uN,{...t,children:(0,K.jsx)(MN,{...n,children:(0,K.jsx)(cP,{ref:i,className:Y(`bg-panel border border-border rounded-md py-1 shadow-lg z-50`,e),...r})})}));bP.displayName=`SelectContent`;var xP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(vP,{ref:n,className:Y(`font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none`,e),...t}));xP.displayName=`SelectItem`;var SP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`textarea`,{ref:n,className:Y(`bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]`,e),...t}));SP.displayName=`Textarea`;var CP=G.createContext(void 0);function wP(e=!0){let t=G.useContext(CP);if(t===void 0&&!e)throw Error(zS(7));return t}function TP(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=KC(),{ref:i,index:a}=gP(e),o=n===a,s=G.useRef(null),c=ES(i,s);return{compositeProps:G.useMemo(()=>({tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}}),[o,r,a,t]),compositeRef:c,index:a}}function EP(e){let{render:t,className:n,state:r=LS,props:i=IS,refs:a=IS,metadata:o,stateAttributesMapping:s,tag:c=`div`,...l}=e,{compositeProps:u,compositeRef:d}=TP({metadata:o});return lC(c,e,{state:r,ref:[...a,d],props:[u,...i,l],stateAttributesMapping:s})}var DP=G.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,...f}=e,p=yC(u||void 0),m=wP(),h=m?.value??[],g=m?void 0:r,_=(i||m?.disabled)??!1,[v,y]=yS({controlled:m?p!==void 0&&h.indexOf(p)>-1:s,default:g,name:`Toggle`,state:`pressed`}),b=X((e,t)=>{p&&m?.setGroupValue?.(p,e,t),o?.(e,t)}),{getButtonProps:x,buttonRef:S}=JC({disabled:_,native:d}),C={disabled:_,pressed:v},w=[S,t],T=[{"aria-pressed":v,onClick(e){let t=!v,n=Aw(vw,e.nativeEvent);b(t,n),!n.isCanceled&&y(t)}},f,x],E=lC(`button`,e,{enabled:!m,state:C,ref:w,props:T});return m?(0,K.jsx)(EP,{tag:`button`,render:c,className:n,state:C,refs:w,props:T}):E}),OP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(DP,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]`,e),...t}));OP.displayName=`Toggle`;function kP(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var AP=`data-composite-item-active`,jP=[];function MP(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=jP}=e,[m,h]=G.useState(0),g=n>1,_=G.useRef(null),v=ES(_,l),y=G.useRef([]),b=G.useRef(!1),x=s??m,S=X((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];$N(_.current,t,o,a)}}),C=X(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),$N(_.current,n,o,a)}),w=G.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){!_.current||!QN(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?JN:qN;if(!s.has(e.key)||NP(e,p)||!_.current)return;let c=o===`rtl`,l=c?BN:VN,m={horizontal:l,vertical:zN,both:l}[a],h=c?VN:BN,v={horizontal:h,vertical:RN,both:h}[a];if(QN(e.target)&&!kP(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=vD(y,f),w=yD(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=SD(o,n,i),l=s.findIndex(e=>e!=null&&!TD(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!TD(y,t,f)?n:e,-1);b=s[xD({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:wD([...f||y.current.map((e,t)=>TD(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:CD(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[zN],both:[l,zN]}[a],E={horizontal:[h],vertical:[RN],both:[h,RN]}[a],D=g?s:{horizontal:u?WN:UN,vertical:u?KN:GN,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:bD(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!_D(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return G.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function NP(e,t){for(let n of XN.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function PP(e){let{render:t,className:n,refs:r=IS,props:i=IS,state:a=LS,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=MP({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:Gj(),disabledIndices:v,modifierKeys:y}),k=lC(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=G.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,K.jsx)(GC.Provider,{value:A,children:(0,K.jsx)(SN,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var FP=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),IP={multiple(e){return e?{[FP.multiple]:``}:null}},LP=G.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,...d}=e,f=LN(!0),p=G.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),m=G.useMemo(()=>c!==void 0||n!==void 0,[c,n]),h=(f?.disabled??!1)||r,[g,_]=yS({controlled:c,default:p,name:`ToggleGroup`,state:`value`}),v=X((e,t,n)=>{let r;if(s?(r=g.slice(),t?r.push(e):r.splice(g.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;_(r)}}),y={disabled:h,multiple:s,orientation:o},b=G.useMemo(()=>({disabled:h,orientation:o,setGroupValue:v,value:g,isValueInitialized:m}),[h,o,v,g,m]),x={role:`group`},S=lC(`div`,e,{enabled:!!f,state:y,ref:t,props:[x,d],stateAttributesMapping:IP});return(0,K.jsx)(CP.Provider,{value:b,children:f?S:(0,K.jsx)(PP,{render:u,className:l,state:y,refs:[t],props:[x,d],stateAttributesMapping:IP,loopFocus:i,enableHomeAndEndKeys:!0})})}),RP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(LP,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));RP.displayName=`ToggleGroup`;var zP=Y(Yw({variant:`secondary`,size:`sm`}),`h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline`);function BP({active:e,onClick:t,children:n,className:r}){return(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:Y(`font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors`,e?`text-white`:`text-neutral-500 hover:text-neutral-300`,r),children:[n,e&&(0,K.jsx)(`span`,{className:`absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]`})]})}function VP({items:e,activeId:t,onItemChange:n,renderItem:r,className:i}){return(0,K.jsx)(`div`,{className:Y(`flex items-center gap-0.5`,i),children:e.map(e=>{let i=e.id===t,a=()=>n?.(e.id);return r?(0,K.jsx)(`span`,{children:r(e,{active:i,onClick:a})},e.id):(0,K.jsx)(BP,{active:i,onClick:a,children:e.label},e.id)})})}var HP=gS(`rounded-full inline-block flex-shrink-0`,{variants:{color:{healthy:`bg-healthy`,syncing:`bg-syncing`,offline:`bg-offline`,flow:`bg-flow`,relay:`bg-relay`,encrypt:`bg-encrypt`,muted:`bg-neutral-500`},size:{sm:`w-1.5 h-1.5`,md:`w-2 h-2`,lg:`w-2.5 h-2.5`},glow:{true:``,false:``}},defaultVariants:{color:`healthy`,size:`sm`,glow:!1}}),UP={healthy:`0 0 6px #22c55e`,syncing:`0 0 6px #f59e0b`,offline:`0 0 6px #ef4444`,flow:`0 0 6px #3b82f6`,relay:`0 0 6px #8b5cf6`,encrypt:`0 0 6px #f472b6`,muted:`none`};function WP({color:e,size:t,glow:n,pulse:r,className:i}){return(0,K.jsx)(`span`,{className:Y(HP({color:e,size:t,glow:n}),r&&`dot-pulse`,i),style:n?{boxShadow:UP[e??`healthy`]}:void 0})}var GP={name:`@syncular/ui`,version:`0.0.6-248`,description:`Reusable Syncular UI components and styles`,license:`Apache-2.0`,author:`Benjamin Kniffler`,homepage:`https://syncular.dev`,repository:{type:`git`,url:`https://github.com/syncular/syncular.git`,directory:`packages/ui`},bugs:{url:`https://github.com/syncular/syncular/issues`},keywords:[`sync`,`offline-first`,`realtime`,`ui`,`react`],publishConfig:{access:`public`},type:`module`,exports:{".":{bun:`./src/index.ts`,browser:`./src/index.ts`,import:{types:`./dist/index.d.ts`,default:`./dist/index.js`}},"./charts":{bun:`./src/charts/index.ts`,browser:`./src/charts/index.ts`,import:{types:`./dist/charts/index.d.ts`,default:`./dist/charts/index.js`}},"./console":{bun:`./src/console/index.ts`,browser:`./src/console/index.ts`,import:{types:`./dist/console/index.d.ts`,default:`./dist/console/index.js`}},"./forms":{bun:`./src/forms/index.ts`,browser:`./src/forms/index.ts`,import:{types:`./dist/forms/index.d.ts`,default:`./dist/forms/index.js`}},"./primitives":{bun:`./src/primitives/index.ts`,browser:`./src/primitives/index.ts`,import:{types:`./dist/primitives/index.d.ts`,default:`./dist/primitives/index.js`}},"./observable-universe":{bun:`./src/observable-universe/index.ts`,browser:`./src/observable-universe/index.ts`,import:{types:`./dist/observable-universe/index.d.ts`,default:`./dist/observable-universe/index.js`}},"./demo":{bun:`./src/demo/index.ts`,browser:`./src/demo/index.ts`,import:{types:`./dist/demo/index.d.ts`,default:`./dist/demo/index.js`}},"./navigation":{bun:`./src/navigation/index.ts`,browser:`./src/navigation/index.ts`,import:{types:`./dist/navigation/index.d.ts`,default:`./dist/navigation/index.js`}},"./styles.css":`./dist/styles.css`,"./styles.source.css":`./src/styles/styles.css`,"./styles/tokens.css":`./src/styles/tokens.css`,"./package.json":`./package.json`},files:[`dist`,`src`],scripts:{tsgo:`tsgo --noEmit`,"build:css":`bunx @tailwindcss/cli -i src/styles/styles.css -o dist/styles.css`,build:`tsgo && bun run build:css`,release:`bunx syncular-publish`},peerDependencies:{react:`^19.0.0`,"react-dom":`^19.0.0`},dependencies:{"@base-ui/react":`^1.3.0`,"class-variance-authority":`^0.7.1`,clsx:`^2.1.1`,"lucide-react":`^1.7.0`,recharts:`^3.8.1`,"tailwind-merge":`^3.5.0`,tailwindcss:`^4.2.2`},devDependencies:{"@syncular/config":`workspace:*`,"@tailwindcss/cli":`^4.2.2`,"@types/react":`^19.2.14`}}.version;function KP({label:e,className:t}){return(0,K.jsxs)(`div`,{className:Y(`flex items-center gap-3`,t),children:[(0,K.jsx)(WP,{color:`healthy`,size:`md`,glow:!0}),(0,K.jsx)(`span`,{className:`font-display font-bold text-white text-sm tracking-tight`,children:`syncular`}),e&&(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-600 uppercase tracking-widest`,children:e}),(0,K.jsxs)(`span`,{className:`font-mono text-[9px] text-neutral-600 tracking-wider`,children:[`v`,GP]})]})}function qP({brand:e,center:t,right:n,className:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`h-[42px] shrink-0`}),(0,K.jsxs)(`nav`,{className:Y(`fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5`,r),children:[(0,K.jsx)(`div`,{className:`flex items-center gap-3`,children:e}),(0,K.jsx)(`div`,{className:`flex items-center gap-0.5`,children:t}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})]})}var JP=gS(`border rounded-lg p-3 font-mono text-[11px]`,{variants:{variant:{default:`border-border bg-panel`,destructive:`border-offline/20 bg-offline/5 text-offline`}},defaultVariants:{variant:`default`}}),YP=(0,G.forwardRef)(({className:e,variant:t,...n},r)=>(0,K.jsx)(`div`,{ref:r,role:`alert`,className:Y(JP({variant:t,className:e})),...n}));YP.displayName=`Alert`;var XP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`h5`,{ref:n,className:Y(`font-medium text-white mb-1`,e),...t}));XP.displayName=`AlertTitle`;var ZP=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`text-neutral-400`,e),...t}));ZP.displayName=`AlertDescription`;var QP=G.createContext(void 0);function $P(e){let t=G.useContext(QP);if(e===!1&&t===void 0)throw Error(zS(27));return t}var eF={...Pj,...IA},tF=G.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=$P(),s=o.useState(`open`),c=o.useState(`nested`),l=o.useState(`mounted`);return lC(`div`,e,{state:{open:s,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:eF,props:[{role:`presentation`,hidden:!l,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!c})}),nF=G.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=$P(),s=yC(i);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),lC(`p`,e,{ref:t,props:[{id:s},a]})}),rF=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),iF=function(e){return e[e.open=Tj.open]=`open`,e[e.closed=Tj.closed]=`closed`,e[e.startingStyle=Tj.startingStyle]=`startingStyle`,e[e.endingStyle=Tj.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),aF=G.createContext(void 0);function oF(){let e=G.useContext(aF);if(e===void 0)throw Error(zS(26));return e}var sF={...Pj,...IA,nestedDialogOpen(e){return e?{[iF.nestedDialogOpen]:``}:null}},cF=G.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:s}=$P(),c=s.useState(`descriptionElementId`),l=s.useState(`disablePointerDismissal`),u=s.useState(`floatingRootContext`),d=s.useState(`popupProps`),f=s.useState(`modal`),p=s.useState(`mounted`),m=s.useState(`nested`),h=s.useState(`nestedOpenDialogCount`),g=s.useState(`open`),_=s.useState(`openMethod`),v=s.useState(`titleElementId`),y=s.useState(`transitionStatus`),b=s.useState(`role`);oF(),RA({open:g,ref:s.context.popupRef,onComplete(){g&&s.context.onOpenChangeComplete?.(!0)}});function x(e){return e===`touch`?s.context.popupRef.current:!0}let S=i===void 0?x:i,C=lC(`div`,e,{state:{open:g,nested:m,transitionStatus:y,nestedDialogOpen:h>0},props:[d,{"aria-labelledby":v??void 0,"aria-describedby":c??void 0,role:b,tabIndex:-1,hidden:!p,onKeyDown(e){YN.has(e.key)&&e.stopPropagation()},style:{[rF.nestedDialogs]:h}},o],ref:[t,s.context.popupRef,s.useStateSetter(`popupElement`)],stateAttributesMapping:sF});return(0,K.jsx)(ak,{context:u,openInteractionType:_,disabled:!p,closeOnFocusOut:!l,initialFocus:S,returnFocus:r,modal:f!==!1,restoreFocus:`popup`,children:C})}),lF=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=$P(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,K.jsx)(aF.Provider,{value:n,children:(0,K.jsxs)(UO,{ref:t,...r,children:[a&&o===!0&&(0,K.jsx)(ON,{ref:i.context.internalBackdropRef,inert:aM(!s)}),e.children]})}):null});function uF(e){let{store:t,parentContext:n,actionsRef:r}=e,i=t.useState(`open`),a=t.useState(`disablePointerDismissal`),o=t.useState(`modal`),s=t.useState(`popupElement`),{openMethod:c,triggerProps:l}=tN(i);VA(t);let{forceUnmount:u}=HA(i,t),d=X(e=>{let n=Aw(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),f=G.useCallback(()=>{t.setOpen(!1,d(Ow))},[t,d]);G.useImperativeHandle(r,()=>({unmount:u,close:f}),[u,f]);let p=XA({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[m,h]=G.useState(0),g=m===0,_=fj(p),v=fk(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=DE(e);if(g&&!a){let e=n;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||TE(e,s)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:g});yN(i&&o===!0,s);let{getReferenceProps:y,getFloatingProps:b,getTriggerProps:x}=cj([_,v]);t.useContextCallback(`onNestedDialogOpen`,e=>{h(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{h(0)}),G.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(m),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,m]);let S=G.useMemo(()=>y(l),[y,l]),C=G.useMemo(()=>x(l),[x,l]),w=G.useMemo(()=>b(),[b]);t.useSyncedValues({openMethod:c,activeTriggerProps:S,inactiveTriggerProps:C,popupProps:w,floatingRootContext:p,nestedOpenDialogCount:m})}var dF={...qA,modal:$(e=>e.modal),nested:$(e=>e.nested),nestedOpenDialogCount:$(e=>e.nestedOpenDialogCount),disablePointerDismissal:$(e=>e.disablePointerDismissal),openMethod:$(e=>e.openMethod),descriptionElementId:$(e=>e.descriptionElementId),titleElementId:$(e=>e.titleElementId),viewportElement:$(e=>e.viewportElement),role:$(e=>e.role)},fF=class extends kA{constructor(e){super(pF(e),{popupRef:G.createRef(),backdropRef:G.createRef(),internalBackdropRef:G.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new UA,onOpenChange:void 0,onOpenChangeComplete:void 0},dF)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function pF(e={}){return{...GA(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}function mF(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=$P(!0),p=!!f,m=xS(()=>l?.store??new fF({open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:p})).current;tE(()=>{n===void 0&&m.state.open===!1&&r===!0&&m.update({open:!0,activeTriggerId:d})}),m.useControlledProp(`openProp`,n),m.useControlledProp(`triggerIdProp`,u),m.useSyncedValues({disablePointerDismissal:o,nested:p,modal:s}),m.useContextCallback(`onOpenChange`,i),m.useContextCallback(`onOpenChangeComplete`,a);let h=m.useState(`payload`);uF({store:m,actionsRef:c,parentContext:f?.store.context,onOpenChange:i,triggerIdProp:u});let g=G.useMemo(()=>({store:m}),[m]);return(0,K.jsx)(QP.Provider,{value:g,children:typeof t==`function`?t({payload:h}):t})}var hF=G.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=$P(),s=yC(i);return o.useSyncedValueWithCleanup(`titleElementId`,s),lC(`h2`,e,{ref:t,props:[{id:s},a]})}),gF=mF,_F=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(tF,{ref:n,className:Y(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`,e),...t}));_F.displayName=`DialogOverlay`;var vF=(0,G.forwardRef)(({className:e,children:t,...n},r)=>(0,K.jsxs)(lF,{children:[(0,K.jsx)(tF,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(cF,{ref:r,className:Y(`fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0`,e),...n,children:t})]}));vF.displayName=`DialogContent`;var yF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));yF.displayName=`DialogHeader`;var bF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));bF.displayName=`DialogFooter`;var xF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(hF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));xF.displayName=`DialogTitle`;var SF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(nF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));SF.displayName=`DialogDescription`;var CF=(0,G.forwardRef)(({className:e,page:t,totalPages:n,totalItems:r,onPageChange:i,...a},o)=>(0,K.jsxs)(`div`,{ref:o,className:Y(`px-5 py-2.5 border-t border-border flex items-center justify-between`,e),...a,children:[(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-600`,children:[r,` items · Page `,t,` of `,n]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Q,{size:`sm`,variant:`default`,disabled:t<=1,onClick:()=>i(t-1),children:`Prev`}),(0,K.jsx)(Q,{size:`sm`,variant:`default`,disabled:t>=n,onClick:()=>i(t+1),children:`Next`})]})]}));CF.displayName=`Pagination`;var wF=(0,G.forwardRef)(({className:e,orientation:t=`horizontal`,...n},r)=>(0,K.jsx)(`hr`,{ref:r,"aria-orientation":t===`vertical`?`vertical`:void 0,className:Y(`border-none m-0`,t===`horizontal`?`h-px w-full bg-border`:`w-px h-4 bg-border`,e),...n}));wF.displayName=`Separator`;var TF=gS(`fixed z-50 bg-panel shadow-lg overflow-auto`,{variants:{side:{top:`top-0 left-0 w-full h-[400px] border-b border-border`,right:`right-0 top-0 h-full w-[400px] border-l border-border`,bottom:`bottom-0 left-0 w-full h-[400px] border-t border-border`,left:`left-0 top-0 h-full w-[400px] border-r border-border`}},defaultVariants:{side:`right`}}),EF=(0,G.forwardRef)(({className:e,side:t,children:n,...r},i)=>(0,K.jsxs)(lF,{children:[(0,K.jsx)(tF,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(cF,{ref:i,className:Y(TF({side:t,className:e})),...r,children:n})]}));EF.displayName=`SheetContent`;var DF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));DF.displayName=`SheetHeader`;var OF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));OF.displayName=`SheetFooter`;var kF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(hF,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));kF.displayName=`SheetTitle`;var AF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(nF,{ref:n,className:Y(`text-sm text-neutral-400`,e),...t}));AF.displayName=`SheetDescription`;var jF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`div`,{ref:n,className:Y(`rounded-md bg-neutral-800 animate-pulse`,e),...t}));jF.displayName=`Skeleton`;var MF=G.createContext(void 0);function NF(){let e=G.useContext(MF);if(e===void 0)throw Error(zS(64));return e}var PF=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),FF={tabActivationDirection:e=>({[PF.activationDirection]:e})},IF=G.createContext(void 0);function LF(){let e=G.useContext(IF);if(e===void 0)throw Error(zS(65));return e}var RF=G.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=NF(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=LF(),v=yC(o),{compositeProps:y,compositeRef:b,index:x}=TP({metadata:G.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a])}),S=a===l,C=G.useRef(!1),w=G.useRef(null);G.useEffect(()=>{let e=w.current;if(e)return h(e)},[h]),Z(()=>{if(C.current){C.current=!1;return}if(!(S&&x>-1&&p!==x))return;let e=_;if(e!=null){let t=wE(rO(e));if(t&&TE(e,t))return}r||g(x)},[S,x,p,g,r,_]);let{getButtonProps:T,buttonRef:E}=JC({disabled:r,native:s,focusableWhenDisabled:!0}),D=u(a),O=G.useRef(!1),k=G.useRef(!1);function A(e){S||r||m(a,Aw(vw,e.nativeEvent,void 0,{activationDirection:`none`}))}function j(e){S||(x>-1&&!r&&g(x),!r&&f&&(!O.current||O.current&&k.current)&&m(a,Aw(vw,e.nativeEvent,void 0,{activationDirection:`none`})))}function M(e){if(S||r)return;O.current=!0;function t(){O.current=!1,k.current=!1}(!e.button||e.button===0)&&(k.current=!0,rO(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return lC(`button`,e,{state:{disabled:r,active:S,orientation:d},ref:[t,E,b,w],props:[y,{role:`tab`,"aria-controls":D,"aria-selected":S,id:v,onClick:A,onFocus:j,onPointerDown:M,[AP]:S?``:void 0,onKeyDownCapture(){C.current=!0}},c,T]})}),zF=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=NA.startingStyle]=`startingStyle`,e[e.endingStyle=NA.endingStyle]=`endingStyle`,e}({}),BF={...FF,...IA},VF=G.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=NF(),p=yC(),{ref:m,index:h}=gP({metadata:G.useMemo(()=>({id:p,value:r}),[p,r])}),g=r===s,{mounted:_,transitionStatus:v,setMounted:y}=MA(g),b=!_,x=c(r),S={hidden:b,orientation:l,tabActivationDirection:u,transitionStatus:v},C=G.useRef(null),w=lC(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:aM(!g),[zF.index]:h},o],stateAttributesMapping:BF});return RA({open:g,ref:C,onComplete(){g||y(!1)}}),Z(()=>{if(!(b&&!a)&&p!=null)return d(r,p),()=>{f(r,p)}},[b,a,r,p,d,f]),a||_?w:null}),HF=G.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=NF(),[p,m]=G.useState(0),[h,g]=G.useState(null),_=G.useRef(new Set),v=G.useRef(new Set),y=G.useRef(null),b=X(()=>{_.current.forEach(e=>{e()})});G.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=X(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=X(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=WF(u,l,h,s),w=X((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=G.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,K.jsx)(IF.Provider,{value:D,children:(0,K.jsx)(PP,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:FF,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:IS})})});function UF(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function WF(e,t,n,r){let[i,a]=G.useState(null);return Z(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=UF(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),G.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=UF(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var GF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(HF,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));GF.displayName=`TabsList`;var KF=gS(`inline-flex items-center justify-center cursor-pointer transition-all outline-none`,{variants:{variant:{default:`font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]`,pills:`font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]`}},defaultVariants:{variant:`default`}}),qF=(0,G.forwardRef)(({className:e,variant:t,...n},r)=>(0,K.jsx)(RF,{ref:r,className:Y(KF({variant:t,className:e})),...n}));qF.displayName=`TabsTrigger`;var JF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(VF,{ref:n,className:Y(`outline-none`,e),...t}));JF.displayName=`TabsContent`;var YF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300`,e),...t}));YF.displayName=`Text`;var XF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`p`,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));XF.displayName=`TextMuted`;var ZF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`code`,{ref:n,className:Y(`font-mono text-[11px] text-white`,e),...t}));ZF.displayName=`TextCode`;var QF=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`span`,{ref:n,className:Y(`font-mono text-[9px] uppercase tracking-wider text-neutral-500`,e),...t}));QF.displayName=`TextLabel`;var $F=(0,G.forwardRef)(({className:e,...t},n)=>(0,K.jsx)(`pre`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto`,e),...t}));$F.displayName=`CodeBlock`;function eI(e,t){let[n,r]=(0,G.useState)(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}});return(0,G.useEffect)(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,(0,G.useCallback)(e=>{r(t=>typeof e==`function`?e(t):e)},[])]}var tI=`console:instance-id`;function nI(){let[e,t]=eI(tI,``),n=e.trim();return(0,G.useMemo)(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t(``)}),[n,e,t])}var rI={stats:e=>[`console`,`stats`,e],timeseries:e=>[`console`,`stats`,`timeseries`,e],latency:e=>[`console`,`stats`,`latency`,e],commits:e=>[`console`,`commits`,e],commitDetail:(e,t,n)=>[`console`,`commit-detail`,e,t,n],timeline:e=>[`console`,`timeline`,e],clients:e=>[`console`,`clients`,e],eventDetail:(e,t,n)=>[`console`,`event-detail`,e,t,n],eventPayload:(e,t,n)=>[`console`,`event-payload`,e,t,n],handlers:e=>[`console`,`handlers`,e],prunePreview:e=>[`console`,`prune`,`preview`,e],operations:e=>[`console`,`operations`,e],apiKeys:e=>[`console`,`api-keys`,e],storage:e=>[`console`,`storage`,e]};function iI(e,t){return e===0?!1:e??t}function aI(e){let t=new URLSearchParams;if(!e)return t;for(let[n,r]of Object.entries(e))r!=null&&t.set(n,String(r));return t}function oI(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e,i=aI(n)?.toString();return`${r}${t}${i?`?${i}`:``}`}function sI(e,t){if(!t||!e)throw Error(`Not connected`);return e}async function cI(e){let t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t[`Content-Type`]=`application/json`);let n=await fetch(oI(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??`GET`,headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw Error(e.errorMessage);return n.json()}async function lI(e){let t=await fetch(oI(e.connectionConfig.serverUrl,e.path,e.query),{method:`GET`,headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw Error(e.errorMessage);return t.blob()}function uI(e){let{config:t,isConnected:n}=Ny();return ih({queryKey:e.queryKey,queryFn:()=>cI({connectionConfig:sI(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function dI(e){let{config:t,isConnected:n}=Ny();return ih({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw Error(e.requiredMessage);return cI({connectionConfig:sI(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function fI(e,t){for(let n of t)e.invalidateQueries({queryKey:n})}function pI(e){let{instanceId:t}=nI();return e??t}function mI(e){let{config:t,isConnected:n}=Ny(),{instanceId:r}=nI(),i=Um();return ah({mutationFn:i=>e.mutationFn({connectionConfig:sI(t,n),variables:i,selectedInstanceId:r}),onSuccess:()=>{e.invalidateQueryKeys&&fI(i,e.invalidateQueryKeys)}})}function hI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.stats({partitionId:e.partitionId,instanceId:t}),path:`/console/stats`,query:{partitionId:e.partitionId,instanceId:t},errorMessage:`Failed to fetch stats`,refetchInterval:iI(e.refetchIntervalMs,5e3)})}function gI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.timeseries({...e,instanceId:n}),path:`/console/stats/timeseries`,query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch timeseries stats`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,3e4)})}function _I(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.latency({...e,instanceId:n}),path:`/console/stats/latency`,query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch latency stats`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,3e4)})}function vI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.commits({...e,instanceId:n}),path:`/console/commits`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch commits`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function yI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.commitDetail(e,t.partitionId,n),id:e,requiredMessage:`Commit sequence is required`,path:e=>`/console/commits/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch commit detail`,enabled:t.enabled})}function bI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.timeline({...e,instanceId:n}),path:`/console/timeline`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to,instanceId:n},errorMessage:`Failed to fetch timeline`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function xI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.clients({...e,instanceId:n}),path:`/console/clients`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch clients`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function SI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.eventDetail(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event detail`,enabled:t.enabled})}function CI(e,t={}){let n=pI(t.instanceId);return dI({queryKey:rI.eventPayload(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event payload`,enabled:t.enabled})}function wI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.handlers(t),path:`/console/handlers`,query:{instanceId:t},errorMessage:`Failed to fetch handlers`})}function TI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.prunePreview(t),path:`/console/prune/preview`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to fetch prune preview`,enabled:e.enabled})}function EI(e={},t={}){let n=pI(e.instanceId);return uI({queryKey:rI.operations({...e,instanceId:n}),path:`/console/operations`,query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch operations`,enabled:t.enabled,refetchInterval:iI(t.refetchIntervalMs,1e4)})}function DI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/events`,query:{instanceId:t},method:`DELETE`,errorMessage:`Failed to clear events`}),invalidateQueryKeys:[[`console`,`events`]]})}function OI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{let r=t.instanceId??n;return cI({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:r},method:`DELETE`,errorMessage:`Failed to evict client`})},invalidateQueryKeys:[[`console`,`clients`],[`console`,`stats`],[`console`,`operations`]]})}function kI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/prune`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to prune`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`prune`,`preview`],[`console`,`operations`]]})}function AI(){return mI({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>cI({connectionConfig:e,path:`/console/compact`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to compact`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`operations`]]})}function jI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/notify-data-change`,query:{instanceId:t.instanceId??n},method:`POST`,body:{tables:t.tables,partitionId:t.partitionId},errorMessage:`Failed to notify data change`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`operations`]]})}function MI(e={}){let t=pI(e.instanceId);return uI({queryKey:rI.apiKeys({...e,instanceId:t}),path:`/console/api-keys`,query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:`Failed to fetch API keys`})}function NI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to create API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function PI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:`DELETE`,errorMessage:`Failed to revoke API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function FI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/bulk-revoke`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to bulk revoke API keys`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function II(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function LI(){return mI({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>cI({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to stage-rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function RI(e={}){return uI({queryKey:rI.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:`/console/storage`,query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:`Failed to list blobs`,refetchInterval:iI(e.refetchIntervalMs,3e4)})}function zI(){return mI({mutationFn:async({connectionConfig:e,variables:t})=>cI({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:`DELETE`,errorMessage:`Failed to delete blob`}),invalidateQueryKeys:[[`console`,`storage`]]})}function BI(){let{config:e,isConnected:t}=Ny();return async n=>{let r=await lI({connectionConfig:sI(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:`Failed to download blob`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.split(`/`).pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}var VI=`console:partition-id`;function HI(){let[e,t]=eI(VI,``),n=e.trim();return(0,G.useMemo)(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t(``)}),[n,e,t])}var UI={refreshInterval:5,timeFormat:`relative`,showSparklines:!0,pageSize:20};function WI(){let[e,t]=eI(`console:preferences`,UI);return{preferences:e,setPreferences:t,updatePreference:(e,n)=>{t(t=>({...t,[e]:n}))},resetPreferences:()=>{t(UI)}}}var GI=[{value:5,label:`5 seconds`},{value:10,label:`10 seconds`},{value:30,label:`30 seconds`},{value:60,label:`1 minute`},{value:0,label:`Manual only`}],KI=[{value:10,label:`10`},{value:20,label:`20`},{value:50,label:`50`},{value:100,label:`100`}],qI=`syncular-console-root`;function JI(e){e.classList.add(qI)}var YI=[{suffix:``,label:`Command`},{suffix:`/stream`,label:`Stream`},{suffix:`/fleet`,label:`Fleet`},{suffix:`/ops`,label:`Ops`},{suffix:`/storage`,label:`Storage`},{suffix:`/config`,label:`Config`}];function XI(e){let t=e?.trim()??``;return!t||t===`/`?``:(t.startsWith(`/`)?t:`/${t}`).replace(/\/+$/g,``)}function ZI(e,t){return e?t?`${e}${t}`:e:t||`/`}function QI({basePath:e,appHref:t,modeBadge:n}){let{connect:r,config:i,isConnected:a,isConnecting:o}=Ny(),{preferences:s}=WI(),{instanceId:c,rawInstanceId:l,setInstanceId:u,clearInstanceId:d}=nI(),{partitionId:f,rawPartitionId:p,setPartitionId:m,clearPartitionId:h}=HI(),g=sy({select:e=>e.location.pathname}),{data:_}=hI({refetchIntervalMs:s.refreshInterval*1e3,partitionId:f,instanceId:c}),v=XI(e),y=(0,G.useMemo)(()=>YI.map(e=>({...e,id:ZI(v,e.suffix)})),[v]),b=ZI(v,``),x=ZI(v,`/config`),S=o?`connecting`:a?`connected`:i?`disconnected`:`not-configured`,C=y.find(e=>e.suffix===``?g===b||g===`${b}/`:g.startsWith(e.id))?.id??b,w=_?[{label:`HEAD`,value:`#${_.maxCommitSeq}`},{label:`COMMITS`,value:`${_.commitCount}`},{label:`CHANGES`,value:`${_.changeCount}`},{label:`CLIENTS`,value:`${_.activeClientCount}/${_.clientCount}`}]:[];return(0,K.jsxs)(`div`,{className:`${qI} h-screen bg-background text-foreground flex flex-col`,children:[(0,K.jsx)(qP,{brand:(0,K.jsx)(Rv,{to:b,children:(0,K.jsx)(KP,{label:`console`})}),center:(0,K.jsx)(VP,{items:y,activeId:C,renderItem:(e,{active:t})=>(0,K.jsx)(Rv,{to:e.id,children:(0,K.jsx)(BP,{active:t,children:e.label})},e.id)}),right:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,K.jsx)(Rw,{variant:`flow`,className:`hidden md:inline-flex px-2 py-1 text-[10px]`,children:n}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Instance`}),(0,K.jsx)(vS,{variant:`mono`,value:l,onChange:e=>u(e.target.value),onBlur:e=>u(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),c?(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:d,children:`All`}):null]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Partition`}),(0,K.jsx)(vS,{variant:`mono`,value:p,onChange:e=>m(e.target.value),onBlur:e=>m(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),f?(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:h,children:`All`}):null]}),(0,K.jsx)($w,{state:S}),(0,K.jsx)(Rv,{to:x,children:(0,K.jsx)(Q,{variant:g===x?`secondary`:`ghost`,size:`icon`,children:(0,K.jsx)(wT,{className:`h-3 w-3`})})}),t?(0,K.jsxs)(`a`,{href:t,className:zP,children:[(0,K.jsx)(CT,{className:`h-3 w-3`}),`Go to app`]}):null]})}),(0,K.jsx)(`main`,{className:`flex-1 overflow-auto pb-[32px]`,children:(0,K.jsx)(`div`,{className:`min-h-full`,children:a||g===x?(0,K.jsx)(`div`,{style:{animation:`pageIn 0.3s ease-out`},children:(0,K.jsx)(Qv,{})},g):(0,K.jsx)($I,{configPath:x,hasSavedConfig:!!i,isConnecting:o,onConnect:()=>{r()}})})}),a&&(0,K.jsx)(qw,{isLive:a,metrics:w,uptime:`--`})]})}function $I({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,K.jsx)(`p`,{className:`mb-4 text-foreground-muted`,children:`Not connected to a @syncular server`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,K.jsx)(Q,{variant:`default`,onClick:r,disabled:n,children:n?`Connecting...`:`Connect`}),(0,K.jsx)(Rv,{to:e,children:(0,K.jsx)(Q,{variant:`link`,children:`Configure connection`})})]})]})}var eL=Uv({component:QI});function tL(e={}){let{maxEvents:t=100,enabled:n=!0,staleAfterMs:r=65e3,replayLimit:i=100,partitionId:a,instanceId:o}=e,{config:s,isConnected:c}=Ny(),{instanceId:l}=nI(),u=o??l,[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(`disconnected`),[_,v]=(0,G.useState)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(0),C=(0,G.useRef)(0),w=(0,G.useRef)(null),T=(0,G.useCallback)(()=>{f([]),w.current=null},[]);return(0,G.useEffect)(()=>{if(!n||!c||!s?.serverUrl||!s?.token)return;let e=!1,o=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>`u`)return;let l=()=>{b.current&&=(clearTimeout(b.current),null)},d=()=>{x.current&&=(clearInterval(x.current),null)},p=()=>{if(e||b.current)return;S.current+=1;let t=Math.min(3e4,1e3*2**Math.max(0,S.current-1)),n=t+Math.floor(t*.2*Math.random());b.current=setTimeout(()=>{b.current=null,e||_()},n)},h=()=>{C.current=Date.now(),m(!0),g(`connected`)},_=()=>{if(e)return;g(`connecting`),l();let n=(()=>{let e=new URL(s.serverUrl,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.pathname=`${e.pathname.endsWith(`/`)?e.pathname.slice(0,-1):e.pathname}/console/events/live`,e.search=``,w.current&&e.searchParams.set(`since`,w.current),e.searchParams.set(`replayLimit`,String(o)),a&&e.searchParams.set(`partitionId`,a),u&&e.searchParams.set(`instanceId`,u),e.toString()})(),i=new WebSocket(n);y.current=i,i.onopen=()=>{if(e){i.close();return}S.current=0,v(null),g(`connecting`),m(!1);try{i.send(JSON.stringify({type:`auth`,token:s.token}))}catch{i.close();return}d(),x.current=setInterval(()=>{let e=y.current;if(!e||e.readyState!==WebSocket.OPEN)return;let t=C.current;t&&(Date.now()-t<=r||(m(!1),g(`stale`),e.close()))},1e3)},i.onclose=()=>{e||(m(!1),g(`disconnected`),d(),p())},i.onerror=()=>{e||v(Error(`WebSocket connection failed`))},i.onmessage=e=>{try{let n=JSON.parse(e.data),r=n.type;if(h(),r===`connected`||r===`heartbeat`||r===`auth_required`)return;if(r===`error`){let e=typeof n.message==`string`?n.message:`Live events authentication failed`;v(Error(e));return}let i={type:r,timestamp:n.timestamp||new Date().toISOString(),data:n};if(a&&i.data.partitionId!==a||u&&i.data.instanceId!==u)return;let o=Date.parse(w.current??``),s=Date.parse(i.timestamp);Number.isFinite(s)&&(!Number.isFinite(o)||s>o)&&(w.current=i.timestamp),f(e=>[i,...e].slice(0,t))}catch{}}};return _(),()=>{e=!0,l(),d(),y.current&&=(y.current.close(),null),m(!1),g(`disconnected`)}},[n,c,s?.serverUrl,s?.token,t,a,u,i,r]),{events:d,isConnected:p,connectionState:h,error:_,clearEvents:T}}var nL=(0,G.createContext)(null);function rL(){let[e,t]=eI(`console:time-range`,`24h`);return{range:e,setRange:t}}var iL=[{hint:`ios`,type:`mobile`},{hint:`android`,type:`mobile`},{hint:`mobile`,type:`mobile`},{hint:`tablet`,type:`tablet`},{hint:`desktop`,type:`desktop`},{hint:`mac`,type:`desktop`},{hint:`windows`,type:`desktop`},{hint:`linux`,type:`desktop`},{hint:`browser`,type:`browser`},{hint:`web`,type:`browser`},{hint:`server`,type:`server`},{hint:`api`,type:`server`},{hint:`iot`,type:`iot`},{hint:`sensor`,type:`iot`}];function aL(e){let t=e.toLowerCase();for(let e of iL)if(t.includes(e.hint))return e.type;return`client`}function oL(e){let t=e.toLowerCase();return t.includes(`pglite`)?`PGlite`:t.includes(`sqlite`)||t.includes(`wa-sqlite`)?`SQLite`:t.includes(`postgres`)||t.includes(`pg`)?`PostgreSQL`:`unknown`}function sL(e,t){return typeof e.lagCommitCount==`number`?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function cL(e,t){return e.activityState===`stale`?`offline`:t>0?`syncing`:`online`}function lL(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function uL(e,t,n={}){let r=n.maxNodes??10;return e.slice(0,r).map((e,n)=>{let r=cL(e,sL(e,t));return{id:lL(e.clientId,n),type:aL(e.clientId),status:r,cursor:Math.max(0,e.cursor),actor:e.actorId,mode:e.connectionMode,dialect:oL(e.clientId),scopes:Object.keys(e.effectiveScopes||{}),lastSeen:e.updatedAt}})}var dL={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function fL(e,t=`relative`){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function pL(e){let t=e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e;return t===`/console`||t.startsWith(`/console/`)?`/console/stream`:`/stream`}function mL(){let e=wv(),t=(0,G.useMemo)(()=>typeof window>`u`?`/stream`:pL(window.location.pathname),[]),n=rL(),{range:r}=n,{preferences:i}=WI(),{partitionId:a}=HI(),o=i.refreshInterval*1e3,[s]=eI(`console:alert-config`,dL),[c,l]=(0,G.useState)(`1h`),{data:u}=hI({refetchIntervalMs:o,partitionId:a}),{data:d}=gI({range:r,partitionId:a},{refetchIntervalMs:o}),{data:f}=_I({range:r,partitionId:a},{refetchIntervalMs:o}),{data:p}=vI({limit:5,partitionId:a},{refetchIntervalMs:o}),{data:m}=xI({limit:12,offset:0,partitionId:a},{refetchIntervalMs:o}),{events:h,isConnected:g}=tL({maxEvents:8,partitionId:a}),_=(0,G.useMemo)(()=>{let e=d?.buckets??[],t=0,n=0;for(let r of e)t+=r.pushCount+r.pullCount,n+=r.errorCount;let r=t>0?n/t*100:0;return{totalEvents:t,errorRate:r}},[d?.buckets]),v=(0,G.useMemo)(()=>m?.items?uL(m.items,u,{maxNodes:12}):[],[m?.items,u]),y=v.filter(e=>e.status!==`offline`).length,b=v.filter(e=>e.status===`offline`).length,x=(0,G.useMemo)(()=>u?[{label:`Ops (Range)`,value:_.totalEvents,color:`flow`},{label:`P50 Latency`,value:f?.push?.p50??0,unit:`ms`,color:`healthy`},{label:`Error Rate`,value:`${_.errorRate.toFixed(1)}%`,color:_.errorRate>0?`offline`:`muted`},{label:`Active Clients`,value:u.activeClientCount,color:`syncing`},{label:`Pending`,value:u.maxActiveClientCursor!==null&&u.maxCommitSeq>0?u.maxCommitSeq-(u.minActiveClientCursor??0):0,color:`relay`}]:[],[u,f,_.errorRate,_.totalEvents]),S=(0,G.useMemo)(()=>h.map(e=>({type:e.type.toUpperCase(),actor:e.data?.actorId??``,table:(e.data?.tables??[])[0]??``,time:fL(e.timestamp,i.timeFormat)})),[h,i.timeFormat]),C=(0,G.useMemo)(()=>{let e=d?.buckets;if(!e?.length)return[];let t=Math.max(...e.map(e=>Math.max(e.pushCount,e.pullCount)),1);return e.map(e=>({pushPercent:t>0?e.pushCount/t*100:0,pullPercent:t>0?e.pullCount/t*100:0}))},[d?.buckets]),w=(0,G.useMemo)(()=>{if(!f)return[];let e=Math.max(f.push.p50,f.push.p90,f.push.p99,f.pull.p50,f.pull.p90,f.pull.p99,1);return[{label:`P50`,pushMs:f.push.p50,pullMs:f.pull.p50,pushBarPercent:f.push.p50/e*100,pullBarPercent:f.pull.p50/e*100},{label:`P90`,pushMs:f.push.p90,pullMs:f.pull.p90,pushBarPercent:f.push.p90/e*100,pullBarPercent:f.pull.p90/e*100},{label:`P99`,pushMs:f.push.p99,pullMs:f.pull.p99,pushBarPercent:f.push.p99/e*100,pullBarPercent:f.pull.p99/e*100}]},[f]),T=(0,G.useMemo)(()=>p?.items?p.items.map(e=>({seq:e.commitSeq,actor:e.actorId,changes:e.changeCount,tables:(e.affectedTables??[]).join(`, `),time:fL(e.createdAt,i.timeFormat)})):[],[p?.items,i.timeFormat]),E=(0,G.useMemo)(()=>Math.max(0,100-_.errorRate),[_.errorRate]),D=(0,G.useMemo)(()=>{if(!s.enabled||!u)return[];let e=[];return f?.push?.p90&&f.push.p90>s.thresholds.p90Latency&&e.push(`P90 push latency (${f.push.p90}ms) exceeds threshold (${s.thresholds.p90Latency}ms)`),u.minActiveClientCursor!==null&&u.maxCommitSeq-u.minActiveClientCursor>s.thresholds.clientLag&&e.push(`Client lag (${u.maxCommitSeq-u.minActiveClientCursor}) exceeds threshold (${s.thresholds.clientLag})`),_.errorRate>s.thresholds.errorRate&&e.push(`Error rate (${_.errorRate.toFixed(1)}%) exceeds threshold (${s.thresholds.errorRate}%)`),e},[s,u,f,_.errorRate]);return u?(0,K.jsx)(nL.Provider,{value:n,children:(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[D.length>0&&(0,K.jsx)(`div`,{className:`px-6 pb-4`,children:(0,K.jsxs)(YP,{variant:`destructive`,children:[(0,K.jsx)(XP,{children:`Threshold Exceeded`}),(0,K.jsx)(ZP,{children:D.map((e,t)=>(0,K.jsx)(`span`,{className:`block`,children:e},t))})]})}),(0,K.jsx)(cM,{clients:v,totalNodes:v.length+2,onlineCount:y,offlineCount:b,relayClientIds:[]}),(0,K.jsx)(jT,{items:x}),(0,K.jsxs)(`div`,{className:`flex`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:[(0,K.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,K.jsx)(pS,{bars:C,activeRange:c,onRangeChange:l})}),(0,K.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,K.jsx)(NT,{buckets:w,successRate:E})}),(0,K.jsx)(`div`,{className:`border-r border-border`,children:(0,K.jsx)(Jw,{commits:T,onViewAll:()=>e({href:t})})})]}),(0,K.jsx)(FT,{entries:S,isConnected:g,maxVisible:20,maxHeight:`calc(100vh - 200px)`})]})]})}):(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(Qw,{size:`lg`})})}function hL(){return(0,K.jsx)(mL,{})}var gL=OP;function _L({children:e}){return(0,K.jsxs)(`div`,{className:`space-y-4 px-5 py-5`,children:[(0,K.jsx)(vL,{}),(0,K.jsx)(TL,{}),(0,K.jsx)(EL,{}),e]})}function vL(){let{clearError:e,config:t,connect:n,disconnect:r,error:i,isConnected:a,isConnecting:o}=Ny(),[s,c]=(0,G.useState)(t?.serverUrl??`/api`),[l,u]=(0,G.useState)(t?.token??``),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),[_,v]=eI(`console:disconnect-clear-saved-config`,!1);return(0,G.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`server`),n=!1;if(t&&(c(t),e.delete(`server`),n=!0),e.has(`token`)&&(e.delete(`token`),n=!0),n){let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.replaceState({},``,n)}},[]),(0,G.useEffect)(()=>{t?.serverUrl&&c(t.serverUrl),t?.token&&u(t.token)},[t?.serverUrl,t?.token]),(0,G.useEffect)(()=>{g(null)},[]),(0,K.jsx)(Xw,{isConnected:a,isConnecting:o,isTestingConnection:p,serverUrl:s,onServerUrlChange:c,consoleToken:l,onConsoleTokenChange:u,onSaveAndConnect:async()=>{e(),f(null),g(await n({serverUrl:s.trim(),token:l.trim()},{persistOverride:!0})?`Connected successfully and configuration saved.`:`Failed to connect with the provided settings.`)},onDisconnect:()=>{r({clearSavedConfig:_}),_&&(c(`/api`),u(``)),g(_?`Disconnected and saved credentials cleared.`:`Disconnected.`),f(null)},onTestConnection:async()=>{m(!0),f(null),g(null);let e=performance.now();try{let t=s.trim(),n=l.trim();if(!t||!n)throw Error(`Missing server URL or token`);if(!(await fetch(`${t}/console/stats`,{headers:{Authorization:`Bearer ${n}`}})).ok)throw Error(`Failed to connect`);f(Math.round(performance.now()-e))}catch{f(-1)}finally{m(!1)}},statusMessage:i??h??(d===null?void 0:d<0?`Connection failed`:`Connection successful (${d}ms latency)`),children:(0,K.jsx)(`div`,{className:`px-5 pb-5 -mt-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-400`,children:`Clear saved credentials on disconnect`}),(0,K.jsx)(`p`,{className:`font-mono text-[9px] text-neutral-500`,children:`Removes stored server URL and token from this browser.`})]}),(0,K.jsx)(Pw,{checked:_,onCheckedChange:v})]})})})}var yL=1440*60*1e3;function bL(e){let t=e.trim();if(!t)return null;let n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function xL(e){if(!e)return`Never`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():`Invalid date`}function SL(e){return e.length===0?`all scopes`:e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function CL(e,t){if(e.revokedAt)return`revoked`;if(!e.expiresAt)return`active`;let n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return`active`;let r=Date.now();return n<=r?`expired`:n<=r+t*yL?`expiring`:`active`}function wL(e){return e===`revoked`?`destructive`:e===`expired`?`offline`:e===`expiring`?`syncing`:`healthy`}function TL(){let[e,t]=(0,G.useState)(`all`),[n,r]=(0,G.useState)(`all`),[i,a]=(0,G.useState)(`14`),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(`relay`),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)([]),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(null),[I,L]=(0,G.useState)(null),ee=(0,G.useMemo)(()=>bL(i),[i]),R=ee??14,z=(0,G.useMemo)(()=>bL(v),[v]),B=v.trim().length>0,V=!B||z!==null,{data:H,isLoading:U,error:W}=MI((0,G.useMemo)(()=>({type:e===`all`?void 0:e,status:n===`all`?void 0:n,expiresWithinDays:n===`expiring`?R:void 0}),[e,n,R])),te=NI(),ne=FI(),re=PI(),ie=II(),ae=LI();(0,G.useEffect)(()=>{let e=new Set((H?.items??[]).map(e=>e.keyId));C(t=>t.filter(t=>e.has(t)))},[H?.items]);let oe=async()=>{try{let e=g.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);x((await te.mutateAsync({name:u,keyType:f,actorId:m||void 0,scopeKeys:e.length>0?e:void 0,expiresInDays:B?z??void 0:void 0})).secretKey),d(``),h(``),_(``),y(``)}catch{}},se=e=>{navigator.clipboard.writeText(e),D(e),setTimeout(()=>D(null),2e3)},ce=async()=>{if(O)try{await re.mutateAsync(O)}finally{k(null)}},le=async()=>{if(S.length!==0)try{T(await ne.mutateAsync({keyIds:S})),C([])}catch{}},ue=async()=>{if(A)try{let e=await ae.mutateAsync(A.keyId);N({oldKeyId:A.keyId,oldKeyName:A.name,secretKey:e.secretKey})}catch{}},de=async()=>{if(M)try{await re.mutateAsync(M.oldKeyId)}finally{N(null),j(null)}},fe=async()=>{if(P)try{L((await ie.mutateAsync(P)).secretKey)}finally{F(null)}};if(U)return(0,K.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,K.jsx)(Qw,{size:`lg`})});if(W)return(0,K.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load API keys: `,W.message]})});let pe=(H?.items??[]).filter(e=>e.revokedAt===null).map(e=>e.keyId),me=pe.length>0&&pe.every(e=>S.includes(e)),he=S.length>0,ge=(H?.items??[]).filter(e=>S.includes(e.keyId)).map(e=>e.name);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(VT,{title:`API Keys`,description:`Issue, rotate, revoke, and audit key lifecycle state.`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Q,{size:`sm`,variant:`destructive`,onClick:()=>l(!0),disabled:S.length===0,children:[`Revoke Selected (`,S.length,`)`]}),(0,K.jsx)(Q,{size:`sm`,onClick:()=>s(!0),children:`Create Key`})]}),children:[(0,K.jsxs)(`div`,{className:`mb-4 grid gap-3 lg:grid-cols-3`,children:[(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Type filter`}),(0,K.jsxs)(RP,{value:[e],multiple:!1,onValueChange:e=>{let n=e.find(e=>typeof e==`string`);(n===`all`||n===`relay`||n===`proxy`||n===`admin`)&&t(n)},children:[(0,K.jsx)(gL,{value:`all`,children:`all`}),(0,K.jsx)(gL,{value:`relay`,children:`relay`}),(0,K.jsx)(gL,{value:`proxy`,children:`proxy`}),(0,K.jsx)(gL,{value:`admin`,children:`admin`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Status filter`}),(0,K.jsxs)(RP,{value:[n],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`all`||t===`active`||t===`revoked`||t===`expiring`)&&r(t)},children:[(0,K.jsx)(gL,{value:`all`,children:`all`}),(0,K.jsx)(gL,{value:`active`,children:`active`}),(0,K.jsx)(gL,{value:`revoked`,children:`revoked`}),(0,K.jsx)(gL,{value:`expiring`,children:`expiring`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-expiring-window`,children:`Expiring window (days)`}),(0,K.jsx)(RM,{children:`Used when status filter is set to expiring.`}),(0,K.jsx)(vS,{id:`api-key-expiring-window`,placeholder:`14`,value:i,inputMode:`numeric`,onChange:e=>a(e.target.value)}),ee===null&&i.trim().length>0?(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`}):null]})]}),H?.items.length===0?(0,K.jsx)(aT,{message:`No API keys match the current filters.`}):(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{className:`w-[28px]`,children:(0,K.jsx)(bM,{checked:me,indeterminate:!me&&he&&pe.length>0,onCheckedChange:e=>{C(e?pe:[])},"aria-label":`Select all active keys`})}),(0,K.jsx)(Uw,{className:`w-[100px]`,children:`NAME`}),(0,K.jsx)(Uw,{className:`w-[55px]`,children:`TYPE`}),(0,K.jsx)(Uw,{className:`w-[90px]`,children:`KEY PREFIX`}),(0,K.jsx)(Uw,{className:`w-[80px]`,children:`ACTOR`}),(0,K.jsx)(Uw,{className:`w-[100px]`,children:`SCOPES`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`CREATED`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`LAST USED`}),(0,K.jsx)(Uw,{className:`w-[120px]`,children:`EXPIRES`}),(0,K.jsx)(Uw,{className:`flex-1`,children:`STATUS`})]})}),(0,K.jsx)(Vw,{children:(H?.items??[]).map(e=>{let t=CL(e,R);return(0,K.jsxs)(Hw,{className:`group relative`,children:[(0,K.jsx)(Ww,{className:`w-[28px]`,children:(0,K.jsx)(bM,{checked:S.includes(e.keyId),onCheckedChange:t=>{C(n=>t?[...new Set([...n,e.keyId])]:n.filter(t=>t!==e.keyId))},"aria-label":`Select ${e.name}`,disabled:e.revokedAt!==null})}),(0,K.jsx)(Ww,{className:`w-[100px] font-medium`,children:e.name}),(0,K.jsx)(Ww,{className:`w-[55px]`,children:(0,K.jsx)(Rw,{variant:e.keyType===`admin`?`flow`:e.keyType===`proxy`?`ghost`:`relay`,children:e.keyType})}),(0,K.jsx)(Ww,{className:`w-[90px]`,children:(0,K.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[e.keyPrefix,`...`]})}),(0,K.jsx)(Ww,{className:`w-[80px] text-neutral-500`,children:e.actorId??`-`}),(0,K.jsx)(Ww,{className:`w-[100px] text-neutral-500`,children:(0,K.jsx)(`code`,{className:`font-mono text-[10px]`,children:SL(e.scopeKeys)})}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.createdAt)}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.lastUsedAt)}),(0,K.jsx)(Ww,{className:`w-[120px] text-neutral-500`,children:xL(e.expiresAt)}),(0,K.jsx)(Ww,{className:`flex-1`,children:(0,K.jsx)(Rw,{variant:wL(t),children:t})}),e.revokedAt===null&&(0,K.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors`,children:`stage`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>F(e.keyId),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors`,children:`rotate`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>k(e.keyId),className:`px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors`,children:`revoke`})]})]},e.keyId)})})]})]}),(0,K.jsx)(gF,{open:o,onOpenChange:s,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Create API Key`})}),b?(0,K.jsx)(DL,{copiedKeyId:E,onClose:()=>{x(null),s(!1)},onCopy:se,secretKey:b,warning:`Copy this key now. You will not be able to view it again.`}):(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-name`,children:`Name`}),(0,K.jsx)(vS,{id:`api-key-name`,placeholder:`Backend Relay Key`,value:u,onChange:e=>d(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Key type`}),(0,K.jsxs)(RP,{value:[f],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`relay`||t===`proxy`||t===`admin`)&&p(t)},children:[(0,K.jsx)(gL,{value:`relay`,children:`relay`}),(0,K.jsx)(gL,{value:`proxy`,children:`proxy`}),(0,K.jsx)(gL,{value:`admin`,children:`admin`})]})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-actor-id`,children:`Actor ID (optional)`}),(0,K.jsx)(RM,{children:`Pin this key to a fixed actor ID`}),(0,K.jsx)(vS,{id:`api-key-actor-id`,placeholder:`actor-123`,value:m,onChange:e=>h(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-scope-keys`,children:`Scope keys (optional)`}),(0,K.jsx)(RM,{children:`Comma-separated list of allowed scope keys`}),(0,K.jsx)(vS,{id:`api-key-scope-keys`,placeholder:`scope-a, scope-b`,value:g,onChange:e=>_(e.target.value)})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{htmlFor:`api-key-expires-days`,children:`Expires in days (optional)`}),(0,K.jsx)(RM,{children:`Leave empty to keep the key non-expiring.`}),(0,K.jsx)(vS,{id:`api-key-expires-days`,placeholder:`30`,value:v,inputMode:`numeric`,onChange:e=>y(e.target.value)}),V?null:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>s(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:oe,disabled:te.isPending||!u||!V,children:te.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Creating...`]}):`Create`})]})]})]})}),(0,K.jsx)(gF,{open:c,onOpenChange:e=>{l(e),e||T(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Bulk Revoke API Keys`})}),w?(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsxs)(ZP,{children:[`Requested `,w.requestedCount,` keys. Revoked`,` `,w.revokedCount,`, already revoked`,` `,w.alreadyRevokedCount,`, not found`,` `,w.notFoundCount,`.`]})}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`primary`,onClick:()=>{l(!1),T(null)},children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:`This revokes selected keys immediately and cannot be undone.`})}),(0,K.jsxs)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:[`Selected keys: `,ge.slice(0,5).join(`, `),ge.length>5?` +${ge.length-5} more`:``]})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:le,disabled:ne.isPending||S.length===0,children:ne.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking...`]}):`Revoke Selected`})]})]})]})}),(0,K.jsx)(gF,{open:A!==null||M!==null,onOpenChange:()=>{j(null),N(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Stage Rotate API Key`})}),M?(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsxs)(ZP,{children:[`Replacement key created for `,M.oldKeyName,`. The old key is still active until you revoke it.`]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:M.secretKey}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>se(M.secretKey),children:E===M.secretKey?`Copied`:`Copy`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>{N(null),j(null)},children:`Keep Old Key Active`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:de,disabled:re.isPending,children:re.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking Old Key...`]}):`Finalize and Revoke Old Key`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it.`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>j(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:ue,disabled:ae.isPending||!A,children:ae.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Staging...`]}):`Create Replacement Key`})]})]})]})}),(0,K.jsx)(gF,{open:O!==null,onOpenChange:()=>k(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Revoke API Key`})}),(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:`Revoking a key immediately invalidates it for all requests.`})})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>k(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:ce,disabled:re.isPending,children:re.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Revoking...`]}):`Revoke`})]})]})}),(0,K.jsx)(gF,{open:P!==null||I!==null,onOpenChange:()=>{F(null),L(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Rotate API Key`})}),I?(0,K.jsx)(DL,{copiedKeyId:E,onClose:()=>L(null),onCopy:se,secretKey:I,warning:`The previous key has been invalidated. Store this replacement securely.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-5 py-4`,children:(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Rotating a key invalidates the previous secret immediately.`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>F(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`primary`,onClick:fe,disabled:ie.isPending,children:ie.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Rotating...`]}):`Rotate`})]})]})]})})]})}function EL(){let{preferences:e,updatePreference:t,resetPreferences:n}=WI();return(0,K.jsx)(zT,{rows:[{type:`filter`,label:`Auto-refresh interval`,options:GI.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.refreshInterval}`,onActiveChange:e=>t(`refreshInterval`,Number.parseInt(e,10))},{type:`filter`,label:`Items per page`,options:KI.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.pageSize}`,onActiveChange:e=>t(`pageSize`,Number.parseInt(e,10))},{type:`filter`,label:`Time format`,options:[{id:`relative`,label:`Relative`},{id:`absolute`,label:`Absolute`}],activeId:e.timeFormat,onActiveChange:e=>t(`timeFormat`,e)},{type:`toggle`,label:`Show sparklines`,description:`Display mini trend charts in dashboard metric cards`,checked:e.showSparklines,onCheckedChange:e=>t(`showSparklines`,e)}],onResetDefaults:n})}function DL({copiedKeyId:e,onClose:t,onCopy:n,secretKey:r,warning:i}){return(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:i})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:r}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>n(r),children:e===r?`Copied`:`Copy`})]}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`primary`,onClick:t,children:`Done`})})]})}function OL(e){let t=e.toLowerCase();return t.includes(`mobile`)||t.includes(`ios`)||t.includes(`android`)?`mobile`:t.includes(`tablet`)?`tablet`:t.includes(`desktop`)||t.includes(`laptop`)?`desktop`:t.includes(`edge`)?`edge`:t.includes(`iot`)?`iot`:`desktop`}function kL(e){let t=e.toLowerCase();return t.includes(`pglite`)?`PGlite`:t.includes(`wa-sqlite`)||t.includes(`sqlite`)?`SQLite`:t.includes(`postgres`)||t.includes(`pg`)?`PostgreSQL`:`unknown`}function AL(e,t){if(t===`absolute`)return new Date(e).toLocaleString();try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}catch{return e}}function jL(e,t,n){return{id:e.clientId,type:OL(e.clientId),status:e.activityState===`stale`?`offline`:e.activityState===`idle`?`syncing`:`online`,cursor:e.cursor,actor:e.actorId,mode:e.connectionMode===`realtime`?`realtime`:`polling`,dialect:kL(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:AL(e.updatedAt,n)}}function ML({emptyState:e}={}){let[t,n]=(0,G.useState)(1),[r,i]=(0,G.useState)(null),{preferences:a}=WI(),{partitionId:o}=HI(),s=a.pageSize,c=a.refreshInterval*1e3,{data:l,isLoading:u}=hI({refetchIntervalMs:c,partitionId:o}),{data:d,isLoading:f,error:p}=xI({limit:s,offset:(t-1)*s,partitionId:o},{refetchIntervalMs:c}),m=OI(),h=Math.ceil((d?.total??0)/s),g=l?.maxCommitSeq??0;(0,G.useEffect)(()=>{n(1)},[]);let _=async()=>{if(r)try{await m.mutateAsync({clientId:r,partitionId:o})}finally{i(null)}};if(f||u)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})});if(p)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load clients: `,p.message]})});let v=(d?.items??[]).map(e=>jL(e,g,a.timeFormat));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 px-5 py-5`,children:[v.length>0&&(0,K.jsx)(qT,{clients:v,headSeq:g}),v.length===0?e??(0,K.jsx)(RT,{children:(0,K.jsx)(aT,{message:`No clients yet`})}):(0,K.jsx)(OT,{clients:v,headSeq:g,onEvict:e=>{let t=d?.items.find(t=>t.clientId===e);i(t?.clientId??e)}}),h>1&&(0,K.jsx)(CF,{page:t,totalPages:h,totalItems:d?.total??0,onPageChange:n}),(0,K.jsx)(gF,{open:r!==null,onOpenChange:()=>i(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Evict Client`})}),(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to evict client`,` `,(0,K.jsxs)(`span`,{className:`font-mono text-white`,children:[r?.slice(0,12),`...`]}),`?`]}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This will force the client to re-bootstrap on their next sync.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>i(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:_,disabled:m.isPending,children:m.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Evicting...`]}):`Evict`})]})]})})]})}var NL={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function PL(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function FL(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return Array.from(new Set(t))}function IL(e){switch(e){case`notify_data_change`:return`Notify`;case`evict_client`:return`Evict`;case`compact`:return`Compact`;default:return`Prune`}}function LL(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function RL(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function zL(e){let t=LL(e.requestPayload),n=LL(e.resultPayload);if(e.operationType===`notify_data_change`){let e=RL(t?.tables),r=n?.commitSeq;return`${e.length} table${e.length===1?``:`s`} -> commit #${typeof r==`number`?r:`?`}`}if(e.operationType===`evict_client`){let t=n?.evicted===!0?`evicted`:`not found`;return`client ${e.targetClientId??`?`} ${t}`}return e.operationType===`compact`?`${typeof n?.deletedChanges==`number`?n.deletedChanges:0} changes removed`:`${typeof n?.deletedCommits==`number`?n.deletedCommits:0} commits removed${typeof t?.watermarkCommitSeq==`number`?` at #${t.watermarkCommitSeq}`:``}`}function BL(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function VL(){let{partitionId:e}=HI();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,K.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,K.jsx)(HL,{}),(0,K.jsx)(qL,{})]}),(0,K.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,K.jsx)(UL,{partitionId:e}),(0,K.jsx)(WL,{partitionId:e}),(0,K.jsx)(GL,{partitionId:e})]}),(0,K.jsx)(KL,{partitionId:e})]})}function HL(){let{data:e,isLoading:t,error:n}=wI();return t?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):n?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load handlers: `,n.message]})}):(0,K.jsx)(kT,{handlers:(e?.items??[]).map(e=>({table:e.table,dependsOn:e.dependsOn?.join(`, `)??null,chunkTtl:e.snapshotChunkTtlMs?PL(e.snapshotChunkTtlMs):`default`})),tableCount:e?.items.length??0})}function UL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{data:a,isLoading:o}=hI({partitionId:e}),{data:s,isLoading:c,refetch:l}=TI({enabled:!1}),u=kI();return o?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Prune`,description:`Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.`,dotColor:`syncing`,stats:[{label:`Total commits`,value:a?.commitCount??0},{label:`Commit range`,value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:`Min active cursor`,value:a?.minActiveClientCursor??`N/A`,tone:`syncing`}],actionLabel:`Preview Prune`,actionVariant:`destructive`,onAction:async()=>{n(!0),i(null),await l()}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Prune Old Commits`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?c?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Qw,{size:`sm`})}):s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(YP,{variant:s.commitsToDelete>0?`destructive`:`default`,children:(0,K.jsx)(ZP,{children:s.commitsToDelete>0?(0,K.jsxs)(K.Fragment,{children:[`This will delete`,` `,(0,K.jsx)(`strong`,{children:s.commitsToDelete}),` commits up to sequence`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`#`,s.watermarkCommitSeq]}),`.`]}):`No commits are eligible for pruning.`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px]`,children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Watermark commit seq:`}),(0,K.jsxs)(`span`,{className:`text-white`,children:[`#`,s.watermarkCommitSeq]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px] items-center`,children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Commits to delete:`}),(0,K.jsx)(Rw,{variant:s.commitsToDelete>0?`offline`:`ghost`,children:s.commitsToDelete})]})]})]}):null:(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Pruning Complete`}),(0,K.jsxs)(ZP,{children:[`Successfully deleted `,(0,K.jsx)(`strong`,{children:r}),` commits.`]})]})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,K.jsx)(Q,{variant:`destructive`,onClick:async()=>{i((await u.mutateAsync()).deletedCommits)},disabled:u.isPending||c||(s?.commitsToDelete??0)===0,children:u.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Pruning...`]}):`Prune Now`})]})]})})]})}function WL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{data:a,isLoading:o}=hI({partitionId:e}),s=AI();return o?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Compact`,description:`Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.`,dotColor:`flow`,stats:[{label:`Total changes`,value:a?.changeCount??0},{label:`Total commits`,value:a?.commitCount??0}],actionLabel:`Run Compaction`,actionVariant:`primary`,onAction:()=>{n(!0),i(null)}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Compact Changes`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsx)(ZP,{children:`Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time.`})}):(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Compaction Complete`}),(0,K.jsxs)(ZP,{children:[`Successfully removed `,(0,K.jsx)(`strong`,{children:r}),` redundant changes.`]})]})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,K.jsx)(Q,{variant:`primary`,onClick:async()=>{i((await s.mutateAsync()).deletedChanges)},disabled:s.isPending,children:s.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Compacting...`]}):`Compact Now`})]})]})})]})}function GL({partitionId:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(`tasks`),[a,o]=(0,G.useState)(e??``),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=jI(),f=FL(r),p=[{label:`Next tables`,value:f.length,tone:`syncing`},{label:`Last commit seq`,value:s?`#${s.commitSeq}`:`—`,tone:`syncing`},{label:`Last chunks cleared`,value:s?.deletedChunks??`—`}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LT,{title:`Notify Data Change`,description:`Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.`,dotColor:`healthy`,stats:p,actionLabel:`Notify Clients`,actionVariant:`primary`,onAction:()=>{n(!0),u(null)}}),(0,K.jsx)(gF,{open:t,onOpenChange:n,children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Notify External Data Change`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?(0,K.jsxs)(YP,{variant:`default`,children:[(0,K.jsx)(XP,{children:`Notification Sent`}),(0,K.jsxs)(ZP,{children:[`Created synthetic commit`,` `,(0,K.jsxs)(`strong`,{children:[`#`,s.commitSeq]}),` for`,` `,(0,K.jsx)(`strong`,{children:s.tables.length}),` table`,s.tables.length===1?``:`s`,` and cleared`,` `,(0,K.jsx)(`strong`,{children:s.deletedChunks}),` cached chunk`,s.deletedChunks===1?``:`s`,`.`]})]}):(0,K.jsx)(YP,{variant:`default`,children:(0,K.jsx)(ZP,{children:`Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data.`})}),l?(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsx)(ZP,{children:l})}):null,(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Tables (comma-separated)`}),(0,K.jsx)(vS,{value:r,onChange:e=>i(e.target.value),placeholder:`tasks, notes`,disabled:d.isPending}),(0,K.jsx)(RM,{children:`Enter one or more table names affected by the external change.`})]}),(0,K.jsxs)(IM,{children:[(0,K.jsx)(LM,{children:`Partition ID (optional)`}),(0,K.jsx)(vS,{value:a,onChange:e=>o(e.target.value),placeholder:`default`,disabled:d.isPending})]})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:s?`Close`:`Cancel`}),s?null:(0,K.jsx)(Q,{variant:`primary`,onClick:async()=>{if(f.length===0){u(`Provide at least one table name.`);return}u(null),c(await d.mutateAsync({tables:f,partitionId:a.trim()||void 0}))},disabled:d.isPending,children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),`Notifying...`]}):`Notify Data Change`})]})]})})]})}function KL({partitionId:e}){let[t,n]=(0,G.useState)(`all`),{data:r,isLoading:i,error:a}=EI({limit:20,offset:0,operationType:t===`all`?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return(0,K.jsx)(VT,{title:`Operation Audit`,description:`Recent prune/compact/notify/evict actions with actor and result context.`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Q,{variant:t===`all`?`default`:`ghost`,size:`sm`,onClick:()=>n(`all`),children:`All`}),(0,K.jsx)(Q,{variant:t===`prune`?`default`:`ghost`,size:`sm`,onClick:()=>n(`prune`),children:`Prune`}),(0,K.jsx)(Q,{variant:t===`compact`?`default`:`ghost`,size:`sm`,onClick:()=>n(`compact`),children:`Compact`}),(0,K.jsx)(Q,{variant:t===`notify_data_change`?`default`:`ghost`,size:`sm`,onClick:()=>n(`notify_data_change`),children:`Notify`}),(0,K.jsx)(Q,{variant:t===`evict_client`?`default`:`ghost`,size:`sm`,onClick:()=>n(`evict_client`),children:`Evict`})]}),contentClassName:`pt-2`,children:i?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,K.jsx)(Qw,{size:`lg`})}):a?(0,K.jsx)(YP,{variant:`destructive`,children:(0,K.jsxs)(ZP,{children:[`Failed to load operation audit events: `,a.message]})}):(r?.items.length??0)===0?(0,K.jsx)(`div`,{className:`px-2 py-8 text-sm text-neutral-500`,children:`No operation events found for this filter.`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{children:`Time`}),(0,K.jsx)(Uw,{children:`Type`}),(0,K.jsx)(Uw,{children:`User`}),(0,K.jsx)(Uw,{children:`Target`}),(0,K.jsx)(Uw,{children:`Result`})]})}),(0,K.jsx)(Vw,{children:(r?.items??[]).map((e,t)=>(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Ww,{className:`whitespace-nowrap text-xs text-neutral-400`,children:BL(e.createdAt)}),(0,K.jsx)(Ww,{children:(0,K.jsx)(Rw,{variant:`ghost`,children:IL(e.operationType)})}),(0,K.jsx)(Ww,{className:`font-mono text-xs`,children:e.consoleUserId??`system`}),(0,K.jsx)(Ww,{className:`font-mono text-xs`,children:e.targetClientId??e.partitionId??(e.operationType===`notify_data_change`?`partition default`:`global`)}),(0,K.jsx)(Ww,{className:`font-mono text-xs text-neutral-300`,children:zL(e)})]},`${e.operationId}:${e.createdAt}:${t}`))})]})})})}function qL(){let[e,t]=eI(`console:alert-config`,NL),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold};return(0,K.jsx)(Fw,{enabled:e.enabled,onEnabledChange:e=>{t(t=>({...t,enabled:e}))},thresholds:n,onThresholdsChange:e=>{t(t=>({...t,latencyThresholdMs:e.p90Latency,errorRateThreshold:e.errorRate,clientLagThreshold:e.clientLag}))}})}function JL(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function YL(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function XL(){let[e,t]=(0,G.useState)(``),[n,r]=(0,G.useState)(void 0),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(null),{data:u,isLoading:d,error:f}=RI({prefix:n,cursor:i,limit:100}),p=zI(),m=BI();function h(){let t=e.trim();r(t.length>0?t:void 0),a(void 0),s([])}function g(){t(``),r(void 0),a(void 0),s([])}function _(){u?.cursor&&(s(e=>[...e,i??``]),a(u.cursor))}function v(){s(e=>{let t=[...e],n=t.pop();return a(n&&n.length>0?n:void 0),t})}function y(){c&&p.mutate(c,{onSuccess:()=>l(null)})}if(d)return(0,K.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsx)(Qw,{size:`lg`})})});if(f)return(0,K.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,K.jsxs)(`p`,{className:`text-danger font-mono text-[11px]`,children:[`Failed to load storage items: `,f.message]})})});let b=u?.items??[];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,K.jsx)(VT,{title:`Storage`,actions:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(vS,{placeholder:`Prefix filter...`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},className:`h-7 w-48 text-xs`}),(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:h,children:`Filter`}),n&&(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:g,children:`Clear`})]}),children:b.length===0?(0,K.jsx)(aT,{message:n?`No storage items matching prefix "${n}".`:`No storage items found.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(zw,{children:[(0,K.jsx)(Bw,{children:(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Uw,{children:`Key`}),(0,K.jsx)(Uw,{children:`Size`}),(0,K.jsx)(Uw,{children:`Type`}),(0,K.jsx)(Uw,{children:`Uploaded`}),(0,K.jsx)(Uw,{children:`Actions`})]})}),(0,K.jsx)(Vw,{children:b.map(e=>(0,K.jsxs)(Hw,{children:[(0,K.jsx)(Ww,{className:`font-mono text-xs max-w-[320px]`,title:e.key,children:e.key}),(0,K.jsx)(Ww,{className:`font-mono text-xs text-neutral-400 whitespace-nowrap`,children:JL(e.size)}),(0,K.jsx)(Ww,{children:e.httpMetadata?.contentType?(0,K.jsx)(Rw,{variant:`ghost`,children:e.httpMetadata.contentType}):(0,K.jsx)(`span`,{className:`text-neutral-500 text-xs`,children:`--`})}),(0,K.jsx)(Ww,{className:`whitespace-nowrap text-xs text-neutral-400`,children:YL(e.uploaded)}),(0,K.jsx)(Ww,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>void m(e.key),children:`Download`}),(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>l(e.key),children:`Delete`})]})})]},e.key))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2`,children:[(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:o.length===0,onClick:v,children:`Previous`}),(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!u?.truncated,onClick:_,children:`Next`})]})]})}),(0,K.jsx)(gF,{open:c!==null,onOpenChange:()=>l(null),children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Delete Storage Item`})}),(0,K.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,K.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to delete`,` `,(0,K.jsx)(`span`,{className:`font-mono text-white`,children:c}),`?`]}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This action cannot be undone.`})]}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,onClick:()=>l(null),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,onClick:y,disabled:p.isPending,children:p.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Qw,{size:`sm`}),` Deleting...`]}):`Delete`})]})]})})]})}function ZL(e,t){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}function QL(e){let t=e.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),n={},r=[];for(let e of t){let[t=``,...i]=e.split(`:`),a=i.join(`:`).trim(),o=t.toLowerCase();if(!a){r.push(e);continue}if(o===`actor`){n.actorId=a;continue}if(o===`client`){n.clientId=a;continue}if(o===`table`){n.table=a;continue}if(o===`request`){n.requestId=a;continue}if(o===`trace`){n.traceId=a;continue}r.push(e)}return r.length>0&&(n.search=r.join(` `)),n}function $L(e){return e===`1h`?3600*1e3:e===`6h`?360*60*1e3:e===`24h`?1440*60*1e3:e===`7d`?10080*60*1e3:720*60*60*1e3}function eR(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tR(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:`#?`}function nR(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:`E?`}function rR(e,t,n){return!e||!t?null:e.replaceAll(`{traceId}`,encodeURIComponent(t)).replaceAll(`{spanId}`,encodeURIComponent(n??``))}function iR({initialSelectedEntryId:e}={}){let{preferences:t}=WI(),{partitionId:n}=HI(),{range:r,setRange:i}=rL(),a=t.pageSize,o=t.refreshInterval*1e3,[s,c]=(0,G.useState)(()=>e?.startsWith(`#`)?`commits`:e?.startsWith(`E`)?`events`:`all`),[l,u]=(0,G.useState)(`all`),[d,f]=(0,G.useState)(`all`),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(e??null),x=(0,G.useRef)(!1),S=(0,G.useMemo)(()=>QL(p),[p]),C=(0,G.useMemo)(()=>new Date(Date.now()-$L(r)).toISOString(),[r]),{data:w,isLoading:T,refetch:E}=bI({limit:a,offset:(h-1)*a,...n?{partitionId:n}:{},view:s,...s!==`commits`&&l!==`all`?{eventType:l}:{},...s!==`commits`&&d!==`all`?{outcome:d}:{},...S.actorId?{actorId:S.actorId}:{},...S.clientId?{clientId:S.clientId}:{},...S.requestId?{requestId:S.requestId}:{},...S.traceId?{traceId:S.traceId}:{},...S.table?{table:S.table}:{},...S.search?{search:S.search}:{},from:C},{refetchIntervalMs:o}),D=DI(),O=y?.startsWith(`#`)?y.slice(1):void 0,k=y?.startsWith(`E`)?y.slice(1):void 0,A=O&&O!==`?`?O:void 0,j=k&&k!==`?`?k:void 0,{data:M,isLoading:N,error:P}=yI(A,{enabled:A!==void 0,partitionId:n}),{data:F,isLoading:I,error:L}=SI(j,{enabled:j!==void 0,partitionId:n}),{data:ee,isLoading:R,error:z}=CI(j,{enabled:j!==void 0&&!!F?.payloadRef,partitionId:n}),B=(0,G.useMemo)(()=>rR(void 0,F?.traceId??null,F?.spanId??null),[F?.spanId,F?.traceId,void 0]);(0,G.useEffect)(()=>{g(1)},[]),(0,G.useEffect)(()=>{g(1)},[]),(0,G.useEffect)(()=>{e&&b(e)},[e]),(0,G.useEffect)(()=>{if(!x.current){x.current=!0;return}b(null)},[]),(0,G.useEffect)(()=>{g(1),b(null)},[]);let V=(0,G.useMemo)(()=>(w?.items??[]).map(e=>{let n=e.instanceId??e.commit?.instanceId??e.event?.instanceId,r=n?`[${n}] `:``;if(e.type===`commit`&&e.commit){let i=e.commit;return{type:`commit`,id:tR(i,n),outcome:`--`,duration:`--`,actor:i.actorId,client:i.clientId,detail:`${r}${i.changeCount} chg | ${(i.affectedTables??[]).join(`, `)}`,time:ZL(e.timestamp,t.timeFormat)}}let i=e.event;return i?{type:i.eventType,id:nR(i,n),outcome:i.outcome,duration:`${i.durationMs}ms`,actor:i.actorId,client:i.clientId,detail:`${r}${(i.tables??[]).join(`, `)||`--`}`,time:ZL(e.timestamp,t.timeFormat)}:{type:`pull`,id:`E?`,outcome:`unknown`,duration:`--`,actor:``,client:``,detail:`--`,time:ZL(e.timestamp,t.timeFormat)}}),[t.timeFormat,w?.items]),H=w?.total??0,U=Math.max(1,Math.ceil(H/a)),W=T,te=[{label:``,options:[{id:`all`,label:`All`},{id:`commits`,label:`Commits`},{id:`events`,label:`Events`}],activeId:s,onActiveChange:e=>{c(e),e===`commits`&&(u(`all`),f(`all`)),g(1)}},{label:`Time`,options:[{id:`1h`,label:`1h`},{id:`6h`,label:`6h`},{id:`24h`,label:`24h`},{id:`7d`,label:`7d`},{id:`30d`,label:`30d`}],activeId:r,onActiveChange:e=>{i(e),g(1)}},{label:`Type`,options:[{id:`all`,label:`All`},{id:`push`,label:`Push`},{id:`pull`,label:`Pull`}],activeId:l,onActiveChange:e=>{u(e),g(1)}},{label:`Outcome`,options:[{id:`all`,label:`All`},{id:`applied`,label:`Applied`},{id:`error`,label:`Error`},{id:`rejected`,label:`Rejected`}],activeId:d,onActiveChange:e=>{f(e),g(1)}}];function ne(){D.mutate(void 0,{onSuccess:()=>{v(!1),E()}})}return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[W&&V.length===0?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(Qw,{size:`lg`})}):(0,K.jsx)(WT,{entries:V,selectedEntryId:y,onEntryClick:e=>b(e.id),filterBar:(0,K.jsx)(oT,{groups:te,searchValue:p,searchPlaceholder:`Use actor:, client:, table:, request:, trace: or free text...`,onSearchChange:m,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>void E(),children:`Refresh`}),(0,K.jsx)(Q,{size:`sm`,variant:`ghost`,children:`Export`}),(0,K.jsx)(Q,{size:`sm`,variant:`destructive`,onClick:()=>v(!0),children:`Clear`})]})}),pagination:(0,K.jsx)(CF,{page:h,totalPages:U,totalItems:H,onPageChange:g})}),(0,K.jsx)(gF,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:A===void 0?j===void 0?`Entry details`:`Event E${j}`:`Commit #${A}`})}),(0,K.jsx)(`div`,{className:`px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto`,children:N||I?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Qw,{size:`sm`})}):P||L?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load details.`}):M?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.actorId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.clientId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.instanceId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:ZL(M.createdAt,t.timeFormat)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Changes`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:M.changeCount})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Affected Tables`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:M.affectedTables.join(`, `)||`--`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Changes`}),M.changes.length===0?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No changes recorded.`}):M.changes.map(e=>(0,K.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between font-mono text-[11px]`,children:[(0,K.jsxs)(`span`,{className:`text-neutral-300`,children:[e.table,` | `,e.op]}),(0,K.jsxs)(`span`,{className:`text-neutral-500`,children:[`#`,e.changeId]})]}),(0,K.jsxs)(`div`,{className:`font-mono text-[11px] text-neutral-400`,children:[`rowId: `,e.rowId,e.rowVersion===null?``:` | version: ${e.rowVersion}`]}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(e.rowJson)})]},e.changeId))]})]}):F?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Type`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.eventType})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Path`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.syncPath})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.instanceId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Outcome`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.outcome})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Response Status`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.responseStatus})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.actorId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.clientId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Status`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.statusCode})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Transport`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.transportPath})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Duration`}),(0,K.jsxs)(`div`,{className:`text-neutral-100`,children:[F.durationMs,`ms`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Request ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.requestId})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Trace ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.traceId??`--`}),B&&(0,K.jsx)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`font-mono text-[10px] text-flow underline underline-offset-4`,children:`Open external trace`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Span ID`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.spanId??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Commit Seq`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.commitSeq??`--`}),F.commitSeq!==null&&(0,K.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>b(`#${F.instanceId?`${F.instanceId}:`:``}${F.commitSeq}`),children:`Open linked commit`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Subscription Count`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.subscriptionCount??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Error Code`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.errorCode??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Payload Ref`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:F.payloadRef??`--`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,K.jsx)(`div`,{className:`text-neutral-100`,children:ZL(F.createdAt,t.timeFormat)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Tables`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:F.tables.join(`, `)||`--`})]}),F.scopesSummary&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Scopes Summary`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(F.scopesSummary)})]}),F.payloadRef&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Payload Snapshot`}),R?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Qw,{size:`sm`}),(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`Loading payload snapshot...`})]}):z?(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load payload snapshot.`}):ee?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Request`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(ee.requestPayload)}),(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Response`}),(0,K.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:eR(ee.responsePayload)})]}):(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No payload snapshot available.`})]}),F.errorMessage&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Error`}),(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:F.errorMessage})]})]}):(0,K.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No details available for this row.`})}),(0,K.jsx)(bF,{children:(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>b(null),children:`Close`})})]})}),(0,K.jsx)(gF,{open:_,onOpenChange:e=>{e||v(!1)},children:(0,K.jsxs)(vF,{children:[(0,K.jsx)(yF,{children:(0,K.jsx)(xF,{children:`Clear all events`})}),(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`This will permanently delete all request events. Commits are not affected. Are you sure?`})}),(0,K.jsxs)(bF,{children:[(0,K.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>v(!1),children:`Cancel`}),(0,K.jsx)(Q,{variant:`destructive`,size:`sm`,onClick:ne,disabled:D.isPending,children:D.isPending?`Clearing...`:`Clear all`})]})]})})]})}var aR=Vv({getParentRoute:()=>eL,path:`/config`,component:_L}),oR=Vv({getParentRoute:()=>eL,path:`/fleet`,component:ML}),sR=Vv({getParentRoute:()=>eL,path:`/`,component:hL});function cR(){let{seq:e}=lR.useParams();return(0,K.jsx)(iR,{initialSelectedEntryId:`#${e}`})}var lR=Vv({getParentRoute:()=>eL,path:`/investigate/commit/$seq`,component:cR});function uR(){let{id:e}=dR.useParams();return(0,K.jsx)(iR,{initialSelectedEntryId:`E${e}`})}var dR=Vv({getParentRoute:()=>eL,path:`/investigate/event/$id`,component:uR}),fR=Vv({getParentRoute:()=>eL,path:`/ops`,component:VL}),pR=Vv({getParentRoute:()=>eL,path:`/storage`,component:XL}),mR=Vv({getParentRoute:()=>eL,path:`/stream`,component:iR}),hR=eL.addChildren([sR,mR,lR,dR,oR,fR,pR,aR]),gR=`syncular-console-basepath`,_R=`syncular-console-server-url`,vR=`syncular-console-token`;function yR(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function bR(e){let t=globalThis.document;if(!t)return;let n=t.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return yR(n)}function xR(e){return!e||e===`/`?`/`:(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/g,``)||`/`}function SR(){return xR(bR(gR))}function CR(){let e=bR(_R),t=bR(vR);return!e||!t?null:{serverUrl:e,token:t}}function wR(){return new Bm({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function TR(e){return xR(e??SR())}function ER(e){let[t]=(0,G.useState)(()=>wR()),n=(0,G.useMemo)(()=>ry({routeTree:hR,basepath:TR(e.basePath)}),[e.basePath]);return(0,K.jsx)(Wm,{client:t,children:(0,K.jsx)(jy,{defaultConfig:e.defaultConfig===void 0?CR():e.defaultConfig,autoConnect:e.autoConnect??e.defaultConfig===void 0,storageMode:e.storageMode,children:(0,K.jsx)(oy,{router:n})})})}function DR(e){return(0,K.jsx)(`div`,{className:qI,children:(0,K.jsx)(ER,{...e})})}function OR(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Unable to mount console: ${e} not found`);return t}function kR(e,t={}){let n=OR(e);JI(n);let r=(0,Sy.createRoot)(n),i=(0,K.jsx)(DR,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(r.render(i),r):(r.render((0,K.jsx)(G.StrictMode,{children:i})),r)}var AR=`syncular-sentry-dsn`,jR=`syncular-sentry-environment`,MR=`syncular-sentry-release`;function NR(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function PR(e){if(typeof document>`u`)return;let t=document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return NR(t)}function FR(e){if(!(typeof process>`u`))return NR({}[e])}function IR(e){for(let t of e)if(t)return t}function LR(){let e=IR([NR(globalThis.__SYNCULAR_SENTRY_DSN__),PR(AR),FR(`SYNCULAR_SENTRY_DSN`)]);return e?{dsn:e,environment:IR([NR(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),PR(jR),FR(`SYNCULAR_SENTRY_ENVIRONMENT`)]),release:IR([NR(globalThis.__SYNCULAR_SENTRY_RELEASE__),PR(MR),FR(`SYNCULAR_SENTRY_RELEASE`)]),enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}:null}var RR=LR();RR&&wp(RR),kR(`#root`);
|
package/web-dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="syncular-sentry-environment" content="" />
|
|
11
11
|
<meta name="syncular-sentry-release" content="" />
|
|
12
12
|
<title>@syncular Console</title>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-DL9JUwLV.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-DDuDtRhp.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body class="syncular-console-root min-h-screen bg-background text-foreground">
|