better-auth-studio 1.0.25 → 1.0.26-beta.1
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.
|
@@ -402,4 +402,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
402
402
|
`,`
|
|
403
403
|
+`).split(`
|
|
404
404
|
`)),f=d.reduce((u,h)=>u.concat(...h),[]);return[d,f]}return[[],[]]},[e]);return p.useEffect(()=>{const c=(t==null?void 0:t.target)??Fx,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var b,x;if(i.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!i.current||i.current&&!d)&&_w(m))return!1;const y=Ux(m.code,l);if(o.current.add(m[y]),Bx(a,o.current,!1)){const v=((x=(b=m.composedPath)==null?void 0:b.call(m))==null?void 0:x[0])||m.target,g=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(i.current||!g)&&m.preventDefault(),r(!0)}},u=m=>{const w=Ux(m.code,l);Bx(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(m[w]),m.key==="Meta"&&o.current.clear(),i.current=!1},h=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function Bx(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Ux(e,t){return t.includes(e)?"code":"key"}const bT=()=>{const e=Oe();return p.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=Bh(t,r,i,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??i,u=n.snapToGrid??o;return ma(d,r,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=rc(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function eb(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const c of a)jT(c,l);n.push(l)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function jT(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured??(t.measured={}),t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function tb(e,t){return eb(e,t)}function nb(e,t){return eb(e,t)}function Qr(e,t){return{id:e,type:"select",selected:t}}function qs(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(Qr(o.id,a)))}return r}function Vx({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),c=((i=l==null?void 0:l.internals)==null?void 0:i.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Hx(e){return{id:e.id,type:"remove"}}const Wx=e=>A_(e),NT=e=>ww(e);function rb(e){return p.forwardRef(e)}const kT=typeof window<"u"?p.useLayoutEffect:p.useEffect;function Yx(e){const[t,n]=p.useState(BigInt(0)),[r]=p.useState(()=>ST(()=>n(i=>i+BigInt(1))));return kT(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function ST(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const sb=p.createContext(null);function CT({children:e}){const t=Oe(),n=p.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:u,nodeLookup:h,fitViewQueued:m}=t.getState();let w=c;for(const b of l)w=typeof b=="function"?b(w):b;const y=Vx({items:w,lookup:h});f&&d(w),y.length>0?u==null||u(y):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:b,nodes:x,setNodes:v}=t.getState();b&&v(x)})},[]),r=Yx(n),i=p.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:h}=t.getState();let m=c;for(const w of l)m=typeof w=="function"?w(m):w;f?d(m):u&&u(Vx({items:m,lookup:h}))},[]),o=Yx(i),a=p.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(sb.Provider,{value:a,children:e})}function ET(){const e=p.useContext(sb);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const _T=e=>!!e.panZoom;function Xh(){const e=bT(),t=Oe(),n=ET(),r=ye(_T),i=p.useMemo(()=>{const o=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var x,v;const{nodeLookup:h,nodeOrigin:m}=t.getState(),w=Wx(u)?u:h.get(u.id),y=w.parentId?Cw(w.position,w.measured,w.parentId,h,m):w.position,b={...w,position:y,width:((x=w.measured)==null?void 0:x.width)??w.width,height:((v=w.measured)==null?void 0:v.height)??w.height};return Ci(b)},d=(u,h,m={replace:!1})=>{a(w=>w.map(y=>{if(y.id===u){const b=typeof h=="function"?h(y):h;return m.replace&&Wx(b)?b:{...y,...b}}return y}))},f=(u,h,m={replace:!1})=>{l(w=>w.map(y=>{if(y.id===u){const b=typeof h=="function"?h(y):h;return m.replace&&NT(b)?b:{...y,...b}}return y}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var h;return(h=o(u))==null?void 0:h.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(h=>({...h}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const h=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...h])},addEdges:u=>{const h=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:u=[],edges:h=[],transform:m}=t.getState(),[w,y,b]=m;return{nodes:u.map(x=>({...x})),edges:h.map(x=>({...x})),viewport:{x:w,y,zoom:b}}},deleteElements:async({nodes:u=[],edges:h=[]})=>{const{nodes:m,edges:w,onNodesDelete:y,onEdgesDelete:b,triggerNodeChanges:x,triggerEdgeChanges:v,onDelete:g,onBeforeDelete:j}=t.getState(),{nodes:N,edges:k}=await $_({nodesToRemove:u,edgesToRemove:h,nodes:m,edges:w,onBeforeDelete:j}),S=k.length>0,_=N.length>0;if(S){const I=k.map(Hx);b==null||b(k),v(I)}if(_){const I=N.map(Hx);y==null||y(N),x(I)}return(_||S)&&(g==null||g({nodes:N,edges:k})),{deletedNodes:N,deletedEdges:k}},getIntersectingNodes:(u,h=!0,m)=>{const w=jx(u),y=w?u:c(u),b=m!==void 0;return y?(m||t.getState().nodes).filter(x=>{const v=t.getState().nodeLookup.get(x.id);if(v&&!w&&(x.id===u.id||!v.internals.positionAbsolute))return!1;const g=Ci(b?x:v),j=Yo(g,y);return h&&j>0||j>=g.width*g.height||j>=y.width*y.height}):[]},isNodeIntersecting:(u,h,m=!0)=>{const y=jx(u)?u:c(u);if(!y)return!1;const b=Yo(y,h);return m&&b>0||b>=h.width*h.height||b>=y.width*y.height},updateNode:d,updateNodeData:(u,h,m={replace:!1})=>{d(u,w=>{const y=typeof h=="function"?h(w):h;return m.replace?{...w,data:y}:{...w,data:{...w.data,...y}}},m)},updateEdge:f,updateEdgeData:(u,h,m={replace:!1})=>{f(u,w=>{const y=typeof h=="function"?h(w):h;return m.replace?{...w,data:y}:{...w,data:{...w.data,...y}}},m)},getNodesBounds:u=>{const{nodeLookup:h,nodeOrigin:m}=t.getState();return R_(u,{nodeLookup:h,nodeOrigin:m})},getHandleConnections:({type:u,id:h,nodeId:m})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${m}-${u}${h?`-${h}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:u,handleId:h,nodeId:m})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${m}${u?h?`-${u}-${h}`:`-${u}`:""}`))==null?void 0:w.values())??[])},fitView:async u=>{const h=t.getState().fitViewResolver??B_();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return p.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const Xx=e=>e.selected,PT=typeof window<"u"?window:void 0;function TT({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Oe(),{deleteElements:r}=Xh(),i=Ko(e,{actInsideInputWithModifier:!1}),o=Ko(t,{target:PT});p.useEffect(()=>{if(i){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(Xx),edges:a.filter(Xx)}),n.setState({nodesSelectionActive:!1})}},[i]),p.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function MT(e){const t=Oe();p.useEffect(()=>{const n=()=>{var i,o,a,l;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=Uh(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Ln.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Uc={position:"absolute",width:"100%",height:"100%",top:0,left:0},AT=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function RT({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:o=ls.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:u,zoomActivationKeyCode:h,preventScrolling:m=!0,children:w,noWheelClassName:y,noPanClassName:b,onViewportChange:x,isControlledViewport:v,paneClickDistance:g}){const j=Oe(),N=p.useRef(null),{userSelectionActive:k,lib:S,connectionInProgress:_}=ye(AT,He),I=Ko(h),F=p.useRef();MT(N);const O=p.useCallback(z=>{x==null||x({x:z[0],y:z[1],zoom:z[2]}),v||j.setState({transform:z})},[x,v]);return p.useEffect(()=>{if(N.current){F.current=NP({domNode:N.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,paneClickDistance:g,onDraggingChange:L=>j.setState({paneDragging:L}),onPanZoomStart:(L,A)=>{const{onViewportChangeStart:P,onMoveStart:C}=j.getState();C==null||C(L,A),P==null||P(A)},onPanZoom:(L,A)=>{const{onViewportChange:P,onMove:C}=j.getState();C==null||C(L,A),P==null||P(A)},onPanZoomEnd:(L,A)=>{const{onViewportChangeEnd:P,onMoveEnd:C}=j.getState();C==null||C(L,A),P==null||P(A)}});const{x:z,y:B,zoom:E}=F.current.getViewport();return j.setState({panZoom:F.current,transform:[z,B,E],domNode:N.current.closest(".react-flow")}),()=>{var L;(L=F.current)==null||L.destroy()}}},[]),p.useEffect(()=>{var z;(z=F.current)==null||z.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:I,preventScrolling:m,noPanClassName:b,userSelectionActive:k,noWheelClassName:y,lib:S,onTransformChange:O,connectionInProgress:_})},[e,t,n,r,i,o,a,l,I,m,b,k,y,S,O,_]),s.jsx("div",{className:"react-flow__renderer",ref:N,style:Uc,children:w})}const DT=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function IT(){const{userSelectionActive:e,userSelectionRect:t}=ye(DT,He);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Xd=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},zT=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function $T({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Wo.Full,panOnDrag:r,selectionOnDrag:i,onSelectionStart:o,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:u,onPaneMouseLeave:h,children:m}){const w=Oe(),{userSelectionActive:y,elementsSelectable:b,dragging:x,connectionInProgress:v}=ye(zT,He),g=b&&(e||y),j=p.useRef(null),N=p.useRef(),k=p.useRef(new Set),S=p.useRef(new Set),_=p.useRef(!1),I=p.useRef(!1),F=P=>{if(_.current||v){_.current=!1;return}l==null||l(P),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=P=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){P.preventDefault();return}c==null||c(P)},z=d?P=>d(P):void 0,B=P=>{var T,D;const{resetSelectedElements:C,domNode:M}=w.getState();if(N.current=M==null?void 0:M.getBoundingClientRect(),!b||!e||P.button!==0||P.target!==j.current||!N.current)return;(D=(T=P.target)==null?void 0:T.setPointerCapture)==null||D.call(T,P.pointerId),I.current=!0,_.current=!1;const{x:$,y:R}=pn(P.nativeEvent,N.current);C(),w.setState({userSelectionRect:{width:0,height:0,startX:$,startY:R,x:$,y:R}}),o==null||o(P)},E=P=>{const{userSelectionRect:C,transform:M,nodeLookup:$,edgeLookup:R,connectionLookup:T,triggerNodeChanges:D,triggerEdgeChanges:U,defaultEdgeOptions:H}=w.getState();if(!N.current||!C)return;_.current=!0;const{x:W,y:G}=pn(P.nativeEvent,N.current),{startX:V,startY:q}=C,ne={startX:V,startY:q,x:W<V?W:V,y:G<q?G:q,width:Math.abs(W-V),height:Math.abs(G-q)},se=k.current,te=S.current;k.current=new Set(Fh($,ne,M,n===Wo.Partial,!0).map(re=>re.id)),S.current=new Set;const ee=(H==null?void 0:H.selectable)??!0;for(const re of k.current){const me=T.get(re);if(me)for(const{edgeId:ge}of me.values()){const Ce=R.get(ge);Ce&&(Ce.selectable??ee)&&S.current.add(ge)}}if(!Nx(se,k.current)){const re=qs($,k.current,!0);D(re)}if(!Nx(te,S.current)){const re=qs(R,S.current);U(re)}w.setState({userSelectionRect:ne,userSelectionActive:!0,nodesSelectionActive:!1})},L=P=>{var M,$;if(P.button!==0||!I.current)return;($=(M=P.target)==null?void 0:M.releasePointerCapture)==null||$.call(M,P.pointerId);const{userSelectionRect:C}=w.getState();!y&&C&&P.target===j.current&&(F==null||F(P)),w.setState({userSelectionActive:!1,userSelectionRect:null,nodesSelectionActive:k.current.size>0}),a==null||a(P),(t||i)&&(_.current=!1),I.current=!1},A=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:Je(["react-flow__pane",{draggable:A,dragging:x,selection:e}]),onClick:g?void 0:Xd(F,j),onContextMenu:Xd(O,j),onWheel:Xd(z,j),onPointerEnter:g?void 0:f,onPointerDown:g?B:u,onPointerMove:g?E:u,onPointerUp:g?L:void 0,onPointerLeave:h,ref:j,style:Uc,children:[m,s.jsx(IT,{})]})}function gf({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",Ln.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):i([e])}function ib({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:a}){const l=Oe(),[c,d]=p.useState(!1),f=p.useRef();return p.useEffect(()=>{f.current=lP({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{gf({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),p.useEffect(()=>{var u,h;if(t)(u=f.current)==null||u.destroy();else if(e.current)return(h=f.current)==null||h.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:a}),()=>{var m;(m=f.current)==null||m.destroy()}},[n,r,t,o,e,i]),c}const LT=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ob(){const e=Oe();return p.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),u=new Map,h=LT(a),m=i?o[0]:5,w=i?o[1]:5,y=n.direction.x*m*n.factor,b=n.direction.y*w*n.factor;for(const[,x]of d){if(!h(x))continue;let v={x:x.internals.positionAbsolute.x+y,y:x.internals.positionAbsolute.y+b};i&&(v=ha(v,o));const{position:g,positionAbsolute:j}=bw({nodeId:x.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});x.position=g,x.internals.positionAbsolute=j,u.set(x.id,x)}c(u)},[])}const Gh=p.createContext(null),OT=Gh.Provider;Gh.Consumer;const ab=()=>p.useContext(Gh),FT=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),BT=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===ki.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!i,valid:f&&d}};function UT({type:e="source",position:t=le.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:u,...h},m){var L,A;const w=a||null,y=e==="target",b=Oe(),x=ab(),{connectOnClick:v,noPanClassName:g,rfId:j}=ye(FT,He),{connectingFrom:N,connectingTo:k,clickConnecting:S,isPossibleEndHandle:_,connectionInProcess:I,clickConnectionInProcess:F,valid:O}=ye(BT(x,w,e),He);x||(A=(L=b.getState()).onError)==null||A.call(L,"010",Ln.error010());const z=P=>{const{defaultEdgeOptions:C,onConnect:M,hasDefaultEdges:$}=b.getState(),R={...C,...P};if($){const{edges:T,setEdges:D}=b.getState();D(Rw(R,T))}M==null||M(R),l==null||l(R)},B=P=>{if(!x)return;const C=Pw(P.nativeEvent);if(i&&(C&&P.button===0||!C)){const M=b.getState();xf.onPointerDown(P.nativeEvent,{handleDomNode:P.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:y,handleId:w,nodeId:x,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:M.onConnectEnd,updateConnection:M.updateConnection,onConnect:z,isValidConnection:n||M.isValidConnection,getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}C?f==null||f(P):u==null||u(P)},E=P=>{const{onClickConnectStart:C,onClickConnectEnd:M,connectionClickStartHandle:$,connectionMode:R,isValidConnection:T,lib:D,rfId:U,nodeLookup:H,connection:W}=b.getState();if(!x||!$&&!i)return;if(!$){C==null||C(P.nativeEvent,{nodeId:x,handleId:w,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:x,type:e,id:w}});return}const G=Ew(P.target),V=n||T,{connection:q,isValid:ne}=xf.isValid(P.nativeEvent,{handle:{nodeId:x,id:w,type:e},connectionMode:R,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:V,flowId:U,doc:G,lib:D,nodeLookup:H});ne&&q&&z(q);const se=structuredClone(W);delete se.inProgress,se.toPosition=se.toHandle?se.toHandle.position:null,M==null||M(P,se),b.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":w,"data-nodeid":x,"data-handlepos":t,"data-id":`${j}-${x}-${w}-${e}`,className:Je(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,d,{source:!y,target:y,connectable:r,connectablestart:i,connectableend:o,clickconnecting:S,connectingfrom:N,connectingto:k,valid:O,connectionindicator:r&&(!I||_)&&(I||F?o:i)}]),onMouseDown:B,onTouchStart:B,onClick:v?E:void 0,ref:m,...h,children:c})}const cs=p.memo(rb(UT));function VT({data:e,isConnectable:t,sourcePosition:n=le.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(cs,{type:"source",position:n,isConnectable:t})]})}function HT({data:e,isConnectable:t,targetPosition:n=le.Top,sourcePosition:r=le.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(cs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(cs,{type:"source",position:r,isConnectable:t})]})}function WT(){return null}function YT({data:e,isConnectable:t,targetPosition:n=le.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(cs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const sc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Gx={input:VT,default:HT,output:YT,group:WT};function XT(e){var t,n,r,i;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((i=e.style)==null?void 0:i.height)}}const GT=e=>{const{width:t,height:n,x:r,y:i}=fa(e.nodeLookup,{filter:o=>!!o.selected});return{width:mn(t)?t:null,height:mn(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function KT({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Oe(),{width:i,height:o,transformString:a,userSelectionActive:l}=ye(GT,He),c=ob(),d=p.useRef(null);if(p.useEffect(()=>{var h;n||(h=d.current)==null||h.focus({preventScroll:!0})},[n]),ib({nodeRef:d}),l||!i||!o)return null;const f=e?h=>{const m=r.getState().nodes.filter(w=>w.selected);e(h,m)}:void 0,u=h=>{Object.prototype.hasOwnProperty.call(sc,h.key)&&(h.preventDefault(),c({direction:sc[h.key],factor:h.shiftKey?4:1}))};return s.jsx("div",{className:Je(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:s.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:i,height:o}})})}const Kx=typeof window<"u"?window:void 0,qT=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function lb({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:u,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:w,panActivationKeyCode:y,zoomActivationKeyCode:b,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:j,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:_,defaultViewport:I,translateExtent:F,minZoom:O,maxZoom:z,preventScrolling:B,onSelectionContextMenu:E,noWheelClassName:L,noPanClassName:A,disableKeyboardA11y:P,onViewportChange:C,isControlledViewport:M}){const{nodesSelectionActive:$,userSelectionActive:R}=ye(qT),T=Ko(d,{target:Kx}),D=Ko(y,{target:Kx}),U=D||_,H=D||j,W=f&&U!==!0,G=T||R||W;return TT({deleteKeyCode:c,multiSelectionKeyCode:w}),s.jsx(RT,{onPaneContextMenu:o,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:H,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:!T&&U,defaultViewport:I,translateExtent:F,minZoom:O,maxZoom:z,zoomActivationKeyCode:b,preventScrolling:B,noWheelClassName:L,noPanClassName:A,onViewportChange:C,isControlledViewport:M,paneClickDistance:l,children:s.jsxs($T,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:U,isSelecting:!!G,selectionMode:u,selectionKeyPressed:T,selectionOnDrag:W,children:[e,$&&s.jsx(KT,{onSelectionContextMenu:E,noPanClassName:A,disableKeyboardA11y:P})]})})}lb.displayName="FlowRenderer";const QT=p.memo(lb),ZT=e=>t=>e?Fh(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function JT(e){return ye(p.useCallback(ZT(e),[e]),He)}const eM=e=>e.updateNodeInternals;function tM(){const e=ye(eM),[t]=p.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return p.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function nM({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=Oe(),o=p.useRef(null),a=p.useRef(null),l=p.useRef(e.sourcePosition),c=p.useRef(e.targetPosition),d=p.useRef(t),f=n&&!!e.internals.handleBounds;return p.useEffect(()=>{o.current&&!e.hidden&&(!f||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[f,e.hidden]),p.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),p.useEffect(()=>{if(o.current){const u=d.current!==t,h=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||h||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function rM({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:u,noDragClassName:h,noPanClassName:m,disableKeyboardA11y:w,rfId:y,nodeTypes:b,nodeClickDistance:x,onError:v}){const{node:g,internals:j,isParent:N}=ye(V=>{const q=V.nodeLookup.get(e),ne=V.parentLookup.has(e);return{node:q,internals:q.internals,isParent:ne}},He);let k=g.type||"default",S=(b==null?void 0:b[k])||Gx[k];S===void 0&&(v==null||v("003",Ln.error003(k)),k="default",S=(b==null?void 0:b.default)||Gx.default);const _=!!(g.draggable||l&&typeof g.draggable>"u"),I=!!(g.selectable||c&&typeof g.selectable>"u"),F=!!(g.connectable||d&&typeof g.connectable>"u"),O=!!(g.focusable||f&&typeof g.focusable>"u"),z=Oe(),B=Sw(g),E=nM({node:g,nodeType:k,hasDimensions:B,resizeObserver:u}),L=ib({nodeRef:E,disabled:g.hidden||!_,noDragClassName:h,handleSelector:g.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:x}),A=ob();if(g.hidden)return null;const P=cr(g),C=XT(g),M=I||_||t||n||r||i,$=n?V=>n(V,{...j.userNode}):void 0,R=r?V=>r(V,{...j.userNode}):void 0,T=i?V=>i(V,{...j.userNode}):void 0,D=o?V=>o(V,{...j.userNode}):void 0,U=a?V=>a(V,{...j.userNode}):void 0,H=V=>{const{selectNodesOnDrag:q,nodeDragThreshold:ne}=z.getState();I&&(!q||!_||ne>0)&&gf({id:e,store:z,nodeRef:E}),t&&t(V,{...j.userNode})},W=V=>{if(!(_w(V.nativeEvent)||w)){if(xw.includes(V.key)&&I){const q=V.key==="Escape";gf({id:e,store:z,unselect:q,nodeRef:E})}else if(_&&g.selected&&Object.prototype.hasOwnProperty.call(sc,V.key)){V.preventDefault();const{ariaLabelConfig:q}=z.getState();z.setState({ariaLiveMessage:q["node.a11yDescription.ariaLiveMessage"]({direction:V.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),A({direction:sc[V.key],factor:V.shiftKey?4:1})}}},G=()=>{var re;if(w||!((re=E.current)!=null&&re.matches(":focus-visible")))return;const{transform:V,width:q,height:ne,autoPanOnNodeFocus:se,setCenter:te}=z.getState();if(!se)return;Fh(new Map([[e,g]]),{x:0,y:0,width:q,height:ne},V,!0).length>0||te(g.position.x+P.width/2,g.position.y+P.height/2,{zoom:V[2]})};return s.jsx("div",{className:Je(["react-flow__node",`react-flow__node-${k}`,{[m]:_},g.className,{selected:g.selected,selectable:I,parent:N,draggable:_,dragging:L}]),ref:E,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:B?"visible":"hidden",...g.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:$,onMouseMove:R,onMouseLeave:T,onContextMenu:D,onClick:H,onDoubleClick:U,onKeyDown:O?W:void 0,tabIndex:O?0:void 0,onFocus:O?G:void 0,role:g.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Qw}-${y}`,"aria-label":g.ariaLabel,...g.domAttributes,children:s.jsx(OT,{value:e,children:s.jsx(S,{id:e,data:g.data,type:k,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:g.selected??!1,selectable:I,draggable:_,deletable:g.deletable??!0,isConnectable:F,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:L,dragHandle:g.dragHandle,zIndex:j.z,parentId:g.parentId,...P})})})}const sM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function cb(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:o}=ye(sM,He),a=JT(e.onlyRenderVisibleElements),l=tM();return s.jsx("div",{className:"react-flow__nodes",style:Uc,children:a.map(c=>s.jsx(rM,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}cb.displayName="NodeRenderer";const iM=p.memo(cb);function oM(e){return ye(p.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),a=n.nodeLookup.get(i.target);o&&a&&W_({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),He)}const aM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},lM=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},qx={[tc.Arrow]:aM,[tc.ArrowClosed]:lM};function cM(e){const t=Oe();return p.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(qx,e)?qx[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",Ln.error009(e)),null)},[e])}const dM=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=cM(t);return c?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:s.jsx(c,{color:n,strokeWidth:a})}):null},db=({defaultColor:e,rfId:t})=>{const n=ye(o=>o.edges),r=ye(o=>o.defaultEdgeOptions),i=p.useMemo(()=>Z_(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(dM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};db.displayName="MarkerDefinitions";var uM=p.memo(db);function ub({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[u,h]=p.useState({x:1,y:0,width:0,height:0}),m=Je(["react-flow__edge-textwrapper",d]),w=p.useRef(null);return p.useEffect(()=>{if(w.current){const y=w.current.getBBox();h({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...f,children:[i&&s.jsx("rect",{width:u.width+2*a[0],x:-a[0],y:-a[1],height:u.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),s.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:w,style:r,children:n}),c]}):null}ub.displayName="EdgeText";const fM=p.memo(ub);function Vc({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...f,d:e,fill:"none",className:Je(["react-flow__edge-path",f.className])}),d?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&mn(t)&&mn(n)?s.jsx(fM,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function Qx({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===le.Left||e===le.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function fb({sourceX:e,sourceY:t,sourcePosition:n=le.Bottom,targetX:r,targetY:i,targetPosition:o=le.Top}){const[a,l]=Qx({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,d]=Qx({pos:o,x1:r,y1:i,x2:e,y2:t}),[f,u,h,m]=Tw({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${i}`,f,u,h,m]}function hb(e){return p.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:b,interactionWidth:x})=>{const[v,g,j]=fb({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l}),N=e.isInternal?void 0:t;return s.jsx(Vc,{id:N,path:v,labelX:g,labelY:j,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:b,interactionWidth:x})})}const hM=hb({isInternal:!1}),mb=hb({isInternal:!0});hM.displayName="SimpleBezierEdge";mb.displayName="SimpleBezierEdgeInternal";function pb(e){return p.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:h,sourcePosition:m=le.Bottom,targetPosition:w=le.Top,markerEnd:y,markerStart:b,pathOptions:x,interactionWidth:v})=>{const[g,j,N]=hf({sourceX:n,sourceY:r,sourcePosition:m,targetX:i,targetY:o,targetPosition:w,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset,stepPosition:x==null?void 0:x.stepPosition}),k=e.isInternal?void 0:t;return s.jsx(Vc,{id:k,path:g,labelX:j,labelY:N,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:h,markerEnd:y,markerStart:b,interactionWidth:v})})}const xb=pb({isInternal:!1}),gb=pb({isInternal:!0});xb.displayName="SmoothStepEdge";gb.displayName="SmoothStepEdgeInternal";function yb(e){return p.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(xb,{...n,id:r,pathOptions:p.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const mM=yb({isInternal:!1}),vb=yb({isInternal:!0});mM.displayName="StepEdge";vb.displayName="StepEdgeInternal";function wb(e){return p.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:h,markerEnd:m,markerStart:w,interactionWidth:y})=>{const[b,x,v]=Dw({sourceX:n,sourceY:r,targetX:i,targetY:o}),g=e.isInternal?void 0:t;return s.jsx(Vc,{id:g,path:b,labelX:x,labelY:v,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:h,markerEnd:m,markerStart:w,interactionWidth:y})})}const pM=wb({isInternal:!1}),bb=wb({isInternal:!0});pM.displayName="StraightEdge";bb.displayName="StraightEdgeInternal";function jb(e){return p.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a=le.Bottom,targetPosition:l=le.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:b,pathOptions:x,interactionWidth:v})=>{const[g,j,N]=Mw({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l,curvature:x==null?void 0:x.curvature}),k=e.isInternal?void 0:t;return s.jsx(Vc,{id:k,path:g,labelX:j,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:b,interactionWidth:v})})}const xM=jb({isInternal:!1}),Nb=jb({isInternal:!0});xM.displayName="BezierEdge";Nb.displayName="BezierEdgeInternal";const Zx={default:Nb,straight:bb,step:vb,smoothstep:gb,simplebezier:mb},Jx={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},gM=(e,t,n)=>n===le.Left?e-t:n===le.Right?e+t:e,yM=(e,t,n)=>n===le.Top?e-t:n===le.Bottom?e+t:e,eg="react-flow__edgeupdater";function tg({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:l}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:Je([eg,`${eg}-${l}`]),cx:gM(t,r,e),cy:yM(n,r,e),r,stroke:"transparent",fill:"transparent"})}function vM({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:u,setReconnecting:h,setUpdateHover:m}){const w=Oe(),y=(j,N)=>{if(j.button!==0)return;const{autoPanOnConnect:k,domNode:S,isValidConnection:_,connectionMode:I,connectionRadius:F,lib:O,onConnectStart:z,onConnectEnd:B,cancelConnection:E,nodeLookup:L,rfId:A,panBy:P,updateConnection:C}=w.getState(),M=N.type==="target",$=(D,U)=>{h(!1),u==null||u(D,n,N.type,U)},R=D=>d==null?void 0:d(n,D),T=(D,U)=>{h(!0),f==null||f(j,n,N.type),z==null||z(D,U)};xf.onPointerDown(j.nativeEvent,{autoPanOnConnect:k,connectionMode:I,connectionRadius:F,domNode:S,handleId:N.id,nodeId:N.nodeId,nodeLookup:L,isTarget:M,edgeUpdaterType:N.type,lib:O,flowId:A,cancelConnection:E,panBy:P,isValidConnection:_,onConnect:R,onConnectStart:T,onConnectEnd:B,onReconnectEnd:$,updateConnection:C,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},b=j=>y(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=j=>y(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),g=()=>m(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(tg,{position:l,centerX:r,centerY:i,radius:t,onMouseDown:b,onMouseEnter:v,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&s.jsx(tg,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:x,onMouseEnter:v,onMouseOut:g,type:"target"})]})}function wM({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:u,onReconnectStart:h,onReconnectEnd:m,rfId:w,edgeTypes:y,noPanClassName:b,onError:x,disableKeyboardA11y:v}){let g=ye(te=>te.edgeLookup.get(e));const j=ye(te=>te.defaultEdgeOptions);g=j?{...j,...g}:g;let N=g.type||"default",k=(y==null?void 0:y[N])||Zx[N];k===void 0&&(x==null||x("011",Ln.error011(N)),N="default",k=(y==null?void 0:y.default)||Zx.default);const S=!!(g.focusable||t&&typeof g.focusable>"u"),_=typeof u<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),I=!!(g.selectable||r&&typeof g.selectable>"u"),F=p.useRef(null),[O,z]=p.useState(!1),[B,E]=p.useState(!1),L=Oe(),{zIndex:A,sourceX:P,sourceY:C,targetX:M,targetY:$,sourcePosition:R,targetPosition:T}=ye(p.useCallback(te=>{const ee=te.nodeLookup.get(g.source),re=te.nodeLookup.get(g.target);if(!ee||!re)return{zIndex:g.zIndex,...Jx};const me=Q_({id:e,sourceNode:ee,targetNode:re,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:te.connectionMode,onError:x});return{zIndex:H_({selected:g.selected,zIndex:g.zIndex,sourceNode:ee,targetNode:re,elevateOnSelect:te.elevateEdgesOnSelect}),...me||Jx}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),He),D=p.useMemo(()=>g.markerStart?`url('#${mf(g.markerStart,w)}')`:void 0,[g.markerStart,w]),U=p.useMemo(()=>g.markerEnd?`url('#${mf(g.markerEnd,w)}')`:void 0,[g.markerEnd,w]);if(g.hidden||P===null||C===null||M===null||$===null)return null;const H=te=>{var ge;const{addSelectedEdges:ee,unselectNodesAndEdges:re,multiSelectionActive:me}=L.getState();I&&(L.setState({nodesSelectionActive:!1}),g.selected&&me?(re({nodes:[],edges:[g]}),(ge=F.current)==null||ge.blur()):ee([e])),i&&i(te,g)},W=o?te=>{o(te,{...g})}:void 0,G=a?te=>{a(te,{...g})}:void 0,V=l?te=>{l(te,{...g})}:void 0,q=c?te=>{c(te,{...g})}:void 0,ne=d?te=>{d(te,{...g})}:void 0,se=te=>{var ee;if(!v&&xw.includes(te.key)&&I){const{unselectNodesAndEdges:re,addSelectedEdges:me}=L.getState();te.key==="Escape"?((ee=F.current)==null||ee.blur(),re({edges:[g]})):me([e])}};return s.jsx("svg",{style:{zIndex:A},children:s.jsxs("g",{className:Je(["react-flow__edge",`react-flow__edge-${N}`,g.className,b,{selected:g.selected,animated:g.animated,inactive:!I&&!i,updating:O,selectable:I}]),onClick:H,onDoubleClick:W,onContextMenu:G,onMouseEnter:V,onMouseMove:q,onMouseLeave:ne,onKeyDown:S?se:void 0,tabIndex:S?0:void 0,role:g.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":S?`${Zw}-${w}`:void 0,ref:F,...g.domAttributes,children:[!B&&s.jsx(k,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:I,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:P,sourceY:C,targetX:M,targetY:$,sourcePosition:R,targetPosition:T,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:D,markerEnd:U,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),_&&s.jsx(vM,{edge:g,isReconnectable:_,reconnectRadius:f,onReconnect:u,onReconnectStart:h,onReconnectEnd:m,sourceX:P,sourceY:C,targetX:M,targetY:$,sourcePosition:R,targetPosition:T,setUpdateHover:z,setReconnecting:E})]})})}const bM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function kb({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:h,onReconnectStart:m,onReconnectEnd:w,disableKeyboardA11y:y}){const{edgesFocusable:b,edgesReconnectable:x,elementsSelectable:v,onError:g}=ye(bM,He),j=oM(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(uM,{defaultColor:e,rfId:n}),j.map(N=>s.jsx(wM,{id:N,edgesFocusable:b,edgesReconnectable:x,elementsSelectable:v,noPanClassName:i,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:u,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:w,rfId:n,onError:g,edgeTypes:r,disableKeyboardA11y:y},N))]})}kb.displayName="EdgeRenderer";const jM=p.memo(kb),NM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function kM({children:e}){const t=ye(NM);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function SM(e){const t=Xh(),n=p.useRef(!1);p.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const CM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function EM(e){const t=ye(CM),n=Oe();return p.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function _M(e){return e.connection.inProgress?{...e.connection,to:ma(e.connection.to,e.transform)}:{...e.connection}}function PM(e){return _M}function TM(e){const t=PM();return ye(t,He)}const MM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function AM({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:a,isValid:l,inProgress:c}=ye(MM,He);return!(o&&i&&c)?null:s.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:Je(["react-flow__connection",vw(l)]),children:s.jsx(Sb,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Sb=({style:e,type:t=wr.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:u,toPosition:h}=TM();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:h,connectionStatus:vw(r),toNode:f,toHandle:u});let m="";const w={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:h};switch(t){case wr.Bezier:[m]=Mw(w);break;case wr.SimpleBezier:[m]=fb(w);break;case wr.Step:[m]=hf({...w,borderRadius:0});break;case wr.SmoothStep:[m]=hf(w);break;default:[m]=Dw(w)}return s.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};Sb.displayName="ConnectionLine";const RM={};function ng(e=RM){p.useRef(e),Oe(),p.useEffect(()=>{},[e])}function DM(){Oe(),p.useRef(!1),p.useEffect(()=>{},[])}function Cb({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:h,onSelectionEnd:m,connectionLineType:w,connectionLineStyle:y,connectionLineComponent:b,connectionLineContainerStyle:x,selectionKeyCode:v,selectionOnDrag:g,selectionMode:j,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:S,deleteKeyCode:_,onlyRenderVisibleElements:I,elementsSelectable:F,defaultViewport:O,translateExtent:z,minZoom:B,maxZoom:E,preventScrolling:L,defaultMarkerColor:A,zoomOnScroll:P,zoomOnPinch:C,panOnScroll:M,panOnScrollSpeed:$,panOnScrollMode:R,zoomOnDoubleClick:T,panOnDrag:D,onPaneClick:U,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:G,onPaneScroll:V,onPaneContextMenu:q,paneClickDistance:ne,nodeClickDistance:se,onEdgeContextMenu:te,onEdgeMouseEnter:ee,onEdgeMouseMove:re,onEdgeMouseLeave:me,reconnectRadius:ge,onReconnect:Ce,onReconnectStart:Ke,onReconnectEnd:Ee,noDragClassName:pt,noWheelClassName:Nn,noPanClassName:Ae,disableKeyboardA11y:lt,nodeExtent:on,rfId:kn,viewport:Q,onViewportChange:ie}){return ng(e),ng(t),DM(),SM(n),EM(Q),s.jsx(QT,{onPaneClick:U,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:G,onPaneContextMenu:q,onPaneScroll:V,paneClickDistance:ne,deleteKeyCode:_,selectionKeyCode:v,selectionOnDrag:g,selectionMode:j,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:S,elementsSelectable:F,zoomOnScroll:P,zoomOnPinch:C,zoomOnDoubleClick:T,panOnScroll:M,panOnScrollSpeed:$,panOnScrollMode:R,panOnDrag:D,defaultViewport:O,translateExtent:z,minZoom:B,maxZoom:E,onSelectionContextMenu:u,preventScrolling:L,noDragClassName:pt,noWheelClassName:Nn,noPanClassName:Ae,disableKeyboardA11y:lt,onViewportChange:ie,isControlledViewport:!!Q,children:s.jsxs(kM,{children:[s.jsx(jM,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:a,onReconnect:Ce,onReconnectStart:Ke,onReconnectEnd:Ee,onlyRenderVisibleElements:I,onEdgeContextMenu:te,onEdgeMouseEnter:ee,onEdgeMouseMove:re,onEdgeMouseLeave:me,reconnectRadius:ge,defaultMarkerColor:A,noPanClassName:Ae,disableKeyboardA11y:lt,rfId:kn}),s.jsx(AM,{style:y,type:w,component:b,containerStyle:x}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(iM,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:se,onlyRenderVisibleElements:I,noPanClassName:Ae,noDragClassName:pt,disableKeyboardA11y:lt,nodeExtent:on,rfId:kn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}Cb.displayName="GraphView";const IM=p.memo(Cb),rg=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:u}={})=>{const h=new Map,m=new Map,w=new Map,y=new Map,b=r??t??[],x=n??e??[],v=f??[0,0],g=u??Ho;zw(w,y,b);const j=pf(x,h,m,{nodeOrigin:v,nodeExtent:g,elevateNodesOnSelect:!1});let N=[0,0,1];if(a&&i&&o){const k=fa(h,{filter:F=>!!((F.width||F.initialWidth)&&(F.height||F.initialHeight))}),{x:S,y:_,zoom:I}=Bh(k,i,o,c,d,(l==null?void 0:l.padding)??.1);N=[S,_,I]}return{rfId:"1",width:i??0,height:o??0,transform:N,nodes:x,nodesInitialized:j,nodeLookup:h,parentLookup:m,edges:b,edgeLookup:y,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Ho,nodeExtent:g,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ki.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...yw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:L_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:gw}},zM=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u})=>nT((h,m)=>{async function w(){const{nodeLookup:y,panZoom:b,fitViewOptions:x,fitViewResolver:v,width:g,height:j,minZoom:N,maxZoom:k}=m();b&&(await z_({nodes:y,width:g,height:j,panZoom:b,minZoom:N,maxZoom:k},x),v==null||v.resolve(!0),h({fitViewResolver:null}))}return{...rg({nodes:e,edges:t,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r}),setNodes:y=>{const{nodeLookup:b,parentLookup:x,nodeOrigin:v,elevateNodesOnSelect:g,fitViewQueued:j}=m(),N=pf(y,b,x,{nodeOrigin:v,nodeExtent:u,elevateNodesOnSelect:g,checkEquality:!0});j&&N?(w(),h({nodes:y,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:y,nodesInitialized:N})},setEdges:y=>{const{connectionLookup:b,edgeLookup:x}=m();zw(b,x,y),h({edges:y})},setDefaultNodesAndEdges:(y,b)=>{if(y){const{setNodes:x}=m();x(y),h({hasDefaultNodes:!0})}if(b){const{setEdges:x}=m();x(b),h({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:b,nodeLookup:x,parentLookup:v,domNode:g,nodeOrigin:j,nodeExtent:N,debug:k,fitViewQueued:S}=m(),{changes:_,updatedInternals:I}=sP(y,x,v,g,j,N);I&&(eP(x,v,{nodeOrigin:j,nodeExtent:N}),S?(w(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(_==null?void 0:_.length)>0&&(k&&console.log("React Flow: trigger node changes",_),b==null||b(_)))},updateNodePositions:(y,b=!1)=>{const x=[],v=[],{nodeLookup:g,triggerNodeChanges:j}=m();for(const[N,k]of y){const S=g.get(N),_=!!(S!=null&&S.expandParent&&(S!=null&&S.parentId)&&(k!=null&&k.position)),I={id:N,type:"position",position:_?{x:Math.max(0,k.position.x),y:Math.max(0,k.position.y)}:k.position,dragging:b};_&&S.parentId&&x.push({id:N,parentId:S.parentId,rect:{...k.internals.positionAbsolute,width:k.measured.width??0,height:k.measured.height??0}}),v.push(I)}if(x.length>0){const{parentLookup:N,nodeOrigin:k}=m(),S=Yh(x,g,N,k);v.push(...S)}j(v)},triggerNodeChanges:y=>{const{onNodesChange:b,setNodes:x,nodes:v,hasDefaultNodes:g,debug:j}=m();if(y!=null&&y.length){if(g){const N=tb(y,v);x(N)}j&&console.log("React Flow: trigger node changes",y),b==null||b(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:b,setEdges:x,edges:v,hasDefaultEdges:g,debug:j}=m();if(y!=null&&y.length){if(g){const N=nb(y,v);x(N)}j&&console.log("React Flow: trigger edge changes",y),b==null||b(y)}},addSelectedNodes:y=>{const{multiSelectionActive:b,edgeLookup:x,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:j}=m();if(b){const N=y.map(k=>Qr(k,!0));g(N);return}g(qs(v,new Set([...y]),!0)),j(qs(x))},addSelectedEdges:y=>{const{multiSelectionActive:b,edgeLookup:x,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:j}=m();if(b){const N=y.map(k=>Qr(k,!0));j(N);return}j(qs(x,new Set([...y]))),g(qs(v,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:b}={})=>{const{edges:x,nodes:v,nodeLookup:g,triggerNodeChanges:j,triggerEdgeChanges:N}=m(),k=y||v,S=b||x,_=k.map(F=>{const O=g.get(F.id);return O&&(O.selected=!1),Qr(F.id,!1)}),I=S.map(F=>Qr(F.id,!1));j(_),N(I)},setMinZoom:y=>{const{panZoom:b,maxZoom:x}=m();b==null||b.setScaleExtent([y,x]),h({minZoom:y})},setMaxZoom:y=>{const{panZoom:b,minZoom:x}=m();b==null||b.setScaleExtent([x,y]),h({maxZoom:y})},setTranslateExtent:y=>{var b;(b=m().panZoom)==null||b.setTranslateExtent(y),h({translateExtent:y})},setPaneClickDistance:y=>{var b;(b=m().panZoom)==null||b.setClickDistance(y)},resetSelectedElements:()=>{const{edges:y,nodes:b,triggerNodeChanges:x,triggerEdgeChanges:v,elementsSelectable:g}=m();if(!g)return;const j=b.reduce((k,S)=>S.selected?[...k,Qr(S.id,!1)]:k,[]),N=y.reduce((k,S)=>S.selected?[...k,Qr(S.id,!1)]:k,[]);x(j),v(N)},setNodeExtent:y=>{const{nodes:b,nodeLookup:x,parentLookup:v,nodeOrigin:g,elevateNodesOnSelect:j,nodeExtent:N}=m();y[0][0]===N[0][0]&&y[0][1]===N[0][1]&&y[1][0]===N[1][0]&&y[1][1]===N[1][1]||(pf(b,x,v,{nodeOrigin:g,nodeExtent:y,elevateNodesOnSelect:j,checkEquality:!1}),h({nodeExtent:y}))},panBy:y=>{const{transform:b,width:x,height:v,panZoom:g,translateExtent:j}=m();return iP({delta:y,panZoom:g,transform:b,translateExtent:j,width:x,height:v})},setCenter:async(y,b,x)=>{const{width:v,height:g,maxZoom:j,panZoom:N}=m();if(!N)return Promise.resolve(!1);const k=typeof(x==null?void 0:x.zoom)<"u"?x.zoom:j;return await N.setViewport({x:v/2-y*k,y:g/2-b*k,zoom:k},{duration:x==null?void 0:x.duration,ease:x==null?void 0:x.ease,interpolate:x==null?void 0:x.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...yw}})},updateConnection:y=>{h({connection:y})},reset:()=>h({...rg()})}},Object.is);function $M({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:u,children:h}){const[m]=p.useState(()=>zM({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:u}));return s.jsx(rT,{value:m,children:s.jsx(CT,{children:h})})}function LM({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:u,nodeExtent:h}){return p.useContext(Fc)?s.jsx(s.Fragment,{children:e}):s.jsx($M,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:u,nodeExtent:h,children:e})}const OM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function FM({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:u,onMoveEnd:h,onConnect:m,onConnectStart:w,onConnectEnd:y,onClickConnectStart:b,onClickConnectEnd:x,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:j,onNodeContextMenu:N,onNodeDoubleClick:k,onNodeDragStart:S,onNodeDrag:_,onNodeDragStop:I,onNodesDelete:F,onEdgesDelete:O,onDelete:z,onSelectionChange:B,onSelectionDragStart:E,onSelectionDrag:L,onSelectionDragStop:A,onSelectionContextMenu:P,onSelectionStart:C,onSelectionEnd:M,onBeforeDelete:$,connectionMode:R,connectionLineType:T=wr.Bezier,connectionLineStyle:D,connectionLineComponent:U,connectionLineContainerStyle:H,deleteKeyCode:W="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:V=!1,selectionMode:q=Wo.Full,panActivationKeyCode:ne="Space",multiSelectionKeyCode:se=Xo()?"Meta":"Control",zoomActivationKeyCode:te=Xo()?"Meta":"Control",snapToGrid:ee,snapGrid:re,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:ge,nodesDraggable:Ce,autoPanOnNodeFocus:Ke,nodesConnectable:Ee,nodesFocusable:pt,nodeOrigin:Nn=Jw,edgesFocusable:Ae,edgesReconnectable:lt,elementsSelectable:on=!0,defaultViewport:kn=xT,minZoom:Q=.5,maxZoom:ie=2,translateExtent:he=Ho,preventScrolling:_e=!0,nodeExtent:Fe,defaultMarkerColor:Ne="#b1b1b7",zoomOnScroll:Pe=!0,zoomOnPinch:Xr=!0,panOnScroll:K=!1,panOnScrollSpeed:ae=.5,panOnScrollMode:de=ls.Free,zoomOnDoubleClick:qe=!0,panOnDrag:ct=!0,onPaneClick:je,onPaneMouseEnter:an,onPaneMouseMove:Zc,onPaneMouseLeave:xa,onPaneScroll:ga,onPaneContextMenu:ue,paneClickDistance:Ye=0,nodeClickDistance:it=0,children:jt,onReconnect:Es,onReconnectStart:et,onReconnectEnd:Et,onEdgeContextMenu:_s,onEdgeDoubleClick:It,onEdgeMouseEnter:zt,onEdgeMouseMove:ya,onEdgeMouseLeave:Un,reconnectRadius:om=10,onNodesChange:x1,onEdgesChange:g1,noDragClassName:y1="nodrag",noWheelClassName:v1="nowheel",noPanClassName:am="nopan",fitView:lm,fitViewOptions:cm,connectOnClick:w1,attributionPosition:b1,proOptions:j1,defaultEdgeOptions:N1,elevateNodesOnSelect:k1,elevateEdgesOnSelect:S1,disableKeyboardA11y:dm=!1,autoPanOnConnect:C1,autoPanOnNodeDrag:E1,autoPanSpeed:_1,connectionRadius:P1,isValidConnection:T1,onError:M1,style:A1,id:um,nodeDragThreshold:R1,connectionDragThreshold:D1,viewport:I1,onViewportChange:z1,width:$1,height:L1,colorMode:O1="light",debug:F1,onScroll:va,ariaLabelConfig:B1,...U1},V1){const Jc=um||"1",H1=wT(O1),W1=p.useCallback(fm=>{fm.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),va==null||va(fm)},[va]);return s.jsx("div",{"data-testid":"rf__wrapper",...U1,onScroll:W1,style:{...A1,...OM},ref:V1,className:Je(["react-flow",i,H1]),id:um,role:"application",children:s.jsxs(LM,{nodes:e,edges:t,width:$1,height:L1,fitView:lm,fitViewOptions:cm,minZoom:Q,maxZoom:ie,nodeOrigin:Nn,nodeExtent:Fe,children:[s.jsx(IM,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:j,onNodeContextMenu:N,onNodeDoubleClick:k,nodeTypes:o,edgeTypes:a,connectionLineType:T,connectionLineStyle:D,connectionLineComponent:U,connectionLineContainerStyle:H,selectionKeyCode:G,selectionOnDrag:V,selectionMode:q,deleteKeyCode:W,multiSelectionKeyCode:se,panActivationKeyCode:ne,zoomActivationKeyCode:te,onlyRenderVisibleElements:me,defaultViewport:kn,translateExtent:he,minZoom:Q,maxZoom:ie,preventScrolling:_e,zoomOnScroll:Pe,zoomOnPinch:Xr,zoomOnDoubleClick:qe,panOnScroll:K,panOnScrollSpeed:ae,panOnScrollMode:de,panOnDrag:ct,onPaneClick:je,onPaneMouseEnter:an,onPaneMouseMove:Zc,onPaneMouseLeave:xa,onPaneScroll:ga,onPaneContextMenu:ue,paneClickDistance:Ye,nodeClickDistance:it,onSelectionContextMenu:P,onSelectionStart:C,onSelectionEnd:M,onReconnect:Es,onReconnectStart:et,onReconnectEnd:Et,onEdgeContextMenu:_s,onEdgeDoubleClick:It,onEdgeMouseEnter:zt,onEdgeMouseMove:ya,onEdgeMouseLeave:Un,reconnectRadius:om,defaultMarkerColor:Ne,noDragClassName:y1,noWheelClassName:v1,noPanClassName:am,rfId:Jc,disableKeyboardA11y:dm,nodeExtent:Fe,viewport:I1,onViewportChange:z1}),s.jsx(vT,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:w,onConnectEnd:y,onClickConnectStart:b,onClickConnectEnd:x,nodesDraggable:Ce,autoPanOnNodeFocus:Ke,nodesConnectable:Ee,nodesFocusable:pt,edgesFocusable:Ae,edgesReconnectable:lt,elementsSelectable:on,elevateNodesOnSelect:k1,elevateEdgesOnSelect:S1,minZoom:Q,maxZoom:ie,nodeExtent:Fe,onNodesChange:x1,onEdgesChange:g1,snapToGrid:ee,snapGrid:re,connectionMode:R,translateExtent:he,connectOnClick:w1,defaultEdgeOptions:N1,fitView:lm,fitViewOptions:cm,onNodesDelete:F,onEdgesDelete:O,onDelete:z,onNodeDragStart:S,onNodeDrag:_,onNodeDragStop:I,onSelectionDrag:L,onSelectionDragStart:E,onSelectionDragStop:A,onMove:f,onMoveStart:u,onMoveEnd:h,noPanClassName:am,nodeOrigin:Nn,rfId:Jc,autoPanOnConnect:C1,autoPanOnNodeDrag:E1,autoPanSpeed:_1,onError:M1,connectionRadius:P1,isValidConnection:T1,selectNodesOnDrag:ge,nodeDragThreshold:R1,connectionDragThreshold:D1,onBeforeDelete:$,paneClickDistance:Ye,debug:F1,ariaLabelConfig:B1}),s.jsx(pT,{onSelectionChange:B}),jt,s.jsx(dT,{proOptions:j1,position:b1}),s.jsx(cT,{rfId:Jc,disableKeyboardA11y:dm})]})})}var BM=rb(FM);function UM(e){const[t,n]=p.useState(e),r=p.useCallback(i=>n(o=>tb(i,o)),[]);return[t,n,r]}function VM(e){const[t,n]=p.useState(e),r=p.useCallback(i=>n(o=>nb(i,o)),[]);return[t,n,r]}function HM({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Je(["react-flow__background-pattern",n,r])})}function WM({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:Je(["react-flow__background-pattern","dots",t])})}var er;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(er||(er={}));const YM={[er.Dots]:1,[er.Lines]:1,[er.Cross]:6},XM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Eb({id:e,variant:t=er.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:a,bgColor:l,style:c,className:d,patternClassName:f}){const u=p.useRef(null),{transform:h,patternId:m}=ye(XM,He),w=r||YM[t],y=t===er.Dots,b=t===er.Cross,x=Array.isArray(n)?n:[n,n],v=[x[0]*h[2]||1,x[1]*h[2]||1],g=w*h[2],j=Array.isArray(o)?o:[o,o],N=b?[g,g]:v,k=[j[0]*h[2]||1+N[0]/2,j[1]*h[2]||1+N[1]/2],S=`${m}${e||""}`;return s.jsxs("svg",{className:Je(["react-flow__background",d]),style:{...c,...Uc,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[s.jsx("pattern",{id:S,x:h[0]%v[0],y:h[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:y?s.jsx(WM,{radius:g/2,className:f}):s.jsx(HM,{dimensions:N,lineWidth:i,variant:t,className:f})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}Eb.displayName="Background";const GM=p.memo(Eb);function KM(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function qM(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function QM(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ZM(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function JM(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Qa({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:Je(["react-flow__controls-button",t]),...n,children:e})}const eA=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function _b({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:f,position:u="bottom-left",orientation:h="vertical","aria-label":m}){const w=Oe(),{isInteractive:y,minZoomReached:b,maxZoomReached:x,ariaLabelConfig:v}=ye(eA,He),{zoomIn:g,zoomOut:j,fitView:N}=Xh(),k=()=>{g(),o==null||o()},S=()=>{j(),a==null||a()},_=()=>{N(i),l==null||l()},I=()=>{w.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c==null||c(!y)},F=h==="horizontal"?"horizontal":"vertical";return s.jsxs(Bc,{className:Je(["react-flow__controls",F,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Qa,{onClick:k,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:x,children:s.jsx(KM,{})}),s.jsx(Qa,{onClick:S,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:b,children:s.jsx(qM,{})})]}),n&&s.jsx(Qa,{className:"react-flow__controls-fitview",onClick:_,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:s.jsx(QM,{})}),r&&s.jsx(Qa,{className:"react-flow__controls-interactive",onClick:I,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:y?s.jsx(JM,{}):s.jsx(ZM,{})}),f]})}_b.displayName="Controls";const tA=p.memo(_b);function nA({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:u,selected:h,onClick:m}){const{background:w,backgroundColor:y}=o||{},b=a||w||y;return s.jsx("rect",{className:Je(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:f,ry:f,width:r,height:i,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?x=>m(x,e):void 0})}const rA=p.memo(nA),sA=e=>e.nodes.map(t=>t.id),Gd=e=>e instanceof Function?e:()=>e;function iA({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=rA,onClick:a}){const l=ye(sA,He),c=Gd(t),d=Gd(e),f=Gd(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:l.map(h=>s.jsx(aA,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:a,shapeRendering:u},h))})}function oA({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:f,y:u,width:h,height:m}=ye(w=>{const{internals:y}=w.nodeLookup.get(e),b=y.userNode,{x,y:v}=y.positionAbsolute,{width:g,height:j}=cr(b);return{node:b,x,y:v,width:g,height:j}},He);return!d||d.hidden||!Sw(d)?null:s.jsx(l,{x:f,y:u,width:h,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:i,strokeColor:n(d),strokeWidth:o,shapeRendering:a,onClick:c,id:d.id})}const aA=p.memo(oA);var lA=p.memo(iA);const cA=200,dA=150,uA=e=>!e.hidden,fA=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?kw(fa(e.nodeLookup,{filter:uA}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},hA="react-flow__minimap-desc";function Pb({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:u,position:h="bottom-right",onClick:m,onNodeClick:w,pannable:y=!1,zoomable:b=!1,ariaLabel:x,inversePan:v,zoomStep:g=1,offsetScale:j=5}){const N=Oe(),k=p.useRef(null),{boundingRect:S,viewBB:_,rfId:I,panZoom:F,translateExtent:O,flowWidth:z,flowHeight:B,ariaLabelConfig:E}=ye(fA,He),L=(e==null?void 0:e.width)??cA,A=(e==null?void 0:e.height)??dA,P=S.width/L,C=S.height/A,M=Math.max(P,C),$=M*L,R=M*A,T=j*M,D=S.x-($-S.width)/2-T,U=S.y-(R-S.height)/2-T,H=$+T*2,W=R+T*2,G=`${hA}-${I}`,V=p.useRef(0),q=p.useRef();V.current=M,p.useEffect(()=>{if(k.current&&F)return q.current=mP({domNode:k.current,panZoom:F,getTransform:()=>N.getState().transform,getViewScale:()=>V.current}),()=>{var ee;(ee=q.current)==null||ee.destroy()}},[F]),p.useEffect(()=>{var ee;(ee=q.current)==null||ee.update({translateExtent:O,width:z,height:B,inversePan:v,pannable:y,zoomStep:g,zoomable:b})},[y,b,v,g,O,z,B]);const ne=m?ee=>{var ge;const[re,me]=((ge=q.current)==null?void 0:ge.pointer(ee))||[0,0];m(ee,{x:re,y:me})}:void 0,se=w?p.useCallback((ee,re)=>{const me=N.getState().nodeLookup.get(re).internals.userNode;w(ee,me)},[]):void 0,te=x??E["minimap.ariaLabel"];return s.jsx(Bc,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Je(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:L,height:A,viewBox:`${D} ${U} ${H} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:k,onClick:ne,children:[te&&s.jsx("title",{id:G,children:te}),s.jsx(lA,{onClick:se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:l}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${D-T},${U-T}h${H+T*2}v${W+T*2}h${-H-T*2}z
|
|
405
|
-
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Pb.displayName="MiniMap";const mA=p.memo(Pb),pA=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,xA={[_i.Line]:"right",[_i.Handle]:"bottom-right"};function gA({nodeId:e,position:t,variant:n=_i.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:h,autoScale:m=!0,shouldResize:w,onResizeStart:y,onResize:b,onResizeEnd:x}){const v=ab(),g=typeof e=="string"?e:v,j=Oe(),N=p.useRef(null),k=n===_i.Handle,S=ye(p.useCallback(pA(k&&m),[k,m]),He),_=p.useRef(null),I=t??xA[n];p.useEffect(()=>{if(!(!N.current||!g))return _.current||(_.current=TP({domNode:N.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:O,transform:z,snapGrid:B,snapToGrid:E,nodeOrigin:L,domNode:A}=j.getState();return{nodeLookup:O,transform:z,snapGrid:B,snapToGrid:E,nodeOrigin:L,paneDomNode:A}},onChange:(O,z)=>{const{triggerNodeChanges:B,nodeLookup:E,parentLookup:L,nodeOrigin:A}=j.getState(),P=[],C={x:O.x,y:O.y},M=E.get(g);if(M&&M.expandParent&&M.parentId){const $=M.origin??A,R=O.width??M.measured.width??0,T=O.height??M.measured.height??0,D={id:M.id,parentId:M.parentId,rect:{width:R,height:T,...Cw({x:O.x??M.position.x,y:O.y??M.position.y},{width:R,height:T},M.parentId,E,$)}},U=Yh([D],E,L,A);P.push(...U),C.x=O.x?Math.max($[0]*R,O.x):void 0,C.y=O.y?Math.max($[1]*T,O.y):void 0}if(C.x!==void 0&&C.y!==void 0){const $={id:g,type:"position",position:{...C}};P.push($)}if(O.width!==void 0&&O.height!==void 0){const R={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};P.push(R)}for(const $ of z){const R={...$,type:"position"};P.push(R)}B(P)},onEnd:({width:O,height:z})=>{const B={id:g,type:"dimensions",resizing:!1,dimensions:{width:O,height:z}};j.getState().triggerNodeChanges([B])}})),_.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:h,onResizeStart:y,onResize:b,onResizeEnd:x,shouldResize:w}),()=>{var O;(O=_.current)==null||O.destroy()}},[I,l,c,d,f,u,y,b,x,w]);const F=I.split("-");return s.jsx("div",{className:Je(["react-flow__resize-control","nodrag",...F,n,r]),ref:N,style:{...i,scale:S,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:o})}p.memo(gA);const yA=["top","right","bottom","left"],Br=Math.min,Lt=Math.max,ic=Math.round,Za=Math.floor,$n=e=>({x:e,y:e}),vA={left:"right",right:"left",bottom:"top",top:"bottom"},wA={start:"end",end:"start"};function yf(e,t,n){return Lt(e,Br(t,n))}function or(e,t){return typeof e=="function"?e(t):e}function ar(e){return e.split("-")[0]}function Li(e){return e.split("-")[1]}function Kh(e){return e==="x"?"y":"x"}function qh(e){return e==="y"?"height":"width"}const bA=new Set(["top","bottom"]);function An(e){return bA.has(ar(e))?"y":"x"}function Qh(e){return Kh(An(e))}function jA(e,t,n){n===void 0&&(n=!1);const r=Li(e),i=Qh(e),o=qh(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=oc(a)),[a,oc(a)]}function NA(e){const t=oc(e);return[vf(e),t,vf(t)]}function vf(e){return e.replace(/start|end/g,t=>wA[t])}const sg=["left","right"],ig=["right","left"],kA=["top","bottom"],SA=["bottom","top"];function CA(e,t,n){switch(e){case"top":case"bottom":return n?t?ig:sg:t?sg:ig;case"left":case"right":return t?kA:SA;default:return[]}}function EA(e,t,n,r){const i=Li(e);let o=CA(ar(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(vf)))),o}function oc(e){return e.replace(/left|right|bottom|top/g,t=>vA[t])}function _A(e){return{top:0,right:0,bottom:0,left:0,...e}}function Tb(e){return typeof e!="number"?_A(e):{top:e,right:e,bottom:e,left:e}}function ac(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function og(e,t,n){let{reference:r,floating:i}=e;const o=An(t),a=Qh(t),l=qh(a),c=ar(t),d=o==="y",f=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-i.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-i.width,y:u};break;default:m={x:r.x,y:r.y}}switch(Li(t)){case"start":m[a]-=h*(n&&d?-1:1);break;case"end":m[a]+=h*(n&&d?-1:1);break}return m}const PA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=o.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:u}=og(d,r,c),h=r,m={},w=0;for(let y=0;y<l.length;y++){const{name:b,fn:x}=l[y],{x:v,y:g,data:j,reset:N}=await x({x:f,y:u,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:d,platform:a,elements:{reference:e,floating:t}});f=v??f,u=g??u,m={...m,[b]:{...m[b],...j}},N&&w<=50&&(w++,typeof N=="object"&&(N.placement&&(h=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:f,y:u}=og(d,h,c)),y=-1)}return{x:f,y:u,placement:h,strategy:i,middlewareData:m}};async function qo(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:h=!1,padding:m=0}=or(t,e),w=Tb(m),b=l[h?u==="floating"?"reference":"floating":u],x=ac(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),v=u==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,g=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),j=await(o.isElement==null?void 0:o.isElement(g))?await(o.getScale==null?void 0:o.getScale(g))||{x:1,y:1}:{x:1,y:1},N=ac(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:g,strategy:c}):v);return{top:(x.top-N.top+w.top)/j.y,bottom:(N.bottom-x.bottom+w.bottom)/j.y,left:(x.left-N.left+w.left)/j.x,right:(N.right-x.right+w.right)/j.x}}const TA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=or(e,t)||{};if(d==null)return{};const u=Tb(f),h={x:n,y:r},m=Qh(i),w=qh(m),y=await a.getDimensions(d),b=m==="y",x=b?"top":"left",v=b?"bottom":"right",g=b?"clientHeight":"clientWidth",j=o.reference[w]+o.reference[m]-h[m]-o.floating[w],N=h[m]-o.reference[m],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let S=k?k[g]:0;(!S||!await(a.isElement==null?void 0:a.isElement(k)))&&(S=l.floating[g]||o.floating[w]);const _=j/2-N/2,I=S/2-y[w]/2-1,F=Br(u[x],I),O=Br(u[v],I),z=F,B=S-y[w]-O,E=S/2-y[w]/2+_,L=yf(z,E,B),A=!c.arrow&&Li(i)!=null&&E!==L&&o.reference[w]/2-(E<z?F:O)-y[w]/2<0,P=A?E<z?E-z:E-B:0;return{[m]:h[m]+P,data:{[m]:L,centerOffset:E-L-P,...A&&{alignmentOffset:P}},reset:A}}}),MA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:y=!0,...b}=or(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const x=ar(i),v=An(l),g=ar(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=h||(g||!y?[oc(l)]:NA(l)),k=w!=="none";!h&&k&&N.push(...EA(l,y,w,j));const S=[l,...N],_=await qo(t,b),I=[];let F=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&I.push(_[x]),u){const E=jA(i,a,j);I.push(_[E[0]],_[E[1]])}if(F=[...F,{placement:i,overflows:I}],!I.every(E=>E<=0)){var O,z;const E=(((O=o.flip)==null?void 0:O.index)||0)+1,L=S[E];if(L&&(!(u==="alignment"?v!==An(L):!1)||F.every(C=>An(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:E,overflows:F},reset:{placement:L}};let A=(z=F.filter(P=>P.overflows[0]<=0).sort((P,C)=>P.overflows[1]-C.overflows[1])[0])==null?void 0:z.placement;if(!A)switch(m){case"bestFit":{var B;const P=(B=F.filter(C=>{if(k){const M=An(C.placement);return M===v||M==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(M=>M>0).reduce((M,$)=>M+$,0)]).sort((C,M)=>C[1]-M[1])[0])==null?void 0:B[0];P&&(A=P);break}case"initialPlacement":A=l;break}if(i!==A)return{reset:{placement:A}}}return{}}}};function ag(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lg(e){return yA.some(t=>e[t]>=0)}const AA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=or(e,t);switch(r){case"referenceHidden":{const o=await qo(t,{...i,elementContext:"reference"}),a=ag(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:lg(a)}}}case"escaped":{const o=await qo(t,{...i,altBoundary:!0}),a=ag(o,n.floating);return{data:{escapedOffsets:a,escaped:lg(a)}}}default:return{}}}}},Mb=new Set(["left","top"]);async function RA(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=ar(n),l=Li(n),c=An(n)==="y",d=Mb.has(a)?-1:1,f=o&&c?-1:1,u=or(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:w}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof w=="number"&&(m=l==="end"?w*-1:w),c?{x:m*f,y:h*d}:{x:h*d,y:m*f}}const DA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:l}=t,c=await RA(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}}},IA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x,y:v}=b;return{x,y:v}}},...c}=or(e,t),d={x:n,y:r},f=await qo(t,c),u=An(ar(i)),h=Kh(u);let m=d[h],w=d[u];if(o){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+f[b],g=m-f[x];m=yf(v,m,g)}if(a){const b=u==="y"?"top":"left",x=u==="y"?"bottom":"right",v=w+f[b],g=w-f[x];w=yf(v,w,g)}const y=l.fn({...t,[h]:m,[u]:w});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:o,[u]:a}}}}}},zA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=or(e,t),f={x:n,y:r},u=An(i),h=Kh(u);let m=f[h],w=f[u];const y=or(l,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const g=h==="y"?"height":"width",j=o.reference[h]-o.floating[g]+b.mainAxis,N=o.reference[h]+o.reference[g]-b.mainAxis;m<j?m=j:m>N&&(m=N)}if(d){var x,v;const g=h==="y"?"width":"height",j=Mb.has(ar(i)),N=o.reference[u]-o.floating[g]+(j&&((x=a.offset)==null?void 0:x[u])||0)+(j?0:b.crossAxis),k=o.reference[u]+o.reference[g]+(j?0:((v=a.offset)==null?void 0:v[u])||0)-(j?b.crossAxis:0);w<N?w=N:w>k&&(w=k)}return{[h]:m,[u]:w}}}},$A=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:a,elements:l}=t,{apply:c=()=>{},...d}=or(e,t),f=await qo(t,d),u=ar(i),h=Li(i),m=An(i)==="y",{width:w,height:y}=o.floating;let b,x;u==="top"||u==="bottom"?(b=u,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=u,b=h==="end"?"top":"bottom");const v=y-f.top-f.bottom,g=w-f.left-f.right,j=Br(y-f[b],v),N=Br(w-f[x],g),k=!t.middlewareData.shift;let S=j,_=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=g),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=v),k&&!h){const F=Lt(f.left,0),O=Lt(f.right,0),z=Lt(f.top,0),B=Lt(f.bottom,0);m?_=w-2*(F!==0||O!==0?F+O:Lt(f.left,f.right)):S=y-2*(z!==0||B!==0?z+B:Lt(f.top,f.bottom))}await c({...t,availableWidth:_,availableHeight:S});const I=await a.getDimensions(l.floating);return w!==I.width||y!==I.height?{reset:{rects:!0}}:{}}}};function Hc(){return typeof window<"u"}function Oi(e){return Ab(e)?(e.nodeName||"").toLowerCase():"#document"}function Ut(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bn(e){var t;return(t=(Ab(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ab(e){return Hc()?e instanceof Node||e instanceof Ut(e).Node:!1}function vn(e){return Hc()?e instanceof Element||e instanceof Ut(e).Element:!1}function On(e){return Hc()?e instanceof HTMLElement||e instanceof Ut(e).HTMLElement:!1}function cg(e){return!Hc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ut(e).ShadowRoot}const LA=new Set(["inline","contents"]);function pa(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=wn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!LA.has(i)}const OA=new Set(["table","td","th"]);function FA(e){return OA.has(Oi(e))}const BA=[":popover-open",":modal"];function Wc(e){return BA.some(t=>{try{return e.matches(t)}catch{return!1}})}const UA=["transform","translate","scale","rotate","perspective"],VA=["transform","translate","scale","rotate","perspective","filter"],HA=["paint","layout","strict","content"];function Zh(e){const t=Jh(),n=vn(e)?wn(e):e;return UA.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||VA.some(r=>(n.willChange||"").includes(r))||HA.some(r=>(n.contain||"").includes(r))}function WA(e){let t=Ur(e);for(;On(t)&&!Ti(t);){if(Zh(t))return t;if(Wc(t))return null;t=Ur(t)}return null}function Jh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const YA=new Set(["html","body","#document"]);function Ti(e){return YA.has(Oi(e))}function wn(e){return Ut(e).getComputedStyle(e)}function Yc(e){return vn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ur(e){if(Oi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cg(e)&&e.host||Bn(e);return cg(t)?t.host:t}function Rb(e){const t=Ur(e);return Ti(t)?e.ownerDocument?e.ownerDocument.body:e.body:On(t)&&pa(t)?t:Rb(t)}function Qo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Rb(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=Ut(i);if(o){const l=wf(a);return t.concat(a,a.visualViewport||[],pa(i)?i:[],l&&n?Qo(l):[])}return t.concat(i,Qo(i,[],n))}function wf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Db(e){const t=wn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=On(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=ic(n)!==o||ic(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function em(e){return vn(e)?e:e.contextElement}function li(e){const t=em(e);if(!On(t))return $n(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Db(t);let a=(o?ic(n.width):n.width)/r,l=(o?ic(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const XA=$n(0);function Ib(e){const t=Ut(e);return!Jh()||!t.visualViewport?XA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function GA(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ut(e)?!1:t}function js(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=em(e);let a=$n(1);t&&(r?vn(r)&&(a=li(r)):a=li(e));const l=GA(o,n,r)?Ib(o):$n(0);let c=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,f=i.width/a.x,u=i.height/a.y;if(o){const h=Ut(o),m=r&&vn(r)?Ut(r):r;let w=h,y=wf(w);for(;y&&r&&m!==w;){const b=li(y),x=y.getBoundingClientRect(),v=wn(y),g=x.left+(y.clientLeft+parseFloat(v.paddingLeft))*b.x,j=x.top+(y.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,d*=b.y,f*=b.x,u*=b.y,c+=g,d+=j,w=Ut(y),y=wf(w)}}return ac({width:f,height:u,x:c,y:d})}function Xc(e,t){const n=Yc(e).scrollLeft;return t?t.left+n:js(Bn(e)).left+n}function zb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Xc(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function KA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Bn(r),l=t?Wc(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=$n(1);const f=$n(0),u=On(r);if((u||!u&&!o)&&((Oi(r)!=="body"||pa(a))&&(c=Yc(r)),On(r))){const m=js(r);d=li(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const h=a&&!u&&!o?zb(a,c):$n(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+h.x,y:n.y*d.y-c.scrollTop*d.y+f.y+h.y}}function qA(e){return Array.from(e.getClientRects())}function QA(e){const t=Bn(e),n=Yc(e),r=e.ownerDocument.body,i=Lt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Lt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Xc(e);const l=-n.scrollTop;return wn(r).direction==="rtl"&&(a+=Lt(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:l}}const dg=25;function ZA(e,t){const n=Ut(e),r=Bn(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){o=i.width,a=i.height;const f=Jh();(!f||f&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=Xc(r);if(d<=0){const f=r.ownerDocument,u=f.body,h=getComputedStyle(u),m=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(r.clientWidth-u.clientWidth-m);w<=dg&&(o-=w)}else d<=dg&&(o+=d);return{width:o,height:a,x:l,y:c}}const JA=new Set(["absolute","fixed"]);function eR(e,t){const n=js(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=On(e)?li(e):$n(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=i*o.x,d=r*o.y;return{width:a,height:l,x:c,y:d}}function ug(e,t,n){let r;if(t==="viewport")r=ZA(e,n);else if(t==="document")r=QA(Bn(e));else if(vn(t))r=eR(t,n);else{const i=Ib(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ac(r)}function $b(e,t){const n=Ur(e);return n===t||!vn(n)||Ti(n)?!1:wn(n).position==="fixed"||$b(n,t)}function tR(e,t){const n=t.get(e);if(n)return n;let r=Qo(e,[],!1).filter(l=>vn(l)&&Oi(l)!=="body"),i=null;const o=wn(e).position==="fixed";let a=o?Ur(e):e;for(;vn(a)&&!Ti(a);){const l=wn(a),c=Zh(a);!c&&l.position==="fixed"&&(i=null),(o?!c&&!i:!c&&l.position==="static"&&!!i&&JA.has(i.position)||pa(a)&&!c&&$b(e,a))?r=r.filter(f=>f!==a):i=l,a=Ur(a)}return t.set(e,r),r}function nR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Wc(t)?[]:tR(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((d,f)=>{const u=ug(t,f,i);return d.top=Lt(u.top,d.top),d.right=Br(u.right,d.right),d.bottom=Br(u.bottom,d.bottom),d.left=Lt(u.left,d.left),d},ug(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function rR(e){const{width:t,height:n}=Db(e);return{width:t,height:n}}function sR(e,t,n){const r=On(t),i=Bn(t),o=n==="fixed",a=js(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=$n(0);function d(){c.x=Xc(i)}if(r||!r&&!o)if((Oi(t)!=="body"||pa(i))&&(l=Yc(t)),r){const m=js(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else i&&d();o&&!r&&i&&d();const f=i&&!r&&!o?zb(i,l):$n(0),u=a.left+l.scrollLeft-c.x-f.x,h=a.top+l.scrollTop-c.y-f.y;return{x:u,y:h,width:a.width,height:a.height}}function Kd(e){return wn(e).position==="static"}function fg(e,t){if(!On(e)||wn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bn(e)===n&&(n=n.ownerDocument.body),n}function Lb(e,t){const n=Ut(e);if(Wc(e))return n;if(!On(e)){let i=Ur(e);for(;i&&!Ti(i);){if(vn(i)&&!Kd(i))return i;i=Ur(i)}return n}let r=fg(e,t);for(;r&&FA(r)&&Kd(r);)r=fg(r,t);return r&&Ti(r)&&Kd(r)&&!Zh(r)?n:r||WA(e)||n}const iR=async function(e){const t=this.getOffsetParent||Lb,n=this.getDimensions,r=await n(e.floating);return{reference:sR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oR(e){return wn(e).direction==="rtl"}const aR={convertOffsetParentRelativeRectToViewportRelativeRect:KA,getDocumentElement:Bn,getClippingRect:nR,getOffsetParent:Lb,getElementRects:iR,getClientRects:qA,getDimensions:rR,getScale:li,isElement:vn,isRTL:oR};function Ob(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lR(e,t){let n=null,r;const i=Bn(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const d=e.getBoundingClientRect(),{left:f,top:u,width:h,height:m}=d;if(l||t(),!h||!m)return;const w=Za(u),y=Za(i.clientWidth-(f+h)),b=Za(i.clientHeight-(u+m)),x=Za(f),g={rootMargin:-w+"px "+-y+"px "+-b+"px "+-x+"px",threshold:Lt(0,Br(1,c))||1};let j=!0;function N(k){const S=k[0].intersectionRatio;if(S!==c){if(!j)return a();S?a(!1,S):r=setTimeout(()=>{a(!1,1e-7)},1e3)}S===1&&!Ob(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(N,{...g,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,g)}n.observe(e)}return a(!0),o}function cR(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=em(e),f=i||o?[...d?Qo(d):[],...Qo(t)]:[];f.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),o&&x.addEventListener("resize",n)});const u=d&&l?lR(d,n):null;let h=-1,m=null;a&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var g;(g=m)==null||g.observe(t)})),n()}),d&&!c&&m.observe(d),m.observe(t));let w,y=c?js(e):null;c&&b();function b(){const x=js(e);y&&!Ob(y,x)&&n(),y=x,w=requestAnimationFrame(b)}return n(),()=>{var x;f.forEach(v=>{i&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),u==null||u(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const dR=DA,uR=IA,fR=MA,hR=$A,mR=AA,hg=TA,pR=zA,xR=(e,t,n)=>{const r=new Map,i={platform:aR,...n},o={...i.platform,_c:r};return PA(e,t,{...i,platform:o})};var gR=typeof document<"u",yR=function(){},vl=gR?p.useLayoutEffect:yR;function lc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!lc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!lc(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Fb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mg(e,t){const n=Fb(e);return Math.round(t*n)/n}function qd(e){const t=p.useRef(e);return vl(()=>{t.current=e}),t}function vR(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,u]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);lc(h,r)||m(r);const[w,y]=p.useState(null),[b,x]=p.useState(null),v=p.useCallback(C=>{C!==k.current&&(k.current=C,y(C))},[]),g=p.useCallback(C=>{C!==S.current&&(S.current=C,x(C))},[]),j=o||w,N=a||b,k=p.useRef(null),S=p.useRef(null),_=p.useRef(f),I=c!=null,F=qd(c),O=qd(i),z=qd(d),B=p.useCallback(()=>{if(!k.current||!S.current)return;const C={placement:t,strategy:n,middleware:h};O.current&&(C.platform=O.current),xR(k.current,S.current,C).then(M=>{const $={...M,isPositioned:z.current!==!1};E.current&&!lc(_.current,$)&&(_.current=$,Sc.flushSync(()=>{u($)}))})},[h,t,n,O,z]);vl(()=>{d===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,u(C=>({...C,isPositioned:!1})))},[d]);const E=p.useRef(!1);vl(()=>(E.current=!0,()=>{E.current=!1}),[]),vl(()=>{if(j&&(k.current=j),N&&(S.current=N),j&&N){if(F.current)return F.current(j,N,B);B()}},[j,N,B,F,I]);const L=p.useMemo(()=>({reference:k,floating:S,setReference:v,setFloating:g}),[v,g]),A=p.useMemo(()=>({reference:j,floating:N}),[j,N]),P=p.useMemo(()=>{const C={position:n,left:0,top:0};if(!A.floating)return C;const M=mg(A.floating,f.x),$=mg(A.floating,f.y);return l?{...C,transform:"translate("+M+"px, "+$+"px)",...Fb(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:$}},[n,l,A.floating,f.x,f.y]);return p.useMemo(()=>({...f,update:B,refs:L,elements:A,floatingStyles:P}),[f,B,L,A,P])}const wR=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?hg({element:r.current,padding:i}).fn(n):{}:r?hg({element:r,padding:i}).fn(n):{}}}},bR=(e,t)=>({...dR(e),options:[e,t]}),jR=(e,t)=>({...uR(e),options:[e,t]}),NR=(e,t)=>({...pR(e),options:[e,t]}),kR=(e,t)=>({...fR(e),options:[e,t]}),SR=(e,t)=>({...hR(e),options:[e,t]}),CR=(e,t)=>({...mR(e),options:[e,t]}),ER=(e,t)=>({...wR(e),options:[e,t]});var _R="Arrow",Bb=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return s.jsx(ze.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Bb.displayName=_R;var PR=Bb;function Ub(e){const[t,n]=p.useState(void 0);return Or(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,l;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var tm="Popper",[Vb,Hb]=Ec(tm),[TR,Wb]=Vb(tm),Yb=e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null);return s.jsx(TR,{scope:t,anchor:r,onAnchorChange:i,children:n})};Yb.displayName=tm;var Xb="PopperAnchor",Gb=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=Wb(Xb,n),a=p.useRef(null),l=Xt(t,a),c=p.useRef(null);return p.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||a.current,d!==c.current&&o.onAnchorChange(c.current)}),r?null:s.jsx(ze.div,{...i,ref:l})});Gb.displayName=Xb;var nm="PopperContent",[MR,AR]=Vb(nm),Kb=p.forwardRef((e,t)=>{var G,V,q,ne,se,te;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:w,...y}=e,b=Wb(nm,n),[x,v]=p.useState(null),g=Xt(t,ee=>v(ee)),[j,N]=p.useState(null),k=Ub(j),S=(k==null?void 0:k.width)??0,_=(k==null?void 0:k.height)??0,I=r+(o!=="center"?"-"+o:""),F=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},O=Array.isArray(d)?d:[d],z=O.length>0,B={padding:F,boundary:O.filter(DR),altBoundary:z},{refs:E,floatingStyles:L,placement:A,isPositioned:P,middlewareData:C}=vR({strategy:"fixed",placement:I,whileElementsMounted:(...ee)=>cR(...ee,{animationFrame:m==="always"}),elements:{reference:b.anchor},middleware:[bR({mainAxis:i+_,alignmentAxis:a}),c&&jR({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?NR():void 0,...B}),c&&kR({...B}),SR({...B,apply:({elements:ee,rects:re,availableWidth:me,availableHeight:ge})=>{const{width:Ce,height:Ke}=re.reference,Ee=ee.floating.style;Ee.setProperty("--radix-popper-available-width",`${me}px`),Ee.setProperty("--radix-popper-available-height",`${ge}px`),Ee.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ee.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),j&&ER({element:j,padding:l}),IR({arrowWidth:S,arrowHeight:_}),h&&CR({strategy:"referenceHidden",...B})]}),[M,$]=Zb(A),R=xi(w);Or(()=>{P&&(R==null||R())},[P,R]);const T=(G=C.arrow)==null?void 0:G.x,D=(V=C.arrow)==null?void 0:V.y,U=((q=C.arrow)==null?void 0:q.centerOffset)!==0,[H,W]=p.useState();return Or(()=>{x&&W(window.getComputedStyle(x).zIndex)},[x]),s.jsx("div",{ref:E.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:P?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(ne=C.transformOrigin)==null?void 0:ne.x,(se=C.transformOrigin)==null?void 0:se.y].join(" "),...((te=C.hide)==null?void 0:te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(MR,{scope:n,placedSide:M,onArrowChange:N,arrowX:T,arrowY:D,shouldHideArrow:U,children:s.jsx(ze.div,{"data-side":M,"data-align":$,...y,ref:g,style:{...y.style,animation:P?void 0:"none"}})})})});Kb.displayName=nm;var qb="PopperArrow",RR={top:"bottom",right:"left",bottom:"top",left:"right"},Qb=p.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=AR(qb,r),a=RR[o.placedSide];return s.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:s.jsx(PR,{...i,ref:n,style:{...i.style,display:"block"}})})});Qb.displayName=qb;function DR(e){return e!==null}var IR=e=>({name:"transformOrigin",options:e,fn(t){var b,x,v;const{placement:n,rects:r,middlewareData:i}=t,a=((b=i.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,f]=Zb(n),u={start:"0%",center:"50%",end:"100%"}[f],h=(((x=i.arrow)==null?void 0:x.x)??0)+l/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let w="",y="";return d==="bottom"?(w=a?u:`${h}px`,y=`${-c}px`):d==="top"?(w=a?u:`${h}px`,y=`${r.floating.height+c}px`):d==="right"?(w=`${-c}px`,y=a?u:`${m}px`):d==="left"&&(w=`${r.floating.width+c}px`,y=a?u:`${m}px`),{data:{x:w,y}}}});function Zb(e){const[t,n="center"]=e.split("-");return[t,n]}var zR=Yb,$R=Gb,LR=Kb,OR=Qb,FR=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),BR="VisuallyHidden",Jb=p.forwardRef((e,t)=>s.jsx(ze.span,{...e,ref:t,style:{...FR,...e.style}}));Jb.displayName=BR;var UR=Jb,[Gc]=Ec("Tooltip",[Hb]),Kc=Hb(),e1="TooltipProvider",VR=700,bf="tooltip.open",[HR,rm]=Gc(e1),t1=e=>{const{__scopeTooltip:t,delayDuration:n=VR,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),s.jsx(HR,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:o})};t1.displayName=e1;var Zo="Tooltip",[WR,qc]=Gc(Zo),n1=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:a,delayDuration:l}=e,c=rm(Zo,e.__scopeTooltip),d=Kc(t),[f,u]=p.useState(null),h=In(),m=p.useRef(0),w=a??c.disableHoverableContent,y=l??c.delayDuration,b=p.useRef(!1),[x,v]=kh({prop:r,defaultProp:i??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(bf))):c.onClose(),o==null||o(S)},caller:Zo}),g=p.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),j=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,v(!0)},[v]),N=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),k=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,v(!0),m.current=0},y)},[y,v]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(zR,{...d,children:s.jsx(WR,{scope:t,contentId:h,open:x,stateAttribute:g,trigger:f,onTriggerChange:u,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?k():j()},[c.isOpenDelayedRef,k,j]),onTriggerLeave:p.useCallback(()=>{w?N():(window.clearTimeout(m.current),m.current=0)},[N,w]),onOpen:j,onClose:N,disableHoverableContent:w,children:n})})};n1.displayName=Zo;var jf="TooltipTrigger",r1=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qc(jf,n),o=rm(jf,n),a=Kc(n),l=p.useRef(null),c=Xt(t,l,i.onTriggerChange),d=p.useRef(!1),f=p.useRef(!1),u=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),s.jsx($R,{asChild:!0,...a,children:s.jsx(ze.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:vt(e.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:vt(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:vt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:vt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:vt(e.onBlur,i.onClose),onClick:vt(e.onClick,i.onClose)})})});r1.displayName=jf;var YR="TooltipPortal",[SD,XR]=Gc(YR,{forceMount:void 0}),Mi="TooltipContent",s1=p.forwardRef((e,t)=>{const n=XR(Mi,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,a=qc(Mi,e.__scopeTooltip);return s.jsx(zi,{present:r||a.open,children:a.disableHoverableContent?s.jsx(i1,{side:i,...o,ref:t}):s.jsx(GR,{side:i,...o,ref:t})})}),GR=p.forwardRef((e,t)=>{const n=qc(Mi,e.__scopeTooltip),r=rm(Mi,e.__scopeTooltip),i=p.useRef(null),o=Xt(t,i),[a,l]=p.useState(null),{trigger:c,onClose:d}=n,f=i.current,{onPointerInTransitChange:u}=r,h=p.useCallback(()=>{l(null),u(!1)},[u]),m=p.useCallback((w,y)=>{const b=w.currentTarget,x={x:w.clientX,y:w.clientY},v=JR(x,b.getBoundingClientRect()),g=eD(x,v),j=tD(y.getBoundingClientRect()),N=rD([...g,...j]);l(N),u(!0)},[u]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&f){const w=b=>m(b,f),y=b=>m(b,c);return c.addEventListener("pointerleave",w),f.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",y)}}},[c,f,m,h]),p.useEffect(()=>{if(a){const w=y=>{const b=y.target,x={x:y.clientX,y:y.clientY},v=(c==null?void 0:c.contains(b))||(f==null?void 0:f.contains(b)),g=!nD(x,a);v?h():g&&(h(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,f,a,d,h]),s.jsx(i1,{...e,ref:o})}),[KR,qR]=Gc(Zo,{isInside:!1}),QR=SS("TooltipContent"),i1=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:a,...l}=e,c=qc(Mi,n),d=Kc(n),{onClose:f}=c;return p.useEffect(()=>(document.addEventListener(bf,f),()=>document.removeEventListener(bf,f)),[f]),p.useEffect(()=>{if(c.trigger){const u=h=>{const m=h.target;m!=null&&m.contains(c.trigger)&&f()};return window.addEventListener("scroll",u,{capture:!0}),()=>window.removeEventListener("scroll",u,{capture:!0})}},[c.trigger,f]),s.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:u=>u.preventDefault(),onDismiss:f,children:s.jsxs(LR,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(QR,{children:r}),s.jsx(KR,{scope:n,isInside:!0,children:s.jsx(UR,{id:c.contentId,role:"tooltip",children:i||r})})]})})});s1.displayName=Mi;var o1="TooltipArrow",ZR=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Kc(n);return qR(o1,n).isInside?null:s.jsx(OR,{...i,...r,ref:t})});ZR.displayName=o1;function JR(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function eD(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function tD(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function nD(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){const l=t[o],c=t[a],d=l.x,f=l.y,u=c.x,h=c.y;f>r!=h>r&&n<(u-d)*(r-f)/(h-f)+d&&(i=!i)}return i}function rD(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),sD(t)}function sD(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const o=t[t.length-1],a=t[t.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var iD=t1,oD=n1,aD=r1,a1=s1;const Qd=iD,Zd=oD,Jd=aD,wl=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(a1,{ref:r,sideOffset:t,className:rt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));wl.displayName=a1.displayName;const lD=420,cD=({data:e,targetPosition:t,sourcePosition:n})=>{const r=e,i="!h-1.5 !w-1.5 !min-w-0 !min-h-0 !cursor-grab !border-0 opacity-100",o="h-[22px]";return s.jsx(s.Fragment,{children:r.isForeign?s.jsxs("header",{className:"text-[0.55rem] px-2 py-1 border-[0.5px] border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white flex gap-1 items-center",id:`${r.name}-foreign-key`,children:[s.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:r.name}),t&&s.jsx(cs,{type:"target",id:r.name,position:t,className:rt(i)})]}):s.jsxs("div",{className:rt("border border-gray-200 dark:border-gray-700 overflow-hidden shadow-lg bg-white dark:bg-gray-900 rounded-none"),style:{width:lD/2},id:`${r.name}-table-node`,children:[s.jsx("header",{className:rt("text-[0.55rem] pl-3 pr-2 bg-black text-white flex items-center justify-between border-b border-gray-300",o),children:s.jsxs("div",{className:"flex items-center gap-x-1",children:[s.jsx(sS,{strokeWidth:1,size:12,className:"text-white"}),s.jsx("span",{className:"text-white font-medium",children:r.name})]})}),r.columns.map(a=>s.jsxs("div",{className:rt("text-[8px] leading-5 relative flex flex-row justify-items-start","bg-white dark:bg-gray-900","border-t","border-t-gray-200 dark:border-t-gray-700","hover:bg-gray-50 dark:hover:bg-gray-800 transition cursor-default",o),children:[s.jsxs("div",{className:rt("gap-[0.24rem] flex ml-2 align-middle items-center justify-start"),children:[a.isPrimary&&s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx(Wy,{size:8,strokeWidth:1,className:rt("flex-shrink-0","text-yellow-400 mr-2")})}),s.jsx(wl,{className:"pointer-events-none",sideOffset:0,children:"primary key"})]})}),a.isUnique&&s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx(Jk,{size:8,strokeWidth:1,className:"flex-shrink-0 mr-2 text-green-400"})}),s.jsx(wl,{className:"pointer-events-none ",sideOffset:0,children:"unique"})]})}),a.isIdentity&&s.jsx(eS,{size:8,strokeWidth:1,className:"flex-shrink-0 text-blue-400"}),!a.isIdentity&&!a.isUnique&&!a.isPrimary&&s.jsx("div",{className:" size-4"})]}),s.jsxs("div",{className:"flex justify-between w-full",children:[s.jsxs("div",{className:"relative flex justify-center whitespace-nowrap",children:[a.isNullable?"":s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx("span",{className:"text-muted-foreground absolute left-[-6px] top-[1px]",children:"*"})}),s.jsx(wl,{className:"pointer-events-none scale-70",sideOffset:-5,children:"required"})]})})," ",s.jsx("div",{className:"max-w-[100px] w-fit text-ellipsis overflow-hidden text-gray-900 dark:text-white",children:a.name}),s.jsx("span",{className:"font-mono text-gray-500 dark:text-gray-400 text-[0.35rem] pl-1 mt-[1px]",children:a.format})]}),s.jsx("span",{className:"px-2 inline-flex justify-end text-gray-400 dark:text-gray-500 text-[0.4rem] mt-[1px]",children:a.plugin})]}),s.jsx(cs,{type:"target",id:a.id,position:t||"left",className:rt(i,"!left-[-6px] !top-1/2 !transform !-translate-y-1/2"),style:{background:"#000000",border:"1px solid #ffffff",left:"-6px",top:"50%",transform:"translateY(-50%)",boxShadow:"0 0 0 2px rgba(0, 0, 0, 0.1)"}}),s.jsx(cs,{type:"source",id:a.id,position:n||"right",className:rt(i,"!right-[-6px] !top-1/2 !transform !-translate-y-1/2"),style:{background:"#000000",border:"1px solid #ffffff",right:"-6px",top:"50%",transform:"translateY(-50%)",boxShadow:"0 0 0 2px rgba(0, 0, 0, 0.1)"}})]},a.id))]})})};function dD(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Qc="Checkbox",[uD]=Ec(Qc),[fD,sm]=uD(Qc);function hD(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:o,form:a,name:l,onCheckedChange:c,required:d,value:f="on",internal_do_not_use_render:u}=e,[h,m]=kh({prop:n,defaultProp:i??!1,onChange:c,caller:Qc}),[w,y]=p.useState(null),[b,x]=p.useState(null),v=p.useRef(!1),g=w?!!a||!!w.closest("form"):!0,j={checked:h,disabled:o,setChecked:m,control:w,setControl:y,name:l,form:a,value:f,hasConsumerStoppedPropagationRef:v,required:d,defaultChecked:Ir(i)?!1:i,isFormControl:g,bubbleInput:b,setBubbleInput:x};return s.jsx(fD,{scope:t,...j,children:mD(u)?u(j):r})}var l1="CheckboxTrigger",c1=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{const{control:o,value:a,disabled:l,checked:c,required:d,setControl:f,setChecked:u,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:w}=sm(l1,e),y=Xt(i,f),b=p.useRef(c);return p.useEffect(()=>{const x=o==null?void 0:o.form;if(x){const v=()=>u(b.current);return x.addEventListener("reset",v),()=>x.removeEventListener("reset",v)}},[o,u]),s.jsx(ze.button,{type:"button",role:"checkbox","aria-checked":Ir(c)?"mixed":c,"aria-required":d,"data-state":m1(c),"data-disabled":l?"":void 0,disabled:l,value:a,...r,ref:y,onKeyDown:vt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:vt(n,x=>{u(v=>Ir(v)?!0:!v),w&&m&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})});c1.displayName=l1;var im=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:a,disabled:l,value:c,onCheckedChange:d,form:f,...u}=e;return s.jsx(hD,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:l,required:a,onCheckedChange:d,name:r,form:f,value:c,internal_do_not_use_render:({isFormControl:h})=>s.jsxs(s.Fragment,{children:[s.jsx(c1,{...u,ref:t,__scopeCheckbox:n}),h&&s.jsx(h1,{__scopeCheckbox:n})]})})});im.displayName=Qc;var d1="CheckboxIndicator",u1=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=sm(d1,n);return s.jsx(zi,{present:r||Ir(o.checked)||o.checked===!0,children:s.jsx(ze.span,{"data-state":m1(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});u1.displayName=d1;var f1="CheckboxBubbleInput",h1=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:a,required:l,disabled:c,name:d,value:f,form:u,bubbleInput:h,setBubbleInput:m}=sm(f1,e),w=Xt(n,m),y=dD(o),b=Ub(r);p.useEffect(()=>{const v=h;if(!v)return;const g=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(g,"checked").set,k=!i.current;if(y!==o&&N){const S=new Event("click",{bubbles:k});v.indeterminate=Ir(o),N.call(v,Ir(o)?!1:o),v.dispatchEvent(S)}},[h,y,o,i]);const x=p.useRef(Ir(o)?!1:o);return s.jsx(ze.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:l,disabled:c,name:d,value:f,form:u,...t,tabIndex:-1,ref:w,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});h1.displayName=f1;function mD(e){return typeof e=="function"}function Ir(e){return e==="indeterminate"}function m1(e){return Ir(e)?"indeterminate":e?"checked":"unchecked"}const p1=p.forwardRef(({className:e,...t},n)=>s.jsx(im,{ref:n,className:rt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:s.jsx(u1,{className:rt("flex items-center justify-center text-current"),children:s.jsx(Uy,{className:"h-4 w-4"})})}));p1.displayName=im.displayName;const pD={tableNode:cD},pg=[{name:"organization",displayName:"Organization",description:"Multi-tenant organization support",color:"bg-blue-500"},{name:"teams",displayName:"Teams",description:"Team management within organizations",color:"bg-green-500"},{name:"twoFactor",displayName:"Two Factor",description:"Two-factor authentication support",color:"bg-purple-500"},{name:"apiKey",displayName:"API Key",description:"API key authentication",color:"bg-orange-500"},{name:"passkey",displayName:"Passkey",description:"WebAuthn passkey support",color:"bg-pink-500"}];function xD(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[i,o]=p.useState(null),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m,w]=UM([]),[y,b,x]=VM([]),v=p.useCallback(async()=>{try{const I=await(await fetch("/api/plugins")).json();if(I.plugins&&Array.isArray(I.plugins)){const F=I.plugins.map(O=>({name:O.id,displayName:O.name||O.id,description:O.description||`${O.id} plugin for Better Auth`,color:g(O.id)}));d(F),l(F.map(O=>O.name))}}catch(_){console.error("Error fetching enabled plugins:",_),d(pg),l(["organization"])}},[]),g=_=>{const I=pg.find(F=>F.name===_);return(I==null?void 0:I.color)||"bg-gray-500"},j=p.useCallback(async _=>{try{r(!0);const I=_.length>0?`?plugins=${_.join(",")}`:"",O=await(await fetch(`/api/database/schema${I}`)).json();O.success?t(O.schema):o(O.error||"Failed to fetch schema")}catch(I){o("Failed to fetch database schema"),console.error("Error fetching schema:",I)}finally{r(!1)}},[]);p.useEffect(()=>{v()},[v]),p.useEffect(()=>{a.length>0&&j(a)},[a,j]),p.useEffect(()=>{if(!e)return;const _=[],I=[];e.tables.forEach((F,O)=>{const z=F.fields.map(B=>({id:`${F.name}-${B.name}`,isPrimary:B.primaryKey||!1,isNullable:!B.required,isUnique:B.unique||!1,isIdentity:!1,name:B.name,format:B.type,plugin:N(F.name,B.name,a)}));_.push({id:F.name,type:"tableNode",position:{x:O%4*350,y:Math.floor(O/4)*300},data:{name:F.name,isForeign:!1,columns:z}})}),e.tables.forEach(F=>{F.relationships.forEach(O=>{if(O.type==="many-to-one")return;const z=F.name,B=O.target,E=_.find(A=>A.id===z),L=_.find(A=>A.id===B);if(E&&L){const A=O.type==="one-to-one"?"1:1":"1:N";I.push({id:`${z}-${B}-${O.field}`,source:z,target:B,type:"smoothstep",animated:!1,style:{stroke:"#ffffff",strokeWidth:1.5,strokeDasharray:"0"},label:A,labelStyle:{fontSize:"11px",fill:"#6b7280",fontWeight:"500"},labelBgStyle:{fill:"rgba(255, 255, 255, 0.95)",fillOpacity:1,rx:4,ry:4},markerEnd:{type:"arrowclosed",color:"#ffffff",width:12,height:12}})}})}),m(_),b(I)},[e,a,m,b]);const N=(_,I,F)=>{if(_==="user"||_==="session"||_==="account"||_==="verification")return"core";for(const O of F)if(_===O||_.includes(O))return O;return"core"},k=p.useCallback(_=>b(I=>Rw(_,I)),[b]),S=(_,I)=>{l(I?F=>[...F,_]:F=>F.filter(O=>O!==_))};return n?s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"animate-pulse",children:[s.jsx("div",{className:"h-8 bg-gray-700 rounded w-1/3 mb-6"}),s.jsx("div",{className:"h-96 bg-gray-700 rounded"})]}),s.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-4",children:"Loading plugins and schema..."})]}):i?s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"bg-red-900/20 border border-red-500/20 rounded-none p-6",children:[s.jsx("h2",{className:"text-xl font-semibold text-red-400 mb-2",children:"Error Loading Schema"}),s.jsx("p",{className:"text-gray-300",children:i})]})}):s.jsxs("div",{className:"p-6 h-screen flex flex-col",children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-8 h-8 text-gray-900 dark:text-white"}),s.jsx("h1",{className:"text-2xl font-normal text-gray-900 dark:text-white",children:"Schema Visualizer"})]}),s.jsx("div",{className:"flex items-center space-x-4",children:s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>u(!f),className:"flex items-center space-x-2 rounded-none border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-black",children:[f?s.jsx(Zk,{className:"w-4 h-4"}):s.jsx(oa,{className:"w-4 h-4"}),s.jsx("span",{children:"Plugin Labels"})]})})]}),s.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Visualize your Better Auth database schema with interactive tables and relationships."})]}),s.jsxs("div",{className:"flex-1 grid grid-cols-4 gap-6",children:[s.jsxs("div",{className:"col-span-1",children:[s.jsxs(ut,{className:"rounded-none bg-white dark:bg-black border-gray-200 dark:border-gray-700 h-fit shadow-sm",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-gray-900 dark:text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5"}),s.jsx("span",{children:"Plugins"})]})}),s.jsx(ft,{className:"space-y-3",children:c.length>0?c.map(_=>s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(p1,{id:_.name,checked:a.includes(_.name),onCheckedChange:I=>S(_.name,I)}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{htmlFor:_.name,className:"text-sm font-medium text-gray-900 dark:text-white cursor-pointer",children:_.displayName}),s.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:_.description})]}),s.jsx("div",{className:`w-3 h-3 rounded-full ${_.color}`})]},_.name)):s.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No plugins detected in configuration"})})]}),e&&s.jsxs(ut,{className:"rounded-none bg-white dark:bg-black border-gray-200 dark:border-gray-700 mt-4 shadow-sm",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-gray-900 dark:text-white text-sm",children:"Schema Info"})}),s.jsxs(ft,{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Tables:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:e.tables.length})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Relationships:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:e.tables.reduce((_,I)=>_+I.relationships.length,0)})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Available Plugins:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:c.length})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Selected Plugins:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:a.length})]})]})]})]}),s.jsx("div",{className:"col-span-3",children:s.jsx("div",{className:"h-full bg-white dark:bg-black border border-gray-200 dark:border-gray-700 rounded-none overflow-hidden shadow-sm",children:s.jsxs(BM,{nodes:h,edges:y,onNodesChange:w,onEdgesChange:x,onConnect:k,nodeTypes:pD,fitView:!0,fitViewOptions:{padding:.1,includeHiddenNodes:!1},className:"bg-white dark:bg-black",connectionLineType:"smoothstep",defaultEdgeOptions:{style:{stroke:"#ffffff",strokeWidth:1.5},animated:!1,type:"smoothstep"},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[s.jsx(tA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600"}),s.jsx(mA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600",nodeColor:_=>{var I;return(I=_.data)!=null&&I.isForeign?"#e5e7eb":"#f3f4f6"},maskColor:"rgba(255, 255, 255, 0.8)"}),s.jsx(GM,{variant:er.Dots,gap:20,size:1,color:"#e5e7eb"})]})})})]})]})}function gD(){const{orgId:e}=bh(),t=Cs(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m]=p.useState("details"),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(!1),[j,N]=p.useState(!1),[k,S]=p.useState(!1),[_,I]=p.useState(!1),[F,O]=p.useState(!1),[z,B]=p.useState(!1),[E,L]=p.useState(null),[A,P]=p.useState(""),[C,M]=p.useState(""),[$,R]=p.useState([]),[T,D]=p.useState({name:""}),[U,H]=p.useState(!1),[W,G]=p.useState([]),[V,q]=p.useState(!1),[ne,se]=p.useState([]),[te,ee]=p.useState(!1);p.useEffect(()=>{e&&(me(),Ce(),ge(),Ee(),pt(),Ke())},[e]),p.useEffect(()=>{w&&e&&Ke()},[]),p.useEffect(()=>{h==="members"&&e&&pt()},[h,e]),p.useEffect(()=>{h==="invitations"&&e&&Ee()},[h,e]);const re=K=>{D({name:K})},me=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}`)).json();ae.success&&ae.organization||ae.organization?r(ae.organization):X.error("Organization not found")}catch(K){console.error("Failed to fetch organization:",K),X.error("Failed to load organization")}finally{u(!1)}},ge=async()=>{try{const ae=await(await fetch("/api/plugins/teams/status")).json();y(ae.enabled)}catch(K){console.error("Failed to check teams status:",K),y(!1)}},Ce=async()=>{try{const ae=await(await fetch("/api/plugins/organization/status")).json();x(ae.enabled)}catch(K){console.error("Failed to check organization status:",K),x(!1)}},Ke=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/teams`)).json();ae.success&&o(ae.teams||[])}catch(K){console.error("Failed to fetch teams:",K),X.error("Failed to load teams")}},Ee=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/invitations`)).json();ae.success&&l(ae.invitations||[])}catch(K){console.error("Failed to fetch invitations:",K),X.error("Failed to load invitations")}},pt=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/members`)).json();ae.success&&d(ae.members||[])}catch(K){console.error("Failed to fetch members:",K),X.error("Failed to load members")}},Nn=async K=>{G([]),q(!0),G([{id:"start",type:"info",message:`Starting member seeding process for ${K} members...`,timestamp:new Date}]);try{const de=await(await fetch(`/api/organizations/${e}/seed-members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(de.success){const qe=de.results.map((je,an)=>je.success?{id:`member-${an}`,type:"progress",message:`Adding member: ${je.member.user.name} (${je.member.user.email})`,timestamp:new Date,status:"completed"}:{id:`member-${an}`,type:"error",message:`Failed to add member ${an+1}: ${je.error}`,timestamp:new Date});G(je=>[...je,...qe]);const ct=de.results.filter(je=>je.success).length;G(je=>[...je,{id:"complete",type:"success",message:`✅ Seeding completed! Added ${ct}/${K} members successfully`,timestamp:new Date}]),await pt(),X.success(`Successfully added ${ct} members!`)}else G(qe=>[...qe,{id:"error",type:"error",message:`❌ Seeding failed: ${de.error||"Unknown error"}`,timestamp:new Date}]),X.error(de.error||"Failed to seed members")}catch(ae){G(de=>[...de,{id:"error",type:"error",message:`❌ Network error: ${ae}`,timestamp:new Date}]),X.error("Failed to seed members")}finally{q(!1)}},Ae=async K=>{se([]),ee(!0),se([{id:"start",type:"info",message:`Starting team seeding process for ${K} teams...`,timestamp:new Date}]);try{const de=await(await fetch(`/api/organizations/${e}/seed-teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(de.success){const qe=de.results.map((je,an)=>je.success?{id:`team-${an}`,type:"progress",message:`Creating team: ${je.team.name}`,timestamp:new Date,status:"completed"}:{id:`team-${an}`,type:"error",message:`Failed to create team ${an+1}: ${je.error}`,timestamp:new Date});se(je=>[...je,...qe]);const ct=de.results.filter(je=>je.success).length;se(je=>[...je,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${ct}/${K} teams successfully`,timestamp:new Date}]),await Ke(),X.success(`Successfully created ${ct} teams!`)}else se(qe=>[...qe,{id:"error",type:"error",message:`❌ Seeding failed: ${de.error||"Unknown error"}`,timestamp:new Date}]),X.error(de.error||"Failed to seed teams")}catch(ae){se(de=>[...de,{id:"error",type:"error",message:`❌ Network error: ${ae}`,timestamp:new Date}]),X.error("Failed to seed teams")}finally{ee(!1)}},lt=async()=>{try{const ae=await(await fetch("/api/users/all")).json();ae.success&&R(ae.users||[])}catch(K){console.error("Failed to fetch users:",K)}},on=()=>{lt(),g(!0)},kn=async()=>{if(!A){X.error("Please enter an email address");return}if(!C){X.error("Please select an inviter");return}H(!0);const K=X.loading("Sending invitation...");try{const de=await(await fetch(`/api/organizations/${e}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:A,role:"member",inviterId:C})})).json();de.success?(await Ee(),g(!1),P(""),M(""),X.success("Invitation sent successfully!",{id:K})):X.error(`Error sending invitation: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error sending invitation:",ae),X.error("Error sending invitation",{id:K})}finally{H(!1)}},Q=async K=>{const ae=X.loading("Cancelling invitation...");try{const qe=await(await fetch(`/api/invitations/${K}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();qe.success?(await Ee(),X.success("Invitation cancelled successfully!",{id:ae})):X.error(`Error cancelling invitation: ${qe.error||"Unknown error"}`,{id:ae})}catch(de){console.error("Error cancelling invitation:",de),X.error("Error cancelling invitation",{id:ae})}},ie=async(K,ae)=>{const de=X.loading("Resending invitation...");try{const ct=await(await fetch(`/api/invitations/${K}/resend`,{method:"POST",headers:{"Content-Type":"application/json"}})).json();ct.success?(await Ee(),X.success(`Invitation resent to ${ae}!`,{id:de})):X.error(`Error resending invitation: ${ct.error||"Unknown error"}`,{id:de})}catch(qe){console.error("Error resending invitation:",qe),X.error("Error resending invitation",{id:de})}},he=async(K,ae)=>{const de=X.loading(`Removing ${ae}...`);try{const ct=await(await fetch(`/api/members/${K}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ct.success?(await pt(),X.success(`${ae} removed from organization!`,{id:de})):X.error(`Error removing member: ${ct.error||"Unknown error"}`,{id:de})}catch(qe){console.error("Error removing member:",qe),X.error("Error removing member",{id:de})}},_e=async()=>{if(!T.name){X.error("Please enter a team name");return}const K=X.loading("Creating team...");try{const de=await(await fetch(`/api/organizations/${e}/teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T.name,organizationId:e})})).json();de.success?(await Ke(),I(!1),D({name:""}),X.success("Team created successfully!",{id:K})):X.error(`Error creating team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error creating team:",ae),X.error("Error creating team",{id:K})}},Fe=async()=>{if(!E||!T.name){X.error("Please enter a team name");return}const K=X.loading("Updating team...");try{const de=await(await fetch(`/api/teams/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T.name})})).json();de.success?(await Ke(),O(!1),L(null),D({name:""}),X.success("Team updated successfully!",{id:K})):X.error(`Error updating team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error updating team:",ae),X.error("Error updating team",{id:K})}},Ne=async()=>{if(!E){X.error("No team selected");return}const K=X.loading("Deleting team...");try{const de=await(await fetch(`/api/teams/${E.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();de.success?(await Ke(),B(!1),L(null),X.success("Team deleted successfully!",{id:K})):X.error(`Error deleting team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error deleting team:",ae),X.error("Error deleting team",{id:K})}},Pe=K=>{L(K),D({name:K.name}),O(!0)},Xr=K=>{L(K),B(!0)};return f?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading organization details..."})]})}):n?s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:"/organizations",children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:()=>N(!0),className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[s.jsx(we,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),s.jsxs(Y,{onClick:on,className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Invite User"]}),s.jsxs(Y,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit Organization"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(Xe,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:n.name}),s.jsx("p",{className:"text-gray-400",children:n.slug})]})]}),s.jsx("div",{className:"border-b border-white/10",children:s.jsxs("nav",{className:"flex space-x-8",children:[s.jsxs("button",{onClick:()=>m("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(Xe,{className:"w-4 h-4"}),s.jsx("span",{children:"Details"}),s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length+a.length+i.length})]}),s.jsxs("button",{onClick:()=>m("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Members"}),c.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length})]}),s.jsxs("button",{onClick:()=>m("invitations"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="invitations"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(Qt,{className:"w-4 h-4"}),s.jsx("span",{children:"Invitations"}),a.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]}),s.jsxs("button",{onClick:()=>m("teams"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="teams"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Teams"}),i.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:i.length})]})]})}),h==="details"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[s.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Organization Information"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),s.jsx("p",{className:"text-white mt-1",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Slug"}),s.jsx("p",{className:"text-white mt-1",children:n.slug})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:c.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:i.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Teams"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qt,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Invitations"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Yl,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(n.createdAt).getTime())/(1e3*60*60*24))}),s.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})})]})]}),h==="teams"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Teams (",i.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage teams within this organization"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:()=>S(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Teams"]}),s.jsxs(Y,{onClick:()=>I(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]})]}),w?i.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Team"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Members"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:i.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>t(`/organizations/${e}/teams/${K.id}`),children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",K.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:K.memberCount||0}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(K.createdAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:ae=>{ae.stopPropagation(),Pe(K)},children:[s.jsx(ps,{className:"w-4 h-4 mr-1"}),"Edit"]}),s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:ae=>{ae.stopPropagation(),Xr(K)},children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Delete"]})]})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Teams Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Create your first team to start organizing members within this organization."}),s.jsxs(Y,{onClick:()=>I(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Create First Team"]})]})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:s.jsxs("div",{className:"flex items-start space-x-4",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(we,{className:"w-12 h-12 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Teams Feature Required"}),s.jsx("p",{className:"text-gray-300 mb-6",children:"To use Teams in Better Auth Studio, you need to enable the teams feature in your organization plugin configuration."}),s.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[s.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),s.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:s.jsx("li",{children:"Update your auth configuration file to enable teams:"})}),s.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:s.jsxs("pre",{className:"text-sm text-gray-300",children:[s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"export const"})," ",s.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",s.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",s.jsx("br",{}),s.jsx("span",{className:"text-yellow-300 pl-12",children:"organization"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-16",children:"teams"}),": ","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-yellow-300 pl-20",children:"enabled"}),":"," ",s.jsx("span",{className:"text-blue-400",children:"true"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-16",children:"}"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-12",children:"})"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-10",children:"]"})," ",s.jsx("br",{}),"}",") ",s.jsx("br",{})]})}),s.jsx("div",{className:"mt-4",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"2. Run migrations to create the teams table"})}),s.jsx("div",{className:"mt-2",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),s.jsx(Y,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),s.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",s.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]}),h==="members"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Members (",c.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage organization members and their roles"})]})}),c.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:c.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("img",{src:K.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${K.user.id}`,alt:K.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",K.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:K.user.email}),s.jsx("td",{className:"py-4 px-4",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed rounded-none border-blue-500/30 text-blue-400/70 capitalize",children:K.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(K.joinedAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>he(K.id,K.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Invite users or seed members from existing users to get started."}),s.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[s.jsxs(Y,{onClick:()=>N(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx(we,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),s.jsxs(Y,{onClick:on,className:"bg-white text-white hover:bg-white/90 bg-transparent border border-white/20 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Invite User"]})]})]})})]}),h==="invitations"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Invitations (",a.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage pending invitations to this organization"})]})}),a.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:a.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(Qt,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.email}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Expires on"," ",new Date(K.expiresAt).toLocaleDateString("en-US",{month:"short",year:"numeric",day:"numeric"})]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white capitalize",children:K.role}),s.jsx("td",{className:"py-4 px-4",children:s.jsxs(pe,{variant:"secondary",className:`text-xs font-normal rounded-none border-dashed flex items-center gap-1 w-fit ${K.status==="pending"?"bg-yellow-900/10 border border-yellow-500/30 text-yellow-400/70":K.status==="accepted"?"bg-green-900/10 border border-green-500/30 text-green-400/70":"bg-red-900/10 border border-red-500/30 text-red-400/70"}`,children:[K.status==="pending"&&s.jsx(Qn,{className:"w-3 h-3"}),K.status==="accepted"&&s.jsx(tt,{className:"w-3 h-3"}),K.status==="expired"&&s.jsx(Te,{className:"w-3 h-3"}),K.status]})}),s.jsxs("td",{className:"py-4 px-4 text-sm text-gray-400",children:[new Date(K.expiresAt).toLocaleDateString(),s.jsx("br",{}),s.jsx("span",{className:"text-xs text-gray-400",children:new Date(K.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>ie(K.id,K.email),children:[s.jsx(Ip,{className:"w-4 h-4 mr-1"}),"Resend"]}),s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>Q(K.id),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Cancel"]})]})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Qt,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Invitations"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Start inviting users to join this organization."}),s.jsxs(Y,{onClick:on,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Send First Invitation"]})]})})]}),v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Invite User"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{g(!1),P(""),M("")},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"invite-email",className:"text-sm text-gray-400 font-light",children:"Email Address"}),s.jsx(be,{id:"invite-email",type:"email",value:A,onChange:K=>P(K.target.value),placeholder:"user@example.com",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"inviter-select",className:"text-sm text-gray-400 font-light",children:"Inviter"}),s.jsxs(yi,{value:C,onValueChange:M,children:[s.jsx(vi,{children:s.jsx(wi,{placeholder:"Select an inviter..."})}),s.jsx(bi,{children:$.map(K=>s.jsx(tn,{value:K.id,children:s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("img",{src:K.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${K.id}`,alt:K.name,className:"w-6 h-6 rounded-none border border-dashed border-white/20"}),s.jsxs("span",{children:[K.name," (",K.email,")"]})]})},K.id))})]})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{g(!1),P(""),M("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:kn,disabled:U,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[U?s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}):s.jsx(Ip,{className:"w-4 h-4 mr-2"}),U?"Sending...":"Send Invitation"]})]})]})}),_&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Create Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{I(!1),D({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"team-name",value:T.name,onChange:K=>re(K.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{I(!1),D({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:_e,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create Team"})]})]})}),F&&E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{O(!1),D({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:E.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",E.id]})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"edit-team-name",value:T.name,onChange:K=>re(K.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{O(!1),D({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})}),z&&E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>B(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:E.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",E.id]})]})]}),s.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this team? This action cannot be undone."})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>B(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:Ne,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete Team"})]})]})}),j&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Members"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(we,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Add Members from Existing Users"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"member-count",className:"text-sm text-gray-400 font-light",children:"Number of members to add"}),s.jsx(be,{id:"member-count",type:"number",min:"1",max:"50",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var ae;const K=parseInt(((ae=document.getElementById("member-count"))==null?void 0:ae.value)||"5");Nn(K)},disabled:V,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:V?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(we,{className:"w-3 h-3 mr-2"}),"Seed Members"]})})]})]}),W.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Member Seeding Terminal",lines:W,isRunning:V,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>N(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),k&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Teams"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Xe,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Create Teams"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"team-count",className:"text-sm text-gray-400 font-light",children:"Number of teams to create"}),s.jsx(be,{id:"team-count",type:"number",min:"1",max:"20",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var ae;const K=parseInt(((ae=document.getElementById("team-count"))==null?void 0:ae.value)||"3");Ae(K)},disabled:te,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:te?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Xe,{className:"w-3 h-3 mr-2"}),"Seed Teams"]})})]})]}),ne.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Team Seeding Terminal",lines:ne,isRunning:te,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>S(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:"/organizations",children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),s.jsx("br",{}),s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Xe,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Organization Not Found"}),s.jsx("p",{className:"text-gray-400",children:"The organization you're looking for doesn't exist."})]})]})}function yD(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[i,o]=p.useState(""),[a,l]=p.useState("all"),[c,d]=p.useState(!1),[f,u]=p.useState(!1),[h,m]=p.useState(!1),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(null),[j,N]=p.useState([]),[k,S]=p.useState(!1);p.useEffect(()=>{_()},[]);const _=async()=>{try{const M=await(await fetch("/api/sessions")).json();t(M.sessions||[])}catch(C){console.error("Failed to fetch sessions:",C)}finally{r(!1)}},I=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${C} sessions...`,timestamp:new Date}]);try{const $=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if($.success){const R=$.results.map((D,U)=>D.success?{id:`session-${U}`,type:"progress",message:`Creating session: ${D.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${U}`,type:"error",message:`Failed to create session ${U+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const T=$.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${T}/${C} sessions successfully`,timestamp:new Date}]),await _()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${$.error||"Unknown error"}`,timestamp:new Date}])}catch(M){N($=>[...$,{id:"error",type:"error",message:`❌ Network error: ${M}`,timestamp:new Date}])}finally{S(!1)}},F=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting account seeding process for ${C} accounts...`,timestamp:new Date}]);try{const $=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if($.success){const R=$.results.map((D,U)=>D.success?{id:`account-${U}`,type:"progress",message:`Creating account: ${D.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${U}`,type:"error",message:`Failed to create account ${U+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const T=$.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${T}/${C} accounts successfully`,timestamp:new Date}]),await _()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${$.error||"Unknown error"}`,timestamp:new Date}])}catch(M){N($=>[...$,{id:"error",type:"error",message:`❌ Network error: ${M}`,timestamp:new Date}])}finally{S(!1)}},O=C=>{g(C),y(!0)},z=C=>{g(C),u(!0)},B=C=>{g(C),m(!0)},E=async C=>{console.log("Creating session:",C),d(!1)},L=async C=>{console.log("Updating session:",C),u(!1)},A=async()=>{console.log("Deleting session:",v==null?void 0:v.id),m(!1)},P=e.filter(C=>{const M=C.id.toLowerCase().includes(i.toLowerCase())||C.userId.toLowerCase().includes(i.toLowerCase()),$=a==="all"||a==="active"&&new Date(C.expiresAt)>new Date||a==="expired"&&new Date(C.expiresAt)<=new Date;return M&&$});return n?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading sessions..."})]})}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl text-white font-light",children:["Sessions (",e.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage user sessions and accounts"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>x(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed"]}),s.jsxs(Y,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>d(!0),children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Add Session"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsxs("div",{className:"flex-1 relative",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{placeholder:"Search sessions...",value:i,onChange:C=>o(C.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(jh,{className:"w-4 h-4 text-gray-400"}),s.jsxs(yi,{value:a,onValueChange:l,children:[s.jsx(vi,{children:s.jsx(wi,{})}),s.jsxs(bi,{children:[s.jsx(tn,{value:"all",children:"All"}),s.jsx(tn,{value:"active",children:"Active"}),s.jsx(tn,{value:"expired",children:"Expired"})]})]})]})]}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Session"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User ID"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:P.map(C=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",C.id.slice(0,8),"..."]}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",C.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:C.userId}),s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-2",children:[new Date(C.expiresAt)>new Date?s.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}):s.jsx("div",{className:"w-2 h-2 bg-red-400 rounded-full"}),s.jsx("span",{className:"text-sm text-gray-400",children:new Date(C.expiresAt)>new Date?"Active":"Expired"})]})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(C.expiresAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>O(C),children:s.jsx(oa,{className:"w-4 h-4"})}),s.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>z(C),children:s.jsx(ps,{className:"w-4 h-4"})}),s.jsx(Y,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:()=>B(C),children:s.jsx(os,{className:"w-4 h-4"})})]})})]},C.id))})]})})}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>x(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Seed Sessions"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),s.jsx(be,{id:"session-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var M;const C=parseInt(((M=document.getElementById("session-count"))==null?void 0:M.value)||"5");I(C)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx($e,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(go,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Seed Accounts"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),s.jsx(be,{id:"account-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var M;const C=parseInt(((M=document.getElementById("account-count"))==null?void 0:M.value)||"5");F(C)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(go,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]})]}),j.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:j,isRunning:k,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),c&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Create Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"create-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),s.jsx(be,{id:"create-user-id",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"create-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),s.jsx(be,{id:"create-expires",type:"datetime-local",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>d(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>E({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),f&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),s.jsx(be,{id:"edit-user-id",defaultValue:v.userId,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),s.jsx(be,{id:"edit-expires",type:"datetime-local",defaultValue:new Date(v.expiresAt).toISOString().slice(0,16),className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>u(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>L({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),h&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this session? This action cannot be undone."})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>m(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:A,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Session Details"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"ID:"}),s.jsx("span",{className:"text-white text-sm",children:v.id})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"User ID:"}),s.jsx("span",{className:"text-white text-sm",children:v.userId})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Status:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.expiresAt)>new Date?"Active":"Expired"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Expires:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.expiresAt).toLocaleString()})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Created:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.createdAt).toLocaleString()})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Updated:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.updatedAt).toLocaleString()})]})]})]}),s.jsx("div",{className:"flex justify-end mt-6",children:s.jsx(Y,{onClick:()=>y(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function vD(e){const t=p.useRef(null),n=p.useRef(null),r=p.useRef(0),i=5;p.useEffect(()=>{const o=()=>{try{const l=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`;console.log("🔌 Attempting to connect to WebSocket:",l),t.current=new WebSocket(l),t.current.onopen=()=>{console.log("✅ WebSocket connected successfully"),r.current=0,n.current&&(clearTimeout(n.current),n.current=null)},t.current.onmessage=c=>{try{const d=JSON.parse(c.data);console.log("📨 WebSocket message received:",d),e(d)}catch(d){console.error("❌ Failed to parse WebSocket message:",d)}},t.current.onclose=c=>{if(console.log("🔌 WebSocket disconnected:",c.code,c.reason),c.code===1006||c.code===1001){console.log("ℹ️ WebSocket server not available (running in normal mode)");return}if(r.current<i){r.current++;const d=Math.min(1e3*2**r.current,1e4);console.log(`🔄 Attempting to reconnect in ${d}ms (attempt ${r.current}/${i})`),n.current=setTimeout(()=>{o()},d)}else console.log("❌ Max reconnection attempts reached")},t.current.onerror=c=>{console.error("❌ WebSocket error:",c)}}catch(a){console.error("❌ Failed to connect WebSocket:",a)}};return o(),()=>{t.current&&t.current.close(),n.current&&clearTimeout(n.current)}},[e])}function wD(){var y,b,x,v,g,j,N,k,S,_,I,F,O,z,B,E,L,A,P,C,M,$,R,T,D,U,H;const[e,t]=p.useState(null),[n,r]=p.useState(null),[i,o]=p.useState(null),[a,l]=p.useState(!0),[c,d]=p.useState(null);vD(W=>{W.type==="config_changed"?(console.log("🔄 Config changed, refreshing data..."),setTimeout(()=>{f(),u(),h()},500)):W.type==="connected"&&console.log("✅ Connected to Better Auth Studio WebSocket")}),p.useEffect(()=>{f(),u(),h()},[]);const f=async()=>{var W;try{const V=await(await fetch("/api/config")).json();(W=V.studio)!=null&&W.version&&d(`v${V.studio.version}`),t(V)}catch(G){console.error("Failed to fetch config:",G)}finally{l(!1)}},u=async()=>{try{const G=await(await fetch("/api/health")).json();r(G.system||{studioVersion:c||"v1.0.0",nodeVersion:process.version,platform:navigator.platform,uptime:"2h 15m"})}catch(W){console.error("Failed to fetch system info:",W),r({studioVersion:c||"v1.0.0",nodeVersion:"v18.0.0",platform:"macOS",uptime:"2h 15m"})}},h=async()=>{try{const G=await(await fetch("/api/plugins")).json();o(G)}catch(W){console.error("Failed to fetch plugins:",W),o({plugins:[],configPath:null,totalPlugins:0,error:"Failed to fetch plugins"})}},m=W=>{switch(W==null?void 0:W.toLowerCase()){case"postgresql":case"postgres":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Connected"]});case"mysql":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Connected"]});case"sqlite":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(Gi,{className:"w-3 h-3"}),"Local"]});default:return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(Vn,{className:"w-3 h-3"}),"Unknown"]})}},w=W=>{switch(W.toLowerCase()){case"google":return s.jsx(qr,{className:"w-5 h-5 text-white"});case"github":return s.jsx(Hn,{className:"w-5 h-5 text-white"});case"discord":return s.jsx(qr,{className:"w-5 h-5 text-white"});case"twitter":return s.jsx(qr,{className:"w-5 h-5 text-white"});default:return s.jsx(qr,{className:"w-5 h-5 text-white"})}};return a?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-white"})}):s.jsxs("div",{className:"space-y-8 animate-fade-in",children:[s.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Settings"}),s.jsx("p",{className:"text-gray-300 mt-2",children:"Configure your Better Auth application"})]})}),s.jsx("hr",{className:"w-full border-white/15 h-px"}),s.jsx("hr",{className:"w-full border-white/15 h-px"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 p-5",children:[s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Application"})]}),s.jsx(En,{children:"Basic application configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsxs(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(qr,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"App Name"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Application display name"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.appName)||"Better Auth"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Wy,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Base URL"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Application base URL"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.baseURL)||"http://localhost:3000"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Base Path"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auth API base path"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.basePath)||"/api/auth"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Secret"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Encryption secret"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.secret)==="Configured"?"Configured":"Not set"})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Database"})]}),s.jsx(En,{children:"Database connection and configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsxs(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:((y=e==null?void 0:e.database)==null?void 0:y.type)&&((b=e==null?void 0:e.database)==null?void 0:b.type.charAt(0).toUpperCase())+((x=e==null?void 0:e.database)==null?void 0:x.type.slice(1))||"Unknown"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database Type"})]})]}),((v=e==null?void 0:e.database)==null?void 0:v.type)&&m(e.database.type)]}),((g=e==null?void 0:e.database)==null?void 0:g.dialect)&&s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Dialect"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database dialect"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:e.database.dialect})})]}),((j=e==null?void 0:e.database)==null?void 0:j.casing)&&s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Casing"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Table name casing"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:e.database.casing})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Dp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Debug Logs"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database debug logging"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(N=e==null?void 0:e.database)!=null&&N.debugLogs?s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Providers"})]}),s.jsx(En,{children:"Configured authentication providers"})]}),s.jsx(ft,{className:"p-0",children:e!=null&&e.socialProviders&&e.socialProviders.length>0?e.socialProviders.map((W,G)=>s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[w(W.type),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:W.type}),s.jsx("p",{className:"text-xs text-gray-400",children:W.clientId?"Configured":"Not configured"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:W.clientId?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Active"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Setup Required"]})})]},G)):s.jsxs("div",{className:"text-center py-8",children:[s.jsx(Hn,{className:"w-8 h-8 text-white mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-gray-400",children:"No providers configured"})]})})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Qt,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Email & Password"})]}),s.jsx(En,{children:"Email authentication settings"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qt,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Email Authentication"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Allow users to sign up with email"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(k=e==null?void 0:e.emailAndPassword)!=null&&k.enabled?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]})})]}),((S=e==null?void 0:e.emailAndPassword)==null?void 0:S.enabled)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Sign Up"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Allow new user registration"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(_=e==null?void 0:e.emailAndPassword)!=null&&_.disableSignUp?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Email Verification"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Require email verification"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(I=e==null?void 0:e.emailAndPassword)!=null&&I.requireEmailVerification?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Required"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Optional"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Password Length"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Min/Max password length"})]})]}),s.jsx("div",{className:"text-right",children:s.jsxs("p",{className:"text-sm font-medium text-white",children:[((F=e==null?void 0:e.emailAndPassword)==null?void 0:F.minPasswordLength)||8," -"," ",((O=e==null?void 0:e.emailAndPassword)==null?void 0:O.maxPasswordLength)||128]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Auto Sign In"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auto sign in after registration"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(z=e==null?void 0:e.emailAndPassword)!=null&&z.autoSignIn?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Session"})]}),s.jsx(En,{children:"Session management settings"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Session Duration"}),s.jsx("p",{className:"text-xs text-gray-400",children:"How long sessions last"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(B=e==null?void 0:e.session)!=null&&B.expiresIn?`${Math.floor(e.session.expiresIn/(60*60*24))} days`:"7 days"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Default"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Dp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Update Age"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Session refresh interval"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(E=e==null?void 0:e.session)!=null&&E.updateAge?`${Math.floor(e.session.updateAge/(60*60))} hours`:"24 hours"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Session Refresh"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auto refresh sessions"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(L=e==null?void 0:e.session)!=null&&L.disableSessionRefresh?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Store in Database"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Store sessions in database"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(A=e==null?void 0:e.session)!=null&&A.storeSessionInDatabase?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Gi,{className:"w-3 h-3"}),"Secondary Storage"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Rate Limiting"})]}),s.jsx(En,{children:"API rate limiting configuration"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limiting"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Enable rate limiting"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(P=e==null?void 0:e.rateLimit)!=null&&P.enabled?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-red-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limit Window"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Time window for rate limiting"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(C=e==null?void 0:e.rateLimit)!=null&&C.window?`${e.rateLimit.window} seconds`:"10 seconds"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Window"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Max Requests"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Maximum requests per window"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:((M=e==null?void 0:e.rateLimit)==null?void 0:M.max)||100}),s.jsx("p",{className:"text-xs text-gray-400",children:"Requests"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Storage"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Rate limit storage type"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:(($=e==null?void 0:e.rateLimit)==null?void 0:$.storage)||"memory"})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Advanced"})]}),s.jsx(En,{children:"Advanced configuration options"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Secure Cookies"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Use secure cookies"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(R=e==null?void 0:e.advanced)!=null&&R.useSecureCookies?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"CSRF Check"}),s.jsx("p",{className:"text-xs text-gray-400",children:"CSRF protection"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(T=e==null?void 0:e.advanced)!=null&&T.disableCSRFCheck?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(oa,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"IP Tracking"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Track IP addresses"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(U=(D=e==null?void 0:e.advanced)==null?void 0:D.ipAddress)!=null&&U.disableIpTracking?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gk,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Telemetry"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Usage analytics"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(H=e==null?void 0:e.telemetry)!=null&&H.enabled?s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"System Info"})]}),s.jsx(En,{children:"Better Auth Studio system information"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Studio Version"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Better Auth Studio"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:c||"v1.0.0"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Latest"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Node.js Version"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Runtime environment"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.nodeVersion)||"v18.0.0"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Current"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(qr,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Platform"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Operating system"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.platform)||"macOS"}),s.jsx("p",{className:"text-xs text-gray-400",children:"System"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Uptime"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Service uptime"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.uptime)||"2h 15m"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Running"})]})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none lg:col-span-2",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Rp,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Plugins"})]}),s.jsx(En,{children:"Better Auth plugins enabled in your configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsx(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:i!=null&&i.plugins&&i.plugins.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Total Plugins"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Currently enabled plugins"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:i.totalPlugins}),s.jsx("p",{className:"text-xs text-gray-400",children:"Active"})]})]}),i.plugins.map((W,G)=>s.jsxs("div",{className:`flex items-center justify-between p-4 px-5 ${G<i.plugins.length-1?"border-b border-white/15":""}`,children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Rp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:W.name.slice(0,1).toUpperCase()+W.name.slice(1).replace("-"," ")}),s.jsx("p",{className:"text-xs text-gray-400",children:W.description})]})]}),s.jsx("div",{className:"text-right flex items-center space-x-2",children:s.jsxs(pe,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400 flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]},W.id)),i.configPath&&s.jsx("div",{className:"p-4 px-5 bg-black/30 border-t border-white/10",children:s.jsxs("p",{className:"text-xs text-gray-400",children:["Config file:"," ",s.jsx("span",{className:"text-white font-mono",children:i.configPath})]})})]}):s.jsxs("div",{className:"flex items-center justify-between p-4 px-5",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Vn,{className:"w-5 h-5 text-yellow-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"No Plugins Enabled"}),s.jsx("p",{className:"text-xs text-gray-400",children:(i==null?void 0:i.error)||"No plugins are currently configured in your Better Auth setup"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs bg-yellow-900/50 border border-yellow-500/30 text-yellow-400 rounded-sm",children:"None"})]})})]})]})]})}function xg(){var L,A;const{orgId:e,teamId:t}=bh(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState(!0),[c,d]=p.useState("details"),[f,u]=p.useState(!1),[h,m]=p.useState(!1),[w,y]=p.useState(""),[b,x]=p.useState([]),[v,g]=p.useState([]),[j,N]=p.useState({name:""});p.useEffect(()=>{t&&(k(),S())},[t]);const k=async()=>{try{const C=await(await fetch(`/api/teams/${t}`)).json();C.success&&C.team?(r(C.team),N({name:C.team.name})):C.team?(r(C.team),N({name:C.team.name})):X.error("Team not found")}catch(P){console.error("Failed to fetch team:",P),X.error("Failed to load team")}finally{l(!1)}},S=async()=>{try{const C=await(await fetch(`/api/teams/${t}/members`)).json();C.success&&o(C.members||[])}catch(P){console.error("Failed to fetch team members:",P),X.error("Failed to load team members")}},_=async()=>{try{const C=await(await fetch("/api/users?limit=10000")).json(),M=i.map(R=>R.userId),$=(C.users||[]).filter(R=>!M.includes(R.id));x($)}catch(P){console.error("Failed to fetch available users:",P),X.error("Failed to load users")}},I=async()=>{if(!j.name){X.error("Please enter a team name");return}const P=X.loading("Updating team...");try{const M=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name})})).json();M.success?(await k(),m(!1),X.success("Team updated successfully!",{id:P})):X.error(`Error updating team: ${M.error||"Unknown error"}`,{id:P})}catch(C){console.error("Error updating team:",C),X.error("Error updating team",{id:P})}},F=async()=>{if(v.length===0){X.error("Please select at least one user");return}const P=X.loading(`Adding ${v.length} members...`);try{const M=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:v})})).json();M.success?(await S(),u(!1),g([]),y(""),X.success(`Successfully added ${v.length} members!`,{id:P})):X.error(`Error adding members: ${M.error||"Unknown error"}`,{id:P})}catch(C){console.error("Error adding members:",C),X.error("Error adding members",{id:P})}},O=async(P,C)=>{const M=X.loading(`Removing ${C}...`);try{const R=await(await fetch(`/api/team-members/${P}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();R.success?(await S(),X.success(`${C} removed from team!`,{id:M})):X.error(`Error removing member: ${R.error||"Unknown error"}`,{id:M})}catch($){console.error("Error removing team member:",$),X.error("Error removing team member",{id:M})}},z=()=>{_(),u(!0)},B=P=>{g(C=>C.includes(P)?C.filter(M=>M!==P):[...C,P])},E=b.filter(P=>P.name.toLowerCase().includes(w.toLowerCase())||P.email.toLowerCase().includes(w.toLowerCase()));return a?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading team details..."})]})}):n?s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:`/organizations/${n.organizationId}`,children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:z,className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add Members"]}),s.jsxs(Y,{onClick:()=>m(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit Team"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:n.name}),s.jsx("div",{className:"flex items-center space-x-2",children:n.organization&&s.jsxs(ri,{to:`/organizations/${n.organizationId}`,className:"text-gray-400 hover:text-white text-sm",children:[s.jsx(Xe,{className:"w-4 h-4 inline mr-1"}),n.organization.name]})})]})]}),s.jsx("div",{className:"border-b border-white/10",children:s.jsxs("nav",{className:"flex space-x-8",children:[s.jsxs("button",{onClick:()=>d("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Details"})]}),s.jsxs("button",{onClick:()=>d("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Members"}),i.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:i.length})]})]})}),c==="details"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[s.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Team Information"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),s.jsx("p",{className:"text-white mt-1",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Organization"}),s.jsx("p",{className:"text-white mt-1",children:((L=n.organization)==null?void 0:L.name)||"Unknown"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:i.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Yl,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(n.createdAt).getTime())/(1e3*60*60*24))}),s.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Xe,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:"1"}),s.jsx("p",{className:"text-sm text-gray-400",children:"Organization"})]})]})})]})]}),c==="members"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Team Members (",i.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage members of this team"})]})}),i.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:i.map(P=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("img",{src:P.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${P.user.id}`,alt:P.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:P.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",P.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:P.user.email}),s.jsx("td",{className:"py-4 px-4",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed border-blue-500/30 text-blue-400/70 rounded-none capitalize",children:P.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(P.joinedAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>O(P.id,P.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},P.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Add members to this team to get started."}),s.jsxs(Y,{onClick:z,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add First Members"]})]})})]}),f&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Add Team Members"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{u(!1),g([]),y("")},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{placeholder:"Search users by name or email...",value:w,onChange:P=>y(P.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),v.length>0&&s.jsx("div",{className:"bg-blue-900/20 border border-blue-500/30 rounded-none p-3",children:s.jsxs("p",{className:"text-blue-400 text-sm",children:[v.length," user",v.length!==1?"s":""," selected"]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none max-h-96 overflow-y-auto",children:E.length>0?s.jsx("div",{className:"divide-y divide-white/5",children:E.map(P=>s.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${v.includes(P.id)?"bg-blue-900/20":""}`,onClick:()=>B(P.id),children:[s.jsx("input",{type:"checkbox",checked:v.includes(P.id),onChange:()=>B(P.id),className:"rounded border-gray-300"}),s.jsx("img",{src:P.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${P.id}`,alt:P.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white font-light",children:P.name}),s.jsx("div",{className:"text-sm text-gray-400",children:P.email})]})]},P.id))}):s.jsx("div",{className:"p-8 text-center",children:s.jsx("p",{className:"text-gray-400",children:"No users found matching your search."})})})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{u(!1),g([]),y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:F,disabled:v.length===0,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add ",v.length," Member",v.length!==1?"s":""]})]})]})}),h&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:n.name}),s.jsx("div",{className:"text-sm text-gray-400",children:(A=n.organization)==null?void 0:A.name})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"edit-team-name",value:j.name,onChange:P=>N({name:P.target.value}),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>m(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:I,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:`/organizations/${e}`,children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Team Not Found"}),s.jsx("p",{className:"text-gray-400",children:"The team you're looking for doesn't exist."})]})]})}function bD(){const e=Cs(),[t,n]=p.useState([]),[r,i]=p.useState(!0),[o,a]=p.useState(null),[l,c]=p.useState(""),[d,f]=p.useState("all"),[u,h]=p.useState(1),[m]=p.useState(20);p.useEffect(()=>{w()},[]);const w=async()=>{try{const k=await(await fetch("/api/plugins")).json(),S=(k==null?void 0:k.plugins).find(_=>_.id==="teams");a({enabled:!!S,availablePlugins:(k==null?void 0:k.plugins).map(_=>_.id),configPath:k.configPath,teamsPlugin:(k==null?void 0:k.plugins).find(_=>_.id==="teams")}),S?await y():i(!1)}catch(N){console.error("Failed to check teams plugin status:",N),a({enabled:!1,error:"Failed to check plugin status"}),i(!1)}},y=async()=>{try{const k=await(await fetch("/api/teams")).json();k.success&&n(k.teams||[])}catch(N){console.error("Failed to fetch teams:",N),X.error("Failed to load teams")}finally{i(!1)}},b=t.filter(N=>{var S;const k=N.name.toLowerCase().includes(l.toLowerCase())||((S=N.organization)==null?void 0:S.name.toLowerCase().includes(l.toLowerCase()));if(d==="all")return k;if(d==="recent"){const _=new Date;return _.setDate(_.getDate()-7),k&&new Date(N.createdAt)>_}return k}),x=u*m,v=x-m,g=b.slice(v,x),j=Math.ceil(b.length/m);return r?s.jsx("div",{className:"flex items-center justify-center min-h-screen",children:s.jsx(wt,{className:"w-8 h-8 animate-spin text-white"})}):o!=null&&o.enabled?s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-light tracking-tight text-white",children:"Teams"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:[b.length," team",b.length!==1?"s":""," found"]})]}),s.jsx("div",{className:"flex items-center space-x-3",children:s.jsxs(Y,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Create Team"]})})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{type:"text",placeholder:"Search teams...",value:l,onChange:N=>c(N.target.value),className:"pl-10 bg-black border-dashed border-white/20 text-white placeholder-gray-400 focus:ring-2 focus:ring-white focus:border-transparent"})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Y,{variant:d==="all"?"default":"outline",size:"sm",onClick:()=>f("all"),className:d==="all"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"All"}),s.jsx(Y,{variant:d==="recent"?"default":"outline",size:"sm",onClick:()=>f("recent"),className:d==="recent"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"Recent"})]})]}),g.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-light text-white mb-2",children:"No teams found"}),s.jsx("p",{className:"text-gray-400 mb-6",children:l?"Try adjusting your search terms":"Get started by creating your first team"}),!l&&s.jsxs(Y,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]}):s.jsx("div",{className:"grid gap-4",children:g.map(N=>{var k;return s.jsx("div",{className:"bg-black/30 border border-white/15 rounded-none p-4 hover:bg-black/40 transition-colors cursor-pointer",onClick:()=>e(`/teams/${N.id}`),children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:N.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:[(k=N.organization)==null?void 0:k.name," • ",N.memberCount||0," members"]})]})]}),s.jsx("div",{className:"flex items-center space-x-2",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400",children:"Active"})})]})},N.id)})}),j>1&&s.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.max(1,u-1)),disabled:u===1,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Previous"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["Page ",u," of ",j]}),s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.min(j,u+1)),disabled:u===j,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Next"})]})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:"Teams"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application organizations"})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:s.jsxs("div",{className:"flex items-start space-x-4",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(Xe,{className:"w-12 h-12 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),s.jsx("p",{className:"text-gray-300 mb-6",children:"To use Organizations in Better Auth Studio, you need to enable the organization plugin in your Better Auth configuration."}),s.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[s.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),s.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:s.jsxs("li",{children:["Import the plugin in your auth configuration file",(o==null?void 0:o.configPath)&&s.jsxs("span",{className:"text-gray-400",children:[" (",o.configPath,")"]}),":"]})}),s.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:s.jsxs("pre",{className:"text-sm text-gray-300",children:[s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"export const"})," ",s.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",s.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",s.jsx("br",{}),s.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),s.jsx("br",{}),s.jsx("span",{className:"pl-10",children:"]"})," ",s.jsx("br",{}),"}",") ",s.jsx("br",{})]})}),s.jsx("div",{className:"mt-4",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),s.jsx("div",{className:"mt-2",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),(o==null?void 0:o.availablePlugins)&&o.availablePlugins.length>0&&s.jsx("div",{className:"mb-4",children:s.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",o.availablePlugins.join(", ")]})}),s.jsx(Y,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),s.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",s.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]})}function jD(){const{userId:e}=bh(),t=Cs(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m]=p.useState("details"),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(!1),[j,N]=p.useState([]),[k,S]=p.useState(!1),[_,I]=p.useState({});p.useEffect(()=>{e&&(B(),E())},[e]);const F=async R=>{try{const T=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:R})});if(T.ok){const D=await T.json();if(D.success&&D.location)return D.location}return null}catch(T){return console.error("Failed to resolve IP location:",T),null}},O=async R=>{const T=R.map(async H=>{if(!_[H.id]){const W=await F(H.ipAddress);if(W)return{sessionId:H.id,location:W}}return null}),D=await Promise.all(T),U={};D.forEach(H=>{H&&(U[H.sessionId]=H.location)}),Object.keys(U).length>0&&I(H=>({...H,...U}))},z=R=>{if(!R)return"🌍";const T=R.toUpperCase().split("").map(D=>127397+D.charCodeAt(0));return String.fromCodePoint(...T)},B=async()=>{try{const R=await fetch(`/api/users/${e}`);if(R.ok){const T=await R.json();r(T.user)}else X.error("Failed to fetch user details"),t("/users")}catch(R){console.error("Failed to fetch user details:",R),X.error("Failed to fetch user details"),t("/users")}finally{u(!1)}},E=async()=>{try{const[R,T,D]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(R.ok){const U=await R.json();o(U.memberships||[])}if(T.ok){const U=await T.json();l(U.memberships||[])}if(D.ok){const H=(await D.json()).sessions||[];d(H),O(H)}}catch(R){console.error("Failed to fetch user memberships:",R)}},L=async()=>{var U,H;if(!n)return;const R=(U=document.getElementById("edit-name"))==null?void 0:U.value,T=(H=document.getElementById("edit-email"))==null?void 0:H.value;if(!R||!T){X.error("Please fill in all fields");return}const D=X.loading("Updating user...");try{const G=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R,email:T})})).json();G.success?(r({...n,name:R,email:T}),y(!1),X.success("User updated successfully!",{id:D})):X.error(`Error updating user: ${G.error||"Unknown error"}`,{id:D})}catch(W){console.error("Error updating user:",W),X.error("Error updating user",{id:D})}},A=async()=>{if(!n)return;const R=X.loading("Banning user...");try{const D=await(await fetch(`/api/users/${e}/ban`,{method:"POST"})).json();D.success?(X.success("User banned successfully!",{id:R}),t("/users")):X.error(`Error banning user: ${D.error||"Unknown error"}`,{id:R})}catch(T){console.error("Error banning user:",T),X.error("Error banning user",{id:R})}},P=async R=>{const T=X.loading("Removing user from organization...");try{const U=await(await fetch(`/api/organizations/members/${R}`,{method:"DELETE"})).json();U.success?(o(H=>H.filter(W=>W.id!==R)),X.success("User removed from organization!",{id:T})):X.error(`Error removing user: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error removing user from organization:",D),X.error("Error removing user from organization",{id:T})}},C=async R=>{const T=X.loading("Removing user from team...");try{const U=await(await fetch(`/api/teams/members/${R}`,{method:"DELETE"})).json();U.success?(l(H=>H.filter(W=>W.id!==R)),X.success("User removed from team!",{id:T})):X.error(`Error removing user: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error removing user from team:",D),X.error("Error removing user from team",{id:T})}},M=async R=>{const T=X.loading("Deleting session...");try{const U=await(await fetch(`/api/sessions/${R}`,{method:"DELETE"})).json();U.success?(d(H=>H.filter(W=>W.id!==R)),X.success("Session deleted successfully!",{id:T})):X.error(`Error deleting session: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error deleting session:",D),X.error("Error deleting session",{id:T})}},$=async(R=3)=>{if(e){N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${R} sessions...`,timestamp:new Date}]);try{const D=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:R})})).json();if(D.success){const U=D.results.map((W,G)=>W.success?{id:`session-${G}`,type:"progress",message:`Creating session ${G+1}: ${W.session.token.substring(0,20)}... from ${W.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${G}`,type:"error",message:`Failed to create session ${G+1}: ${W.error}`,timestamp:new Date});N(W=>[...W,...U]);const H=D.results.filter(W=>W.success).length;N(W=>[...W,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${H}/${R} sessions successfully`,timestamp:new Date}]),E()}else N(U=>[...U,{id:"error",type:"error",message:`❌ Session seeding failed: ${D.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(D=>[...D,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}}};return f?s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):n?s.jsxs("div",{className:"min-h-screen bg-black w-full",children:[s.jsxs("div",{className:"w-full px-6 py-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsxs(Y,{variant:"outline",onClick:()=>t("/users"),className:"mb-4 border-none text-white",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Users"]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:n.image?s.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):s.jsx(go,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-white",children:n.name}),s.jsx("p",{className:"text-gray-400",children:n.email}),s.jsx("div",{className:"flex items-center space-x-2 mt-2",children:s.jsx(pe,{variant:n.emailVerified?"default":"destructive",className:"rounded-none",children:n.emailVerified?"Verified":"Unverified"})})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsxs(Y,{variant:"outline",onClick:()=>y(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit User"]}),s.jsxs(Y,{variant:"outline",onClick:()=>x(!0),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(Ap,{className:"w-4 h-4 mr-2"}),"Ban User"]})]})]})]}),s.jsxs("div",{className:"border border-dashed border-white/10 rounded-none",children:[s.jsx("div",{className:"border-b border-dashed border-white/10",children:s.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:go},{id:"organizations",name:"Organizations",icon:Xe,count:i.length},{id:"teams",name:"Teams",icon:we,count:a.length},{id:"sessions",name:"Sessions",icon:Qn,count:c.length}].map(R=>s.jsxs("button",{onClick:()=>m(R.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${h===R.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[s.jsx(R.icon,{className:"w-4 h-4"}),s.jsx("span",{children:R.name}),R.count!==void 0&&s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.count})]},R.id))})}),s.jsxs("div",{className:"p-6",children:[h==="details"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),s.jsx("div",{className:"text-white",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Qt,{className:"w-4 h-4"}),s.jsx("span",{children:n.email})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email Status"}),s.jsx(pe,{variant:n.emailVerified?"default":"destructive",className:"rounded-none",children:n.emailVerified?"Verified":"Unverified"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Created"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Yl,{className:"w-4 h-4"}),s.jsx("span",{children:new Date(n.createdAt).toLocaleDateString()})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Last Updated"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Yl,{className:"w-4 h-4"}),s.jsx("span",{children:new Date(n.updatedAt).toLocaleDateString()})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"User ID"}),s.jsx("div",{className:"text-white font-mono text-sm",children:n.id})]})]})]})}),h==="organizations"&&s.jsx("div",{className:"space-y-4",children:i.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Xe,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),s.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):s.jsx("div",{className:"grid gap-4",children:i.map(R=>s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-12 h-12 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:R.organization.image?s.jsx("img",{src:R.organization.image,alt:R.organization.name,className:"w-12 h-12 object-cover"}):s.jsx(Xe,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:R.organization.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["@",R.organization.slug]}),s.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.role}),s.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(R.joinedAt).toLocaleDateString()]})]})]})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>P(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(zp,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},R.id))})}),h==="teams"&&s.jsx("div",{className:"space-y-4",children:a.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),s.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):s.jsx("div",{className:"grid gap-4",children:a.map(R=>s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:s.jsx(we,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:R.team.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["in ",R.team.organizationName]}),s.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.role}),s.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(R.joinedAt).toLocaleDateString()]})]})]})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>C(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(zp,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},R.id))})}),h==="sessions"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium text-white",children:"Sessions"}),s.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user authentication sessions"})]}),s.jsxs(Y,{variant:"outline",onClick:()=>{N([]),S(!1),g(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Qn,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),s.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):s.jsx("div",{className:"grid gap-4",children:c.map(R=>{var T,D,U,H;return s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[s.jsx("div",{className:"w-12 -mt-2 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:s.jsx(nS,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"flex items-center space-x-3 mb-2",children:s.jsxs("h3",{className:"text-white font-medium",children:["Session ",R.id.substring(0,8),"..."]})}),s.jsxs("div",{className:"flex items-center space-x-4 mb-1",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(qr,{className:"w-4 h-4 text-white"}),s.jsx("span",{className:"text-white text-sm",children:R.ipAddress})]}),s.jsxs("div",{className:"flex items-center space-x-1",children:[s.jsx("span",{className:"text-gray-400 text-xs",children:"📍"}),s.jsxs("span",{className:"text-gray-300 text-sm",children:[((T=_[R.id])==null?void 0:T.city)||"...",","," ",((D=_[R.id])==null?void 0:D.country)||"..."]}),((U=_[R.id])==null?void 0:U.countryCode)&&s.jsx("span",{className:"text-sm ml-1",children:z((H=_[R.id])==null?void 0:H.countryCode)})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-4 h-4 text-white"}),s.jsx("span",{className:"text-gray-400 text-sm",children:"Expires:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(R.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>M(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(Ap,{className:"w-4 h-4 mr-1"}),"Revoke"]})]})]})]})})},R.id)})})]})]})]})]}),w&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:"×"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n!=null&&n.image?s.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):s.jsx(go,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h4",{className:"text-white font-medium",children:n==null?void 0:n.name}),s.jsx("p",{className:"text-gray-400 text-sm",children:n==null?void 0:n.email})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),s.jsx("input",{id:"edit-name",type:"text",defaultValue:(n==null?void 0:n.name)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),s.jsx("input",{id:"edit-email",type:"email",defaultValue:(n==null?void 0:n.email)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:L,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black border border-dashed border-red-400/50 rounded-none p-6 w-full max-w-md",children:[s.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),s.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to ban ",s.jsx("strong",{children:n.name}),"? This will prevent them from accessing the system."]}),s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx(Y,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:A,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Sessions"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("h4",{className:"text-white font-light",children:["Create Sessions for ",n==null?void 0:n.name]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),s.jsx(be,{id:"session-count",type:"number",min:"1",max:"50",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx("p",{className:"text-xs text-gray-400",children:"Each session will have a unique token, IP address, and 7-day expiration."})]})]}),j.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:j,isRunning:k,className:"w-full",defaultCollapsed:!1})})]}),s.jsxs("div",{className:"flex justify-end space-x-2 mt-6 pt-6 border-t border-dashed border-white/10",children:[s.jsx(Y,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>{var T;const R=parseInt(((T=document.getElementById("session-count"))==null?void 0:T.value)||"3");$(R)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-4 h-4 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})})]})]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function ND(){return s.jsx(oS,{children:s.jsxs(pk,{children:[s.jsx(q4,{children:s.jsxs(lk,{children:[s.jsx(Gt,{path:"/",element:s.jsx(Z4,{})}),s.jsx(Gt,{path:"/users",element:s.jsx(Ov,{})}),s.jsx(Gt,{path:"/users/:userId",element:s.jsx(jD,{})}),s.jsx(Gt,{path:"/organizations",element:s.jsx(Lv,{})}),s.jsx(Gt,{path:"/organizations/:orgId",element:s.jsx(gD,{})}),s.jsx(Gt,{path:"/teams",element:s.jsx(bD,{})}),s.jsx(Gt,{path:"/teams/:teamId",element:s.jsx(xg,{})}),s.jsx(Gt,{path:"/organizations/:orgId/teams/:teamId",element:s.jsx(xg,{})}),s.jsx(Gt,{path:"/sessions",element:s.jsx(yD,{})}),s.jsx(Gt,{path:"/database",element:s.jsx(xD,{})}),s.jsx(Gt,{path:"/settings",element:s.jsx(wD,{})})]})}),s.jsx(Wk,{theme:"dark",position:"top-right",richColors:!0,closeButton:!0})]})})}eu.createRoot(document.getElementById("root")).render(s.jsx(J.StrictMode,{children:s.jsx(ND,{})}));
|
|
405
|
+
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Pb.displayName="MiniMap";const mA=p.memo(Pb),pA=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,xA={[_i.Line]:"right",[_i.Handle]:"bottom-right"};function gA({nodeId:e,position:t,variant:n=_i.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:h,autoScale:m=!0,shouldResize:w,onResizeStart:y,onResize:b,onResizeEnd:x}){const v=ab(),g=typeof e=="string"?e:v,j=Oe(),N=p.useRef(null),k=n===_i.Handle,S=ye(p.useCallback(pA(k&&m),[k,m]),He),_=p.useRef(null),I=t??xA[n];p.useEffect(()=>{if(!(!N.current||!g))return _.current||(_.current=TP({domNode:N.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:O,transform:z,snapGrid:B,snapToGrid:E,nodeOrigin:L,domNode:A}=j.getState();return{nodeLookup:O,transform:z,snapGrid:B,snapToGrid:E,nodeOrigin:L,paneDomNode:A}},onChange:(O,z)=>{const{triggerNodeChanges:B,nodeLookup:E,parentLookup:L,nodeOrigin:A}=j.getState(),P=[],C={x:O.x,y:O.y},M=E.get(g);if(M&&M.expandParent&&M.parentId){const $=M.origin??A,R=O.width??M.measured.width??0,T=O.height??M.measured.height??0,D={id:M.id,parentId:M.parentId,rect:{width:R,height:T,...Cw({x:O.x??M.position.x,y:O.y??M.position.y},{width:R,height:T},M.parentId,E,$)}},U=Yh([D],E,L,A);P.push(...U),C.x=O.x?Math.max($[0]*R,O.x):void 0,C.y=O.y?Math.max($[1]*T,O.y):void 0}if(C.x!==void 0&&C.y!==void 0){const $={id:g,type:"position",position:{...C}};P.push($)}if(O.width!==void 0&&O.height!==void 0){const R={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};P.push(R)}for(const $ of z){const R={...$,type:"position"};P.push(R)}B(P)},onEnd:({width:O,height:z})=>{const B={id:g,type:"dimensions",resizing:!1,dimensions:{width:O,height:z}};j.getState().triggerNodeChanges([B])}})),_.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:h,onResizeStart:y,onResize:b,onResizeEnd:x,shouldResize:w}),()=>{var O;(O=_.current)==null||O.destroy()}},[I,l,c,d,f,u,y,b,x,w]);const F=I.split("-");return s.jsx("div",{className:Je(["react-flow__resize-control","nodrag",...F,n,r]),ref:N,style:{...i,scale:S,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:o})}p.memo(gA);const yA=["top","right","bottom","left"],Br=Math.min,Lt=Math.max,ic=Math.round,Za=Math.floor,$n=e=>({x:e,y:e}),vA={left:"right",right:"left",bottom:"top",top:"bottom"},wA={start:"end",end:"start"};function yf(e,t,n){return Lt(e,Br(t,n))}function or(e,t){return typeof e=="function"?e(t):e}function ar(e){return e.split("-")[0]}function Li(e){return e.split("-")[1]}function Kh(e){return e==="x"?"y":"x"}function qh(e){return e==="y"?"height":"width"}const bA=new Set(["top","bottom"]);function An(e){return bA.has(ar(e))?"y":"x"}function Qh(e){return Kh(An(e))}function jA(e,t,n){n===void 0&&(n=!1);const r=Li(e),i=Qh(e),o=qh(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=oc(a)),[a,oc(a)]}function NA(e){const t=oc(e);return[vf(e),t,vf(t)]}function vf(e){return e.replace(/start|end/g,t=>wA[t])}const sg=["left","right"],ig=["right","left"],kA=["top","bottom"],SA=["bottom","top"];function CA(e,t,n){switch(e){case"top":case"bottom":return n?t?ig:sg:t?sg:ig;case"left":case"right":return t?kA:SA;default:return[]}}function EA(e,t,n,r){const i=Li(e);let o=CA(ar(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(vf)))),o}function oc(e){return e.replace(/left|right|bottom|top/g,t=>vA[t])}function _A(e){return{top:0,right:0,bottom:0,left:0,...e}}function Tb(e){return typeof e!="number"?_A(e):{top:e,right:e,bottom:e,left:e}}function ac(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function og(e,t,n){let{reference:r,floating:i}=e;const o=An(t),a=Qh(t),l=qh(a),c=ar(t),d=o==="y",f=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-i.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-i.width,y:u};break;default:m={x:r.x,y:r.y}}switch(Li(t)){case"start":m[a]-=h*(n&&d?-1:1);break;case"end":m[a]+=h*(n&&d?-1:1);break}return m}const PA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=o.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:u}=og(d,r,c),h=r,m={},w=0;for(let y=0;y<l.length;y++){const{name:b,fn:x}=l[y],{x:v,y:g,data:j,reset:N}=await x({x:f,y:u,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:d,platform:a,elements:{reference:e,floating:t}});f=v??f,u=g??u,m={...m,[b]:{...m[b],...j}},N&&w<=50&&(w++,typeof N=="object"&&(N.placement&&(h=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:f,y:u}=og(d,h,c)),y=-1)}return{x:f,y:u,placement:h,strategy:i,middlewareData:m}};async function qo(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:h=!1,padding:m=0}=or(t,e),w=Tb(m),b=l[h?u==="floating"?"reference":"floating":u],x=ac(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),v=u==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,g=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),j=await(o.isElement==null?void 0:o.isElement(g))?await(o.getScale==null?void 0:o.getScale(g))||{x:1,y:1}:{x:1,y:1},N=ac(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:g,strategy:c}):v);return{top:(x.top-N.top+w.top)/j.y,bottom:(N.bottom-x.bottom+w.bottom)/j.y,left:(x.left-N.left+w.left)/j.x,right:(N.right-x.right+w.right)/j.x}}const TA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=or(e,t)||{};if(d==null)return{};const u=Tb(f),h={x:n,y:r},m=Qh(i),w=qh(m),y=await a.getDimensions(d),b=m==="y",x=b?"top":"left",v=b?"bottom":"right",g=b?"clientHeight":"clientWidth",j=o.reference[w]+o.reference[m]-h[m]-o.floating[w],N=h[m]-o.reference[m],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let S=k?k[g]:0;(!S||!await(a.isElement==null?void 0:a.isElement(k)))&&(S=l.floating[g]||o.floating[w]);const _=j/2-N/2,I=S/2-y[w]/2-1,F=Br(u[x],I),O=Br(u[v],I),z=F,B=S-y[w]-O,E=S/2-y[w]/2+_,L=yf(z,E,B),A=!c.arrow&&Li(i)!=null&&E!==L&&o.reference[w]/2-(E<z?F:O)-y[w]/2<0,P=A?E<z?E-z:E-B:0;return{[m]:h[m]+P,data:{[m]:L,centerOffset:E-L-P,...A&&{alignmentOffset:P}},reset:A}}}),MA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:y=!0,...b}=or(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const x=ar(i),v=An(l),g=ar(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=h||(g||!y?[oc(l)]:NA(l)),k=w!=="none";!h&&k&&N.push(...EA(l,y,w,j));const S=[l,...N],_=await qo(t,b),I=[];let F=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&I.push(_[x]),u){const E=jA(i,a,j);I.push(_[E[0]],_[E[1]])}if(F=[...F,{placement:i,overflows:I}],!I.every(E=>E<=0)){var O,z;const E=(((O=o.flip)==null?void 0:O.index)||0)+1,L=S[E];if(L&&(!(u==="alignment"?v!==An(L):!1)||F.every(C=>An(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:E,overflows:F},reset:{placement:L}};let A=(z=F.filter(P=>P.overflows[0]<=0).sort((P,C)=>P.overflows[1]-C.overflows[1])[0])==null?void 0:z.placement;if(!A)switch(m){case"bestFit":{var B;const P=(B=F.filter(C=>{if(k){const M=An(C.placement);return M===v||M==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(M=>M>0).reduce((M,$)=>M+$,0)]).sort((C,M)=>C[1]-M[1])[0])==null?void 0:B[0];P&&(A=P);break}case"initialPlacement":A=l;break}if(i!==A)return{reset:{placement:A}}}return{}}}};function ag(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lg(e){return yA.some(t=>e[t]>=0)}const AA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=or(e,t);switch(r){case"referenceHidden":{const o=await qo(t,{...i,elementContext:"reference"}),a=ag(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:lg(a)}}}case"escaped":{const o=await qo(t,{...i,altBoundary:!0}),a=ag(o,n.floating);return{data:{escapedOffsets:a,escaped:lg(a)}}}default:return{}}}}},Mb=new Set(["left","top"]);async function RA(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=ar(n),l=Li(n),c=An(n)==="y",d=Mb.has(a)?-1:1,f=o&&c?-1:1,u=or(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:w}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof w=="number"&&(m=l==="end"?w*-1:w),c?{x:m*f,y:h*d}:{x:h*d,y:m*f}}const DA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:l}=t,c=await RA(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}}},IA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x,y:v}=b;return{x,y:v}}},...c}=or(e,t),d={x:n,y:r},f=await qo(t,c),u=An(ar(i)),h=Kh(u);let m=d[h],w=d[u];if(o){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+f[b],g=m-f[x];m=yf(v,m,g)}if(a){const b=u==="y"?"top":"left",x=u==="y"?"bottom":"right",v=w+f[b],g=w-f[x];w=yf(v,w,g)}const y=l.fn({...t,[h]:m,[u]:w});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:o,[u]:a}}}}}},zA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=or(e,t),f={x:n,y:r},u=An(i),h=Kh(u);let m=f[h],w=f[u];const y=or(l,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const g=h==="y"?"height":"width",j=o.reference[h]-o.floating[g]+b.mainAxis,N=o.reference[h]+o.reference[g]-b.mainAxis;m<j?m=j:m>N&&(m=N)}if(d){var x,v;const g=h==="y"?"width":"height",j=Mb.has(ar(i)),N=o.reference[u]-o.floating[g]+(j&&((x=a.offset)==null?void 0:x[u])||0)+(j?0:b.crossAxis),k=o.reference[u]+o.reference[g]+(j?0:((v=a.offset)==null?void 0:v[u])||0)-(j?b.crossAxis:0);w<N?w=N:w>k&&(w=k)}return{[h]:m,[u]:w}}}},$A=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:a,elements:l}=t,{apply:c=()=>{},...d}=or(e,t),f=await qo(t,d),u=ar(i),h=Li(i),m=An(i)==="y",{width:w,height:y}=o.floating;let b,x;u==="top"||u==="bottom"?(b=u,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=u,b=h==="end"?"top":"bottom");const v=y-f.top-f.bottom,g=w-f.left-f.right,j=Br(y-f[b],v),N=Br(w-f[x],g),k=!t.middlewareData.shift;let S=j,_=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=g),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=v),k&&!h){const F=Lt(f.left,0),O=Lt(f.right,0),z=Lt(f.top,0),B=Lt(f.bottom,0);m?_=w-2*(F!==0||O!==0?F+O:Lt(f.left,f.right)):S=y-2*(z!==0||B!==0?z+B:Lt(f.top,f.bottom))}await c({...t,availableWidth:_,availableHeight:S});const I=await a.getDimensions(l.floating);return w!==I.width||y!==I.height?{reset:{rects:!0}}:{}}}};function Hc(){return typeof window<"u"}function Oi(e){return Ab(e)?(e.nodeName||"").toLowerCase():"#document"}function Ut(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bn(e){var t;return(t=(Ab(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ab(e){return Hc()?e instanceof Node||e instanceof Ut(e).Node:!1}function vn(e){return Hc()?e instanceof Element||e instanceof Ut(e).Element:!1}function On(e){return Hc()?e instanceof HTMLElement||e instanceof Ut(e).HTMLElement:!1}function cg(e){return!Hc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ut(e).ShadowRoot}const LA=new Set(["inline","contents"]);function pa(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=wn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!LA.has(i)}const OA=new Set(["table","td","th"]);function FA(e){return OA.has(Oi(e))}const BA=[":popover-open",":modal"];function Wc(e){return BA.some(t=>{try{return e.matches(t)}catch{return!1}})}const UA=["transform","translate","scale","rotate","perspective"],VA=["transform","translate","scale","rotate","perspective","filter"],HA=["paint","layout","strict","content"];function Zh(e){const t=Jh(),n=vn(e)?wn(e):e;return UA.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||VA.some(r=>(n.willChange||"").includes(r))||HA.some(r=>(n.contain||"").includes(r))}function WA(e){let t=Ur(e);for(;On(t)&&!Ti(t);){if(Zh(t))return t;if(Wc(t))return null;t=Ur(t)}return null}function Jh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const YA=new Set(["html","body","#document"]);function Ti(e){return YA.has(Oi(e))}function wn(e){return Ut(e).getComputedStyle(e)}function Yc(e){return vn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ur(e){if(Oi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cg(e)&&e.host||Bn(e);return cg(t)?t.host:t}function Rb(e){const t=Ur(e);return Ti(t)?e.ownerDocument?e.ownerDocument.body:e.body:On(t)&&pa(t)?t:Rb(t)}function Qo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Rb(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=Ut(i);if(o){const l=wf(a);return t.concat(a,a.visualViewport||[],pa(i)?i:[],l&&n?Qo(l):[])}return t.concat(i,Qo(i,[],n))}function wf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Db(e){const t=wn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=On(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=ic(n)!==o||ic(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function em(e){return vn(e)?e:e.contextElement}function li(e){const t=em(e);if(!On(t))return $n(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Db(t);let a=(o?ic(n.width):n.width)/r,l=(o?ic(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const XA=$n(0);function Ib(e){const t=Ut(e);return!Jh()||!t.visualViewport?XA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function GA(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ut(e)?!1:t}function js(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=em(e);let a=$n(1);t&&(r?vn(r)&&(a=li(r)):a=li(e));const l=GA(o,n,r)?Ib(o):$n(0);let c=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,f=i.width/a.x,u=i.height/a.y;if(o){const h=Ut(o),m=r&&vn(r)?Ut(r):r;let w=h,y=wf(w);for(;y&&r&&m!==w;){const b=li(y),x=y.getBoundingClientRect(),v=wn(y),g=x.left+(y.clientLeft+parseFloat(v.paddingLeft))*b.x,j=x.top+(y.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,d*=b.y,f*=b.x,u*=b.y,c+=g,d+=j,w=Ut(y),y=wf(w)}}return ac({width:f,height:u,x:c,y:d})}function Xc(e,t){const n=Yc(e).scrollLeft;return t?t.left+n:js(Bn(e)).left+n}function zb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Xc(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function KA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Bn(r),l=t?Wc(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=$n(1);const f=$n(0),u=On(r);if((u||!u&&!o)&&((Oi(r)!=="body"||pa(a))&&(c=Yc(r)),On(r))){const m=js(r);d=li(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const h=a&&!u&&!o?zb(a,c):$n(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+h.x,y:n.y*d.y-c.scrollTop*d.y+f.y+h.y}}function qA(e){return Array.from(e.getClientRects())}function QA(e){const t=Bn(e),n=Yc(e),r=e.ownerDocument.body,i=Lt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Lt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Xc(e);const l=-n.scrollTop;return wn(r).direction==="rtl"&&(a+=Lt(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:l}}const dg=25;function ZA(e,t){const n=Ut(e),r=Bn(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){o=i.width,a=i.height;const f=Jh();(!f||f&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=Xc(r);if(d<=0){const f=r.ownerDocument,u=f.body,h=getComputedStyle(u),m=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(r.clientWidth-u.clientWidth-m);w<=dg&&(o-=w)}else d<=dg&&(o+=d);return{width:o,height:a,x:l,y:c}}const JA=new Set(["absolute","fixed"]);function eR(e,t){const n=js(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=On(e)?li(e):$n(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=i*o.x,d=r*o.y;return{width:a,height:l,x:c,y:d}}function ug(e,t,n){let r;if(t==="viewport")r=ZA(e,n);else if(t==="document")r=QA(Bn(e));else if(vn(t))r=eR(t,n);else{const i=Ib(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ac(r)}function $b(e,t){const n=Ur(e);return n===t||!vn(n)||Ti(n)?!1:wn(n).position==="fixed"||$b(n,t)}function tR(e,t){const n=t.get(e);if(n)return n;let r=Qo(e,[],!1).filter(l=>vn(l)&&Oi(l)!=="body"),i=null;const o=wn(e).position==="fixed";let a=o?Ur(e):e;for(;vn(a)&&!Ti(a);){const l=wn(a),c=Zh(a);!c&&l.position==="fixed"&&(i=null),(o?!c&&!i:!c&&l.position==="static"&&!!i&&JA.has(i.position)||pa(a)&&!c&&$b(e,a))?r=r.filter(f=>f!==a):i=l,a=Ur(a)}return t.set(e,r),r}function nR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Wc(t)?[]:tR(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((d,f)=>{const u=ug(t,f,i);return d.top=Lt(u.top,d.top),d.right=Br(u.right,d.right),d.bottom=Br(u.bottom,d.bottom),d.left=Lt(u.left,d.left),d},ug(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function rR(e){const{width:t,height:n}=Db(e);return{width:t,height:n}}function sR(e,t,n){const r=On(t),i=Bn(t),o=n==="fixed",a=js(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=$n(0);function d(){c.x=Xc(i)}if(r||!r&&!o)if((Oi(t)!=="body"||pa(i))&&(l=Yc(t)),r){const m=js(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else i&&d();o&&!r&&i&&d();const f=i&&!r&&!o?zb(i,l):$n(0),u=a.left+l.scrollLeft-c.x-f.x,h=a.top+l.scrollTop-c.y-f.y;return{x:u,y:h,width:a.width,height:a.height}}function Kd(e){return wn(e).position==="static"}function fg(e,t){if(!On(e)||wn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bn(e)===n&&(n=n.ownerDocument.body),n}function Lb(e,t){const n=Ut(e);if(Wc(e))return n;if(!On(e)){let i=Ur(e);for(;i&&!Ti(i);){if(vn(i)&&!Kd(i))return i;i=Ur(i)}return n}let r=fg(e,t);for(;r&&FA(r)&&Kd(r);)r=fg(r,t);return r&&Ti(r)&&Kd(r)&&!Zh(r)?n:r||WA(e)||n}const iR=async function(e){const t=this.getOffsetParent||Lb,n=this.getDimensions,r=await n(e.floating);return{reference:sR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oR(e){return wn(e).direction==="rtl"}const aR={convertOffsetParentRelativeRectToViewportRelativeRect:KA,getDocumentElement:Bn,getClippingRect:nR,getOffsetParent:Lb,getElementRects:iR,getClientRects:qA,getDimensions:rR,getScale:li,isElement:vn,isRTL:oR};function Ob(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lR(e,t){let n=null,r;const i=Bn(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const d=e.getBoundingClientRect(),{left:f,top:u,width:h,height:m}=d;if(l||t(),!h||!m)return;const w=Za(u),y=Za(i.clientWidth-(f+h)),b=Za(i.clientHeight-(u+m)),x=Za(f),g={rootMargin:-w+"px "+-y+"px "+-b+"px "+-x+"px",threshold:Lt(0,Br(1,c))||1};let j=!0;function N(k){const S=k[0].intersectionRatio;if(S!==c){if(!j)return a();S?a(!1,S):r=setTimeout(()=>{a(!1,1e-7)},1e3)}S===1&&!Ob(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(N,{...g,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,g)}n.observe(e)}return a(!0),o}function cR(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=em(e),f=i||o?[...d?Qo(d):[],...Qo(t)]:[];f.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),o&&x.addEventListener("resize",n)});const u=d&&l?lR(d,n):null;let h=-1,m=null;a&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var g;(g=m)==null||g.observe(t)})),n()}),d&&!c&&m.observe(d),m.observe(t));let w,y=c?js(e):null;c&&b();function b(){const x=js(e);y&&!Ob(y,x)&&n(),y=x,w=requestAnimationFrame(b)}return n(),()=>{var x;f.forEach(v=>{i&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),u==null||u(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const dR=DA,uR=IA,fR=MA,hR=$A,mR=AA,hg=TA,pR=zA,xR=(e,t,n)=>{const r=new Map,i={platform:aR,...n},o={...i.platform,_c:r};return PA(e,t,{...i,platform:o})};var gR=typeof document<"u",yR=function(){},vl=gR?p.useLayoutEffect:yR;function lc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!lc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!lc(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Fb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mg(e,t){const n=Fb(e);return Math.round(t*n)/n}function qd(e){const t=p.useRef(e);return vl(()=>{t.current=e}),t}function vR(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,u]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);lc(h,r)||m(r);const[w,y]=p.useState(null),[b,x]=p.useState(null),v=p.useCallback(C=>{C!==k.current&&(k.current=C,y(C))},[]),g=p.useCallback(C=>{C!==S.current&&(S.current=C,x(C))},[]),j=o||w,N=a||b,k=p.useRef(null),S=p.useRef(null),_=p.useRef(f),I=c!=null,F=qd(c),O=qd(i),z=qd(d),B=p.useCallback(()=>{if(!k.current||!S.current)return;const C={placement:t,strategy:n,middleware:h};O.current&&(C.platform=O.current),xR(k.current,S.current,C).then(M=>{const $={...M,isPositioned:z.current!==!1};E.current&&!lc(_.current,$)&&(_.current=$,Sc.flushSync(()=>{u($)}))})},[h,t,n,O,z]);vl(()=>{d===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,u(C=>({...C,isPositioned:!1})))},[d]);const E=p.useRef(!1);vl(()=>(E.current=!0,()=>{E.current=!1}),[]),vl(()=>{if(j&&(k.current=j),N&&(S.current=N),j&&N){if(F.current)return F.current(j,N,B);B()}},[j,N,B,F,I]);const L=p.useMemo(()=>({reference:k,floating:S,setReference:v,setFloating:g}),[v,g]),A=p.useMemo(()=>({reference:j,floating:N}),[j,N]),P=p.useMemo(()=>{const C={position:n,left:0,top:0};if(!A.floating)return C;const M=mg(A.floating,f.x),$=mg(A.floating,f.y);return l?{...C,transform:"translate("+M+"px, "+$+"px)",...Fb(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:$}},[n,l,A.floating,f.x,f.y]);return p.useMemo(()=>({...f,update:B,refs:L,elements:A,floatingStyles:P}),[f,B,L,A,P])}const wR=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?hg({element:r.current,padding:i}).fn(n):{}:r?hg({element:r,padding:i}).fn(n):{}}}},bR=(e,t)=>({...dR(e),options:[e,t]}),jR=(e,t)=>({...uR(e),options:[e,t]}),NR=(e,t)=>({...pR(e),options:[e,t]}),kR=(e,t)=>({...fR(e),options:[e,t]}),SR=(e,t)=>({...hR(e),options:[e,t]}),CR=(e,t)=>({...mR(e),options:[e,t]}),ER=(e,t)=>({...wR(e),options:[e,t]});var _R="Arrow",Bb=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return s.jsx(ze.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Bb.displayName=_R;var PR=Bb;function Ub(e){const[t,n]=p.useState(void 0);return Or(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,l;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var tm="Popper",[Vb,Hb]=Ec(tm),[TR,Wb]=Vb(tm),Yb=e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null);return s.jsx(TR,{scope:t,anchor:r,onAnchorChange:i,children:n})};Yb.displayName=tm;var Xb="PopperAnchor",Gb=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=Wb(Xb,n),a=p.useRef(null),l=Xt(t,a),c=p.useRef(null);return p.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||a.current,d!==c.current&&o.onAnchorChange(c.current)}),r?null:s.jsx(ze.div,{...i,ref:l})});Gb.displayName=Xb;var nm="PopperContent",[MR,AR]=Vb(nm),Kb=p.forwardRef((e,t)=>{var G,V,q,ne,se,te;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:w,...y}=e,b=Wb(nm,n),[x,v]=p.useState(null),g=Xt(t,ee=>v(ee)),[j,N]=p.useState(null),k=Ub(j),S=(k==null?void 0:k.width)??0,_=(k==null?void 0:k.height)??0,I=r+(o!=="center"?"-"+o:""),F=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},O=Array.isArray(d)?d:[d],z=O.length>0,B={padding:F,boundary:O.filter(DR),altBoundary:z},{refs:E,floatingStyles:L,placement:A,isPositioned:P,middlewareData:C}=vR({strategy:"fixed",placement:I,whileElementsMounted:(...ee)=>cR(...ee,{animationFrame:m==="always"}),elements:{reference:b.anchor},middleware:[bR({mainAxis:i+_,alignmentAxis:a}),c&&jR({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?NR():void 0,...B}),c&&kR({...B}),SR({...B,apply:({elements:ee,rects:re,availableWidth:me,availableHeight:ge})=>{const{width:Ce,height:Ke}=re.reference,Ee=ee.floating.style;Ee.setProperty("--radix-popper-available-width",`${me}px`),Ee.setProperty("--radix-popper-available-height",`${ge}px`),Ee.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ee.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),j&&ER({element:j,padding:l}),IR({arrowWidth:S,arrowHeight:_}),h&&CR({strategy:"referenceHidden",...B})]}),[M,$]=Zb(A),R=xi(w);Or(()=>{P&&(R==null||R())},[P,R]);const T=(G=C.arrow)==null?void 0:G.x,D=(V=C.arrow)==null?void 0:V.y,U=((q=C.arrow)==null?void 0:q.centerOffset)!==0,[H,W]=p.useState();return Or(()=>{x&&W(window.getComputedStyle(x).zIndex)},[x]),s.jsx("div",{ref:E.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:P?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(ne=C.transformOrigin)==null?void 0:ne.x,(se=C.transformOrigin)==null?void 0:se.y].join(" "),...((te=C.hide)==null?void 0:te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(MR,{scope:n,placedSide:M,onArrowChange:N,arrowX:T,arrowY:D,shouldHideArrow:U,children:s.jsx(ze.div,{"data-side":M,"data-align":$,...y,ref:g,style:{...y.style,animation:P?void 0:"none"}})})})});Kb.displayName=nm;var qb="PopperArrow",RR={top:"bottom",right:"left",bottom:"top",left:"right"},Qb=p.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=AR(qb,r),a=RR[o.placedSide];return s.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:s.jsx(PR,{...i,ref:n,style:{...i.style,display:"block"}})})});Qb.displayName=qb;function DR(e){return e!==null}var IR=e=>({name:"transformOrigin",options:e,fn(t){var b,x,v;const{placement:n,rects:r,middlewareData:i}=t,a=((b=i.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,f]=Zb(n),u={start:"0%",center:"50%",end:"100%"}[f],h=(((x=i.arrow)==null?void 0:x.x)??0)+l/2,m=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let w="",y="";return d==="bottom"?(w=a?u:`${h}px`,y=`${-c}px`):d==="top"?(w=a?u:`${h}px`,y=`${r.floating.height+c}px`):d==="right"?(w=`${-c}px`,y=a?u:`${m}px`):d==="left"&&(w=`${r.floating.width+c}px`,y=a?u:`${m}px`),{data:{x:w,y}}}});function Zb(e){const[t,n="center"]=e.split("-");return[t,n]}var zR=Yb,$R=Gb,LR=Kb,OR=Qb,FR=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),BR="VisuallyHidden",Jb=p.forwardRef((e,t)=>s.jsx(ze.span,{...e,ref:t,style:{...FR,...e.style}}));Jb.displayName=BR;var UR=Jb,[Gc]=Ec("Tooltip",[Hb]),Kc=Hb(),e1="TooltipProvider",VR=700,bf="tooltip.open",[HR,rm]=Gc(e1),t1=e=>{const{__scopeTooltip:t,delayDuration:n=VR,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),s.jsx(HR,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:o})};t1.displayName=e1;var Zo="Tooltip",[WR,qc]=Gc(Zo),n1=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:a,delayDuration:l}=e,c=rm(Zo,e.__scopeTooltip),d=Kc(t),[f,u]=p.useState(null),h=In(),m=p.useRef(0),w=a??c.disableHoverableContent,y=l??c.delayDuration,b=p.useRef(!1),[x,v]=kh({prop:r,defaultProp:i??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(bf))):c.onClose(),o==null||o(S)},caller:Zo}),g=p.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),j=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,v(!0)},[v]),N=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),k=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,v(!0),m.current=0},y)},[y,v]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(zR,{...d,children:s.jsx(WR,{scope:t,contentId:h,open:x,stateAttribute:g,trigger:f,onTriggerChange:u,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?k():j()},[c.isOpenDelayedRef,k,j]),onTriggerLeave:p.useCallback(()=>{w?N():(window.clearTimeout(m.current),m.current=0)},[N,w]),onOpen:j,onClose:N,disableHoverableContent:w,children:n})})};n1.displayName=Zo;var jf="TooltipTrigger",r1=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qc(jf,n),o=rm(jf,n),a=Kc(n),l=p.useRef(null),c=Xt(t,l,i.onTriggerChange),d=p.useRef(!1),f=p.useRef(!1),u=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),s.jsx($R,{asChild:!0,...a,children:s.jsx(ze.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:vt(e.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:vt(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:vt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:vt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:vt(e.onBlur,i.onClose),onClick:vt(e.onClick,i.onClose)})})});r1.displayName=jf;var YR="TooltipPortal",[SD,XR]=Gc(YR,{forceMount:void 0}),Mi="TooltipContent",s1=p.forwardRef((e,t)=>{const n=XR(Mi,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,a=qc(Mi,e.__scopeTooltip);return s.jsx(zi,{present:r||a.open,children:a.disableHoverableContent?s.jsx(i1,{side:i,...o,ref:t}):s.jsx(GR,{side:i,...o,ref:t})})}),GR=p.forwardRef((e,t)=>{const n=qc(Mi,e.__scopeTooltip),r=rm(Mi,e.__scopeTooltip),i=p.useRef(null),o=Xt(t,i),[a,l]=p.useState(null),{trigger:c,onClose:d}=n,f=i.current,{onPointerInTransitChange:u}=r,h=p.useCallback(()=>{l(null),u(!1)},[u]),m=p.useCallback((w,y)=>{const b=w.currentTarget,x={x:w.clientX,y:w.clientY},v=JR(x,b.getBoundingClientRect()),g=eD(x,v),j=tD(y.getBoundingClientRect()),N=rD([...g,...j]);l(N),u(!0)},[u]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&f){const w=b=>m(b,f),y=b=>m(b,c);return c.addEventListener("pointerleave",w),f.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",y)}}},[c,f,m,h]),p.useEffect(()=>{if(a){const w=y=>{const b=y.target,x={x:y.clientX,y:y.clientY},v=(c==null?void 0:c.contains(b))||(f==null?void 0:f.contains(b)),g=!nD(x,a);v?h():g&&(h(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,f,a,d,h]),s.jsx(i1,{...e,ref:o})}),[KR,qR]=Gc(Zo,{isInside:!1}),QR=SS("TooltipContent"),i1=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:a,...l}=e,c=qc(Mi,n),d=Kc(n),{onClose:f}=c;return p.useEffect(()=>(document.addEventListener(bf,f),()=>document.removeEventListener(bf,f)),[f]),p.useEffect(()=>{if(c.trigger){const u=h=>{const m=h.target;m!=null&&m.contains(c.trigger)&&f()};return window.addEventListener("scroll",u,{capture:!0}),()=>window.removeEventListener("scroll",u,{capture:!0})}},[c.trigger,f]),s.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:u=>u.preventDefault(),onDismiss:f,children:s.jsxs(LR,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(QR,{children:r}),s.jsx(KR,{scope:n,isInside:!0,children:s.jsx(UR,{id:c.contentId,role:"tooltip",children:i||r})})]})})});s1.displayName=Mi;var o1="TooltipArrow",ZR=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Kc(n);return qR(o1,n).isInside?null:s.jsx(OR,{...i,...r,ref:t})});ZR.displayName=o1;function JR(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function eD(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function tD(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function nD(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){const l=t[o],c=t[a],d=l.x,f=l.y,u=c.x,h=c.y;f>r!=h>r&&n<(u-d)*(r-f)/(h-f)+d&&(i=!i)}return i}function rD(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),sD(t)}function sD(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const o=t[t.length-1],a=t[t.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var iD=t1,oD=n1,aD=r1,a1=s1;const Qd=iD,Zd=oD,Jd=aD,wl=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(a1,{ref:r,sideOffset:t,className:rt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));wl.displayName=a1.displayName;const lD=420,cD=({data:e,targetPosition:t,sourcePosition:n})=>{const r=e,i="!h-1.5 !w-1.5 !min-w-0 !min-h-0 !cursor-grab !border-0 opacity-100",o="h-[22px]";return s.jsx(s.Fragment,{children:r.isForeign?s.jsxs("header",{className:"text-[0.55rem] px-2 py-1 border-[0.5px] border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white flex gap-1 items-center",id:`${r.name}-foreign-key`,children:[s.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:r.name}),t&&s.jsx(cs,{type:"target",id:r.name,position:t,className:rt(i)})]}):s.jsxs("div",{className:rt("border border-gray-200 dark:border-gray-700 overflow-hidden shadow-lg bg-white dark:bg-gray-900 rounded-none"),style:{width:lD/2},id:`${r.name}-table-node`,children:[s.jsx("header",{className:rt("text-[0.55rem] pl-3 pr-2 bg-black text-white flex items-center justify-between border-b border-gray-300",o),children:s.jsxs("div",{className:"flex items-center gap-x-1",children:[s.jsx(sS,{strokeWidth:1,size:12,className:"text-white"}),s.jsx("span",{className:"text-white font-medium",children:r.name})]})}),r.columns.map(a=>s.jsxs("div",{className:rt("text-[8px] leading-5 relative flex flex-row justify-items-start","bg-white dark:bg-gray-900","border-t","border-t-gray-200 dark:border-t-gray-700","hover:bg-gray-50 dark:hover:bg-gray-800 transition cursor-default",o),children:[s.jsxs("div",{className:rt("gap-[0.24rem] flex ml-2 align-middle items-center justify-start"),children:[a.isPrimary&&s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx(Wy,{size:8,strokeWidth:1,className:rt("flex-shrink-0","text-yellow-400 mr-2")})}),s.jsx(wl,{className:"pointer-events-none",sideOffset:0,children:"primary key"})]})}),a.isUnique&&s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx(Jk,{size:8,strokeWidth:1,className:"flex-shrink-0 mr-2 text-green-400"})}),s.jsx(wl,{className:"pointer-events-none ",sideOffset:0,children:"unique"})]})}),a.isIdentity&&s.jsx(eS,{size:8,strokeWidth:1,className:"flex-shrink-0 text-blue-400"}),!a.isIdentity&&!a.isUnique&&!a.isPrimary&&s.jsx("div",{className:" size-4"})]}),s.jsxs("div",{className:"flex justify-between w-full",children:[s.jsxs("div",{className:"relative flex justify-center whitespace-nowrap",children:[a.isNullable?"":s.jsx(Qd,{delayDuration:10,children:s.jsxs(Zd,{children:[s.jsx(Jd,{asChild:!0,children:s.jsx("span",{className:"text-muted-foreground absolute left-[-6px] top-[1px]",children:"*"})}),s.jsx(wl,{className:"pointer-events-none scale-70",sideOffset:-5,children:"required"})]})})," ",s.jsx("div",{className:"max-w-[100px] w-fit text-ellipsis overflow-hidden text-gray-900 dark:text-white",children:a.name}),s.jsx("span",{className:"font-mono text-gray-500 dark:text-gray-400 text-[0.35rem] pl-1 mt-[1px]",children:a.format})]}),s.jsx("span",{className:"px-2 inline-flex justify-end text-gray-400 dark:text-gray-500 text-[0.4rem] mt-[1px]",children:a.plugin})]}),s.jsx(cs,{type:"target",id:a.id,position:t||"left",className:rt(i,"!left-[-6px] !top-1/2 !transform !-translate-y-1/2"),style:{background:"#000000",border:"1px solid #ffffff",left:"-6px",top:"50%",transform:"translateY(-50%)",boxShadow:"0 0 0 2px rgba(0, 0, 0, 0.1)"}}),s.jsx(cs,{type:"source",id:a.id,position:n||"right",className:rt(i,"!right-[-6px] !top-1/2 !transform !-translate-y-1/2"),style:{background:"#000000",border:"1px solid #ffffff",right:"-6px",top:"50%",transform:"translateY(-50%)",boxShadow:"0 0 0 2px rgba(0, 0, 0, 0.1)"}})]},a.id))]})})};function dD(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Qc="Checkbox",[uD]=Ec(Qc),[fD,sm]=uD(Qc);function hD(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:o,form:a,name:l,onCheckedChange:c,required:d,value:f="on",internal_do_not_use_render:u}=e,[h,m]=kh({prop:n,defaultProp:i??!1,onChange:c,caller:Qc}),[w,y]=p.useState(null),[b,x]=p.useState(null),v=p.useRef(!1),g=w?!!a||!!w.closest("form"):!0,j={checked:h,disabled:o,setChecked:m,control:w,setControl:y,name:l,form:a,value:f,hasConsumerStoppedPropagationRef:v,required:d,defaultChecked:Ir(i)?!1:i,isFormControl:g,bubbleInput:b,setBubbleInput:x};return s.jsx(fD,{scope:t,...j,children:mD(u)?u(j):r})}var l1="CheckboxTrigger",c1=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{const{control:o,value:a,disabled:l,checked:c,required:d,setControl:f,setChecked:u,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:w}=sm(l1,e),y=Xt(i,f),b=p.useRef(c);return p.useEffect(()=>{const x=o==null?void 0:o.form;if(x){const v=()=>u(b.current);return x.addEventListener("reset",v),()=>x.removeEventListener("reset",v)}},[o,u]),s.jsx(ze.button,{type:"button",role:"checkbox","aria-checked":Ir(c)?"mixed":c,"aria-required":d,"data-state":m1(c),"data-disabled":l?"":void 0,disabled:l,value:a,...r,ref:y,onKeyDown:vt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:vt(n,x=>{u(v=>Ir(v)?!0:!v),w&&m&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})});c1.displayName=l1;var im=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:a,disabled:l,value:c,onCheckedChange:d,form:f,...u}=e;return s.jsx(hD,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:l,required:a,onCheckedChange:d,name:r,form:f,value:c,internal_do_not_use_render:({isFormControl:h})=>s.jsxs(s.Fragment,{children:[s.jsx(c1,{...u,ref:t,__scopeCheckbox:n}),h&&s.jsx(h1,{__scopeCheckbox:n})]})})});im.displayName=Qc;var d1="CheckboxIndicator",u1=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=sm(d1,n);return s.jsx(zi,{present:r||Ir(o.checked)||o.checked===!0,children:s.jsx(ze.span,{"data-state":m1(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});u1.displayName=d1;var f1="CheckboxBubbleInput",h1=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:a,required:l,disabled:c,name:d,value:f,form:u,bubbleInput:h,setBubbleInput:m}=sm(f1,e),w=Xt(n,m),y=dD(o),b=Ub(r);p.useEffect(()=>{const v=h;if(!v)return;const g=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(g,"checked").set,k=!i.current;if(y!==o&&N){const S=new Event("click",{bubbles:k});v.indeterminate=Ir(o),N.call(v,Ir(o)?!1:o),v.dispatchEvent(S)}},[h,y,o,i]);const x=p.useRef(Ir(o)?!1:o);return s.jsx(ze.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:l,disabled:c,name:d,value:f,form:u,...t,tabIndex:-1,ref:w,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});h1.displayName=f1;function mD(e){return typeof e=="function"}function Ir(e){return e==="indeterminate"}function m1(e){return Ir(e)?"indeterminate":e?"checked":"unchecked"}const p1=p.forwardRef(({className:e,...t},n)=>s.jsx(im,{ref:n,className:rt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:s.jsx(u1,{className:rt("flex items-center justify-center text-current"),children:s.jsx(Uy,{className:"h-4 w-4"})})}));p1.displayName=im.displayName;const pD={tableNode:cD},pg=[{name:"organization",displayName:"Organization",description:"Multi-tenant organization support",color:"bg-blue-500"},{name:"teams",displayName:"Teams",description:"Team management within organizations",color:"bg-green-500"},{name:"twoFactor",displayName:"Two Factor",description:"Two-factor authentication support",color:"bg-purple-500"},{name:"apiKey",displayName:"API Key",description:"API key authentication",color:"bg-orange-500"},{name:"passkey",displayName:"Passkey",description:"WebAuthn passkey support",color:"bg-pink-500"}];function xD(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[i,o]=p.useState(null),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m,w]=UM([]),[y,b,x]=VM([]),v=p.useCallback(async()=>{try{const I=await(await fetch("/api/plugins")).json();if(I.plugins&&Array.isArray(I.plugins)){const F=I.plugins.map(O=>({name:O.id,displayName:O.name||O.id,description:O.description||`${O.id} plugin for Better Auth`,color:g(O.id)}));d(F),l(F.map(O=>O.name))}}catch(_){console.error("Error fetching enabled plugins:",_),d(pg),l(["organization"])}},[]),g=_=>{const I=pg.find(F=>F.name===_);return(I==null?void 0:I.color)||"bg-gray-500"},j=p.useCallback(async _=>{try{r(!0);const I=_.length>0?`?plugins=${_.join(",")}`:"",O=await(await fetch(`/api/database/schema${I}`)).json();O.success?t(O.schema):o(O.error||"Failed to fetch schema")}catch(I){o("Failed to fetch database schema"),console.error("Error fetching schema:",I)}finally{r(!1)}},[]);p.useEffect(()=>{v()},[v]),p.useEffect(()=>{a.length>0&&j(a)},[a,j]),p.useEffect(()=>{if(!e)return;const _=[],I=[];e.tables.forEach((F,O)=>{const z=F.fields.map(B=>({id:`${F.name}-${B.name}`,isPrimary:B.primaryKey||!1,isNullable:!B.required,isUnique:B.unique||!1,isIdentity:!1,name:B.name,format:B.type,plugin:N(F.name,B.name,a)}));_.push({id:F.name,type:"tableNode",position:{x:O%4*350,y:Math.floor(O/4)*300},data:{name:F.name,isForeign:!1,columns:z}})}),e.tables.forEach(F=>{F.relationships.forEach(O=>{if(O.type==="many-to-one")return;const z=F.name,B=O.target,E=_.find(A=>A.id===z),L=_.find(A=>A.id===B);if(E&&L){const A=O.type==="one-to-one"?"1:1":"1:N";I.push({id:`${z}-${B}-${O.field}`,source:z,target:B,type:"smoothstep",animated:!1,style:{stroke:"#ffffff",strokeWidth:1.5,strokeDasharray:"0"},label:A,labelStyle:{fontSize:"11px",fill:"#6b7280",fontWeight:"500"},labelBgStyle:{fill:"rgba(255, 255, 255, 0.95)",fillOpacity:1,rx:4,ry:4},markerEnd:{type:"arrowclosed",color:"#ffffff",width:12,height:12}})}})}),m(_),b(I)},[e,a,m,b]);const N=(_,I,F)=>{if(_==="user"||_==="session"||_==="account"||_==="verification")return"core";for(const O of F)if(_===O||_.includes(O))return O;return"core"},k=p.useCallback(_=>b(I=>Rw(_,I)),[b]),S=(_,I)=>{l(I?F=>[...F,_]:F=>F.filter(O=>O!==_))};return n?s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"animate-pulse",children:[s.jsx("div",{className:"h-8 bg-gray-700 rounded w-1/3 mb-6"}),s.jsx("div",{className:"h-96 bg-gray-700 rounded"})]}),s.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-4",children:"Loading plugins and schema..."})]}):i?s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"bg-red-900/20 border border-red-500/20 rounded-none p-6",children:[s.jsx("h2",{className:"text-xl font-semibold text-red-400 mb-2",children:"Error Loading Schema"}),s.jsx("p",{className:"text-gray-300",children:i})]})}):s.jsxs("div",{className:"p-6 h-screen flex flex-col",children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-8 h-8 text-gray-900 dark:text-white"}),s.jsx("h1",{className:"text-2xl font-normal text-gray-900 dark:text-white",children:"Schema Visualizer"})]}),s.jsx("div",{className:"flex items-center space-x-4",children:s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>u(!f),className:"flex items-center space-x-2 rounded-none border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-black",children:[f?s.jsx(Zk,{className:"w-4 h-4"}):s.jsx(oa,{className:"w-4 h-4"}),s.jsx("span",{children:"Plugin Labels"})]})})]}),s.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Visualize your Better Auth database schema with interactive tables and relationships."})]}),s.jsxs("div",{className:"flex-1 grid grid-cols-4 gap-6",children:[s.jsxs("div",{className:"col-span-1",children:[s.jsxs(ut,{className:"rounded-none bg-white dark:bg-black border-gray-200 dark:border-gray-700 h-fit shadow-sm",children:[s.jsx(Kt,{children:s.jsxs(qt,{className:"text-gray-900 dark:text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5"}),s.jsx("span",{children:"Plugins"})]})}),s.jsx(ft,{className:"space-y-3",children:c.length>0?c.map(_=>s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(p1,{id:_.name,checked:a.includes(_.name),onCheckedChange:I=>S(_.name,I)}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{htmlFor:_.name,className:"text-sm font-medium text-gray-900 dark:text-white cursor-pointer",children:_.displayName}),s.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:_.description})]}),s.jsx("div",{className:`w-3 h-3 rounded-full ${_.color}`})]},_.name)):s.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No plugins detected in configuration"})})]}),e&&s.jsxs(ut,{className:"rounded-none bg-white dark:bg-black border-gray-200 dark:border-gray-700 mt-4 shadow-sm",children:[s.jsx(Kt,{children:s.jsx(qt,{className:"text-gray-900 dark:text-white text-sm",children:"Schema Info"})}),s.jsxs(ft,{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Tables:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:e.tables.length})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Relationships:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:e.tables.reduce((_,I)=>_+I.relationships.length,0)})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Available Plugins:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:c.length})]}),s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Selected Plugins:"}),s.jsx("span",{className:"text-gray-900 dark:text-white",children:a.length})]})]})]})]}),s.jsx("div",{className:"col-span-3",children:s.jsx("div",{className:"h-full bg-white dark:bg-black border border-gray-200 dark:border-gray-700 rounded-none overflow-hidden shadow-sm",children:s.jsxs(BM,{nodes:h,edges:y,onNodesChange:w,onEdgesChange:x,onConnect:k,nodeTypes:pD,fitView:!0,fitViewOptions:{padding:.1,includeHiddenNodes:!1},className:"bg-white dark:bg-black",connectionLineType:"smoothstep",defaultEdgeOptions:{style:{stroke:"#ffffff",strokeWidth:1.5},animated:!1,type:"smoothstep"},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[s.jsx(tA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600"}),s.jsx(mA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600",nodeColor:_=>{var I;return(I=_.data)!=null&&I.isForeign?"#e5e7eb":"#f3f4f6"},maskColor:"rgba(255, 255, 255, 0.8)"}),s.jsx(GM,{variant:er.Dots,gap:20,size:1,color:"#e5e7eb"})]})})})]})]})}function gD(){const{orgId:e}=bh(),t=Cs(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m]=p.useState("details"),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(!1),[j,N]=p.useState(!1),[k,S]=p.useState(!1),[_,I]=p.useState(!1),[F,O]=p.useState(!1),[z,B]=p.useState(!1),[E,L]=p.useState(null),[A,P]=p.useState(""),[C,M]=p.useState(""),[$,R]=p.useState([]),[T,D]=p.useState({name:""}),[U,H]=p.useState(!1),[W,G]=p.useState([]),[V,q]=p.useState(!1),[ne,se]=p.useState([]),[te,ee]=p.useState(!1);p.useEffect(()=>{e&&(me(),Ce(),ge(),Ee(),pt(),Ke())},[e]),p.useEffect(()=>{w&&e&&Ke()},[]),p.useEffect(()=>{h==="members"&&e&&pt()},[h,e]),p.useEffect(()=>{h==="invitations"&&e&&Ee()},[h,e]);const re=K=>{D({name:K})},me=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}`)).json();ae.success&&ae.organization||ae.organization?r(ae.organization):X.error("Organization not found")}catch(K){console.error("Failed to fetch organization:",K),X.error("Failed to load organization")}finally{u(!1)}},ge=async()=>{try{const ae=await(await fetch("/api/plugins/teams/status")).json();y(ae.enabled)}catch(K){console.error("Failed to check teams status:",K),y(!1)}},Ce=async()=>{try{const ae=await(await fetch("/api/plugins/organization/status")).json();x(ae.enabled)}catch(K){console.error("Failed to check organization status:",K),x(!1)}},Ke=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/teams`)).json();ae.success&&o(ae.teams||[])}catch(K){console.error("Failed to fetch teams:",K),X.error("Failed to load teams")}},Ee=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/invitations`)).json();ae.success&&l(ae.invitations||[])}catch(K){console.error("Failed to fetch invitations:",K),X.error("Failed to load invitations")}},pt=async()=>{try{const ae=await(await fetch(`/api/organizations/${e}/members`)).json();ae.success&&d(ae.members||[])}catch(K){console.error("Failed to fetch members:",K),X.error("Failed to load members")}},Nn=async K=>{G([]),q(!0),G([{id:"start",type:"info",message:`Starting member seeding process for ${K} members...`,timestamp:new Date}]);try{const de=await(await fetch(`/api/organizations/${e}/seed-members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(de.success){const qe=de.results.map((je,an)=>je.success?{id:`member-${an}`,type:"progress",message:`Adding member: ${je.member.user.name} (${je.member.user.email})`,timestamp:new Date,status:"completed"}:{id:`member-${an}`,type:"error",message:`Failed to add member ${an+1}: ${je.error}`,timestamp:new Date});G(je=>[...je,...qe]);const ct=de.results.filter(je=>je.success).length;G(je=>[...je,{id:"complete",type:"success",message:`✅ Seeding completed! Added ${ct}/${K} members successfully`,timestamp:new Date}]),await pt(),X.success(`Successfully added ${ct} members!`)}else G(qe=>[...qe,{id:"error",type:"error",message:`❌ Seeding failed: ${de.error||"Unknown error"}`,timestamp:new Date}]),X.error(de.error||"Failed to seed members")}catch(ae){G(de=>[...de,{id:"error",type:"error",message:`❌ Network error: ${ae}`,timestamp:new Date}]),X.error("Failed to seed members")}finally{q(!1)}},Ae=async K=>{se([]),ee(!0),se([{id:"start",type:"info",message:`Starting team seeding process for ${K} teams...`,timestamp:new Date}]);try{const de=await(await fetch(`/api/organizations/${e}/seed-teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(de.success){const qe=de.results.map((je,an)=>je.success?{id:`team-${an}`,type:"progress",message:`Creating team: ${je.team.name}`,timestamp:new Date,status:"completed"}:{id:`team-${an}`,type:"error",message:`Failed to create team ${an+1}: ${je.error}`,timestamp:new Date});se(je=>[...je,...qe]);const ct=de.results.filter(je=>je.success).length;se(je=>[...je,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${ct}/${K} teams successfully`,timestamp:new Date}]),await Ke(),X.success(`Successfully created ${ct} teams!`)}else se(qe=>[...qe,{id:"error",type:"error",message:`❌ Seeding failed: ${de.error||"Unknown error"}`,timestamp:new Date}]),X.error(de.error||"Failed to seed teams")}catch(ae){se(de=>[...de,{id:"error",type:"error",message:`❌ Network error: ${ae}`,timestamp:new Date}]),X.error("Failed to seed teams")}finally{ee(!1)}},lt=async()=>{try{const ae=await(await fetch("/api/users/all")).json();ae.success&&R(ae.users||[])}catch(K){console.error("Failed to fetch users:",K)}},on=()=>{lt(),g(!0)},kn=async()=>{if(!A){X.error("Please enter an email address");return}if(!C){X.error("Please select an inviter");return}H(!0);const K=X.loading("Sending invitation...");try{const de=await(await fetch(`/api/organizations/${e}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:A,role:"member",inviterId:C})})).json();de.success?(await Ee(),g(!1),P(""),M(""),X.success("Invitation sent successfully!",{id:K})):X.error(`Error sending invitation: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error sending invitation:",ae),X.error("Error sending invitation",{id:K})}finally{H(!1)}},Q=async K=>{const ae=X.loading("Cancelling invitation...");try{const qe=await(await fetch(`/api/invitations/${K}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();qe.success?(await Ee(),X.success("Invitation cancelled successfully!",{id:ae})):X.error(`Error cancelling invitation: ${qe.error||"Unknown error"}`,{id:ae})}catch(de){console.error("Error cancelling invitation:",de),X.error("Error cancelling invitation",{id:ae})}},ie=async(K,ae)=>{const de=X.loading("Resending invitation...");try{const ct=await(await fetch(`/api/invitations/${K}/resend`,{method:"POST",headers:{"Content-Type":"application/json"}})).json();ct.success?(await Ee(),X.success(`Invitation resent to ${ae}!`,{id:de})):X.error(`Error resending invitation: ${ct.error||"Unknown error"}`,{id:de})}catch(qe){console.error("Error resending invitation:",qe),X.error("Error resending invitation",{id:de})}},he=async(K,ae)=>{const de=X.loading(`Removing ${ae}...`);try{const ct=await(await fetch(`/api/members/${K}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ct.success?(await pt(),X.success(`${ae} removed from organization!`,{id:de})):X.error(`Error removing member: ${ct.error||"Unknown error"}`,{id:de})}catch(qe){console.error("Error removing member:",qe),X.error("Error removing member",{id:de})}},_e=async()=>{if(!T.name){X.error("Please enter a team name");return}const K=X.loading("Creating team...");try{const de=await(await fetch(`/api/organizations/${e}/teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T.name,organizationId:e})})).json();de.success?(await Ke(),I(!1),D({name:""}),X.success("Team created successfully!",{id:K})):X.error(`Error creating team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error creating team:",ae),X.error("Error creating team",{id:K})}},Fe=async()=>{if(!E||!T.name){X.error("Please enter a team name");return}const K=X.loading("Updating team...");try{const de=await(await fetch(`/api/teams/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T.name})})).json();de.success?(await Ke(),O(!1),L(null),D({name:""}),X.success("Team updated successfully!",{id:K})):X.error(`Error updating team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error updating team:",ae),X.error("Error updating team",{id:K})}},Ne=async()=>{if(!E){X.error("No team selected");return}const K=X.loading("Deleting team...");try{const de=await(await fetch(`/api/teams/${E.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();de.success?(await Ke(),B(!1),L(null),X.success("Team deleted successfully!",{id:K})):X.error(`Error deleting team: ${de.error||"Unknown error"}`,{id:K})}catch(ae){console.error("Error deleting team:",ae),X.error("Error deleting team",{id:K})}},Pe=K=>{L(K),D({name:K.name}),O(!0)},Xr=K=>{L(K),B(!0)};return f?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading organization details..."})]})}):n?s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:"/organizations",children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:()=>N(!0),className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[s.jsx(we,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),s.jsxs(Y,{onClick:on,className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Invite User"]}),s.jsxs(Y,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit Organization"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(Xe,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:n.name}),s.jsx("p",{className:"text-gray-400",children:n.slug})]})]}),s.jsx("div",{className:"border-b border-white/10",children:s.jsxs("nav",{className:"flex space-x-8",children:[s.jsxs("button",{onClick:()=>m("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(Xe,{className:"w-4 h-4"}),s.jsx("span",{children:"Details"}),s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length+a.length+i.length})]}),s.jsxs("button",{onClick:()=>m("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Members"}),c.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length})]}),s.jsxs("button",{onClick:()=>m("invitations"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="invitations"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(Qt,{className:"w-4 h-4"}),s.jsx("span",{children:"Invitations"}),a.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]}),s.jsxs("button",{onClick:()=>m("teams"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${h==="teams"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Teams"}),i.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:i.length})]})]})}),h==="details"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[s.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Organization Information"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),s.jsx("p",{className:"text-white mt-1",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Slug"}),s.jsx("p",{className:"text-white mt-1",children:n.slug})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:c.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:i.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Teams"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qt,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Invitations"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Yl,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(n.createdAt).getTime())/(1e3*60*60*24))}),s.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})})]})]}),h==="teams"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Teams (",i.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage teams within this organization"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:()=>S(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Teams"]}),s.jsxs(Y,{onClick:()=>I(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]})]}),w?i.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Team"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Members"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:i.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>t(`/organizations/${e}/teams/${K.id}`),children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",K.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:K.memberCount||0}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(K.createdAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:ae=>{ae.stopPropagation(),Pe(K)},children:[s.jsx(ps,{className:"w-4 h-4 mr-1"}),"Edit"]}),s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:ae=>{ae.stopPropagation(),Xr(K)},children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Delete"]})]})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Teams Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Create your first team to start organizing members within this organization."}),s.jsxs(Y,{onClick:()=>I(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Create First Team"]})]})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:s.jsxs("div",{className:"flex items-start space-x-4",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(we,{className:"w-12 h-12 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Teams Feature Required"}),s.jsx("p",{className:"text-gray-300 mb-6",children:"To use Teams in Better Auth Studio, you need to enable the teams feature in your organization plugin configuration."}),s.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[s.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),s.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:s.jsx("li",{children:"Update your auth configuration file to enable teams:"})}),s.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:s.jsxs("pre",{className:"text-sm text-gray-300",children:[s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"export const"})," ",s.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",s.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",s.jsx("br",{}),s.jsx("span",{className:"text-yellow-300 pl-12",children:"organization"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-16",children:"teams"}),": ","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-yellow-300 pl-20",children:"enabled"}),":"," ",s.jsx("span",{className:"text-blue-400",children:"true"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-16",children:"}"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-12",children:"})"})," ",s.jsx("br",{}),s.jsx("span",{className:"pl-10",children:"]"})," ",s.jsx("br",{}),"}",") ",s.jsx("br",{})]})}),s.jsx("div",{className:"mt-4",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"2. Run migrations to create the teams table"})}),s.jsx("div",{className:"mt-2",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),s.jsx(Y,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),s.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",s.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]}),h==="members"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Members (",c.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage organization members and their roles"})]})}),c.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:c.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("img",{src:K.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${K.user.id}`,alt:K.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",K.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:K.user.email}),s.jsx("td",{className:"py-4 px-4",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed rounded-none border-blue-500/30 text-blue-400/70 capitalize",children:K.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(K.joinedAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>he(K.id,K.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Invite users or seed members from existing users to get started."}),s.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[s.jsxs(Y,{onClick:()=>N(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx(we,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),s.jsxs(Y,{onClick:on,className:"bg-white text-white hover:bg-white/90 bg-transparent border border-white/20 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Invite User"]})]})]})})]}),h==="invitations"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Invitations (",a.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage pending invitations to this organization"})]})}),a.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:a.map(K=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(Qt,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:K.email}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Expires on"," ",new Date(K.expiresAt).toLocaleDateString("en-US",{month:"short",year:"numeric",day:"numeric"})]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white capitalize",children:K.role}),s.jsx("td",{className:"py-4 px-4",children:s.jsxs(pe,{variant:"secondary",className:`text-xs font-normal rounded-none border-dashed flex items-center gap-1 w-fit ${K.status==="pending"?"bg-yellow-900/10 border border-yellow-500/30 text-yellow-400/70":K.status==="accepted"?"bg-green-900/10 border border-green-500/30 text-green-400/70":"bg-red-900/10 border border-red-500/30 text-red-400/70"}`,children:[K.status==="pending"&&s.jsx(Qn,{className:"w-3 h-3"}),K.status==="accepted"&&s.jsx(tt,{className:"w-3 h-3"}),K.status==="expired"&&s.jsx(Te,{className:"w-3 h-3"}),K.status]})}),s.jsxs("td",{className:"py-4 px-4 text-sm text-gray-400",children:[new Date(K.expiresAt).toLocaleDateString(),s.jsx("br",{}),s.jsx("span",{className:"text-xs text-gray-400",children:new Date(K.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>ie(K.id,K.email),children:[s.jsx(Ip,{className:"w-4 h-4 mr-1"}),"Resend"]}),s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>Q(K.id),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Cancel"]})]})})]},K.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Qt,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Invitations"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Start inviting users to join this organization."}),s.jsxs(Y,{onClick:on,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Qt,{className:"w-4 h-4 mr-2"}),"Send First Invitation"]})]})})]}),v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Invite User"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{g(!1),P(""),M("")},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"invite-email",className:"text-sm text-gray-400 font-light",children:"Email Address"}),s.jsx(be,{id:"invite-email",type:"email",value:A,onChange:K=>P(K.target.value),placeholder:"user@example.com",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"inviter-select",className:"text-sm text-gray-400 font-light",children:"Inviter"}),s.jsxs(yi,{value:C,onValueChange:M,children:[s.jsx(vi,{children:s.jsx(wi,{placeholder:"Select an inviter..."})}),s.jsx(bi,{children:$.map(K=>s.jsx(tn,{value:K.id,children:s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("img",{src:K.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${K.id}`,alt:K.name,className:"w-6 h-6 rounded-none border border-dashed border-white/20"}),s.jsxs("span",{children:[K.name," (",K.email,")"]})]})},K.id))})]})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{g(!1),P(""),M("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:kn,disabled:U,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[U?s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}):s.jsx(Ip,{className:"w-4 h-4 mr-2"}),U?"Sending...":"Send Invitation"]})]})]})}),_&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Create Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{I(!1),D({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"team-name",value:T.name,onChange:K=>re(K.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{I(!1),D({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:_e,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create Team"})]})]})}),F&&E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{O(!1),D({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:E.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",E.id]})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"edit-team-name",value:T.name,onChange:K=>re(K.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{O(!1),D({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})}),z&&E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>B(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:E.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",E.id]})]})]}),s.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this team? This action cannot be undone."})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>B(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:Ne,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete Team"})]})]})}),j&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Members"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(we,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Add Members from Existing Users"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"member-count",className:"text-sm text-gray-400 font-light",children:"Number of members to add"}),s.jsx(be,{id:"member-count",type:"number",min:"1",max:"50",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var ae;const K=parseInt(((ae=document.getElementById("member-count"))==null?void 0:ae.value)||"5");Nn(K)},disabled:V,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:V?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(we,{className:"w-3 h-3 mr-2"}),"Seed Members"]})})]})]}),W.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Member Seeding Terminal",lines:W,isRunning:V,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>N(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),k&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Teams"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Xe,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Create Teams"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"team-count",className:"text-sm text-gray-400 font-light",children:"Number of teams to create"}),s.jsx(be,{id:"team-count",type:"number",min:"1",max:"20",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var ae;const K=parseInt(((ae=document.getElementById("team-count"))==null?void 0:ae.value)||"3");Ae(K)},disabled:te,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:te?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Xe,{className:"w-3 h-3 mr-2"}),"Seed Teams"]})})]})]}),ne.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Team Seeding Terminal",lines:ne,isRunning:te,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>S(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:"/organizations",children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),s.jsx("br",{}),s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Xe,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Organization Not Found"}),s.jsx("p",{className:"text-gray-400",children:"The organization you're looking for doesn't exist."})]})]})}function yD(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[i,o]=p.useState(""),[a,l]=p.useState("all"),[c,d]=p.useState(!1),[f,u]=p.useState(!1),[h,m]=p.useState(!1),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(null),[j,N]=p.useState([]),[k,S]=p.useState(!1);p.useEffect(()=>{_()},[]);const _=async()=>{try{const M=await(await fetch("/api/sessions")).json();t(M.sessions||[])}catch(C){console.error("Failed to fetch sessions:",C)}finally{r(!1)}},I=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${C} sessions...`,timestamp:new Date}]);try{const $=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if($.success){const R=$.results.map((D,U)=>D.success?{id:`session-${U}`,type:"progress",message:`Creating session: ${D.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${U}`,type:"error",message:`Failed to create session ${U+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const T=$.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${T}/${C} sessions successfully`,timestamp:new Date}]),await _()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${$.error||"Unknown error"}`,timestamp:new Date}])}catch(M){N($=>[...$,{id:"error",type:"error",message:`❌ Network error: ${M}`,timestamp:new Date}])}finally{S(!1)}},F=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting account seeding process for ${C} accounts...`,timestamp:new Date}]);try{const $=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if($.success){const R=$.results.map((D,U)=>D.success?{id:`account-${U}`,type:"progress",message:`Creating account: ${D.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${U}`,type:"error",message:`Failed to create account ${U+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const T=$.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${T}/${C} accounts successfully`,timestamp:new Date}]),await _()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${$.error||"Unknown error"}`,timestamp:new Date}])}catch(M){N($=>[...$,{id:"error",type:"error",message:`❌ Network error: ${M}`,timestamp:new Date}])}finally{S(!1)}},O=C=>{g(C),y(!0)},z=C=>{g(C),u(!0)},B=C=>{g(C),m(!0)},E=async C=>{console.log("Creating session:",C),d(!1)},L=async C=>{console.log("Updating session:",C),u(!1)},A=async()=>{console.log("Deleting session:",v==null?void 0:v.id),m(!1)},P=e.filter(C=>{const M=C.id.toLowerCase().includes(i.toLowerCase())||C.userId.toLowerCase().includes(i.toLowerCase()),$=a==="all"||a==="active"&&new Date(C.expiresAt)>new Date||a==="expired"&&new Date(C.expiresAt)<=new Date;return M&&$});return n?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading sessions..."})]})}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl text-white font-light",children:["Sessions (",e.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage user sessions and accounts"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>x(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed"]}),s.jsxs(Y,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>d(!0),children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Add Session"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsxs("div",{className:"flex-1 relative",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{placeholder:"Search sessions...",value:i,onChange:C=>o(C.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(jh,{className:"w-4 h-4 text-gray-400"}),s.jsxs(yi,{value:a,onValueChange:l,children:[s.jsx(vi,{children:s.jsx(wi,{})}),s.jsxs(bi,{children:[s.jsx(tn,{value:"all",children:"All"}),s.jsx(tn,{value:"active",children:"Active"}),s.jsx(tn,{value:"expired",children:"Expired"})]})]})]})]}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Session"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User ID"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:P.map(C=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",C.id.slice(0,8),"..."]}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",C.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:C.userId}),s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-2",children:[new Date(C.expiresAt)>new Date?s.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}):s.jsx("div",{className:"w-2 h-2 bg-red-400 rounded-full"}),s.jsx("span",{className:"text-sm text-gray-400",children:new Date(C.expiresAt)>new Date?"Active":"Expired"})]})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(C.expiresAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[s.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>O(C),children:s.jsx(oa,{className:"w-4 h-4"})}),s.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>z(C),children:s.jsx(ps,{className:"w-4 h-4"})}),s.jsx(Y,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:()=>B(C),children:s.jsx(os,{className:"w-4 h-4"})})]})})]},C.id))})]})})}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>x(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Seed Sessions"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),s.jsx(be,{id:"session-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var M;const C=parseInt(((M=document.getElementById("session-count"))==null?void 0:M.value)||"5");I(C)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx($e,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(go,{className:"w-5 h-5 text-white"}),s.jsx("h4",{className:"text-white font-light",children:"Seed Accounts"})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(ke,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),s.jsx(be,{id:"account-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx(Y,{onClick:()=>{var M;const C=parseInt(((M=document.getElementById("account-count"))==null?void 0:M.value)||"5");F(C)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx(go,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]})]}),j.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:j,isRunning:k,className:"w-full",defaultCollapsed:!0})})]}),s.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:s.jsx(Y,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),c&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Create Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"create-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),s.jsx(be,{id:"create-user-id",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"create-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),s.jsx(be,{id:"create-expires",type:"datetime-local",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>d(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>E({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),f&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),s.jsx(be,{id:"edit-user-id",defaultValue:v.userId,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),s.jsx(be,{id:"edit-expires",type:"datetime-local",defaultValue:new Date(v.expiresAt).toISOString().slice(0,16),className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>u(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>L({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),h&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Session"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this session? This action cannot be undone."})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>m(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:A,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Session Details"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:s.jsx($e,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-white font-light",children:["Session ",v.id.slice(0,8),"..."]}),s.jsx("div",{className:"text-sm text-gray-400",children:v.userId})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"ID:"}),s.jsx("span",{className:"text-white text-sm",children:v.id})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"User ID:"}),s.jsx("span",{className:"text-white text-sm",children:v.userId})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Status:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.expiresAt)>new Date?"Active":"Expired"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Expires:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.expiresAt).toLocaleString()})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Created:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.createdAt).toLocaleString()})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-gray-400",children:"Updated:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(v.updatedAt).toLocaleString()})]})]})]}),s.jsx("div",{className:"flex justify-end mt-6",children:s.jsx(Y,{onClick:()=>y(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function vD(e){const t=p.useRef(null),n=p.useRef(null),r=p.useRef(0),i=5;p.useEffect(()=>{const o=()=>{try{const l=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`;console.log("🔌 Attempting to connect to WebSocket:",l),t.current=new WebSocket(l),t.current.onopen=()=>{console.log("✅ WebSocket connected successfully"),r.current=0,n.current&&(clearTimeout(n.current),n.current=null)},t.current.onmessage=c=>{try{const d=JSON.parse(c.data);console.log("📨 WebSocket message received:",d),e(d)}catch(d){console.error("❌ Failed to parse WebSocket message:",d)}},t.current.onclose=c=>{if(console.log("🔌 WebSocket disconnected:",c.code,c.reason),c.code===1006||c.code===1001){console.log("ℹ️ WebSocket server not available (running in normal mode)");return}if(r.current<i){r.current++;const d=Math.min(1e3*2**r.current,1e4);console.log(`🔄 Attempting to reconnect in ${d}ms (attempt ${r.current}/${i})`),n.current=setTimeout(()=>{o()},d)}else console.log("❌ Max reconnection attempts reached")},t.current.onerror=c=>{console.error("❌ WebSocket error:",c)}}catch(a){console.error("❌ Failed to connect WebSocket:",a)}};return o(),()=>{t.current&&t.current.close(),n.current&&clearTimeout(n.current)}},[e])}function wD(){var y,b,x,v,g,j,N,k,S,_,I,F,O,z,B,E,L,A,P,C,M,$,R,T,D,U,H;const[e,t]=p.useState(null),[n,r]=p.useState(null),[i,o]=p.useState(null),[a,l]=p.useState(!0),[c,d]=p.useState(null);vD(W=>{W.type==="config_changed"?(console.log("🔄 Config changed, refreshing data..."),setTimeout(()=>{f(),u(),h()},500)):W.type==="connected"&&console.log("✅ Connected to Better Auth Studio WebSocket")}),p.useEffect(()=>{f(),u(),h()},[]);const f=async()=>{var W;try{const V=await(await fetch("/api/config")).json();(W=V.studio)!=null&&W.version&&d(`v${V.studio.version}`),t(V)}catch(G){console.error("Failed to fetch config:",G)}finally{l(!1)}},u=async()=>{try{const G=await(await fetch("/api/health")).json();r(G.system||{studioVersion:c||"v1.0.0",nodeVersion:process.version,platform:navigator.platform,uptime:"2h 15m"})}catch(W){console.error("Failed to fetch system info:",W),r({studioVersion:c||"v1.0.0",nodeVersion:"v18.0.0",platform:"macOS",uptime:"2h 15m"})}},h=async()=>{try{const G=await(await fetch("/api/plugins")).json();o(G)}catch(W){console.error("Failed to fetch plugins:",W),o({plugins:[],configPath:null,totalPlugins:0,error:"Failed to fetch plugins"})}},m=W=>{switch(W==null?void 0:W.toLowerCase()){case"postgresql":case"postgres":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Connected"]});case"mysql":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Connected"]});case"sqlite":return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(Gi,{className:"w-3 h-3"}),"Local"]});default:return s.jsxs(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[s.jsx(Vn,{className:"w-3 h-3"}),"Unknown"]})}},w=W=>{switch(W.toLowerCase()){case"google":return s.jsx(qr,{className:"w-5 h-5 text-white"});case"github":return s.jsx(Hn,{className:"w-5 h-5 text-white"});case"discord":return s.jsx(qr,{className:"w-5 h-5 text-white"});case"twitter":return s.jsx(qr,{className:"w-5 h-5 text-white"});default:return s.jsx(qr,{className:"w-5 h-5 text-white"})}};return a?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-white"})}):s.jsxs("div",{className:"space-y-8 animate-fade-in",children:[s.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Settings"}),s.jsx("p",{className:"text-gray-300 mt-2",children:"Configure your Better Auth application"})]})}),s.jsx("hr",{className:"w-full border-white/15 h-px"}),s.jsx("hr",{className:"w-full border-white/15 h-px"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 p-5",children:[s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Application"})]}),s.jsx(En,{children:"Basic application configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsxs(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(qr,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"App Name"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Application display name"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.appName)||"Better Auth"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Wy,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Base URL"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Application base URL"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.baseURL)||"http://localhost:3000"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Base Path"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auth API base path"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.basePath)||"/api/auth"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Secret"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Encryption secret"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.secret)==="Configured"?"Configured":"Not set"})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Database"})]}),s.jsx(En,{children:"Database connection and configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsxs(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:((y=e==null?void 0:e.database)==null?void 0:y.type)&&((b=e==null?void 0:e.database)==null?void 0:b.type.charAt(0).toUpperCase())+((x=e==null?void 0:e.database)==null?void 0:x.type.slice(1))||"Unknown"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database Type"})]})]}),((v=e==null?void 0:e.database)==null?void 0:v.type)&&m(e.database.type)]}),((g=e==null?void 0:e.database)==null?void 0:g.dialect)&&s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Dialect"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database dialect"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:e.database.dialect})})]}),((j=e==null?void 0:e.database)==null?void 0:j.casing)&&s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Casing"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Table name casing"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:e.database.casing})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Dp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Debug Logs"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Database debug logging"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(N=e==null?void 0:e.database)!=null&&N.debugLogs?s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Providers"})]}),s.jsx(En,{children:"Configured authentication providers"})]}),s.jsx(ft,{className:"p-0",children:e!=null&&e.socialProviders&&e.socialProviders.length>0?e.socialProviders.map((W,G)=>s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[w(W.type),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:W.type}),s.jsx("p",{className:"text-xs text-gray-400",children:W.clientId?"Configured":"Not configured"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:W.clientId?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Active"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Setup Required"]})})]},G)):s.jsxs("div",{className:"text-center py-8",children:[s.jsx(Hn,{className:"w-8 h-8 text-white mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-gray-400",children:"No providers configured"})]})})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Qt,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Email & Password"})]}),s.jsx(En,{children:"Email authentication settings"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qt,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Email Authentication"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Allow users to sign up with email"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(k=e==null?void 0:e.emailAndPassword)!=null&&k.enabled?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]})})]}),((S=e==null?void 0:e.emailAndPassword)==null?void 0:S.enabled)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Sign Up"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Allow new user registration"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(_=e==null?void 0:e.emailAndPassword)!=null&&_.disableSignUp?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Email Verification"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Require email verification"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(I=e==null?void 0:e.emailAndPassword)!=null&&I.requireEmailVerification?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Required"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Optional"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Password Length"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Min/Max password length"})]})]}),s.jsx("div",{className:"text-right",children:s.jsxs("p",{className:"text-sm font-medium text-white",children:[((F=e==null?void 0:e.emailAndPassword)==null?void 0:F.minPasswordLength)||8," -"," ",((O=e==null?void 0:e.emailAndPassword)==null?void 0:O.maxPasswordLength)||128]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Auto Sign In"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auto sign in after registration"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(z=e==null?void 0:e.emailAndPassword)!=null&&z.autoSignIn?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Session"})]}),s.jsx(En,{children:"Session management settings"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Session Duration"}),s.jsx("p",{className:"text-xs text-gray-400",children:"How long sessions last"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(B=e==null?void 0:e.session)!=null&&B.expiresIn?`${Math.floor(e.session.expiresIn/(60*60*24))} days`:"7 days"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Default"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Dp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Update Age"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Session refresh interval"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white",children:(E=e==null?void 0:e.session)!=null&&E.updateAge?`${Math.floor(e.session.updateAge/(60*60))} hours`:"24 hours"})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Session Refresh"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Auto refresh sessions"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(L=e==null?void 0:e.session)!=null&&L.disableSessionRefresh?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Store in Database"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Store sessions in database"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(A=e==null?void 0:e.session)!=null&&A.storeSessionInDatabase?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Gi,{className:"w-3 h-3"}),"Secondary Storage"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Rate Limiting"})]}),s.jsx(En,{children:"API rate limiting configuration"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limiting"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Enable rate limiting"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(P=e==null?void 0:e.rateLimit)!=null&&P.enabled?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-red-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limit Window"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Time window for rate limiting"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(C=e==null?void 0:e.rateLimit)!=null&&C.window?`${e.rateLimit.window} seconds`:"10 seconds"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Window"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Max Requests"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Maximum requests per window"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:((M=e==null?void 0:e.rateLimit)==null?void 0:M.max)||100}),s.jsx("p",{className:"text-xs text-gray-400",children:"Requests"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx($e,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Storage"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Rate limit storage type"})]})]}),s.jsx("div",{className:"text-right",children:s.jsx("p",{className:"text-sm font-medium text-white capitalize",children:(($=e==null?void 0:e.rateLimit)==null?void 0:$.storage)||"memory"})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(is,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Advanced"})]}),s.jsx(En,{children:"Advanced configuration options"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Ed,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Secure Cookies"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Use secure cookies"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(R=e==null?void 0:e.advanced)!=null&&R.useSecureCookies?s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Disabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Hn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"CSRF Check"}),s.jsx("p",{className:"text-xs text-gray-400",children:"CSRF protection"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(T=e==null?void 0:e.advanced)!=null&&T.disableCSRFCheck?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(oa,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"IP Tracking"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Track IP addresses"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(U=(D=e==null?void 0:e.advanced)==null?void 0:D.ipAddress)!=null&&U.disableIpTracking?s.jsxs(s.Fragment,{children:[s.jsx(Zr,{className:"w-3 h-3"}),"Disabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gk,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Telemetry"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Usage analytics"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(H=e==null?void 0:e.telemetry)!=null&&H.enabled?s.jsxs(s.Fragment,{children:[s.jsx(Vn,{className:"w-3 h-3"}),"Enabled"]}):s.jsxs(s.Fragment,{children:[s.jsx(tt,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black rounded-none",children:[s.jsxs(Kt,{className:"border-b border-white/15",children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"System Info"})]}),s.jsx(En,{children:"Better Auth Studio system information"})]}),s.jsxs(ft,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(ul,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Studio Version"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Better Auth Studio"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:c||"v1.0.0"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Latest"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Node.js Version"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Runtime environment"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.nodeVersion)||"v18.0.0"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Current"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(qr,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Platform"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Operating system"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.platform)||"macOS"}),s.jsx("p",{className:"text-xs text-gray-400",children:"System"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Uptime"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Service uptime"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:(n==null?void 0:n.uptime)||"2h 15m"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Running"})]})]})]})]}),s.jsxs(ut,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none lg:col-span-2",children:[s.jsxs(Kt,{children:[s.jsxs(qt,{className:"text-white flex items-center space-x-2",children:[s.jsx(Rp,{className:"w-5 h-5 text-white"}),s.jsx("span",{children:"Plugins"})]}),s.jsx(En,{children:"Better Auth plugins enabled in your configuration"})]}),s.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),s.jsx(ft,{className:"space-y-0 px-0 pb-0 border-b-none",children:i!=null&&i.plugins&&i.plugins.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Gi,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Total Plugins"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Currently enabled plugins"})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:i.totalPlugins}),s.jsx("p",{className:"text-xs text-gray-400",children:"Active"})]})]}),i.plugins.map((W,G)=>s.jsxs("div",{className:`flex items-center justify-between p-4 px-5 ${G<i.plugins.length-1?"border-b border-white/15":""}`,children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Rp,{className:"w-5 h-5 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:W.name.slice(0,1).toUpperCase()+W.name.slice(1).replace("-"," ")}),s.jsx("p",{className:"text-xs text-gray-400",children:W.description})]})]}),s.jsx("div",{className:"text-right flex items-center space-x-2",children:s.jsxs(pe,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400 flex items-center gap-1",children:[s.jsx(tt,{className:"w-3 h-3"}),"Enabled"]})})]},W.id)),i.configPath&&s.jsx("div",{className:"p-4 px-5 bg-black/30 border-t border-white/10",children:s.jsxs("p",{className:"text-xs text-gray-400",children:["Config file:"," ",s.jsx("span",{className:"text-white font-mono",children:i.configPath})]})})]}):s.jsxs("div",{className:"flex items-center justify-between p-4 px-5",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Vn,{className:"w-5 h-5 text-yellow-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"No Plugins Enabled"}),s.jsx("p",{className:"text-xs text-gray-400",children:(i==null?void 0:i.error)||"No plugins are currently configured in your Better Auth setup"})]})]}),s.jsx(pe,{variant:"secondary",className:"text-xs bg-yellow-900/50 border border-yellow-500/30 text-yellow-400 rounded-sm",children:"None"})]})})]})]})]})}function xg(){var L,A;const{orgId:e,teamId:t}=bh(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState(!0),[c,d]=p.useState("details"),[f,u]=p.useState(!1),[h,m]=p.useState(!1),[w,y]=p.useState(""),[b,x]=p.useState([]),[v,g]=p.useState([]),[j,N]=p.useState({name:""});p.useEffect(()=>{t&&(k(),S())},[t]);const k=async()=>{try{const C=await(await fetch(`/api/teams/${t}`)).json();C.success&&C.team?(r(C.team),N({name:C.team.name})):C.team?(r(C.team),N({name:C.team.name})):X.error("Team not found")}catch(P){console.error("Failed to fetch team:",P),X.error("Failed to load team")}finally{l(!1)}},S=async()=>{try{const C=await(await fetch(`/api/teams/${t}/members`)).json();C.success&&o(C.members||[])}catch(P){console.error("Failed to fetch team members:",P),X.error("Failed to load team members")}},_=async()=>{try{const C=await(await fetch("/api/users?limit=10000")).json(),M=i.map(R=>R.userId),$=(C.users||[]).filter(R=>!M.includes(R.id));x($)}catch(P){console.error("Failed to fetch available users:",P),X.error("Failed to load users")}},I=async()=>{if(!j.name){X.error("Please enter a team name");return}const P=X.loading("Updating team...");try{const M=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name})})).json();M.success?(await k(),m(!1),X.success("Team updated successfully!",{id:P})):X.error(`Error updating team: ${M.error||"Unknown error"}`,{id:P})}catch(C){console.error("Error updating team:",C),X.error("Error updating team",{id:P})}},F=async()=>{if(v.length===0){X.error("Please select at least one user");return}const P=X.loading(`Adding ${v.length} members...`);try{const M=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:v})})).json();M.success?(await S(),u(!1),g([]),y(""),X.success(`Successfully added ${v.length} members!`,{id:P})):X.error(`Error adding members: ${M.error||"Unknown error"}`,{id:P})}catch(C){console.error("Error adding members:",C),X.error("Error adding members",{id:P})}},O=async(P,C)=>{const M=X.loading(`Removing ${C}...`);try{const R=await(await fetch(`/api/team-members/${P}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();R.success?(await S(),X.success(`${C} removed from team!`,{id:M})):X.error(`Error removing member: ${R.error||"Unknown error"}`,{id:M})}catch($){console.error("Error removing team member:",$),X.error("Error removing team member",{id:M})}},z=()=>{_(),u(!0)},B=P=>{g(C=>C.includes(P)?C.filter(M=>M!==P):[...C,P])},E=b.filter(P=>P.name.toLowerCase().includes(w.toLowerCase())||P.email.toLowerCase().includes(w.toLowerCase()));return a?s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[s.jsx(wt,{className:"w-6 h-6 text-white animate-spin"}),s.jsx("div",{className:"text-white text-sm",children:"Loading team details..."})]})}):n?s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:`/organizations/${n.organizationId}`,children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsxs(Y,{onClick:z,className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add Members"]}),s.jsxs(Y,{onClick:()=>m(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit Team"]})]})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:n.name}),s.jsx("div",{className:"flex items-center space-x-2",children:n.organization&&s.jsxs(ri,{to:`/organizations/${n.organizationId}`,className:"text-gray-400 hover:text-white text-sm",children:[s.jsx(Xe,{className:"w-4 h-4 inline mr-1"}),n.organization.name]})})]})]}),s.jsx("div",{className:"border-b border-white/10",children:s.jsxs("nav",{className:"flex space-x-8",children:[s.jsxs("button",{onClick:()=>d("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Details"})]}),s.jsxs("button",{onClick:()=>d("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[s.jsx(we,{className:"w-4 h-4"}),s.jsx("span",{children:"Members"}),i.length>0&&s.jsx(pe,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:i.length})]})]})}),c==="details"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[s.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Team Information"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),s.jsx("p",{className:"text-white mt-1",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Organization"}),s.jsx("p",{className:"text-white mt-1",children:((L=n.organization)==null?void 0:L.name)||"Unknown"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),s.jsx("p",{className:"text-white mt-1",children:new Date(n.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(we,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:i.length}),s.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Yl,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(n.createdAt).getTime())/(1e3*60*60*24))}),s.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(Xe,{className:"w-8 h-8 text-white"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl text-white font-light",children:"1"}),s.jsx("p",{className:"text-sm text-gray-400",children:"Organization"})]})]})})]})]}),c==="members"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg text-white font-light",children:["Team Members (",i.length,")"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage members of this team"})]})}),i.length>0?s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),s.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),s.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),s.jsx("tbody",{children:i.map(P=>s.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[s.jsx("td",{className:"py-4 px-4",children:s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("img",{src:P.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${P.user.id}`,alt:P.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:P.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",P.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:P.user.email}),s.jsx("td",{className:"py-4 px-4",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed border-blue-500/30 text-blue-400/70 rounded-none capitalize",children:P.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(P.joinedAt).toLocaleDateString()}),s.jsx("td",{className:"py-4 px-4 text-right",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsxs(Y,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>O(P.id,P.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},P.id))})]})})}):s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:s.jsxs("div",{className:"text-center",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),s.jsx("p",{className:"text-gray-400 mb-6",children:"Add members to this team to get started."}),s.jsxs(Y,{onClick:z,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add First Members"]})]})})]}),f&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Add Team Members"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{u(!1),g([]),y("")},className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{placeholder:"Search users by name or email...",value:w,onChange:P=>y(P.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),v.length>0&&s.jsx("div",{className:"bg-blue-900/20 border border-blue-500/30 rounded-none p-3",children:s.jsxs("p",{className:"text-blue-400 text-sm",children:[v.length," user",v.length!==1?"s":""," selected"]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none max-h-96 overflow-y-auto",children:E.length>0?s.jsx("div",{className:"divide-y divide-white/5",children:E.map(P=>s.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${v.includes(P.id)?"bg-blue-900/20":""}`,onClick:()=>B(P.id),children:[s.jsx("input",{type:"checkbox",checked:v.includes(P.id),onChange:()=>B(P.id),className:"rounded border-gray-300"}),s.jsx("img",{src:P.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${P.id}`,alt:P.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white font-light",children:P.name}),s.jsx("div",{className:"text-sm text-gray-400",children:P.email})]})]},P.id))}):s.jsx("div",{className:"p-8 text-center",children:s.jsx("p",{className:"text-gray-400",children:"No users found matching your search."})})})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>{u(!1),g([]),y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:F,disabled:v.length===0,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[s.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Add ",v.length," Member",v.length!==1?"s":""]})]})]})}),h&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-light",children:n.name}),s.jsx("div",{className:"text-sm text-gray-400",children:(A=n.organization)==null?void 0:A.name})]})]}),s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),s.jsx(be,{id:"edit-team-name",value:j.name,onChange:P=>N({name:P.target.value}),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>m(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:I,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center space-x-4",children:s.jsx(ri,{to:`/organizations/${e}`,children:s.jsxs(Y,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),s.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Team Not Found"}),s.jsx("p",{className:"text-gray-400",children:"The team you're looking for doesn't exist."})]})]})}function bD(){const e=Cs(),[t,n]=p.useState([]),[r,i]=p.useState(!0),[o,a]=p.useState(null),[l,c]=p.useState(""),[d,f]=p.useState("all"),[u,h]=p.useState(1),[m]=p.useState(20);p.useEffect(()=>{w()},[]);const w=async()=>{try{const k=await(await fetch("/api/plugins")).json(),S=(k==null?void 0:k.plugins).find(_=>_.id==="teams");a({enabled:!!S,availablePlugins:(k==null?void 0:k.plugins).map(_=>_.id),configPath:k.configPath,teamsPlugin:(k==null?void 0:k.plugins).find(_=>_.id==="teams")}),S?await y():i(!1)}catch(N){console.error("Failed to check teams plugin status:",N),a({enabled:!1,error:"Failed to check plugin status"}),i(!1)}},y=async()=>{try{const k=await(await fetch("/api/teams")).json();k.success&&n(k.teams||[])}catch(N){console.error("Failed to fetch teams:",N),X.error("Failed to load teams")}finally{i(!1)}},b=t.filter(N=>{var S;const k=N.name.toLowerCase().includes(l.toLowerCase())||((S=N.organization)==null?void 0:S.name.toLowerCase().includes(l.toLowerCase()));if(d==="all")return k;if(d==="recent"){const _=new Date;return _.setDate(_.getDate()-7),k&&new Date(N.createdAt)>_}return k}),x=u*m,v=x-m,g=b.slice(v,x),j=Math.ceil(b.length/m);return r?s.jsx("div",{className:"flex items-center justify-center min-h-screen",children:s.jsx(wt,{className:"w-8 h-8 animate-spin text-white"})}):o!=null&&o.enabled?s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-light tracking-tight text-white",children:"Teams"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:[b.length," team",b.length!==1?"s":""," found"]})]}),s.jsx("div",{className:"flex items-center space-x-3",children:s.jsxs(Y,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Create Team"]})})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(Lr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),s.jsx(be,{type:"text",placeholder:"Search teams...",value:l,onChange:N=>c(N.target.value),className:"pl-10 bg-black border-dashed border-white/20 text-white placeholder-gray-400 focus:ring-2 focus:ring-white focus:border-transparent"})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Y,{variant:d==="all"?"default":"outline",size:"sm",onClick:()=>f("all"),className:d==="all"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"All"}),s.jsx(Y,{variant:d==="recent"?"default":"outline",size:"sm",onClick:()=>f("recent"),className:d==="recent"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"Recent"})]})]}),g.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-light text-white mb-2",children:"No teams found"}),s.jsx("p",{className:"text-gray-400 mb-6",children:l?"Try adjusting your search terms":"Get started by creating your first team"}),!l&&s.jsxs(Y,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[s.jsx(kr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]}):s.jsx("div",{className:"grid gap-4",children:g.map(N=>{var k;return s.jsx("div",{className:"bg-black/30 border border-white/15 rounded-none p-4 hover:bg-black/40 transition-colors cursor-pointer",onClick:()=>e(`/teams/${N.id}`),children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-10 h-10 bg-white/10 rounded-none flex items-center justify-center",children:s.jsx(we,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:N.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:[(k=N.organization)==null?void 0:k.name," • ",N.memberCount||0," members"]})]})]}),s.jsx("div",{className:"flex items-center space-x-2",children:s.jsx(pe,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400",children:"Active"})})]})},N.id)})}),j>1&&s.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.max(1,u-1)),disabled:u===1,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Previous"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["Page ",u," of ",j]}),s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.min(j,u+1)),disabled:u===j,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Next"})]})]}):s.jsxs("div",{className:"space-y-6 p-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl text-white font-light",children:"Teams"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application organizations"})]})}),s.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:s.jsxs("div",{className:"flex items-start space-x-4",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(Xe,{className:"w-12 h-12 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),s.jsx("p",{className:"text-gray-300 mb-6",children:"To use Organizations in Better Auth Studio, you need to enable the organization plugin in your Better Auth configuration."}),s.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[s.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),s.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:s.jsxs("li",{children:["Import the plugin in your auth configuration file",(o==null?void 0:o.configPath)&&s.jsxs("span",{className:"text-gray-400",children:[" (",o.configPath,")"]}),":"]})}),s.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:s.jsxs("pre",{className:"text-sm text-gray-300",children:[s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",s.jsx("span",{className:"text-blue-400",children:"from"})," ",s.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",s.jsx("br",{}),s.jsx("span",{className:"text-blue-400",children:"export const"})," ",s.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",s.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",s.jsx("br",{}),s.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",s.jsx("br",{}),s.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",s.jsx("br",{}),s.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),s.jsx("br",{}),s.jsx("span",{className:"pl-10",children:"]"})," ",s.jsx("br",{}),"}",") ",s.jsx("br",{})]})}),s.jsx("div",{className:"mt-4",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),s.jsx("div",{className:"mt-2",children:s.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),(o==null?void 0:o.availablePlugins)&&o.availablePlugins.length>0&&s.jsx("div",{className:"mb-4",children:s.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",o.availablePlugins.join(", ")]})}),s.jsx(Y,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),s.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",s.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]})}function jD(){const{userId:e}=bh(),t=Cs(),[n,r]=p.useState(null),[i,o]=p.useState([]),[a,l]=p.useState([]),[c,d]=p.useState([]),[f,u]=p.useState(!0),[h,m]=p.useState("details"),[w,y]=p.useState(!1),[b,x]=p.useState(!1),[v,g]=p.useState(!1),[j,N]=p.useState([]),[k,S]=p.useState(!1),[_,I]=p.useState({});p.useEffect(()=>{e&&(B(),E())},[e]);const F=async R=>{try{const T=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:R})});if(T.ok){const D=await T.json();if(D.success&&D.location)return D.location}return null}catch(T){return console.error("Failed to resolve IP location:",T),null}},O=async R=>{const T=R.map(async H=>{if(!_[H.id]){const W=await F(H.ipAddress);if(W)return{sessionId:H.id,location:W}}return null}),D=await Promise.all(T),U={};D.forEach(H=>{H&&(U[H.sessionId]=H.location)}),Object.keys(U).length>0&&I(H=>({...H,...U}))},z=R=>{if(!R)return"🌍";const T=R.toUpperCase().split("").map(D=>127397+D.charCodeAt(0));return String.fromCodePoint(...T)},B=async()=>{try{const R=await fetch(`/api/users/${e}`);if(R.ok){const T=await R.json();r(T.user)}else X.error("Failed to fetch user details"),t("/users")}catch(R){console.error("Failed to fetch user details:",R),X.error("Failed to fetch user details"),t("/users")}finally{u(!1)}},E=async()=>{try{const[R,T,D]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(R.ok){const U=await R.json();o(U.memberships||[])}if(T.ok){const U=await T.json();l(U.memberships||[])}if(D.ok){const H=(await D.json()).sessions||[];d(H),O(H)}}catch(R){console.error("Failed to fetch user memberships:",R)}},L=async()=>{var U,H;if(!n)return;const R=(U=document.getElementById("edit-name"))==null?void 0:U.value,T=(H=document.getElementById("edit-email"))==null?void 0:H.value;if(!R||!T){X.error("Please fill in all fields");return}const D=X.loading("Updating user...");try{const G=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R,email:T})})).json();G.success?(r({...n,name:R,email:T}),y(!1),X.success("User updated successfully!",{id:D})):X.error(`Error updating user: ${G.error||"Unknown error"}`,{id:D})}catch(W){console.error("Error updating user:",W),X.error("Error updating user",{id:D})}},A=async()=>{if(!n)return;const R=X.loading("Banning user...");try{const D=await(await fetch(`/api/users/${e}/ban`,{method:"POST"})).json();D.success?(X.success("User banned successfully!",{id:R}),t("/users")):X.error(`Error banning user: ${D.error||"Unknown error"}`,{id:R})}catch(T){console.error("Error banning user:",T),X.error("Error banning user",{id:R})}},P=async R=>{const T=X.loading("Removing user from organization...");try{const U=await(await fetch(`/api/organizations/members/${R}`,{method:"DELETE"})).json();U.success?(o(H=>H.filter(W=>W.id!==R)),X.success("User removed from organization!",{id:T})):X.error(`Error removing user: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error removing user from organization:",D),X.error("Error removing user from organization",{id:T})}},C=async R=>{const T=X.loading("Removing user from team...");try{const U=await(await fetch(`/api/teams/members/${R}`,{method:"DELETE"})).json();U.success?(l(H=>H.filter(W=>W.id!==R)),X.success("User removed from team!",{id:T})):X.error(`Error removing user: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error removing user from team:",D),X.error("Error removing user from team",{id:T})}},M=async R=>{const T=X.loading("Deleting session...");try{const U=await(await fetch(`/api/sessions/${R}`,{method:"DELETE"})).json();U.success?(d(H=>H.filter(W=>W.id!==R)),X.success("Session deleted successfully!",{id:T})):X.error(`Error deleting session: ${U.error||"Unknown error"}`,{id:T})}catch(D){console.error("Error deleting session:",D),X.error("Error deleting session",{id:T})}},$=async(R=3)=>{if(e){N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${R} sessions...`,timestamp:new Date}]);try{const D=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:R})})).json();if(D.success){const U=D.results.map((W,G)=>W.success?{id:`session-${G}`,type:"progress",message:`Creating session ${G+1}: ${W.session.token.substring(0,20)}... from ${W.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${G}`,type:"error",message:`Failed to create session ${G+1}: ${W.error}`,timestamp:new Date});N(W=>[...W,...U]);const H=D.results.filter(W=>W.success).length;N(W=>[...W,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${H}/${R} sessions successfully`,timestamp:new Date}]),E()}else N(U=>[...U,{id:"error",type:"error",message:`❌ Session seeding failed: ${D.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(D=>[...D,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}}};return f?s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):n?s.jsxs("div",{className:"min-h-screen bg-black w-full",children:[s.jsxs("div",{className:"w-full px-6 py-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsxs(Y,{variant:"outline",onClick:()=>t("/users"),className:"mb-4 border-none text-white",children:[s.jsx(Oo,{className:"w-4 h-4 mr-2"}),"Back to Users"]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:n.image?s.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):s.jsx(go,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-white",children:n.name}),s.jsx("p",{className:"text-gray-400",children:n.email}),s.jsx("div",{className:"flex items-center space-x-2 mt-2",children:s.jsx(pe,{variant:n.emailVerified?"default":"destructive",className:"rounded-none",children:n.emailVerified?"Verified":"Unverified"})})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsxs(Y,{variant:"outline",onClick:()=>y(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Edit User"]}),s.jsxs(Y,{variant:"outline",onClick:()=>x(!0),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(Ap,{className:"w-4 h-4 mr-2"}),"Ban User"]})]})]})]}),s.jsxs("div",{className:"border border-dashed border-white/10 rounded-none",children:[s.jsx("div",{className:"border-b border-dashed border-white/10",children:s.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:go},{id:"organizations",name:"Organizations",icon:Xe,count:i.length},{id:"teams",name:"Teams",icon:we,count:a.length},{id:"sessions",name:"Sessions",icon:Qn,count:c.length}].map(R=>s.jsxs("button",{onClick:()=>m(R.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${h===R.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[s.jsx(R.icon,{className:"w-4 h-4"}),s.jsx("span",{children:R.name}),R.count!==void 0&&s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.count})]},R.id))})}),s.jsxs("div",{className:"p-6",children:[h==="details"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),s.jsx("div",{className:"text-white",children:n.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Qt,{className:"w-4 h-4"}),s.jsx("span",{children:n.email})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email Status"}),s.jsx(pe,{variant:n.emailVerified?"default":"destructive",className:"rounded-none",children:n.emailVerified?"Verified":"Unverified"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Created"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Yl,{className:"w-4 h-4"}),s.jsx("span",{children:new Date(n.createdAt).toLocaleDateString()})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Last Updated"}),s.jsxs("div",{className:"text-white flex items-center space-x-2",children:[s.jsx(Yl,{className:"w-4 h-4"}),s.jsx("span",{children:new Date(n.updatedAt).toLocaleDateString()})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"User ID"}),s.jsx("div",{className:"text-white font-mono text-sm",children:n.id})]})]})]})}),h==="organizations"&&s.jsx("div",{className:"space-y-4",children:i.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Xe,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),s.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):s.jsx("div",{className:"grid gap-4",children:i.map(R=>s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-12 h-12 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:R.organization.image?s.jsx("img",{src:R.organization.image,alt:R.organization.name,className:"w-12 h-12 object-cover"}):s.jsx(Xe,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:R.organization.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["@",R.organization.slug]}),s.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.role}),s.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(R.joinedAt).toLocaleDateString()]})]})]})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>P(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(zp,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},R.id))})}),h==="teams"&&s.jsx("div",{className:"space-y-4",children:a.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(we,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),s.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):s.jsx("div",{className:"grid gap-4",children:a.map(R=>s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:s.jsx(we,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:R.team.name}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["in ",R.team.organizationName]}),s.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[s.jsx(pe,{variant:"outline",className:"rounded-none text-xs",children:R.role}),s.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(R.joinedAt).toLocaleDateString()]})]})]})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>C(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(zp,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},R.id))})}),h==="sessions"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium text-white",children:"Sessions"}),s.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user authentication sessions"})]}),s.jsxs(Y,{variant:"outline",onClick:()=>{N([]),S(!1),g(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Qn,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),s.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):s.jsx("div",{className:"grid gap-4",children:c.map(R=>{var T,D,U,H;return s.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[s.jsx("div",{className:"w-12 -mt-2 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:s.jsx(nS,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"flex items-center space-x-3 mb-2",children:s.jsxs("h3",{className:"text-white font-medium",children:["Session ",R.id.substring(0,8),"..."]})}),s.jsxs("div",{className:"flex items-center space-x-4 mb-1",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(qr,{className:"w-4 h-4 text-white"}),s.jsx("span",{className:"text-white text-sm",children:R.ipAddress})]}),s.jsxs("div",{className:"flex items-center space-x-1",children:[s.jsx("span",{className:"text-gray-400 text-xs",children:"📍"}),s.jsxs("span",{className:"text-gray-300 text-sm",children:[((T=_[R.id])==null?void 0:T.city)||"...",","," ",((D=_[R.id])==null?void 0:D.country)||"..."]}),((U=_[R.id])==null?void 0:U.countryCode)&&s.jsx("span",{className:"text-sm ml-1",children:z((H=_[R.id])==null?void 0:H.countryCode)})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-4 h-4 text-white"}),s.jsx("span",{className:"text-gray-400 text-sm",children:"Expires:"}),s.jsx("span",{className:"text-white text-sm",children:new Date(R.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]}),s.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>M(R.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[s.jsx(Ap,{className:"w-4 h-4 mr-1"}),"Revoke"]})]})]})]})})},R.id)})})]})]})]})]}),w&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:"×"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n!=null&&n.image?s.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):s.jsx(go,{className:"w-8 h-8 text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h4",{className:"text-white font-medium",children:n==null?void 0:n.name}),s.jsx("p",{className:"text-gray-400 text-sm",children:n==null?void 0:n.email})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),s.jsx("input",{id:"edit-name",type:"text",defaultValue:(n==null?void 0:n.name)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),s.jsx("input",{id:"edit-email",type:"email",defaultValue:(n==null?void 0:n.email)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]})]}),s.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[s.jsx(Y,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:L,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black border border-dashed border-red-400/50 rounded-none p-6 w-full max-w-md",children:[s.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),s.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to ban ",s.jsx("strong",{children:n.name}),"? This will prevent them from accessing the system."]}),s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx(Y,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:A,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),v&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Sessions"}),s.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:s.jsx(Te,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Qn,{className:"w-5 h-5 text-white"}),s.jsxs("h4",{className:"text-white font-light",children:["Create Sessions for ",n==null?void 0:n.name]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(ke,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),s.jsx(be,{id:"session-count",type:"number",min:"1",max:"50",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),s.jsx("p",{className:"text-xs text-gray-400",children:"Each session will have a unique token, IP address, and 7-day expiration."})]})]}),j.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:j,isRunning:k,className:"w-full",defaultCollapsed:!1})})]}),s.jsxs("div",{className:"flex justify-end space-x-2 mt-6 pt-6 border-t border-dashed border-white/10",children:[s.jsx(Y,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsx(Y,{onClick:()=>{var T;const R=parseInt(((T=document.getElementById("session-count"))==null?void 0:T.value)||"3");$(R)},disabled:k,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:k?s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"w-4 h-4 mr-2 animate-spin"}),"Seeding..."]}):s.jsxs(s.Fragment,{children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})})]})]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function ND(){return s.jsx(oS,{children:s.jsxs(pk,{children:[s.jsx(q4,{children:s.jsxs(lk,{children:[s.jsx(Gt,{path:"/",element:s.jsx(Z4,{})}),s.jsx(Gt,{path:"/users",element:s.jsx(Ov,{})}),s.jsx(Gt,{path:"/users/:userId",element:s.jsx(jD,{})}),s.jsx(Gt,{path:"/organizations",element:s.jsx(Lv,{})}),s.jsx(Gt,{path:"/organizations/:orgId",element:s.jsx(gD,{})}),s.jsx(Gt,{path:"/teams",element:s.jsx(bD,{})}),s.jsx(Gt,{path:"/teams/:teamId",element:s.jsx(xg,{})}),s.jsx(Gt,{path:"/organizations/:orgId/teams/:teamId",element:s.jsx(xg,{})}),s.jsx(Gt,{path:"/sessions",element:s.jsx(yD,{})}),s.jsx(Gt,{path:"/database",element:s.jsx(xD,{})}),s.jsx(Gt,{path:"/settings",element:s.jsx(wD,{})})]})}),s.jsx(Wk,{theme:"dark",position:"top-right",richColors:!0,closeButton:!0})]})})}eu.createRoot(document.getElementById("root")).render(s.jsx(J.StrictMode,{children:s.jsx(ND,{})}));
|