better-auth-studio 1.0.23 → 1.0.24-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 j,x;if(i.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!i.current||i.current&&!d)&&Ew(m))return!1;const y=Ux(m.code,l);if(o.current.add(m[y]),Bx(a,o.current,!1)){const v=((x=(j=m.composedPath)==null?void 0:j.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 wT=()=>{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 Jw(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)bT(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 bT(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 eb(e,t){return Jw(e,t)}function tb(e,t){return Jw(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=>M_(e),jT=e=>vw(e);function nb(e){return p.forwardRef(e)}const NT=typeof window<"u"?p.useLayoutEffect:p.useEffect;function Yx(e){const[t,n]=p.useState(BigInt(0)),[r]=p.useState(()=>kT(()=>n(i=>i+BigInt(1))));return NT(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function kT(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const rb=p.createContext(null);function ST({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 j of l)w=typeof j=="function"?j(w):j;const y=Vx({items:w,lookup:h});f&&d(w),y.length>0?u==null||u(y):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:j,nodes:x,setNodes:v}=t.getState();j&&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(rb.Provider,{value:a,children:e})}function CT(){const e=p.useContext(rb);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const ET=e=>!!e.panZoom;function Xh(){const e=wT(),t=Oe(),n=CT(),r=ye(ET),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?Sw(w.position,w.measured,w.parentId,h,m):w.position,j={...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(j)},d=(u,h,m={replace:!1})=>{a(w=>w.map(y=>{if(y.id===u){const j=typeof h=="function"?h(y):h;return m.replace&&Wx(j)?j:{...y,...j}}return y}))},f=(u,h,m={replace:!1})=>{l(w=>w.map(y=>{if(y.id===u){const j=typeof h=="function"?h(y):h;return m.replace&&jT(j)?j:{...y,...j}}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,j]=m;return{nodes:u.map(x=>({...x})),edges:h.map(x=>({...x})),viewport:{x:w,y,zoom:j}}},deleteElements:async({nodes:u=[],edges:h=[]})=>{const{nodes:m,edges:w,onNodesDelete:y,onEdgesDelete:j,triggerNodeChanges:x,triggerEdgeChanges:v,onDelete:g,onBeforeDelete:b}=t.getState(),{nodes:N,edges:k}=await z_({nodesToRemove:u,edgesToRemove:h,nodes:m,edges:w,onBeforeDelete:b}),S=k.length>0,M=N.length>0;if(S){const L=k.map(Hx);j==null||j(k),v(L)}if(M){const L=N.map(Hx);y==null||y(N),x(L)}return(M||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),j=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(j?x:v),b=Yo(g,y);return h&&b>0||b>=g.width*g.height||b>=y.width*y.height}):[]},isNodeIntersecting:(u,h,m=!0)=>{const y=jx(u)?u:c(u);if(!y)return!1;const j=Yo(y,h);return m&&j>0||j>=h.width*h.height||j>=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 A_(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??F_();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,_T=typeof window<"u"?window:void 0;function PT({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Oe(),{deleteElements:r}=Xh(),i=Ko(e,{actInsideInputWithModifier:!1}),o=Ko(t,{target:_T});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 TT(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},MT=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function AT({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:j,onViewportChange:x,isControlledViewport:v,paneClickDistance:g}){const b=Oe(),N=p.useRef(null),{userSelectionActive:k,lib:S,connectionInProgress:M}=ye(MT,He),L=Ko(h),U=p.useRef();TT(N);const V=p.useCallback(I=>{x==null||x({x:I[0],y:I[1],zoom:I[2]}),v||b.setState({transform:I})},[x,v]);return p.useEffect(()=>{if(N.current){U.current=jP({domNode:N.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,paneClickDistance:g,onDraggingChange:$=>b.setState({paneDragging:$}),onPanZoomStart:($,A)=>{const{onViewportChangeStart:_,onMoveStart:C}=b.getState();C==null||C($,A),_==null||_(A)},onPanZoom:($,A)=>{const{onViewportChange:_,onMove:C}=b.getState();C==null||C($,A),_==null||_(A)},onPanZoomEnd:($,A)=>{const{onViewportChangeEnd:_,onMoveEnd:C}=b.getState();C==null||C($,A),_==null||_(A)}});const{x:I,y:O,zoom:E}=U.current.getViewport();return b.setState({panZoom:U.current,transform:[I,O,E],domNode:N.current.closest(".react-flow")}),()=>{var $;($=U.current)==null||$.destroy()}}},[]),p.useEffect(()=>{var I;(I=U.current)==null||I.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:L,preventScrolling:m,noPanClassName:j,userSelectionActive:k,noWheelClassName:y,lib:S,onTransformChange:V,connectionInProgress:M})},[e,t,n,r,i,o,a,l,L,m,j,k,y,S,V,M]),s.jsx("div",{className:"react-flow__renderer",ref:N,style:Uc,children:w})}const RT=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function DT(){const{userSelectionActive:e,userSelectionRect:t}=ye(RT,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))},IT=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function zT({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:j,dragging:x,connectionInProgress:v}=ye(IT,He),g=j&&(e||y),b=p.useRef(null),N=p.useRef(),k=p.useRef(new Set),S=p.useRef(new Set),M=p.useRef(!1),L=p.useRef(!1),U=_=>{if(M.current||v){M.current=!1;return}l==null||l(_),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},V=_=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){_.preventDefault();return}c==null||c(_)},I=d?_=>d(_):void 0,O=_=>{var P,D;const{resetSelectedElements:C,domNode:T}=w.getState();if(N.current=T==null?void 0:T.getBoundingClientRect(),!j||!e||_.button!==0||_.target!==b.current||!N.current)return;(D=(P=_.target)==null?void 0:P.setPointerCapture)==null||D.call(P,_.pointerId),L.current=!0,M.current=!1;const{x:z,y:R}=pn(_.nativeEvent,N.current);C(),w.setState({userSelectionRect:{width:0,height:0,startX:z,startY:R,x:z,y:R}}),o==null||o(_)},E=_=>{const{userSelectionRect:C,transform:T,nodeLookup:z,edgeLookup:R,connectionLookup:P,triggerNodeChanges:D,triggerEdgeChanges:F,defaultEdgeOptions:H}=w.getState();if(!N.current||!C)return;M.current=!0;const{x:W,y:G}=pn(_.nativeEvent,N.current),{startX:B,startY:q}=C,ne={startX:B,startY:q,x:W<B?W:B,y:G<q?G:q,width:Math.abs(W-B),height:Math.abs(G-q)},se=k.current,te=S.current;k.current=new Set(Fh(z,ne,T,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=P.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(z,k.current,!0);D(re)}if(!Nx(te,S.current)){const re=qs(R,S.current);F(re)}w.setState({userSelectionRect:ne,userSelectionActive:!0,nodesSelectionActive:!1})},$=_=>{var T,z;if(_.button!==0||!L.current)return;(z=(T=_.target)==null?void 0:T.releasePointerCapture)==null||z.call(T,_.pointerId);const{userSelectionRect:C}=w.getState();!y&&C&&_.target===b.current&&(U==null||U(_)),w.setState({userSelectionActive:!1,userSelectionRect:null,nodesSelectionActive:k.current.size>0}),a==null||a(_),(t||i)&&(M.current=!1),L.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(U,b),onContextMenu:Xd(V,b),onWheel:Xd(I,b),onPointerEnter:g?void 0:f,onPointerDown:g?O:u,onPointerMove:g?E:u,onPointerUp:g?$:void 0,onPointerLeave:h,ref:b,style:Uc,children:[m,s.jsx(DT,{})]})}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 sb({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=aP({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 $T=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ib(){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=$T(a),m=i?o[0]:5,w=i?o[1]:5,y=n.direction.x*m*n.factor,j=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+j};i&&(v=ha(v,o));const{position:g,positionAbsolute:b}=ww({nodeId:x.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});x.position=g,x.internals.positionAbsolute=b,u.set(x.id,x)}c(u)},[])}const Gh=p.createContext(null),LT=Gh.Provider;Gh.Consumer;const ob=()=>p.useContext(Gh),OT=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),FT=(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 BT({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 $,A;const w=a||null,y=e==="target",j=Oe(),x=ob(),{connectOnClick:v,noPanClassName:g,rfId:b}=ye(OT,He),{connectingFrom:N,connectingTo:k,clickConnecting:S,isPossibleEndHandle:M,connectionInProcess:L,clickConnectionInProcess:U,valid:V}=ye(FT(x,w,e),He);x||(A=($=j.getState()).onError)==null||A.call($,"010",Ln.error010());const I=_=>{const{defaultEdgeOptions:C,onConnect:T,hasDefaultEdges:z}=j.getState(),R={...C,..._};if(z){const{edges:P,setEdges:D}=j.getState();D(Aw(R,P))}T==null||T(R),l==null||l(R)},O=_=>{if(!x)return;const C=_w(_.nativeEvent);if(i&&(C&&_.button===0||!C)){const T=j.getState();xf.onPointerDown(_.nativeEvent,{handleDomNode:_.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:y,handleId:w,nodeId:x,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:T.onConnectEnd,updateConnection:T.updateConnection,onConnect:I,isValidConnection:n||T.isValidConnection,getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}C?f==null||f(_):u==null||u(_)},E=_=>{const{onClickConnectStart:C,onClickConnectEnd:T,connectionClickStartHandle:z,connectionMode:R,isValidConnection:P,lib:D,rfId:F,nodeLookup:H,connection:W}=j.getState();if(!x||!z&&!i)return;if(!z){C==null||C(_.nativeEvent,{nodeId:x,handleId:w,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:x,type:e,id:w}});return}const G=Cw(_.target),B=n||P,{connection:q,isValid:ne}=xf.isValid(_.nativeEvent,{handle:{nodeId:x,id:w,type:e},connectionMode:R,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:B,flowId:F,doc:G,lib:D,nodeLookup:H});ne&&q&&I(q);const se=structuredClone(W);delete se.inProgress,se.toPosition=se.toHandle?se.toHandle.position:null,T==null||T(_,se),j.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":w,"data-nodeid":x,"data-handlepos":t,"data-id":`${b}-${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:V,connectionindicator:r&&(!L||M)&&(L||U?o:i)}]),onMouseDown:O,onTouchStart:O,onClick:v?E:void 0,ref:m,...h,children:c})}const cs=p.memo(nb(BT));function UT({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 VT({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 HT(){return null}function WT({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:UT,default:VT,output:WT,group:HT};function YT(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 XT=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 GT({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Oe(),{width:i,height:o,transformString:a,userSelectionActive:l}=ye(XT,He),c=ib(),d=p.useRef(null);if(p.useEffect(()=>{var h;n||(h=d.current)==null||h.focus({preventScroll:!0})},[n]),sb({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,KT=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ab({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:j,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:b,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:M,defaultViewport:L,translateExtent:U,minZoom:V,maxZoom:I,preventScrolling:O,onSelectionContextMenu:E,noWheelClassName:$,noPanClassName:A,disableKeyboardA11y:_,onViewportChange:C,isControlledViewport:T}){const{nodesSelectionActive:z,userSelectionActive:R}=ye(KT),P=Ko(d,{target:Kx}),D=Ko(y,{target:Kx}),F=D||M,H=D||b,W=f&&F!==!0,G=P||R||W;return PT({deleteKeyCode:c,multiSelectionKeyCode:w}),s.jsx(AT,{onPaneContextMenu:o,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:H,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:!P&&F,defaultViewport:L,translateExtent:U,minZoom:V,maxZoom:I,zoomActivationKeyCode:j,preventScrolling:O,noWheelClassName:$,noPanClassName:A,onViewportChange:C,isControlledViewport:T,paneClickDistance:l,children:s.jsxs(zT,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:F,isSelecting:!!G,selectionMode:u,selectionKeyPressed:P,selectionOnDrag:W,children:[e,z&&s.jsx(GT,{onSelectionContextMenu:E,noPanClassName:A,disableKeyboardA11y:_})]})})}ab.displayName="FlowRenderer";const qT=p.memo(ab),QT=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 ZT(e){return ye(p.useCallback(QT(e),[e]),He)}const JT=e=>e.updateNodeInternals;function eM(){const e=ye(JT),[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 tM({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 nM({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:j,nodeClickDistance:x,onError:v}){const{node:g,internals:b,isParent:N}=ye(B=>{const q=B.nodeLookup.get(e),ne=B.parentLookup.has(e);return{node:q,internals:q.internals,isParent:ne}},He);let k=g.type||"default",S=(j==null?void 0:j[k])||Gx[k];S===void 0&&(v==null||v("003",Ln.error003(k)),k="default",S=(j==null?void 0:j.default)||Gx.default);const M=!!(g.draggable||l&&typeof g.draggable>"u"),L=!!(g.selectable||c&&typeof g.selectable>"u"),U=!!(g.connectable||d&&typeof g.connectable>"u"),V=!!(g.focusable||f&&typeof g.focusable>"u"),I=Oe(),O=kw(g),E=tM({node:g,nodeType:k,hasDimensions:O,resizeObserver:u}),$=sb({nodeRef:E,disabled:g.hidden||!M,noDragClassName:h,handleSelector:g.dragHandle,nodeId:e,isSelectable:L,nodeClickDistance:x}),A=ib();if(g.hidden)return null;const _=cr(g),C=YT(g),T=L||M||t||n||r||i,z=n?B=>n(B,{...b.userNode}):void 0,R=r?B=>r(B,{...b.userNode}):void 0,P=i?B=>i(B,{...b.userNode}):void 0,D=o?B=>o(B,{...b.userNode}):void 0,F=a?B=>a(B,{...b.userNode}):void 0,H=B=>{const{selectNodesOnDrag:q,nodeDragThreshold:ne}=I.getState();L&&(!q||!M||ne>0)&&gf({id:e,store:I,nodeRef:E}),t&&t(B,{...b.userNode})},W=B=>{if(!(Ew(B.nativeEvent)||w)){if(pw.includes(B.key)&&L){const q=B.key==="Escape";gf({id:e,store:I,unselect:q,nodeRef:E})}else if(M&&g.selected&&Object.prototype.hasOwnProperty.call(sc,B.key)){B.preventDefault();const{ariaLabelConfig:q}=I.getState();I.setState({ariaLiveMessage:q["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),A({direction:sc[B.key],factor:B.shiftKey?4:1})}}},G=()=>{var re;if(w||!((re=E.current)!=null&&re.matches(":focus-visible")))return;const{transform:B,width:q,height:ne,autoPanOnNodeFocus:se,setCenter:te}=I.getState();if(!se)return;Fh(new Map([[e,g]]),{x:0,y:0,width:q,height:ne},B,!0).length>0||te(g.position.x+_.width/2,g.position.y+_.height/2,{zoom:B[2]})};return s.jsx("div",{className:Je(["react-flow__node",`react-flow__node-${k}`,{[m]:M},g.className,{selected:g.selected,selectable:L,parent:N,draggable:M,dragging:$}]),ref:E,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:O?"visible":"hidden",...g.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:R,onMouseLeave:P,onContextMenu:D,onClick:H,onDoubleClick:F,onKeyDown:V?W:void 0,tabIndex:V?0:void 0,onFocus:V?G:void 0,role:g.ariaRole??(V?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${qw}-${y}`,"aria-label":g.ariaLabel,...g.domAttributes,children:s.jsx(LT,{value:e,children:s.jsx(S,{id:e,data:g.data,type:k,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:g.selected??!1,selectable:L,draggable:M,deletable:g.deletable??!0,isConnectable:U,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:$,dragHandle:g.dragHandle,zIndex:b.z,parentId:g.parentId,..._})})})}const rM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function lb(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:o}=ye(rM,He),a=ZT(e.onlyRenderVisibleElements),l=eM();return s.jsx("div",{className:"react-flow__nodes",style:Uc,children:a.map(c=>s.jsx(nM,{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))})}lb.displayName="NodeRenderer";const sM=p.memo(lb);function iM(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&&H_({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),He)}const oM=({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"})},aM=({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]:oM,[tc.ArrowClosed]:aM};function lM(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 cM=({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=lM(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},cb=({defaultColor:e,rfId:t})=>{const n=ye(o=>o.edges),r=ye(o=>o.defaultEdgeOptions),i=p.useMemo(()=>Q_(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(cM,{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};cb.displayName="MarkerDefinitions";var dM=p.memo(cb);function db({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}db.displayName="EdgeText";const uM=p.memo(db);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(uM,{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 ub({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]=Pw({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 fb(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:j,interactionWidth:x})=>{const[v,g,b]=ub({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:b,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:j,interactionWidth:x})})}const fM=fb({isInternal:!1}),hb=fb({isInternal:!0});fM.displayName="SimpleBezierEdge";hb.displayName="SimpleBezierEdgeInternal";function mb(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:j,pathOptions:x,interactionWidth:v})=>{const[g,b,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:b,labelY:N,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:h,markerEnd:y,markerStart:j,interactionWidth:v})})}const pb=mb({isInternal:!1}),xb=mb({isInternal:!0});pb.displayName="SmoothStepEdge";xb.displayName="SmoothStepEdgeInternal";function gb(e){return p.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(pb,{...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 hM=gb({isInternal:!1}),yb=gb({isInternal:!0});hM.displayName="StepEdge";yb.displayName="StepEdgeInternal";function vb(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[j,x,v]=Rw({sourceX:n,sourceY:r,targetX:i,targetY:o}),g=e.isInternal?void 0:t;return s.jsx(Vc,{id:g,path:j,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 mM=vb({isInternal:!1}),wb=vb({isInternal:!0});mM.displayName="StraightEdge";wb.displayName="StraightEdgeInternal";function bb(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:j,pathOptions:x,interactionWidth:v})=>{const[g,b,N]=Tw({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:b,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:m,style:w,markerEnd:y,markerStart:j,interactionWidth:v})})}const pM=bb({isInternal:!1}),jb=bb({isInternal:!0});pM.displayName="BezierEdge";jb.displayName="BezierEdgeInternal";const Zx={default:jb,straight:wb,step:yb,smoothstep:xb,simplebezier:hb},Jx={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},xM=(e,t,n)=>n===le.Left?e-t:n===le.Right?e+t:e,gM=(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:xM(t,r,e),cy:gM(n,r,e),r,stroke:"transparent",fill:"transparent"})}function yM({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=(b,N)=>{if(b.button!==0)return;const{autoPanOnConnect:k,domNode:S,isValidConnection:M,connectionMode:L,connectionRadius:U,lib:V,onConnectStart:I,onConnectEnd:O,cancelConnection:E,nodeLookup:$,rfId:A,panBy:_,updateConnection:C}=w.getState(),T=N.type==="target",z=(D,F)=>{h(!1),u==null||u(D,n,N.type,F)},R=D=>d==null?void 0:d(n,D),P=(D,F)=>{h(!0),f==null||f(b,n,N.type),I==null||I(D,F)};xf.onPointerDown(b.nativeEvent,{autoPanOnConnect:k,connectionMode:L,connectionRadius:U,domNode:S,handleId:N.id,nodeId:N.nodeId,nodeLookup:$,isTarget:T,edgeUpdaterType:N.type,lib:V,flowId:A,cancelConnection:E,panBy:_,isValidConnection:M,onConnect:R,onConnectStart:P,onConnectEnd:O,onReconnectEnd:z,updateConnection:C,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},j=b=>y(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=b=>y(b,{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:j,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 vM({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:j,onError:x,disableKeyboardA11y:v}){let g=ye(te=>te.edgeLookup.get(e));const b=ye(te=>te.defaultEdgeOptions);g=b?{...b,...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"),M=typeof u<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),L=!!(g.selectable||r&&typeof g.selectable>"u"),U=p.useRef(null),[V,I]=p.useState(!1),[O,E]=p.useState(!1),$=Oe(),{zIndex:A,sourceX:_,sourceY:C,targetX:T,targetY:z,sourcePosition:R,targetPosition:P}=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:V_({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]),F=p.useMemo(()=>g.markerEnd?`url('#${mf(g.markerEnd,w)}')`:void 0,[g.markerEnd,w]);if(g.hidden||_===null||C===null||T===null||z===null)return null;const H=te=>{var ge;const{addSelectedEdges:ee,unselectNodesAndEdges:re,multiSelectionActive:me}=$.getState();L&&($.setState({nodesSelectionActive:!1}),g.selected&&me?(re({nodes:[],edges:[g]}),(ge=U.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,B=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&&pw.includes(te.key)&&L){const{unselectNodesAndEdges:re,addSelectedEdges:me}=$.getState();te.key==="Escape"?((ee=U.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,j,{selected:g.selected,animated:g.animated,inactive:!L&&!i,updating:V,selectable:L}]),onClick:H,onDoubleClick:W,onContextMenu:G,onMouseEnter:B,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?`${Qw}-${w}`:void 0,ref:U,...g.domAttributes,children:[!O&&s.jsx(k,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:L,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:_,sourceY:C,targetX:T,targetY:z,sourcePosition:R,targetPosition:P,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:D,markerEnd:F,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),M&&s.jsx(yM,{edge:g,isReconnectable:M,reconnectRadius:f,onReconnect:u,onReconnectStart:h,onReconnectEnd:m,sourceX:_,sourceY:C,targetX:T,targetY:z,sourcePosition:R,targetPosition:P,setUpdateHover:I,setReconnecting:E})]})})}const wM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Nb({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:j,edgesReconnectable:x,elementsSelectable:v,onError:g}=ye(wM,He),b=iM(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(dM,{defaultColor:e,rfId:n}),b.map(N=>s.jsx(vM,{id:N,edgesFocusable:j,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))]})}Nb.displayName="EdgeRenderer";const bM=p.memo(Nb),jM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function NM({children:e}){const t=ye(jM);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function kM(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 SM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function CM(e){const t=ye(SM),n=Oe();return p.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function EM(e){return e.connection.inProgress?{...e.connection,to:ma(e.connection.to,e.transform)}:{...e.connection}}function _M(e){return EM}function PM(e){const t=_M();return ye(t,He)}const TM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function MM({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:a,isValid:l,inProgress:c}=ye(TM,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",yw(l)]),children:s.jsx(kb,{style:t,type:n,CustomComponent:r,isValid:l})})})}const kb=({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}=PM();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:yw(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]=Tw(w);break;case wr.SimpleBezier:[m]=ub(w);break;case wr.Step:[m]=hf({...w,borderRadius:0});break;case wr.SmoothStep:[m]=hf(w);break;default:[m]=Rw(w)}return s.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};kb.displayName="ConnectionLine";const AM={};function ng(e=AM){p.useRef(e),Oe(),p.useEffect(()=>{},[e])}function RM(){Oe(),p.useRef(!1),p.useEffect(()=>{},[])}function Sb({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:j,connectionLineContainerStyle:x,selectionKeyCode:v,selectionOnDrag:g,selectionMode:b,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:S,deleteKeyCode:M,onlyRenderVisibleElements:L,elementsSelectable:U,defaultViewport:V,translateExtent:I,minZoom:O,maxZoom:E,preventScrolling:$,defaultMarkerColor:A,zoomOnScroll:_,zoomOnPinch:C,panOnScroll:T,panOnScrollSpeed:z,panOnScrollMode:R,zoomOnDoubleClick:P,panOnDrag:D,onPaneClick:F,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:G,onPaneScroll:B,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),RM(),kM(n),CM(Q),s.jsx(qT,{onPaneClick:F,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:G,onPaneContextMenu:q,onPaneScroll:B,paneClickDistance:ne,deleteKeyCode:M,selectionKeyCode:v,selectionOnDrag:g,selectionMode:b,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:S,elementsSelectable:U,zoomOnScroll:_,zoomOnPinch:C,zoomOnDoubleClick:P,panOnScroll:T,panOnScrollSpeed:z,panOnScrollMode:R,panOnDrag:D,defaultViewport:V,translateExtent:I,minZoom:O,maxZoom:E,onSelectionContextMenu:u,preventScrolling:$,noDragClassName:pt,noWheelClassName:Nn,noPanClassName:Ae,disableKeyboardA11y:lt,onViewportChange:ie,isControlledViewport:!!Q,children:s.jsxs(NM,{children:[s.jsx(bM,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:a,onReconnect:Ce,onReconnectStart:Ke,onReconnectEnd:Ee,onlyRenderVisibleElements:L,onEdgeContextMenu:te,onEdgeMouseEnter:ee,onEdgeMouseMove:re,onEdgeMouseLeave:me,reconnectRadius:ge,defaultMarkerColor:A,noPanClassName:Ae,disableKeyboardA11y:lt,rfId:kn}),s.jsx(MM,{style:y,type:w,component:j,containerStyle:x}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(sM,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:se,onlyRenderVisibleElements:L,noPanClassName:Ae,noDragClassName:pt,disableKeyboardA11y:lt,nodeExtent:on,rfId:kn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}Sb.displayName="GraphView";const DM=p.memo(Sb),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,j=r??t??[],x=n??e??[],v=f??[0,0],g=u??Ho;Iw(w,y,j);const b=pf(x,h,m,{nodeOrigin:v,nodeExtent:g,elevateNodesOnSelect:!1});let N=[0,0,1];if(a&&i&&o){const k=fa(h,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:S,y:M,zoom:L}=Bh(k,i,o,c,d,(l==null?void 0:l.padding)??.1);N=[S,M,L]}return{rfId:"1",width:i??0,height:o??0,transform:N,nodes:x,nodesInitialized:b,nodeLookup:h,parentLookup:m,edges:j,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:{...gw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:$_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:xw}},IM=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u})=>tT((h,m)=>{async function w(){const{nodeLookup:y,panZoom:j,fitViewOptions:x,fitViewResolver:v,width:g,height:b,minZoom:N,maxZoom:k}=m();j&&(await I_({nodes:y,width:g,height:b,panZoom:j,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:j,parentLookup:x,nodeOrigin:v,elevateNodesOnSelect:g,fitViewQueued:b}=m(),N=pf(y,j,x,{nodeOrigin:v,nodeExtent:u,elevateNodesOnSelect:g,checkEquality:!0});b&&N?(w(),h({nodes:y,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:y,nodesInitialized:N})},setEdges:y=>{const{connectionLookup:j,edgeLookup:x}=m();Iw(j,x,y),h({edges:y})},setDefaultNodesAndEdges:(y,j)=>{if(y){const{setNodes:x}=m();x(y),h({hasDefaultNodes:!0})}if(j){const{setEdges:x}=m();x(j),h({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:j,nodeLookup:x,parentLookup:v,domNode:g,nodeOrigin:b,nodeExtent:N,debug:k,fitViewQueued:S}=m(),{changes:M,updatedInternals:L}=rP(y,x,v,g,b,N);L&&(J_(x,v,{nodeOrigin:b,nodeExtent:N}),S?(w(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(M==null?void 0:M.length)>0&&(k&&console.log("React Flow: trigger node changes",M),j==null||j(M)))},updateNodePositions:(y,j=!1)=>{const x=[],v=[],{nodeLookup:g,triggerNodeChanges:b}=m();for(const[N,k]of y){const S=g.get(N),M=!!(S!=null&&S.expandParent&&(S!=null&&S.parentId)&&(k!=null&&k.position)),L={id:N,type:"position",position:M?{x:Math.max(0,k.position.x),y:Math.max(0,k.position.y)}:k.position,dragging:j};M&&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(L)}if(x.length>0){const{parentLookup:N,nodeOrigin:k}=m(),S=Yh(x,g,N,k);v.push(...S)}b(v)},triggerNodeChanges:y=>{const{onNodesChange:j,setNodes:x,nodes:v,hasDefaultNodes:g,debug:b}=m();if(y!=null&&y.length){if(g){const N=eb(y,v);x(N)}b&&console.log("React Flow: trigger node changes",y),j==null||j(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:j,setEdges:x,edges:v,hasDefaultEdges:g,debug:b}=m();if(y!=null&&y.length){if(g){const N=tb(y,v);x(N)}b&&console.log("React Flow: trigger edge changes",y),j==null||j(y)}},addSelectedNodes:y=>{const{multiSelectionActive:j,edgeLookup:x,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:b}=m();if(j){const N=y.map(k=>Qr(k,!0));g(N);return}g(qs(v,new Set([...y]),!0)),b(qs(x))},addSelectedEdges:y=>{const{multiSelectionActive:j,edgeLookup:x,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:b}=m();if(j){const N=y.map(k=>Qr(k,!0));b(N);return}b(qs(x,new Set([...y]))),g(qs(v,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:j}={})=>{const{edges:x,nodes:v,nodeLookup:g,triggerNodeChanges:b,triggerEdgeChanges:N}=m(),k=y||v,S=j||x,M=k.map(U=>{const V=g.get(U.id);return V&&(V.selected=!1),Qr(U.id,!1)}),L=S.map(U=>Qr(U.id,!1));b(M),N(L)},setMinZoom:y=>{const{panZoom:j,maxZoom:x}=m();j==null||j.setScaleExtent([y,x]),h({minZoom:y})},setMaxZoom:y=>{const{panZoom:j,minZoom:x}=m();j==null||j.setScaleExtent([x,y]),h({maxZoom:y})},setTranslateExtent:y=>{var j;(j=m().panZoom)==null||j.setTranslateExtent(y),h({translateExtent:y})},setPaneClickDistance:y=>{var j;(j=m().panZoom)==null||j.setClickDistance(y)},resetSelectedElements:()=>{const{edges:y,nodes:j,triggerNodeChanges:x,triggerEdgeChanges:v,elementsSelectable:g}=m();if(!g)return;const b=j.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(b),v(N)},setNodeExtent:y=>{const{nodes:j,nodeLookup:x,parentLookup:v,nodeOrigin:g,elevateNodesOnSelect:b,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(j,x,v,{nodeOrigin:g,nodeExtent:y,elevateNodesOnSelect:b,checkEquality:!1}),h({nodeExtent:y}))},panBy:y=>{const{transform:j,width:x,height:v,panZoom:g,translateExtent:b}=m();return sP({delta:y,panZoom:g,transform:j,translateExtent:b,width:x,height:v})},setCenter:async(y,j,x)=>{const{width:v,height:g,maxZoom:b,panZoom:N}=m();if(!N)return Promise.resolve(!1);const k=typeof(x==null?void 0:x.zoom)<"u"?x.zoom:b;return await N.setViewport({x:v/2-y*k,y:g/2-j*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:{...gw}})},updateConnection:y=>{h({connection:y})},reset:()=>h({...rg()})}},Object.is);function zM({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(()=>IM({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(nT,{value:m,children:s.jsx(ST,{children:h})})}function $M({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(zM,{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 LM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function OM({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:j,onClickConnectEnd:x,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:b,onNodeContextMenu:N,onNodeDoubleClick:k,onNodeDragStart:S,onNodeDrag:M,onNodeDragStop:L,onNodesDelete:U,onEdgesDelete:V,onDelete:I,onSelectionChange:O,onSelectionDragStart:E,onSelectionDrag:$,onSelectionDragStop:A,onSelectionContextMenu:_,onSelectionStart:C,onSelectionEnd:T,onBeforeDelete:z,connectionMode:R,connectionLineType:P=wr.Bezier,connectionLineStyle:D,connectionLineComponent:F,connectionLineContainerStyle:H,deleteKeyCode:W="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:B=!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=Zw,edgesFocusable:Ae,edgesReconnectable:lt,elementsSelectable:on=!0,defaultViewport:kn=pT,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:p1,onEdgesChange:x1,noDragClassName:g1="nodrag",noWheelClassName:y1="nowheel",noPanClassName:am="nopan",fitView:lm,fitViewOptions:cm,connectOnClick:v1,attributionPosition:w1,proOptions:b1,defaultEdgeOptions:j1,elevateNodesOnSelect:N1,elevateEdgesOnSelect:k1,disableKeyboardA11y:dm=!1,autoPanOnConnect:S1,autoPanOnNodeDrag:C1,autoPanSpeed:E1,connectionRadius:_1,isValidConnection:P1,onError:T1,style:M1,id:um,nodeDragThreshold:A1,connectionDragThreshold:R1,viewport:D1,onViewportChange:I1,width:z1,height:$1,colorMode:L1="light",debug:O1,onScroll:va,ariaLabelConfig:F1,...B1},U1){const Jc=um||"1",V1=vT(L1),H1=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",...B1,onScroll:H1,style:{...M1,...LM},ref:U1,className:Je(["react-flow",i,V1]),id:um,role:"application",children:s.jsxs($M,{nodes:e,edges:t,width:z1,height:$1,fitView:lm,fitViewOptions:cm,minZoom:Q,maxZoom:ie,nodeOrigin:Nn,nodeExtent:Fe,children:[s.jsx(DM,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:b,onNodeContextMenu:N,onNodeDoubleClick:k,nodeTypes:o,edgeTypes:a,connectionLineType:P,connectionLineStyle:D,connectionLineComponent:F,connectionLineContainerStyle:H,selectionKeyCode:G,selectionOnDrag:B,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:_,onSelectionStart:C,onSelectionEnd:T,onReconnect:Es,onReconnectStart:et,onReconnectEnd:Et,onEdgeContextMenu:_s,onEdgeDoubleClick:It,onEdgeMouseEnter:zt,onEdgeMouseMove:ya,onEdgeMouseLeave:Un,reconnectRadius:om,defaultMarkerColor:Ne,noDragClassName:g1,noWheelClassName:y1,noPanClassName:am,rfId:Jc,disableKeyboardA11y:dm,nodeExtent:Fe,viewport:D1,onViewportChange:I1}),s.jsx(yT,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:w,onConnectEnd:y,onClickConnectStart:j,onClickConnectEnd:x,nodesDraggable:Ce,autoPanOnNodeFocus:Ke,nodesConnectable:Ee,nodesFocusable:pt,edgesFocusable:Ae,edgesReconnectable:lt,elementsSelectable:on,elevateNodesOnSelect:N1,elevateEdgesOnSelect:k1,minZoom:Q,maxZoom:ie,nodeExtent:Fe,onNodesChange:p1,onEdgesChange:x1,snapToGrid:ee,snapGrid:re,connectionMode:R,translateExtent:he,connectOnClick:v1,defaultEdgeOptions:j1,fitView:lm,fitViewOptions:cm,onNodesDelete:U,onEdgesDelete:V,onDelete:I,onNodeDragStart:S,onNodeDrag:M,onNodeDragStop:L,onSelectionDrag:$,onSelectionDragStart:E,onSelectionDragStop:A,onMove:f,onMoveStart:u,onMoveEnd:h,noPanClassName:am,nodeOrigin:Nn,rfId:Jc,autoPanOnConnect:S1,autoPanOnNodeDrag:C1,autoPanSpeed:E1,onError:T1,connectionRadius:_1,isValidConnection:P1,selectNodesOnDrag:ge,nodeDragThreshold:A1,connectionDragThreshold:R1,onBeforeDelete:z,paneClickDistance:Ye,debug:O1,ariaLabelConfig:F1}),s.jsx(mT,{onSelectionChange:O}),jt,s.jsx(cT,{proOptions:b1,position:w1}),s.jsx(lT,{rfId:Jc,disableKeyboardA11y:dm})]})})}var FM=nb(OM);function BM(e){const[t,n]=p.useState(e),r=p.useCallback(i=>n(o=>eb(i,o)),[]);return[t,n,r]}function UM(e){const[t,n]=p.useState(e),r=p.useCallback(i=>n(o=>tb(i,o)),[]);return[t,n,r]}function VM({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 HM({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 WM={[er.Dots]:1,[er.Lines]:1,[er.Cross]:6},YM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cb({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(YM,He),w=r||WM[t],y=t===er.Dots,j=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],b=Array.isArray(o)?o:[o,o],N=j?[g,g]:v,k=[b[0]*h[2]||1+N[0]/2,b[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(HM,{radius:g/2,className:f}):s.jsx(VM,{dimensions:N,lineWidth:i,variant:t,className:f})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}Cb.displayName="Background";const XM=p.memo(Cb);function GM(){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 KM(){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 QM(){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 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 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 JM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Eb({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:j,maxZoomReached:x,ariaLabelConfig:v}=ye(JM,He),{zoomIn:g,zoomOut:b,fitView:N}=Xh(),k=()=>{g(),o==null||o()},S=()=>{b(),a==null||a()},M=()=>{N(i),l==null||l()},L=()=>{w.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c==null||c(!y)},U=h==="horizontal"?"horizontal":"vertical";return s.jsxs(Bc,{className:Je(["react-flow__controls",U,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(GM,{})}),s.jsx(Qa,{onClick:S,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:j,children:s.jsx(KM,{})})]}),n&&s.jsx(Qa,{className:"react-flow__controls-fitview",onClick:M,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:L,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:y?s.jsx(ZM,{}):s.jsx(QM,{})}),f]})}Eb.displayName="Controls";const eA=p.memo(Eb);function tA({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||{},j=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:j,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?x=>m(x,e):void 0})}const nA=p.memo(tA),rA=e=>e.nodes.map(t=>t.id),Gd=e=>e instanceof Function?e:()=>e;function sA({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=nA,onClick:a}){const l=ye(rA,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(oA,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:a,shapeRendering:u},h))})}function iA({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),j=y.userNode,{x,y:v}=y.positionAbsolute,{width:g,height:b}=cr(j);return{node:j,x,y:v,width:g,height:b}},He);return!d||d.hidden||!kw(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 oA=p.memo(iA);var aA=p.memo(sA);const lA=200,cA=150,dA=e=>!e.hidden,uA=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?Nw(fa(e.nodeLookup,{filter:dA}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},fA="react-flow__minimap-desc";function _b({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:j=!1,ariaLabel:x,inversePan:v,zoomStep:g=1,offsetScale:b=5}){const N=Oe(),k=p.useRef(null),{boundingRect:S,viewBB:M,rfId:L,panZoom:U,translateExtent:V,flowWidth:I,flowHeight:O,ariaLabelConfig:E}=ye(uA,He),$=(e==null?void 0:e.width)??lA,A=(e==null?void 0:e.height)??cA,_=S.width/$,C=S.height/A,T=Math.max(_,C),z=T*$,R=T*A,P=b*T,D=S.x-(z-S.width)/2-P,F=S.y-(R-S.height)/2-P,H=z+P*2,W=R+P*2,G=`${fA}-${L}`,B=p.useRef(0),q=p.useRef();B.current=T,p.useEffect(()=>{if(k.current&&U)return q.current=hP({domNode:k.current,panZoom:U,getTransform:()=>N.getState().transform,getViewScale:()=>B.current}),()=>{var ee;(ee=q.current)==null||ee.destroy()}},[U]),p.useEffect(()=>{var ee;(ee=q.current)==null||ee.update({translateExtent:V,width:I,height:O,inversePan:v,pannable:y,zoomStep:g,zoomable:j})},[y,j,v,g,V,I,O]);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*T: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:$,height:A,viewBox:`${D} ${F} ${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(aA,{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-P},${F-P}h${H+P*2}v${W+P*2}h${-H-P*2}z
405
- M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_b.displayName="MiniMap";const hA=p.memo(_b),mA=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,pA={[_i.Line]:"right",[_i.Handle]:"bottom-right"};function xA({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:j,onResizeEnd:x}){const v=ob(),g=typeof e=="string"?e:v,b=Oe(),N=p.useRef(null),k=n===_i.Handle,S=ye(p.useCallback(mA(k&&m),[k,m]),He),M=p.useRef(null),L=t??pA[n];p.useEffect(()=>{if(!(!N.current||!g))return M.current||(M.current=PP({domNode:N.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:V,transform:I,snapGrid:O,snapToGrid:E,nodeOrigin:$,domNode:A}=b.getState();return{nodeLookup:V,transform:I,snapGrid:O,snapToGrid:E,nodeOrigin:$,paneDomNode:A}},onChange:(V,I)=>{const{triggerNodeChanges:O,nodeLookup:E,parentLookup:$,nodeOrigin:A}=b.getState(),_=[],C={x:V.x,y:V.y},T=E.get(g);if(T&&T.expandParent&&T.parentId){const z=T.origin??A,R=V.width??T.measured.width??0,P=V.height??T.measured.height??0,D={id:T.id,parentId:T.parentId,rect:{width:R,height:P,...Sw({x:V.x??T.position.x,y:V.y??T.position.y},{width:R,height:P},T.parentId,E,z)}},F=Yh([D],E,$,A);_.push(...F),C.x=V.x?Math.max(z[0]*R,V.x):void 0,C.y=V.y?Math.max(z[1]*P,V.y):void 0}if(C.x!==void 0&&C.y!==void 0){const z={id:g,type:"position",position:{...C}};_.push(z)}if(V.width!==void 0&&V.height!==void 0){const R={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:V.width,height:V.height}};_.push(R)}for(const z of I){const R={...z,type:"position"};_.push(R)}O(_)},onEnd:({width:V,height:I})=>{const O={id:g,type:"dimensions",resizing:!1,dimensions:{width:V,height:I}};b.getState().triggerNodeChanges([O])}})),M.current.update({controlPosition:L,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:h,onResizeStart:y,onResize:j,onResizeEnd:x,shouldResize:w}),()=>{var V;(V=M.current)==null||V.destroy()}},[L,l,c,d,f,u,y,j,x,w]);const U=L.split("-");return s.jsx("div",{className:Je(["react-flow__resize-control","nodrag",...U,n,r]),ref:N,style:{...i,scale:S,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:o})}p.memo(xA);const gA=["top","right","bottom","left"],Br=Math.min,Lt=Math.max,ic=Math.round,Za=Math.floor,$n=e=>({x:e,y:e}),yA={left:"right",right:"left",bottom:"top",top:"bottom"},vA={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 wA=new Set(["top","bottom"]);function An(e){return wA.has(ar(e))?"y":"x"}function Qh(e){return Kh(An(e))}function bA(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 jA(e){const t=oc(e);return[vf(e),t,vf(t)]}function vf(e){return e.replace(/start|end/g,t=>vA[t])}const sg=["left","right"],ig=["right","left"],NA=["top","bottom"],kA=["bottom","top"];function SA(e,t,n){switch(e){case"top":case"bottom":return n?t?ig:sg:t?sg:ig;case"left":case"right":return t?NA:kA;default:return[]}}function CA(e,t,n,r){const i=Li(e);let o=SA(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=>yA[t])}function EA(e){return{top:0,right:0,bottom:0,left:0,...e}}function Pb(e){return typeof e!="number"?EA(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 _A=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:j,fn:x}=l[y],{x:v,y:g,data:b,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,[j]:{...m[j],...b}},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=Pb(m),j=l[h?u==="floating"?"reference":"floating":u],x=ac(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(j)))==null||n?j:j.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)),b=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)/b.y,bottom:(N.bottom-x.bottom+w.bottom)/b.y,left:(x.left-N.left+w.left)/b.x,right:(N.right-x.right+w.right)/b.x}}const PA=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=Pb(f),h={x:n,y:r},m=Qh(i),w=qh(m),y=await a.getDimensions(d),j=m==="y",x=j?"top":"left",v=j?"bottom":"right",g=j?"clientHeight":"clientWidth",b=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 M=b/2-N/2,L=S/2-y[w]/2-1,U=Br(u[x],L),V=Br(u[v],L),I=U,O=S-y[w]-V,E=S/2-y[w]/2+M,$=yf(I,E,O),A=!c.arrow&&Li(i)!=null&&E!==$&&o.reference[w]/2-(E<I?U:V)-y[w]/2<0,_=A?E<I?E-I:E-O:0;return{[m]:h[m]+_,data:{[m]:$,centerOffset:E-$-_,...A&&{alignmentOffset:_}},reset:A}}}),TA=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,...j}=or(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const x=ar(i),v=An(l),g=ar(l)===l,b=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=h||(g||!y?[oc(l)]:jA(l)),k=w!=="none";!h&&k&&N.push(...CA(l,y,w,b));const S=[l,...N],M=await qo(t,j),L=[];let U=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&L.push(M[x]),u){const E=bA(i,a,b);L.push(M[E[0]],M[E[1]])}if(U=[...U,{placement:i,overflows:L}],!L.every(E=>E<=0)){var V,I;const E=(((V=o.flip)==null?void 0:V.index)||0)+1,$=S[E];if($&&(!(u==="alignment"?v!==An($):!1)||U.every(C=>An(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:E,overflows:U},reset:{placement:$}};let A=(I=U.filter(_=>_.overflows[0]<=0).sort((_,C)=>_.overflows[1]-C.overflows[1])[0])==null?void 0:I.placement;if(!A)switch(m){case"bestFit":{var O;const _=(O=U.filter(C=>{if(k){const T=An(C.placement);return T===v||T==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(T=>T>0).reduce((T,z)=>T+z,0)]).sort((C,T)=>C[1]-T[1])[0])==null?void 0:O[0];_&&(A=_);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 gA.some(t=>e[t]>=0)}const MA=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{}}}}},Tb=new Set(["left","top"]);async function AA(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=Tb.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 RA=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 AA(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}}}}},DA=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:j=>{let{x,y:v}=j;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 j=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+f[j],g=m-f[x];m=yf(v,m,g)}if(a){const j=u==="y"?"top":"left",x=u==="y"?"bottom":"right",v=w+f[j],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}}}}}},IA=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),j=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const g=h==="y"?"height":"width",b=o.reference[h]-o.floating[g]+j.mainAxis,N=o.reference[h]+o.reference[g]-j.mainAxis;m<b?m=b:m>N&&(m=N)}if(d){var x,v;const g=h==="y"?"width":"height",b=Tb.has(ar(i)),N=o.reference[u]-o.floating[g]+(b&&((x=a.offset)==null?void 0:x[u])||0)+(b?0:j.crossAxis),k=o.reference[u]+o.reference[g]+(b?0:((v=a.offset)==null?void 0:v[u])||0)-(b?j.crossAxis:0);w<N?w=N:w>k&&(w=k)}return{[h]:m,[u]:w}}}},zA=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 j,x;u==="top"||u==="bottom"?(j=u,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=u,j=h==="end"?"top":"bottom");const v=y-f.top-f.bottom,g=w-f.left-f.right,b=Br(y-f[j],v),N=Br(w-f[x],g),k=!t.middlewareData.shift;let S=b,M=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=g),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=v),k&&!h){const U=Lt(f.left,0),V=Lt(f.right,0),I=Lt(f.top,0),O=Lt(f.bottom,0);m?M=w-2*(U!==0||V!==0?U+V:Lt(f.left,f.right)):S=y-2*(I!==0||O!==0?I+O:Lt(f.top,f.bottom))}await c({...t,availableWidth:M,availableHeight:S});const L=await a.getDimensions(l.floating);return w!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function Hc(){return typeof window<"u"}function Oi(e){return Mb(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=(Mb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mb(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 $A=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)&&!$A.has(i)}const LA=new Set(["table","td","th"]);function OA(e){return LA.has(Oi(e))}const FA=[":popover-open",":modal"];function Wc(e){return FA.some(t=>{try{return e.matches(t)}catch{return!1}})}const BA=["transform","translate","scale","rotate","perspective"],UA=["transform","translate","scale","rotate","perspective","filter"],VA=["paint","layout","strict","content"];function Zh(e){const t=Jh(),n=vn(e)?wn(e):e;return BA.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)||UA.some(r=>(n.willChange||"").includes(r))||VA.some(r=>(n.contain||"").includes(r))}function HA(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 WA=new Set(["html","body","#document"]);function Ti(e){return WA.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 Ab(e){const t=Ur(e);return Ti(t)?e.ownerDocument?e.ownerDocument.body:e.body:On(t)&&pa(t)?t:Ab(t)}function Qo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Ab(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 Rb(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}=Rb(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 YA=$n(0);function Db(e){const t=Ut(e);return!Jh()||!t.visualViewport?YA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function XA(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=XA(o,n,r)?Db(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 j=li(y),x=y.getBoundingClientRect(),v=wn(y),g=x.left+(y.clientLeft+parseFloat(v.paddingLeft))*j.x,b=x.top+(y.clientTop+parseFloat(v.paddingTop))*j.y;c*=j.x,d*=j.y,f*=j.x,u*=j.y,c+=g,d+=b,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 Ib(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 GA(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?Ib(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 KA(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 QA(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 ZA=new Set(["absolute","fixed"]);function JA(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=QA(e,n);else if(t==="document")r=qA(Bn(e));else if(vn(t))r=JA(t,n);else{const i=Db(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ac(r)}function zb(e,t){const n=Ur(e);return n===t||!vn(n)||Ti(n)?!1:wn(n).position==="fixed"||zb(n,t)}function eR(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&&ZA.has(i.position)||pa(a)&&!c&&zb(e,a))?r=r.filter(f=>f!==a):i=l,a=Ur(a)}return t.set(e,r),r}function tR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Wc(t)?[]:eR(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 nR(e){const{width:t,height:n}=Rb(e);return{width:t,height:n}}function rR(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?Ib(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 $b(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&&OA(r)&&Kd(r);)r=fg(r,t);return r&&Ti(r)&&Kd(r)&&!Zh(r)?n:r||HA(e)||n}const sR=async function(e){const t=this.getOffsetParent||$b,n=this.getDimensions,r=await n(e.floating);return{reference:rR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function iR(e){return wn(e).direction==="rtl"}const oR={convertOffsetParentRelativeRectToViewportRelativeRect:GA,getDocumentElement:Bn,getClippingRect:tR,getOffsetParent:$b,getElementRects:sR,getClientRects:KA,getDimensions:nR,getScale:li,isElement:vn,isRTL:iR};function Lb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function aR(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)),j=Za(i.clientHeight-(u+m)),x=Za(f),g={rootMargin:-w+"px "+-y+"px "+-j+"px "+-x+"px",threshold:Lt(0,Br(1,c))||1};let b=!0;function N(k){const S=k[0].intersectionRatio;if(S!==c){if(!b)return a();S?a(!1,S):r=setTimeout(()=>{a(!1,1e-7)},1e3)}S===1&&!Lb(d,e.getBoundingClientRect())&&a(),b=!1}try{n=new IntersectionObserver(N,{...g,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,g)}n.observe(e)}return a(!0),o}function lR(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?aR(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&&j();function j(){const x=js(e);y&&!Lb(y,x)&&n(),y=x,w=requestAnimationFrame(j)}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 cR=RA,dR=DA,uR=TA,fR=zA,hR=MA,hg=PA,mR=IA,pR=(e,t,n)=>{const r=new Map,i={platform:oR,...n},o={...i.platform,_c:r};return _A(e,t,{...i,platform:o})};var xR=typeof document<"u",gR=function(){},vl=xR?p.useLayoutEffect:gR;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 Ob(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mg(e,t){const n=Ob(e);return Math.round(t*n)/n}function qd(e){const t=p.useRef(e);return vl(()=>{t.current=e}),t}function yR(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),[j,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))},[]),b=o||w,N=a||j,k=p.useRef(null),S=p.useRef(null),M=p.useRef(f),L=c!=null,U=qd(c),V=qd(i),I=qd(d),O=p.useCallback(()=>{if(!k.current||!S.current)return;const C={placement:t,strategy:n,middleware:h};V.current&&(C.platform=V.current),pR(k.current,S.current,C).then(T=>{const z={...T,isPositioned:I.current!==!1};E.current&&!lc(M.current,z)&&(M.current=z,Sc.flushSync(()=>{u(z)}))})},[h,t,n,V,I]);vl(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,u(C=>({...C,isPositioned:!1})))},[d]);const E=p.useRef(!1);vl(()=>(E.current=!0,()=>{E.current=!1}),[]),vl(()=>{if(b&&(k.current=b),N&&(S.current=N),b&&N){if(U.current)return U.current(b,N,O);O()}},[b,N,O,U,L]);const $=p.useMemo(()=>({reference:k,floating:S,setReference:v,setFloating:g}),[v,g]),A=p.useMemo(()=>({reference:b,floating:N}),[b,N]),_=p.useMemo(()=>{const C={position:n,left:0,top:0};if(!A.floating)return C;const T=mg(A.floating,f.x),z=mg(A.floating,f.y);return l?{...C,transform:"translate("+T+"px, "+z+"px)",...Ob(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:z}},[n,l,A.floating,f.x,f.y]);return p.useMemo(()=>({...f,update:O,refs:$,elements:A,floatingStyles:_}),[f,O,$,A,_])}const vR=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):{}}}},wR=(e,t)=>({...cR(e),options:[e,t]}),bR=(e,t)=>({...dR(e),options:[e,t]}),jR=(e,t)=>({...mR(e),options:[e,t]}),NR=(e,t)=>({...uR(e),options:[e,t]}),kR=(e,t)=>({...fR(e),options:[e,t]}),SR=(e,t)=>({...hR(e),options:[e,t]}),CR=(e,t)=>({...vR(e),options:[e,t]});var ER="Arrow",Fb=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"})})});Fb.displayName=ER;var _R=Fb;function Bb(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",[Ub,Vb]=Ec(tm),[PR,Hb]=Ub(tm),Wb=e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null);return s.jsx(PR,{scope:t,anchor:r,onAnchorChange:i,children:n})};Wb.displayName=tm;var Yb="PopperAnchor",Xb=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=Hb(Yb,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})});Xb.displayName=Yb;var nm="PopperContent",[TR,MR]=Ub(nm),Gb=p.forwardRef((e,t)=>{var G,B,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,j=Hb(nm,n),[x,v]=p.useState(null),g=Xt(t,ee=>v(ee)),[b,N]=p.useState(null),k=Bb(b),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,L=r+(o!=="center"?"-"+o:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},V=Array.isArray(d)?d:[d],I=V.length>0,O={padding:U,boundary:V.filter(RR),altBoundary:I},{refs:E,floatingStyles:$,placement:A,isPositioned:_,middlewareData:C}=yR({strategy:"fixed",placement:L,whileElementsMounted:(...ee)=>lR(...ee,{animationFrame:m==="always"}),elements:{reference:j.anchor},middleware:[wR({mainAxis:i+M,alignmentAxis:a}),c&&bR({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?jR():void 0,...O}),c&&NR({...O}),kR({...O,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`)}}),b&&CR({element:b,padding:l}),DR({arrowWidth:S,arrowHeight:M}),h&&SR({strategy:"referenceHidden",...O})]}),[T,z]=Qb(A),R=xi(w);Or(()=>{_&&(R==null||R())},[_,R]);const P=(G=C.arrow)==null?void 0:G.x,D=(B=C.arrow)==null?void 0:B.y,F=((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:{...$,transform:_?$.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(TR,{scope:n,placedSide:T,onArrowChange:N,arrowX:P,arrowY:D,shouldHideArrow:F,children:s.jsx(ze.div,{"data-side":T,"data-align":z,...y,ref:g,style:{...y.style,animation:_?void 0:"none"}})})})});Gb.displayName=nm;var Kb="PopperArrow",AR={top:"bottom",right:"left",bottom:"top",left:"right"},qb=p.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=MR(Kb,r),a=AR[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(_R,{...i,ref:n,style:{...i.style,display:"block"}})})});qb.displayName=Kb;function RR(e){return e!==null}var DR=e=>({name:"transformOrigin",options:e,fn(t){var j,x,v;const{placement:n,rects:r,middlewareData:i}=t,a=((j=i.arrow)==null?void 0:j.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,f]=Qb(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 Qb(e){const[t,n="center"]=e.split("-");return[t,n]}var IR=Wb,zR=Xb,$R=Gb,LR=qb,OR=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"}),FR="VisuallyHidden",Zb=p.forwardRef((e,t)=>s.jsx(ze.span,{...e,ref:t,style:{...OR,...e.style}}));Zb.displayName=FR;var BR=Zb,[Gc]=Ec("Tooltip",[Vb]),Kc=Vb(),Jb="TooltipProvider",UR=700,bf="tooltip.open",[VR,rm]=Gc(Jb),e1=e=>{const{__scopeTooltip:t,delayDuration:n=UR,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(VR,{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})};e1.displayName=Jb;var Zo="Tooltip",[HR,qc]=Gc(Zo),t1=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,j=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?j.current?"delayed-open":"instant-open":"closed",[x]),b=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j.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(()=>{j.current=!0,v(!0),m.current=0},y)},[y,v]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(IR,{...d,children:s.jsx(HR,{scope:t,contentId:h,open:x,stateAttribute:g,trigger:f,onTriggerChange:u,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?k():b()},[c.isOpenDelayedRef,k,b]),onTriggerLeave:p.useCallback(()=>{w?N():(window.clearTimeout(m.current),m.current=0)},[N,w]),onOpen:b,onClose:N,disableHoverableContent:w,children:n})})};t1.displayName=Zo;var jf="TooltipTrigger",n1=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(zR,{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)})})});n1.displayName=jf;var WR="TooltipPortal",[SD,YR]=Gc(WR,{forceMount:void 0}),Mi="TooltipContent",r1=p.forwardRef((e,t)=>{const n=YR(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(s1,{side:i,...o,ref:t}):s.jsx(XR,{side:i,...o,ref:t})})}),XR=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 j=w.currentTarget,x={x:w.clientX,y:w.clientY},v=ZR(x,j.getBoundingClientRect()),g=JR(x,v),b=eD(y.getBoundingClientRect()),N=nD([...g,...b]);l(N),u(!0)},[u]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&f){const w=j=>m(j,f),y=j=>m(j,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 j=y.target,x={x:y.clientX,y:y.clientY},v=(c==null?void 0:c.contains(j))||(f==null?void 0:f.contains(j)),g=!tD(x,a);v?h():g&&(h(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,f,a,d,h]),s.jsx(s1,{...e,ref:o})}),[GR,KR]=Gc(Zo,{isInside:!1}),qR=kS("TooltipContent"),s1=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($R,{"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(GR,{scope:n,isInside:!0,children:s.jsx(BR,{id:c.contentId,role:"tooltip",children:i||r})})]})})});r1.displayName=Mi;var i1="TooltipArrow",QR=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Kc(n);return KR(i1,n).isInside?null:s.jsx(LR,{...i,...r,ref:t})});QR.displayName=i1;function ZR(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 JR(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 eD(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 tD(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 nD(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),rD(t)}function rD(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 sD=e1,iD=t1,oD=n1,o1=r1;const Qd=sD,Zd=iD,Jd=oD,wl=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(o1,{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=o1.displayName;const aD=420,lD=({data:e,targetPosition:t,sourcePosition:n})=>{const r=e,i="!h-px !w-px !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-[0.5px] border-gray-300 dark:border-gray-600 overflow-hidden shadow-sm bg-black"),style:{width:aD/2},id:`${r.name}-table-node`,children:[s.jsx("header",{className:rt("text-[0.55rem] pl-2 pr-1 bg-gray-800 text-white flex items-center justify-between border-b border-gray-600",o),children:s.jsxs("div",{className:"flex items-center gap-x-1",children:[s.jsx(rS,{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-black","border-t","border-t-gray-600","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(Hy,{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(Zk,{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(Jk,{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-white",children:a.name}),s.jsx("span",{className:"font-mono 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-500 text-[0.4rem] mt-[1px]",children:a.plugin})]}),t&&s.jsx(cs,{type:"target",id:a.id,position:t,className:rt(i,"!left-0")}),n&&s.jsx(cs,{type:"source",id:a.id,position:n,className:rt(i,"!right-0")})]},a.id))]})})};function cD(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",[dD]=Ec(Qc),[uD,sm]=dD(Qc);function fD(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),[j,x]=p.useState(null),v=p.useRef(!1),g=w?!!a||!!w.closest("form"):!0,b={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:j,setBubbleInput:x};return s.jsx(uD,{scope:t,...b,children:hD(u)?u(b):r})}var a1="CheckboxTrigger",l1=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(a1,e),y=Xt(i,f),j=p.useRef(c);return p.useEffect(()=>{const x=o==null?void 0:o.form;if(x){const v=()=>u(j.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":h1(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())})})});l1.displayName=a1;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(fD,{__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(l1,{...u,ref:t,__scopeCheckbox:n}),h&&s.jsx(f1,{__scopeCheckbox:n})]})})});im.displayName=Qc;var c1="CheckboxIndicator",d1=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=sm(c1,n);return s.jsx(zi,{present:r||Ir(o.checked)||o.checked===!0,children:s.jsx(ze.span,{"data-state":h1(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});d1.displayName=c1;var u1="CheckboxBubbleInput",f1=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(u1,e),w=Xt(n,m),y=cD(o),j=Bb(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,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});f1.displayName=u1;function hD(e){return typeof e=="function"}function Ir(e){return e==="indeterminate"}function h1(e){return Ir(e)?"indeterminate":e?"checked":"unchecked"}const m1=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(d1,{className:rt("flex items-center justify-center text-current"),children:s.jsx(By,{className:"h-4 w-4"})})}));m1.displayName=im.displayName;const mD={tableNode:lD},pD=[{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(["organization"]),[c,d]=p.useState(!0),[f,u,h]=BM([]),[m,w,y]=UM([]),j=p.useCallback(async b=>{try{r(!0);const N=b.length>0?`?plugins=${b.join(",")}`:"",S=await(await fetch(`/api/database/schema${N}`)).json();S.success?t(S.schema):o(S.error||"Failed to fetch schema")}catch(N){o("Failed to fetch database schema"),console.error("Error fetching schema:",N)}finally{r(!1)}},[]);p.useEffect(()=>{j(a)},[a,j]),p.useEffect(()=>{if(!e)return;const b=[],N=[];e.tables.forEach((k,S)=>{const M=k.fields.map(L=>({id:`${k.name}-${L.name}`,isPrimary:L.primaryKey||!1,isNullable:!L.required,isUnique:L.unique||!1,isIdentity:!1,name:L.name,format:L.type,plugin:x(k.name,L.name,a)}));b.push({id:k.name,type:"tableNode",position:{x:S%3*250,y:Math.floor(S/3)*200},data:{name:k.name,isForeign:!1,columns:M}})}),e.tables.forEach(k=>{k.relationships.forEach(S=>{const M=k.name,L=S.target,U=b.find(I=>I.id===M),V=b.find(I=>I.id===L);U&&V&&N.push({id:`${M}-${L}-${S.field}`,source:M,target:L,type:"smoothstep",animated:!1,style:{stroke:"#000000",strokeWidth:3},label:`${S.field}: ${S.type.replace("-"," → ")}`,labelStyle:{fontSize:"10px",fill:"#000000",fontWeight:"bold"},labelBgStyle:{fill:"rgba(255, 255, 255, 0.8)",fillOpacity:.9},markerEnd:{type:"arrowclosed",color:"#000000"}})})}),u(b),w(N)},[e,a]);const x=(b,N,k)=>{if(b==="user"||b==="session"||b==="account"||b==="verification")return"core";for(const S of k)if(b===S||b.includes(S))return S;return"core"},v=p.useCallback(b=>w(N=>Aw(b,N)),[w]),g=(b,N)=>{l(N?k=>[...k,b]:k=>k.filter(S=>S!==b))};return n?s.jsx("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"})]})}):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 bg-white dark:bg-black",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:()=>d(!c),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:[c?s.jsx(Qk,{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:pD.map(b=>s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(m1,{id:b.name,checked:a.includes(b.name),onCheckedChange:N=>g(b.name,N)}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{htmlFor:b.name,className:"text-sm font-medium text-gray-900 dark:text-white cursor-pointer",children:b.displayName}),s.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:b.description})]}),s.jsx("div",{className:`w-3 h-3 rounded-full ${b.color}`})]},b.name))})]}),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((b,N)=>b+N.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:"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(FM,{nodes:f,edges:m,onNodesChange:h,onEdgesChange:y,onConnect:v,nodeTypes:mD,fitView:!0,fitViewOptions:{padding:.2},className:"bg-white dark:bg-black",defaultEdgeOptions:{style:{stroke:"#000000",strokeWidth:3},animated:!1,type:"smoothstep"},children:[s.jsx(eA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600"}),s.jsx(hA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600",nodeColor:b=>{var N;return(N=b.data)!=null&&N.isForeign?"#e5e7eb":"#f3f4f6"},maskColor:"rgba(255, 255, 255, 0.8)"}),s.jsx(XM,{variant:er.Dots,gap:20,size:1,color:"#000000"})]})})})]})]})}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),[j,x]=p.useState(!1),[v,g]=p.useState(!1),[b,N]=p.useState(!1),[k,S]=p.useState(!1),[M,L]=p.useState(!1),[U,V]=p.useState(!1),[I,O]=p.useState(!1),[E,$]=p.useState(null),[A,_]=p.useState(""),[C,T]=p.useState(""),[z,R]=p.useState([]),[P,D]=p.useState({name:""}),[F,H]=p.useState(!1),[W,G]=p.useState([]),[B,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.organizationPlugin.options.teams.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),_(""),T(""),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(!P.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:P.name,organizationId:e})})).json();de.success?(await Ke(),L(!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||!P.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:P.name})})).json();de.success?(await Ke(),V(!1),$(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(),O(!1),$(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=>{$(K),D({name:K.name}),V(!0)},Xr=K=>{$(K),O(!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:()=>L(!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:()=>L(!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),_(""),T("")},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=>_(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:T,children:[s.jsx(vi,{children:s.jsx(wi,{placeholder:"Select an inviter..."})}),s.jsx(bi,{children:z.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),_(""),T("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:kn,disabled:F,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[F?s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}):s.jsx(Ip,{className:"w-4 h-4 mr-2"}),F?"Sending...":"Send Invitation"]})]})]})}),M&&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:()=>{L(!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:P.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:()=>{L(!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"})]})]})}),U&&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:()=>{V(!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:P.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:()=>{V(!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"})]})]})}),I&&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:()=>O(!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:()=>O(!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"})]})]})}),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 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:B,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:B?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:B,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),[j,x]=p.useState(!1),[v,g]=p.useState(null),[b,N]=p.useState([]),[k,S]=p.useState(!1);p.useEffect(()=>{M()},[]);const M=async()=>{try{const T=await(await fetch("/api/sessions")).json();t(T.sessions||[])}catch(C){console.error("Failed to fetch sessions:",C)}finally{r(!1)}},L=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${C} sessions...`,timestamp:new Date}]);try{const z=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if(z.success){const R=z.results.map((D,F)=>D.success?{id:`session-${F}`,type:"progress",message:`Creating session: ${D.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${F}`,type:"error",message:`Failed to create session ${F+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const P=z.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${P}/${C} sessions successfully`,timestamp:new Date}]),await M()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${z.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(z=>[...z,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}},U=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting account seeding process for ${C} accounts...`,timestamp:new Date}]);try{const z=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if(z.success){const R=z.results.map((D,F)=>D.success?{id:`account-${F}`,type:"progress",message:`Creating account: ${D.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${F}`,type:"error",message:`Failed to create account ${F+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const P=z.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${P}/${C} accounts successfully`,timestamp:new Date}]),await M()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${z.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(z=>[...z,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}},V=C=>{g(C),y(!0)},I=C=>{g(C),u(!0)},O=C=>{g(C),m(!0)},E=async C=>{console.log("Creating session:",C),d(!1)},$=async C=>{console.log("Updating session:",C),u(!1)},A=async()=>{console.log("Deleting session:",v==null?void 0:v.id),m(!1)},_=e.filter(C=>{const T=C.id.toLowerCase().includes(i.toLowerCase())||C.userId.toLowerCase().includes(i.toLowerCase()),z=a==="all"||a==="active"&&new Date(C.expiresAt)>new Date||a==="expired"&&new Date(C.expiresAt)<=new Date;return T&&z});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:_.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:()=>V(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:()=>I(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:()=>O(C),children:s.jsx(os,{className:"w-4 h-4"})})]})})]},C.id))})]})})}),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 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 T;const C=parseInt(((T=document.getElementById("session-count"))==null?void 0:T.value)||"5");L(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 T;const C=parseInt(((T=document.getElementById("account-count"))==null?void 0:T.value)||"5");U(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"]})})]})]}),b.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:b,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:()=>$({}),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,j,x,v,g,b,N,k,S,M,L,U,V,I,O,E,$,A,_,C,T,z,R,P,D,F,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 B=await(await fetch("/api/config")).json();(W=B.studio)!=null&&W.version&&d(`v${B.studio.version}`),t(B)}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(Hy,{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)&&((j=e==null?void 0:e.database)==null?void 0:j.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})})]}),((b=e==null?void 0:e.database)==null?void 0:b.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:(M=e==null?void 0:e.emailAndPassword)!=null&&M.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:(L=e==null?void 0:e.emailAndPassword)!=null&&L.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:[((U=e==null?void 0:e.emailAndPassword)==null?void 0:U.minPasswordLength)||8," -"," ",((V=e==null?void 0:e.emailAndPassword)==null?void 0:V.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:(I=e==null?void 0:e.emailAndPassword)!=null&&I.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:(O=e==null?void 0:e.session)!=null&&O.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:($=e==null?void 0:e.session)!=null&&$.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:(_=e==null?void 0:e.rateLimit)!=null&&_.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:((T=e==null?void 0:e.rateLimit)==null?void 0:T.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:((z=e==null?void 0:e.rateLimit)==null?void 0:z.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:(P=e==null?void 0:e.advanced)!=null&&P.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:(F=(D=e==null?void 0:e.advanced)==null?void 0:D.ipAddress)!=null&&F.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(Xk,{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 pg(){var $,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(""),[j,x]=p.useState([]),[v,g]=p.useState([]),[b,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(_){console.error("Failed to fetch team:",_),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(_){console.error("Failed to fetch team members:",_),X.error("Failed to load team members")}},M=async()=>{try{const C=await(await fetch("/api/users?limit=10000")).json(),T=i.map(R=>R.userId),z=(C.users||[]).filter(R=>!T.includes(R.id));x(z)}catch(_){console.error("Failed to fetch available users:",_),X.error("Failed to load users")}},L=async()=>{if(!b.name){X.error("Please enter a team name");return}const _=X.loading("Updating team...");try{const T=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name})})).json();T.success?(await k(),m(!1),X.success("Team updated successfully!",{id:_})):X.error(`Error updating team: ${T.error||"Unknown error"}`,{id:_})}catch(C){console.error("Error updating team:",C),X.error("Error updating team",{id:_})}},U=async()=>{if(v.length===0){X.error("Please select at least one user");return}const _=X.loading(`Adding ${v.length} members...`);try{const T=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:v})})).json();T.success?(await S(),u(!1),g([]),y(""),X.success(`Successfully added ${v.length} members!`,{id:_})):X.error(`Error adding members: ${T.error||"Unknown error"}`,{id:_})}catch(C){console.error("Error adding members:",C),X.error("Error adding members",{id:_})}},V=async(_,C)=>{const T=X.loading(`Removing ${C}...`);try{const R=await(await fetch(`/api/team-members/${_}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();R.success?(await S(),X.success(`${C} removed from team!`,{id:T})):X.error(`Error removing member: ${R.error||"Unknown error"}`,{id:T})}catch(z){console.error("Error removing team member:",z),X.error("Error removing team member",{id:T})}},I=()=>{M(),u(!0)},O=_=>{g(C=>C.includes(_)?C.filter(T=>T!==_):[...C,_])},E=j.filter(_=>_.name.toLowerCase().includes(w.toLowerCase())||_.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:I,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:(($=n.organization)==null?void 0:$.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(_=>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:_.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.user.id}`,alt:_.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:_.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",_.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:_.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:_.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(_.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:()=>V(_.id,_.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},_.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:I,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:_=>y(_.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(_=>s.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${v.includes(_.id)?"bg-blue-900/20":""}`,onClick:()=>O(_.id),children:[s.jsx("input",{type:"checkbox",checked:v.includes(_.id),onChange:()=>O(_.id),className:"rounded border-gray-300"}),s.jsx("img",{src:_.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.id}`,alt:_.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:_.name}),s.jsx("div",{className:"text-sm text-gray-400",children:_.email})]})]},_.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:U,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:b.name,onChange:_=>N({name:_.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:L,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(M=>M.id==="teams");a({enabled:!!S,availablePlugins:(k==null?void 0:k.plugins).map(M=>M.id),configPath:k.configPath,teamsPlugin:(k==null?void 0:k.plugins).find(M=>M.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)}},j=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 M=new Date;return M.setDate(M.getDate()-7),k&&new Date(N.createdAt)>M}return k}),x=u*m,v=x-m,g=j.slice(v,x),b=Math.ceil(j.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:[j.length," team",j.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)})}),b>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 ",b]}),s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.min(b,u+1)),disabled:u===b,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),[j,x]=p.useState(!1),[v,g]=p.useState(!1),[b,N]=p.useState([]),[k,S]=p.useState(!1),[M,L]=p.useState({});p.useEffect(()=>{e&&(O(),E())},[e]);const U=async R=>{try{const P=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:R})});if(P.ok){const D=await P.json();if(D.success&&D.location)return D.location}return null}catch(P){return console.error("Failed to resolve IP location:",P),null}},V=async R=>{const P=R.map(async H=>{if(!M[H.id]){const W=await U(H.ipAddress);if(W)return{sessionId:H.id,location:W}}return null}),D=await Promise.all(P),F={};D.forEach(H=>{H&&(F[H.sessionId]=H.location)}),Object.keys(F).length>0&&L(H=>({...H,...F}))},I=R=>{if(!R)return"🌍";const P=R.toUpperCase().split("").map(D=>127397+D.charCodeAt(0));return String.fromCodePoint(...P)},O=async()=>{try{const R=await fetch(`/api/users/${e}`);if(R.ok){const P=await R.json();r(P.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,P,D]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(R.ok){const F=await R.json();o(F.memberships||[])}if(P.ok){const F=await P.json();l(F.memberships||[])}if(D.ok){const H=(await D.json()).sessions||[];d(H),V(H)}}catch(R){console.error("Failed to fetch user memberships:",R)}},$=async()=>{var F,H;if(!n)return;const R=(F=document.getElementById("edit-name"))==null?void 0:F.value,P=(H=document.getElementById("edit-email"))==null?void 0:H.value;if(!R||!P){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:P})})).json();G.success?(r({...n,name:R,email:P}),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(P){console.error("Error banning user:",P),X.error("Error banning user",{id:R})}},_=async R=>{const P=X.loading("Removing user from organization...");try{const F=await(await fetch(`/api/organizations/members/${R}`,{method:"DELETE"})).json();F.success?(o(H=>H.filter(W=>W.id!==R)),X.success("User removed from organization!",{id:P})):X.error(`Error removing user: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error removing user from organization:",D),X.error("Error removing user from organization",{id:P})}},C=async R=>{const P=X.loading("Removing user from team...");try{const F=await(await fetch(`/api/teams/members/${R}`,{method:"DELETE"})).json();F.success?(l(H=>H.filter(W=>W.id!==R)),X.success("User removed from team!",{id:P})):X.error(`Error removing user: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error removing user from team:",D),X.error("Error removing user from team",{id:P})}},T=async R=>{const P=X.loading("Deleting session...");try{const F=await(await fetch(`/api/sessions/${R}`,{method:"DELETE"})).json();F.success?(d(H=>H.filter(W=>W.id!==R)),X.success("Session deleted successfully!",{id:P})):X.error(`Error deleting session: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error deleting session:",D),X.error("Error deleting session",{id:P})}},z=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 F=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,...F]);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(F=>[...F,{id:"error",type:"error",message:`❌ Session seeding failed: ${D.error||"Unknown error"}`,timestamp:new Date}])}catch(P){N(D=>[...D,{id:"error",type:"error",message:`❌ Network error: ${P}`,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:()=>_(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 P,D,F,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(tS,{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:[((P=M[R.id])==null?void 0:P.city)||"...",","," ",((D=M[R.id])==null?void 0:D.country)||"..."]}),((F=M[R.id])==null?void 0:F.countryCode)&&s.jsx("span",{className:"text-sm ml-1",children:I((H=M[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:()=>T(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:$,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),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 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."})]})]}),b.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:b,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 P;const R=parseInt(((P=document.getElementById("session-count"))==null?void 0:P.value)||"3");z(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(iS,{children:s.jsxs(mk,{children:[s.jsx(K4,{children:s.jsxs(ak,{children:[s.jsx(Gt,{path:"/",element:s.jsx(Q4,{})}),s.jsx(Gt,{path:"/users",element:s.jsx(Lv,{})}),s.jsx(Gt,{path:"/users/:userId",element:s.jsx(jD,{})}),s.jsx(Gt,{path:"/organizations",element:s.jsx($v,{})}),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(pg,{})}),s.jsx(Gt,{path:"/organizations/:orgId/teams/:teamId",element:s.jsx(pg,{})}),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(Hk,{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${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_b.displayName="MiniMap";const hA=p.memo(_b),mA=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,pA={[_i.Line]:"right",[_i.Handle]:"bottom-right"};function xA({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:j,onResizeEnd:x}){const v=ob(),g=typeof e=="string"?e:v,b=Oe(),N=p.useRef(null),k=n===_i.Handle,S=ye(p.useCallback(mA(k&&m),[k,m]),He),M=p.useRef(null),L=t??pA[n];p.useEffect(()=>{if(!(!N.current||!g))return M.current||(M.current=PP({domNode:N.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:V,transform:I,snapGrid:O,snapToGrid:E,nodeOrigin:$,domNode:A}=b.getState();return{nodeLookup:V,transform:I,snapGrid:O,snapToGrid:E,nodeOrigin:$,paneDomNode:A}},onChange:(V,I)=>{const{triggerNodeChanges:O,nodeLookup:E,parentLookup:$,nodeOrigin:A}=b.getState(),_=[],C={x:V.x,y:V.y},T=E.get(g);if(T&&T.expandParent&&T.parentId){const z=T.origin??A,R=V.width??T.measured.width??0,P=V.height??T.measured.height??0,D={id:T.id,parentId:T.parentId,rect:{width:R,height:P,...Sw({x:V.x??T.position.x,y:V.y??T.position.y},{width:R,height:P},T.parentId,E,z)}},F=Yh([D],E,$,A);_.push(...F),C.x=V.x?Math.max(z[0]*R,V.x):void 0,C.y=V.y?Math.max(z[1]*P,V.y):void 0}if(C.x!==void 0&&C.y!==void 0){const z={id:g,type:"position",position:{...C}};_.push(z)}if(V.width!==void 0&&V.height!==void 0){const R={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:V.width,height:V.height}};_.push(R)}for(const z of I){const R={...z,type:"position"};_.push(R)}O(_)},onEnd:({width:V,height:I})=>{const O={id:g,type:"dimensions",resizing:!1,dimensions:{width:V,height:I}};b.getState().triggerNodeChanges([O])}})),M.current.update({controlPosition:L,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:h,onResizeStart:y,onResize:j,onResizeEnd:x,shouldResize:w}),()=>{var V;(V=M.current)==null||V.destroy()}},[L,l,c,d,f,u,y,j,x,w]);const U=L.split("-");return s.jsx("div",{className:Je(["react-flow__resize-control","nodrag",...U,n,r]),ref:N,style:{...i,scale:S,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:o})}p.memo(xA);const gA=["top","right","bottom","left"],Br=Math.min,Lt=Math.max,ic=Math.round,Za=Math.floor,$n=e=>({x:e,y:e}),yA={left:"right",right:"left",bottom:"top",top:"bottom"},vA={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 wA=new Set(["top","bottom"]);function An(e){return wA.has(ar(e))?"y":"x"}function Qh(e){return Kh(An(e))}function bA(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 jA(e){const t=oc(e);return[vf(e),t,vf(t)]}function vf(e){return e.replace(/start|end/g,t=>vA[t])}const sg=["left","right"],ig=["right","left"],NA=["top","bottom"],kA=["bottom","top"];function SA(e,t,n){switch(e){case"top":case"bottom":return n?t?ig:sg:t?sg:ig;case"left":case"right":return t?NA:kA;default:return[]}}function CA(e,t,n,r){const i=Li(e);let o=SA(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=>yA[t])}function EA(e){return{top:0,right:0,bottom:0,left:0,...e}}function Pb(e){return typeof e!="number"?EA(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 _A=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:j,fn:x}=l[y],{x:v,y:g,data:b,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,[j]:{...m[j],...b}},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=Pb(m),j=l[h?u==="floating"?"reference":"floating":u],x=ac(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(j)))==null||n?j:j.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)),b=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)/b.y,bottom:(N.bottom-x.bottom+w.bottom)/b.y,left:(x.left-N.left+w.left)/b.x,right:(N.right-x.right+w.right)/b.x}}const PA=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=Pb(f),h={x:n,y:r},m=Qh(i),w=qh(m),y=await a.getDimensions(d),j=m==="y",x=j?"top":"left",v=j?"bottom":"right",g=j?"clientHeight":"clientWidth",b=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 M=b/2-N/2,L=S/2-y[w]/2-1,U=Br(u[x],L),V=Br(u[v],L),I=U,O=S-y[w]-V,E=S/2-y[w]/2+M,$=yf(I,E,O),A=!c.arrow&&Li(i)!=null&&E!==$&&o.reference[w]/2-(E<I?U:V)-y[w]/2<0,_=A?E<I?E-I:E-O:0;return{[m]:h[m]+_,data:{[m]:$,centerOffset:E-$-_,...A&&{alignmentOffset:_}},reset:A}}}),TA=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,...j}=or(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const x=ar(i),v=An(l),g=ar(l)===l,b=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=h||(g||!y?[oc(l)]:jA(l)),k=w!=="none";!h&&k&&N.push(...CA(l,y,w,b));const S=[l,...N],M=await qo(t,j),L=[];let U=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&L.push(M[x]),u){const E=bA(i,a,b);L.push(M[E[0]],M[E[1]])}if(U=[...U,{placement:i,overflows:L}],!L.every(E=>E<=0)){var V,I;const E=(((V=o.flip)==null?void 0:V.index)||0)+1,$=S[E];if($&&(!(u==="alignment"?v!==An($):!1)||U.every(C=>An(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:E,overflows:U},reset:{placement:$}};let A=(I=U.filter(_=>_.overflows[0]<=0).sort((_,C)=>_.overflows[1]-C.overflows[1])[0])==null?void 0:I.placement;if(!A)switch(m){case"bestFit":{var O;const _=(O=U.filter(C=>{if(k){const T=An(C.placement);return T===v||T==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(T=>T>0).reduce((T,z)=>T+z,0)]).sort((C,T)=>C[1]-T[1])[0])==null?void 0:O[0];_&&(A=_);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 gA.some(t=>e[t]>=0)}const MA=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{}}}}},Tb=new Set(["left","top"]);async function AA(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=Tb.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 RA=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 AA(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}}}}},DA=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:j=>{let{x,y:v}=j;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 j=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+f[j],g=m-f[x];m=yf(v,m,g)}if(a){const j=u==="y"?"top":"left",x=u==="y"?"bottom":"right",v=w+f[j],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}}}}}},IA=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),j=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const g=h==="y"?"height":"width",b=o.reference[h]-o.floating[g]+j.mainAxis,N=o.reference[h]+o.reference[g]-j.mainAxis;m<b?m=b:m>N&&(m=N)}if(d){var x,v;const g=h==="y"?"width":"height",b=Tb.has(ar(i)),N=o.reference[u]-o.floating[g]+(b&&((x=a.offset)==null?void 0:x[u])||0)+(b?0:j.crossAxis),k=o.reference[u]+o.reference[g]+(b?0:((v=a.offset)==null?void 0:v[u])||0)-(b?j.crossAxis:0);w<N?w=N:w>k&&(w=k)}return{[h]:m,[u]:w}}}},zA=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 j,x;u==="top"||u==="bottom"?(j=u,x=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=u,j=h==="end"?"top":"bottom");const v=y-f.top-f.bottom,g=w-f.left-f.right,b=Br(y-f[j],v),N=Br(w-f[x],g),k=!t.middlewareData.shift;let S=b,M=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=g),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=v),k&&!h){const U=Lt(f.left,0),V=Lt(f.right,0),I=Lt(f.top,0),O=Lt(f.bottom,0);m?M=w-2*(U!==0||V!==0?U+V:Lt(f.left,f.right)):S=y-2*(I!==0||O!==0?I+O:Lt(f.top,f.bottom))}await c({...t,availableWidth:M,availableHeight:S});const L=await a.getDimensions(l.floating);return w!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function Hc(){return typeof window<"u"}function Oi(e){return Mb(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=(Mb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mb(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 $A=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)&&!$A.has(i)}const LA=new Set(["table","td","th"]);function OA(e){return LA.has(Oi(e))}const FA=[":popover-open",":modal"];function Wc(e){return FA.some(t=>{try{return e.matches(t)}catch{return!1}})}const BA=["transform","translate","scale","rotate","perspective"],UA=["transform","translate","scale","rotate","perspective","filter"],VA=["paint","layout","strict","content"];function Zh(e){const t=Jh(),n=vn(e)?wn(e):e;return BA.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)||UA.some(r=>(n.willChange||"").includes(r))||VA.some(r=>(n.contain||"").includes(r))}function HA(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 WA=new Set(["html","body","#document"]);function Ti(e){return WA.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 Ab(e){const t=Ur(e);return Ti(t)?e.ownerDocument?e.ownerDocument.body:e.body:On(t)&&pa(t)?t:Ab(t)}function Qo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Ab(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 Rb(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}=Rb(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 YA=$n(0);function Db(e){const t=Ut(e);return!Jh()||!t.visualViewport?YA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function XA(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=XA(o,n,r)?Db(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 j=li(y),x=y.getBoundingClientRect(),v=wn(y),g=x.left+(y.clientLeft+parseFloat(v.paddingLeft))*j.x,b=x.top+(y.clientTop+parseFloat(v.paddingTop))*j.y;c*=j.x,d*=j.y,f*=j.x,u*=j.y,c+=g,d+=b,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 Ib(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 GA(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?Ib(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 KA(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 QA(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 ZA=new Set(["absolute","fixed"]);function JA(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=QA(e,n);else if(t==="document")r=qA(Bn(e));else if(vn(t))r=JA(t,n);else{const i=Db(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ac(r)}function zb(e,t){const n=Ur(e);return n===t||!vn(n)||Ti(n)?!1:wn(n).position==="fixed"||zb(n,t)}function eR(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&&ZA.has(i.position)||pa(a)&&!c&&zb(e,a))?r=r.filter(f=>f!==a):i=l,a=Ur(a)}return t.set(e,r),r}function tR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Wc(t)?[]:eR(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 nR(e){const{width:t,height:n}=Rb(e);return{width:t,height:n}}function rR(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?Ib(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 $b(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&&OA(r)&&Kd(r);)r=fg(r,t);return r&&Ti(r)&&Kd(r)&&!Zh(r)?n:r||HA(e)||n}const sR=async function(e){const t=this.getOffsetParent||$b,n=this.getDimensions,r=await n(e.floating);return{reference:rR(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function iR(e){return wn(e).direction==="rtl"}const oR={convertOffsetParentRelativeRectToViewportRelativeRect:GA,getDocumentElement:Bn,getClippingRect:tR,getOffsetParent:$b,getElementRects:sR,getClientRects:KA,getDimensions:nR,getScale:li,isElement:vn,isRTL:iR};function Lb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function aR(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)),j=Za(i.clientHeight-(u+m)),x=Za(f),g={rootMargin:-w+"px "+-y+"px "+-j+"px "+-x+"px",threshold:Lt(0,Br(1,c))||1};let b=!0;function N(k){const S=k[0].intersectionRatio;if(S!==c){if(!b)return a();S?a(!1,S):r=setTimeout(()=>{a(!1,1e-7)},1e3)}S===1&&!Lb(d,e.getBoundingClientRect())&&a(),b=!1}try{n=new IntersectionObserver(N,{...g,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,g)}n.observe(e)}return a(!0),o}function lR(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?aR(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&&j();function j(){const x=js(e);y&&!Lb(y,x)&&n(),y=x,w=requestAnimationFrame(j)}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 cR=RA,dR=DA,uR=TA,fR=zA,hR=MA,hg=PA,mR=IA,pR=(e,t,n)=>{const r=new Map,i={platform:oR,...n},o={...i.platform,_c:r};return _A(e,t,{...i,platform:o})};var xR=typeof document<"u",gR=function(){},vl=xR?p.useLayoutEffect:gR;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 Ob(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mg(e,t){const n=Ob(e);return Math.round(t*n)/n}function qd(e){const t=p.useRef(e);return vl(()=>{t.current=e}),t}function yR(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),[j,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))},[]),b=o||w,N=a||j,k=p.useRef(null),S=p.useRef(null),M=p.useRef(f),L=c!=null,U=qd(c),V=qd(i),I=qd(d),O=p.useCallback(()=>{if(!k.current||!S.current)return;const C={placement:t,strategy:n,middleware:h};V.current&&(C.platform=V.current),pR(k.current,S.current,C).then(T=>{const z={...T,isPositioned:I.current!==!1};E.current&&!lc(M.current,z)&&(M.current=z,Sc.flushSync(()=>{u(z)}))})},[h,t,n,V,I]);vl(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,u(C=>({...C,isPositioned:!1})))},[d]);const E=p.useRef(!1);vl(()=>(E.current=!0,()=>{E.current=!1}),[]),vl(()=>{if(b&&(k.current=b),N&&(S.current=N),b&&N){if(U.current)return U.current(b,N,O);O()}},[b,N,O,U,L]);const $=p.useMemo(()=>({reference:k,floating:S,setReference:v,setFloating:g}),[v,g]),A=p.useMemo(()=>({reference:b,floating:N}),[b,N]),_=p.useMemo(()=>{const C={position:n,left:0,top:0};if(!A.floating)return C;const T=mg(A.floating,f.x),z=mg(A.floating,f.y);return l?{...C,transform:"translate("+T+"px, "+z+"px)",...Ob(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:z}},[n,l,A.floating,f.x,f.y]);return p.useMemo(()=>({...f,update:O,refs:$,elements:A,floatingStyles:_}),[f,O,$,A,_])}const vR=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):{}}}},wR=(e,t)=>({...cR(e),options:[e,t]}),bR=(e,t)=>({...dR(e),options:[e,t]}),jR=(e,t)=>({...mR(e),options:[e,t]}),NR=(e,t)=>({...uR(e),options:[e,t]}),kR=(e,t)=>({...fR(e),options:[e,t]}),SR=(e,t)=>({...hR(e),options:[e,t]}),CR=(e,t)=>({...vR(e),options:[e,t]});var ER="Arrow",Fb=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"})})});Fb.displayName=ER;var _R=Fb;function Bb(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",[Ub,Vb]=Ec(tm),[PR,Hb]=Ub(tm),Wb=e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null);return s.jsx(PR,{scope:t,anchor:r,onAnchorChange:i,children:n})};Wb.displayName=tm;var Yb="PopperAnchor",Xb=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=Hb(Yb,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})});Xb.displayName=Yb;var nm="PopperContent",[TR,MR]=Ub(nm),Gb=p.forwardRef((e,t)=>{var G,B,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,j=Hb(nm,n),[x,v]=p.useState(null),g=Xt(t,ee=>v(ee)),[b,N]=p.useState(null),k=Bb(b),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,L=r+(o!=="center"?"-"+o:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},V=Array.isArray(d)?d:[d],I=V.length>0,O={padding:U,boundary:V.filter(RR),altBoundary:I},{refs:E,floatingStyles:$,placement:A,isPositioned:_,middlewareData:C}=yR({strategy:"fixed",placement:L,whileElementsMounted:(...ee)=>lR(...ee,{animationFrame:m==="always"}),elements:{reference:j.anchor},middleware:[wR({mainAxis:i+M,alignmentAxis:a}),c&&bR({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?jR():void 0,...O}),c&&NR({...O}),kR({...O,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`)}}),b&&CR({element:b,padding:l}),DR({arrowWidth:S,arrowHeight:M}),h&&SR({strategy:"referenceHidden",...O})]}),[T,z]=Qb(A),R=xi(w);Or(()=>{_&&(R==null||R())},[_,R]);const P=(G=C.arrow)==null?void 0:G.x,D=(B=C.arrow)==null?void 0:B.y,F=((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:{...$,transform:_?$.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(TR,{scope:n,placedSide:T,onArrowChange:N,arrowX:P,arrowY:D,shouldHideArrow:F,children:s.jsx(ze.div,{"data-side":T,"data-align":z,...y,ref:g,style:{...y.style,animation:_?void 0:"none"}})})})});Gb.displayName=nm;var Kb="PopperArrow",AR={top:"bottom",right:"left",bottom:"top",left:"right"},qb=p.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=MR(Kb,r),a=AR[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(_R,{...i,ref:n,style:{...i.style,display:"block"}})})});qb.displayName=Kb;function RR(e){return e!==null}var DR=e=>({name:"transformOrigin",options:e,fn(t){var j,x,v;const{placement:n,rects:r,middlewareData:i}=t,a=((j=i.arrow)==null?void 0:j.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,f]=Qb(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 Qb(e){const[t,n="center"]=e.split("-");return[t,n]}var IR=Wb,zR=Xb,$R=Gb,LR=qb,OR=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"}),FR="VisuallyHidden",Zb=p.forwardRef((e,t)=>s.jsx(ze.span,{...e,ref:t,style:{...OR,...e.style}}));Zb.displayName=FR;var BR=Zb,[Gc]=Ec("Tooltip",[Vb]),Kc=Vb(),Jb="TooltipProvider",UR=700,bf="tooltip.open",[VR,rm]=Gc(Jb),e1=e=>{const{__scopeTooltip:t,delayDuration:n=UR,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(VR,{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})};e1.displayName=Jb;var Zo="Tooltip",[HR,qc]=Gc(Zo),t1=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,j=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?j.current?"delayed-open":"instant-open":"closed",[x]),b=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j.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(()=>{j.current=!0,v(!0),m.current=0},y)},[y,v]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(IR,{...d,children:s.jsx(HR,{scope:t,contentId:h,open:x,stateAttribute:g,trigger:f,onTriggerChange:u,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?k():b()},[c.isOpenDelayedRef,k,b]),onTriggerLeave:p.useCallback(()=>{w?N():(window.clearTimeout(m.current),m.current=0)},[N,w]),onOpen:b,onClose:N,disableHoverableContent:w,children:n})})};t1.displayName=Zo;var jf="TooltipTrigger",n1=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(zR,{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)})})});n1.displayName=jf;var WR="TooltipPortal",[SD,YR]=Gc(WR,{forceMount:void 0}),Mi="TooltipContent",r1=p.forwardRef((e,t)=>{const n=YR(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(s1,{side:i,...o,ref:t}):s.jsx(XR,{side:i,...o,ref:t})})}),XR=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 j=w.currentTarget,x={x:w.clientX,y:w.clientY},v=ZR(x,j.getBoundingClientRect()),g=JR(x,v),b=eD(y.getBoundingClientRect()),N=nD([...g,...b]);l(N),u(!0)},[u]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&f){const w=j=>m(j,f),y=j=>m(j,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 j=y.target,x={x:y.clientX,y:y.clientY},v=(c==null?void 0:c.contains(j))||(f==null?void 0:f.contains(j)),g=!tD(x,a);v?h():g&&(h(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,f,a,d,h]),s.jsx(s1,{...e,ref:o})}),[GR,KR]=Gc(Zo,{isInside:!1}),qR=kS("TooltipContent"),s1=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($R,{"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(GR,{scope:n,isInside:!0,children:s.jsx(BR,{id:c.contentId,role:"tooltip",children:i||r})})]})})});r1.displayName=Mi;var i1="TooltipArrow",QR=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Kc(n);return KR(i1,n).isInside?null:s.jsx(LR,{...i,...r,ref:t})});QR.displayName=i1;function ZR(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 JR(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 eD(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 tD(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 nD(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),rD(t)}function rD(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 sD=e1,iD=t1,oD=n1,o1=r1;const Qd=sD,Zd=iD,Jd=oD,wl=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(o1,{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=o1.displayName;const aD=420,lD=({data:e,targetPosition:t,sourcePosition:n})=>{const r=e,i="!h-px !w-px !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-[0.5px] border-gray-300 dark:border-gray-600 overflow-hidden shadow-sm bg-black"),style:{width:aD/2},id:`${r.name}-table-node`,children:[s.jsx("header",{className:rt("text-[0.55rem] pl-2 pr-1 bg-gray-800 text-white flex items-center justify-between border-b border-gray-600",o),children:s.jsxs("div",{className:"flex items-center gap-x-1",children:[s.jsx(rS,{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-black","border-t","border-t-gray-600","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(Hy,{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(Zk,{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(Jk,{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-white",children:a.name}),s.jsx("span",{className:"font-mono 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-500 text-[0.4rem] mt-[1px]",children:a.plugin})]}),t&&s.jsx(cs,{type:"target",id:a.id,position:t,className:rt(i,"!left-0")}),n&&s.jsx(cs,{type:"source",id:a.id,position:n,className:rt(i,"!right-0")})]},a.id))]})})};function cD(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",[dD]=Ec(Qc),[uD,sm]=dD(Qc);function fD(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),[j,x]=p.useState(null),v=p.useRef(!1),g=w?!!a||!!w.closest("form"):!0,b={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:j,setBubbleInput:x};return s.jsx(uD,{scope:t,...b,children:hD(u)?u(b):r})}var a1="CheckboxTrigger",l1=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(a1,e),y=Xt(i,f),j=p.useRef(c);return p.useEffect(()=>{const x=o==null?void 0:o.form;if(x){const v=()=>u(j.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":h1(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())})})});l1.displayName=a1;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(fD,{__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(l1,{...u,ref:t,__scopeCheckbox:n}),h&&s.jsx(f1,{__scopeCheckbox:n})]})})});im.displayName=Qc;var c1="CheckboxIndicator",d1=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=sm(c1,n);return s.jsx(zi,{present:r||Ir(o.checked)||o.checked===!0,children:s.jsx(ze.span,{"data-state":h1(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});d1.displayName=c1;var u1="CheckboxBubbleInput",f1=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(u1,e),w=Xt(n,m),y=cD(o),j=Bb(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,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});f1.displayName=u1;function hD(e){return typeof e=="function"}function Ir(e){return e==="indeterminate"}function h1(e){return Ir(e)?"indeterminate":e?"checked":"unchecked"}const m1=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(d1,{className:rt("flex items-center justify-center text-current"),children:s.jsx(By,{className:"h-4 w-4"})})}));m1.displayName=im.displayName;const mD={tableNode:lD},pD=[{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(["organization"]),[c,d]=p.useState(!0),[f,u,h]=BM([]),[m,w,y]=UM([]),j=p.useCallback(async b=>{try{r(!0);const N=b.length>0?`?plugins=${b.join(",")}`:"",S=await(await fetch(`/api/database/schema${N}`)).json();S.success?t(S.schema):o(S.error||"Failed to fetch schema")}catch(N){o("Failed to fetch database schema"),console.error("Error fetching schema:",N)}finally{r(!1)}},[]);p.useEffect(()=>{j(a)},[a,j]),p.useEffect(()=>{if(!e)return;const b=[],N=[];e.tables.forEach((k,S)=>{const M=k.fields.map(L=>({id:`${k.name}-${L.name}`,isPrimary:L.primaryKey||!1,isNullable:!L.required,isUnique:L.unique||!1,isIdentity:!1,name:L.name,format:L.type,plugin:x(k.name,L.name,a)}));b.push({id:k.name,type:"tableNode",position:{x:S%3*250,y:Math.floor(S/3)*200},data:{name:k.name,isForeign:!1,columns:M}})}),e.tables.forEach(k=>{k.relationships.forEach(S=>{const M=k.name,L=S.target,U=b.find(I=>I.id===M),V=b.find(I=>I.id===L);U&&V&&N.push({id:`${M}-${L}-${S.field}`,source:M,target:L,type:"smoothstep",animated:!1,style:{stroke:"#000000",strokeWidth:3},label:`${S.field}: ${S.type.replace("-"," → ")}`,labelStyle:{fontSize:"10px",fill:"#000000",fontWeight:"bold"},labelBgStyle:{fill:"rgba(255, 255, 255, 0.8)",fillOpacity:.9},markerEnd:{type:"arrowclosed",color:"#000000"}})})}),u(b),w(N)},[e,a]);const x=(b,N,k)=>{if(b==="user"||b==="session"||b==="account"||b==="verification")return"core";for(const S of k)if(b===S||b.includes(S))return S;return"core"},v=p.useCallback(b=>w(N=>Aw(b,N)),[w]),g=(b,N)=>{l(N?k=>[...k,b]:k=>k.filter(S=>S!==b))};return n?s.jsx("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"})]})}):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 bg-white dark:bg-black",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:()=>d(!c),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:[c?s.jsx(Qk,{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:pD.map(b=>s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx(m1,{id:b.name,checked:a.includes(b.name),onCheckedChange:N=>g(b.name,N)}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{htmlFor:b.name,className:"text-sm font-medium text-gray-900 dark:text-white cursor-pointer",children:b.displayName}),s.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:b.description})]}),s.jsx("div",{className:`w-3 h-3 rounded-full ${b.color}`})]},b.name))})]}),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((b,N)=>b+N.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:"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(FM,{nodes:f,edges:m,onNodesChange:h,onEdgesChange:y,onConnect:v,nodeTypes:mD,fitView:!0,fitViewOptions:{padding:.2},className:"bg-white dark:bg-black",defaultEdgeOptions:{style:{stroke:"#000000",strokeWidth:3},animated:!1,type:"smoothstep"},children:[s.jsx(eA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600"}),s.jsx(hA,{className:"bg-white dark:bg-black border-gray-200 dark:border-gray-600",nodeColor:b=>{var N;return(N=b.data)!=null&&N.isForeign?"#e5e7eb":"#f3f4f6"},maskColor:"rgba(255, 255, 255, 0.8)"}),s.jsx(XM,{variant:er.Dots,gap:20,size:1,color:"#000000"})]})})})]})]})}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),[j,x]=p.useState(!1),[v,g]=p.useState(!1),[b,N]=p.useState(!1),[k,S]=p.useState(!1),[M,L]=p.useState(!1),[U,V]=p.useState(!1),[I,O]=p.useState(!1),[E,$]=p.useState(null),[A,_]=p.useState(""),[C,T]=p.useState(""),[z,R]=p.useState([]),[P,D]=p.useState({name:""}),[F,H]=p.useState(!1),[W,G]=p.useState([]),[B,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),_(""),T(""),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(!P.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:P.name,organizationId:e})})).json();de.success?(await Ke(),L(!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||!P.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:P.name})})).json();de.success?(await Ke(),V(!1),$(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(),O(!1),$(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=>{$(K),D({name:K.name}),V(!0)},Xr=K=>{$(K),O(!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:()=>L(!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:()=>L(!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),_(""),T("")},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=>_(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:T,children:[s.jsx(vi,{children:s.jsx(wi,{placeholder:"Select an inviter..."})}),s.jsx(bi,{children:z.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),_(""),T("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),s.jsxs(Y,{onClick:kn,disabled:F,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[F?s.jsx(wt,{className:"w-3 h-3 mr-2 animate-spin"}):s.jsx(Ip,{className:"w-4 h-4 mr-2"}),F?"Sending...":"Send Invitation"]})]})]})}),M&&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:()=>{L(!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:P.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:()=>{L(!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"})]})]})}),U&&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:()=>{V(!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:P.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:()=>{V(!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"})]})]})}),I&&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:()=>O(!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:()=>O(!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"})]})]})}),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 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:B,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:B?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:B,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),[j,x]=p.useState(!1),[v,g]=p.useState(null),[b,N]=p.useState([]),[k,S]=p.useState(!1);p.useEffect(()=>{M()},[]);const M=async()=>{try{const T=await(await fetch("/api/sessions")).json();t(T.sessions||[])}catch(C){console.error("Failed to fetch sessions:",C)}finally{r(!1)}},L=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting session seeding process for ${C} sessions...`,timestamp:new Date}]);try{const z=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if(z.success){const R=z.results.map((D,F)=>D.success?{id:`session-${F}`,type:"progress",message:`Creating session: ${D.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${F}`,type:"error",message:`Failed to create session ${F+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const P=z.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${P}/${C} sessions successfully`,timestamp:new Date}]),await M()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${z.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(z=>[...z,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}},U=async C=>{N([]),S(!0),N([{id:"start",type:"info",message:`Starting account seeding process for ${C} accounts...`,timestamp:new Date}]);try{const z=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:C})})).json();if(z.success){const R=z.results.map((D,F)=>D.success?{id:`account-${F}`,type:"progress",message:`Creating account: ${D.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${F}`,type:"error",message:`Failed to create account ${F+1}: ${D.error}`,timestamp:new Date});N(D=>[...D,...R]);const P=z.results.filter(D=>D.success).length;N(D=>[...D,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${P}/${C} accounts successfully`,timestamp:new Date}]),await M()}else N(R=>[...R,{id:"error",type:"error",message:`❌ Seeding failed: ${z.error||"Unknown error"}`,timestamp:new Date}])}catch(T){N(z=>[...z,{id:"error",type:"error",message:`❌ Network error: ${T}`,timestamp:new Date}])}finally{S(!1)}},V=C=>{g(C),y(!0)},I=C=>{g(C),u(!0)},O=C=>{g(C),m(!0)},E=async C=>{console.log("Creating session:",C),d(!1)},$=async C=>{console.log("Updating session:",C),u(!1)},A=async()=>{console.log("Deleting session:",v==null?void 0:v.id),m(!1)},_=e.filter(C=>{const T=C.id.toLowerCase().includes(i.toLowerCase())||C.userId.toLowerCase().includes(i.toLowerCase()),z=a==="all"||a==="active"&&new Date(C.expiresAt)>new Date||a==="expired"&&new Date(C.expiresAt)<=new Date;return T&&z});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:_.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:()=>V(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:()=>I(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:()=>O(C),children:s.jsx(os,{className:"w-4 h-4"})})]})})]},C.id))})]})})}),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 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 T;const C=parseInt(((T=document.getElementById("session-count"))==null?void 0:T.value)||"5");L(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 T;const C=parseInt(((T=document.getElementById("account-count"))==null?void 0:T.value)||"5");U(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"]})})]})]}),b.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:b,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:()=>$({}),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,j,x,v,g,b,N,k,S,M,L,U,V,I,O,E,$,A,_,C,T,z,R,P,D,F,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 B=await(await fetch("/api/config")).json();(W=B.studio)!=null&&W.version&&d(`v${B.studio.version}`),t(B)}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(Hy,{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)&&((j=e==null?void 0:e.database)==null?void 0:j.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})})]}),((b=e==null?void 0:e.database)==null?void 0:b.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:(M=e==null?void 0:e.emailAndPassword)!=null&&M.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:(L=e==null?void 0:e.emailAndPassword)!=null&&L.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:[((U=e==null?void 0:e.emailAndPassword)==null?void 0:U.minPasswordLength)||8," -"," ",((V=e==null?void 0:e.emailAndPassword)==null?void 0:V.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:(I=e==null?void 0:e.emailAndPassword)!=null&&I.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:(O=e==null?void 0:e.session)!=null&&O.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:($=e==null?void 0:e.session)!=null&&$.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:(_=e==null?void 0:e.rateLimit)!=null&&_.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:((T=e==null?void 0:e.rateLimit)==null?void 0:T.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:((z=e==null?void 0:e.rateLimit)==null?void 0:z.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:(P=e==null?void 0:e.advanced)!=null&&P.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:(F=(D=e==null?void 0:e.advanced)==null?void 0:D.ipAddress)!=null&&F.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(Xk,{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 pg(){var $,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(""),[j,x]=p.useState([]),[v,g]=p.useState([]),[b,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(_){console.error("Failed to fetch team:",_),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(_){console.error("Failed to fetch team members:",_),X.error("Failed to load team members")}},M=async()=>{try{const C=await(await fetch("/api/users?limit=10000")).json(),T=i.map(R=>R.userId),z=(C.users||[]).filter(R=>!T.includes(R.id));x(z)}catch(_){console.error("Failed to fetch available users:",_),X.error("Failed to load users")}},L=async()=>{if(!b.name){X.error("Please enter a team name");return}const _=X.loading("Updating team...");try{const T=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name})})).json();T.success?(await k(),m(!1),X.success("Team updated successfully!",{id:_})):X.error(`Error updating team: ${T.error||"Unknown error"}`,{id:_})}catch(C){console.error("Error updating team:",C),X.error("Error updating team",{id:_})}},U=async()=>{if(v.length===0){X.error("Please select at least one user");return}const _=X.loading(`Adding ${v.length} members...`);try{const T=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:v})})).json();T.success?(await S(),u(!1),g([]),y(""),X.success(`Successfully added ${v.length} members!`,{id:_})):X.error(`Error adding members: ${T.error||"Unknown error"}`,{id:_})}catch(C){console.error("Error adding members:",C),X.error("Error adding members",{id:_})}},V=async(_,C)=>{const T=X.loading(`Removing ${C}...`);try{const R=await(await fetch(`/api/team-members/${_}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();R.success?(await S(),X.success(`${C} removed from team!`,{id:T})):X.error(`Error removing member: ${R.error||"Unknown error"}`,{id:T})}catch(z){console.error("Error removing team member:",z),X.error("Error removing team member",{id:T})}},I=()=>{M(),u(!0)},O=_=>{g(C=>C.includes(_)?C.filter(T=>T!==_):[...C,_])},E=j.filter(_=>_.name.toLowerCase().includes(w.toLowerCase())||_.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:I,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:(($=n.organization)==null?void 0:$.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(_=>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:_.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.user.id}`,alt:_.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:_.user.name}),s.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",_.user.id]})]})]})}),s.jsx("td",{className:"py-4 px-4 text-white",children:_.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:_.role})}),s.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(_.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:()=>V(_.id,_.user.name),children:[s.jsx(os,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},_.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:I,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:_=>y(_.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(_=>s.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${v.includes(_.id)?"bg-blue-900/20":""}`,onClick:()=>O(_.id),children:[s.jsx("input",{type:"checkbox",checked:v.includes(_.id),onChange:()=>O(_.id),className:"rounded border-gray-300"}),s.jsx("img",{src:_.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.id}`,alt:_.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:_.name}),s.jsx("div",{className:"text-sm text-gray-400",children:_.email})]})]},_.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:U,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:b.name,onChange:_=>N({name:_.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:L,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(M=>M.id==="teams");a({enabled:!!S,availablePlugins:(k==null?void 0:k.plugins).map(M=>M.id),configPath:k.configPath,teamsPlugin:(k==null?void 0:k.plugins).find(M=>M.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)}},j=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 M=new Date;return M.setDate(M.getDate()-7),k&&new Date(N.createdAt)>M}return k}),x=u*m,v=x-m,g=j.slice(v,x),b=Math.ceil(j.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:[j.length," team",j.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)})}),b>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 ",b]}),s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>h(Math.min(b,u+1)),disabled:u===b,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),[j,x]=p.useState(!1),[v,g]=p.useState(!1),[b,N]=p.useState([]),[k,S]=p.useState(!1),[M,L]=p.useState({});p.useEffect(()=>{e&&(O(),E())},[e]);const U=async R=>{try{const P=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:R})});if(P.ok){const D=await P.json();if(D.success&&D.location)return D.location}return null}catch(P){return console.error("Failed to resolve IP location:",P),null}},V=async R=>{const P=R.map(async H=>{if(!M[H.id]){const W=await U(H.ipAddress);if(W)return{sessionId:H.id,location:W}}return null}),D=await Promise.all(P),F={};D.forEach(H=>{H&&(F[H.sessionId]=H.location)}),Object.keys(F).length>0&&L(H=>({...H,...F}))},I=R=>{if(!R)return"🌍";const P=R.toUpperCase().split("").map(D=>127397+D.charCodeAt(0));return String.fromCodePoint(...P)},O=async()=>{try{const R=await fetch(`/api/users/${e}`);if(R.ok){const P=await R.json();r(P.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,P,D]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(R.ok){const F=await R.json();o(F.memberships||[])}if(P.ok){const F=await P.json();l(F.memberships||[])}if(D.ok){const H=(await D.json()).sessions||[];d(H),V(H)}}catch(R){console.error("Failed to fetch user memberships:",R)}},$=async()=>{var F,H;if(!n)return;const R=(F=document.getElementById("edit-name"))==null?void 0:F.value,P=(H=document.getElementById("edit-email"))==null?void 0:H.value;if(!R||!P){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:P})})).json();G.success?(r({...n,name:R,email:P}),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(P){console.error("Error banning user:",P),X.error("Error banning user",{id:R})}},_=async R=>{const P=X.loading("Removing user from organization...");try{const F=await(await fetch(`/api/organizations/members/${R}`,{method:"DELETE"})).json();F.success?(o(H=>H.filter(W=>W.id!==R)),X.success("User removed from organization!",{id:P})):X.error(`Error removing user: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error removing user from organization:",D),X.error("Error removing user from organization",{id:P})}},C=async R=>{const P=X.loading("Removing user from team...");try{const F=await(await fetch(`/api/teams/members/${R}`,{method:"DELETE"})).json();F.success?(l(H=>H.filter(W=>W.id!==R)),X.success("User removed from team!",{id:P})):X.error(`Error removing user: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error removing user from team:",D),X.error("Error removing user from team",{id:P})}},T=async R=>{const P=X.loading("Deleting session...");try{const F=await(await fetch(`/api/sessions/${R}`,{method:"DELETE"})).json();F.success?(d(H=>H.filter(W=>W.id!==R)),X.success("Session deleted successfully!",{id:P})):X.error(`Error deleting session: ${F.error||"Unknown error"}`,{id:P})}catch(D){console.error("Error deleting session:",D),X.error("Error deleting session",{id:P})}},z=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 F=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,...F]);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(F=>[...F,{id:"error",type:"error",message:`❌ Session seeding failed: ${D.error||"Unknown error"}`,timestamp:new Date}])}catch(P){N(D=>[...D,{id:"error",type:"error",message:`❌ Network error: ${P}`,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:()=>_(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 P,D,F,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(tS,{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:[((P=M[R.id])==null?void 0:P.city)||"...",","," ",((D=M[R.id])==null?void 0:D.country)||"..."]}),((F=M[R.id])==null?void 0:F.countryCode)&&s.jsx("span",{className:"text-sm ml-1",children:I((H=M[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:()=>T(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:$,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),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 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."})]})]}),b.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(gi,{title:"Session Seeding Terminal",lines:b,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 P;const R=parseInt(((P=document.getElementById("session-count"))==null?void 0:P.value)||"3");z(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(iS,{children:s.jsxs(mk,{children:[s.jsx(K4,{children:s.jsxs(ak,{children:[s.jsx(Gt,{path:"/",element:s.jsx(Q4,{})}),s.jsx(Gt,{path:"/users",element:s.jsx(Lv,{})}),s.jsx(Gt,{path:"/users/:userId",element:s.jsx(jD,{})}),s.jsx(Gt,{path:"/organizations",element:s.jsx($v,{})}),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(pg,{})}),s.jsx(Gt,{path:"/organizations/:orgId/teams/:teamId",element:s.jsx(pg,{})}),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(Hk,{theme:"dark",position:"top-right",richColors:!0,closeButton:!0})]})})}eu.createRoot(document.getElementById("root")).render(s.jsx(J.StrictMode,{children:s.jsx(ND,{})}));