better-auth-studio 1.0.72 → 1.0.74-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.
- package/README.md +32 -24
- package/dist/cli.js +0 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +8 -2
- package/dist/routes.js.map +1 -1
- package/package.json +26 -27
- package/public/assets/{main-Cp6rbsZT.js → main-aKKBakSP.js} +4 -4
- package/public/index.html +1 -1
- package/frontend/package.json +0 -64
|
@@ -94,7 +94,7 @@ Error generating stack: `+n.message+`
|
|
|
94
94
|
|
|
95
95
|
`,`
|
|
96
96
|
+`).split(`
|
|
97
|
-
`)),h=u.reduce((d,f)=>d.concat(...f),[]);return[u,h]}return[[],[]]},[e]);return p.useEffect(()=>{const c=(t==null?void 0:t.target)??aT,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=m=>{var N,b;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!u)&&aL(m))return!1;const x=sT(m.code,l);if(i.current.add(m[x]),rT(o,i.current,!1)){const v=((b=(N=m.composedPath)==null?void 0:N.call(m))==null?void 0:b[0])||m.target,g=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!g)&&m.preventDefault(),a(!0)}},d=m=>{const y=sT(m.code,l);rT(o,i.current,!0)?(a(!1),i.current.clear()):i.current.delete(m[y]),m.key==="Meta"&&i.current.clear(),s.current=!1},f=()=>{i.current.clear(),a(!1)};return c==null||c.addEventListener("keydown",h),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",h),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,a]),n}function rT(e,t,n){return e.filter(a=>n||a.length===t.size).some(a=>a.every(s=>t.has(s)))}function sT(e,t){return t.includes(e)?"code":"key"}const OG=()=>{const e=Vt();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:a}=e.getState();return a?a.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[a,s,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??a,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,a]=e.getState().transform;return{x:t,y:n,zoom:a}},setCenter:async(t,n,a)=>e.getState().setCenter(t,n,a),fitBounds:async(t,n)=>{const{width:a,height:s,minZoom:i,maxZoom:o,panZoom:l}=e.getState(),c=cS(t,a,s,i,o,(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:a,snapGrid:s,snapToGrid:i,domNode:o}=e.getState();if(!o)return t;const{x:l,y:c}=o.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},h=n.snapGrid??s,d=n.snapToGrid??i;return Ku(u,a,d,h)},flowToScreenPosition:t=>{const{transform:n,domNode:a}=e.getState();if(!a)return t;const{x:s,y:i}=a.getBoundingClientRect(),o=cp(t,n);return{x:o.x+s,y:o.y+i}}}),[])};function _L(e,t){const n=[],a=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")a.set(i.id,[i]);else{const o=a.get(i.id);o?o.push(i):a.set(i.id,[i])}for(const i of t){const o=a.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const l={...i};for(const c of o)DG(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function DG(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 RL(e,t){return _L(e,t)}function OL(e,t){return _L(e,t)}function po(e,t){return{id:e,type:"select",selected:t}}function Ll(e,t=new Set,n=!1){const a=[];for(const[s,i]of e){const o=t.has(s);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),a.push(po(i.id,o)))}return a}function iT({items:e=[],lookup:t}){var s;const n=[],a=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const l=t.get(o.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)a.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function oT(e){return{id:e.id,type:"remove"}}const lT=e=>q7(e),IG=e=>XM(e);function DL(e){return p.forwardRef(e)}const MG=typeof window<"u"?p.useLayoutEffect:p.useEffect;function cT(e){const[t,n]=p.useState(BigInt(0)),[a]=p.useState(()=>LG(()=>n(s=>s+BigInt(1))));return MG(()=>{const s=a.get();s.length&&(e(s),a.reset())},[t]),a}function LG(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const IL=p.createContext(null);function UG({children:e}){const t=Vt(),n=p.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:h,onNodesChange:d,nodeLookup:f,fitViewQueued:m}=t.getState();let y=c;for(const N of l)y=typeof N=="function"?N(y):N;const x=iT({items:y,lookup:f});h&&u(y),x.length>0?d==null||d(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:b,setNodes:v}=t.getState();N&&v(b)})},[]),a=cT(n),s=p.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:h,onEdgesChange:d,edgeLookup:f}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;h?u(m):d&&d(iT({items:m,lookup:f}))},[]),i=cT(s),o=p.useMemo(()=>({nodeQueue:a,edgeQueue:i}),[]);return r.jsx(IL.Provider,{value:o,children:e})}function PG(){const e=p.useContext(IL);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const FG=e=>!!e.panZoom;function mS(){const e=OG(),t=Vt(),n=PG(),a=gt(FG),s=p.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),o=d=>{n.nodeQueue.push(d)},l=d=>{n.edgeQueue.push(d)},c=d=>{var b,v;const{nodeLookup:f,nodeOrigin:m}=t.getState(),y=lT(d)?d:f.get(d.id),x=y.parentId?tL(y.position,y.measured,y.parentId,f,m):y.position,N={...y,position:x,width:((b=y.measured)==null?void 0:b.width)??y.width,height:((v=y.measured)==null?void 0:v.height)??y.height};return xc(N)},u=(d,f,m={replace:!1})=>{o(y=>y.map(x=>{if(x.id===d){const N=typeof f=="function"?f(x):f;return m.replace&&lT(N)?N:{...x,...N}}return x}))},h=(d,f,m={replace:!1})=>{l(y=>y.map(x=>{if(x.id===d){const N=typeof f=="function"?f(x):f;return m.replace&&IG(N)?N:{...x,...N}}return x}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:o,setEdges:l,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(m=>[...m,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(m=>[...m,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:m}=t.getState(),[y,x,N]=m;return{nodes:d.map(b=>({...b})),edges:f.map(b=>({...b})),viewport:{x:y,y:x,zoom:N}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:m,edges:y,onNodesDelete:x,onEdgesDelete:N,triggerNodeChanges:b,triggerEdgeChanges:v,onDelete:g,onBeforeDelete:w}=t.getState(),{nodes:S,edges:E}=await X7({nodesToRemove:d,edgesToRemove:f,nodes:m,edges:y,onBeforeDelete:w}),j=E.length>0,_=S.length>0;if(j){const M=E.map(oT);N==null||N(E),v(M)}if(_){const M=S.map(oT);x==null||x(S),b(M)}return(_||j)&&(g==null||g({nodes:S,edges:E})),{deletedNodes:S,deletedEdges:E}},getIntersectingNodes:(d,f=!0,m)=>{const y=Pj(d),x=y?d:c(d),N=m!==void 0;return x?(m||t.getState().nodes).filter(b=>{const v=t.getState().nodeLookup.get(b.id);if(v&&!y&&(b.id===d.id||!v.internals.positionAbsolute))return!1;const g=xc(N?b:v),w=mu(g,x);return f&&w>0||w>=g.width*g.height||w>=x.width*x.height}):[]},isNodeIntersecting:(d,f,m=!0)=>{const x=Pj(d)?d:c(d);if(!x)return!1;const N=mu(x,f);return m&&N>0||N>=f.width*f.height||N>=x.width*x.height},updateNode:u,updateNodeData:(d,f,m={replace:!1})=>{u(d,y=>{const x=typeof f=="function"?f(y):f;return m.replace?{...y,data:x}:{...y,data:{...y.data,...x}}},m)},updateEdge:h,updateEdgeData:(d,f,m={replace:!1})=>{h(d,y=>{const x=typeof f=="function"?f(y):f;return m.replace?{...y,data:x}:{...y,data:{...y.data,...x}}},m)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:m}=t.getState();return G7(d,{nodeLookup:f,nodeOrigin:m})},getHandleConnections:({type:d,id:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${d}${f?`-${f}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:y.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??J7();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(m=>[...m]),f.promise}}},[]);return p.useMemo(()=>({...s,...e,viewportInitialized:a}),[a])}const dT=e=>e.selected,BG=typeof window<"u"?window:void 0;function zG({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Vt(),{deleteElements:a}=mS(),s=xu(e,{actInsideInputWithModifier:!1}),i=xu(t,{target:BG});p.useEffect(()=>{if(s){const{edges:o,nodes:l}=n.getState();a({nodes:l.filter(dT),edges:o.filter(dT)}),n.setState({nodesSelectionActive:!1})}},[s]),p.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function $G(e){const t=Vt();p.useEffect(()=>{const n=()=>{var s,i,o,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const a=dS(e.current);(a.height===0||a.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",Yr.error004())),t.setState({width:a.width||500,height:a.height||500})};if(e.current){n(),window.addEventListener("resize",n);const a=new ResizeObserver(()=>n());return a.observe(e.current),()=>{window.removeEventListener("resize",n),a&&e.current&&a.unobserve(e.current)}}},[])}const am={position:"absolute",width:"100%",height:"100%",top:0,left:0},HG=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function qG({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Ao.Free,zoomOnDoubleClick:o=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:h,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:m=!0,children:y,noWheelClassName:x,noPanClassName:N,onViewportChange:b,isControlledViewport:v,paneClickDistance:g,selectionOnDrag:w}){const S=Vt(),E=p.useRef(null),{userSelectionActive:j,lib:_,connectionInProgress:M}=gt(HG,Zt),U=xu(f),L=p.useRef();$G(E);const F=p.useCallback(G=>{b==null||b({x:G[0],y:G[1],zoom:G[2]}),v||S.setState({transform:G})},[b,v]);return p.useEffect(()=>{if(E.current){L.current=Mq({domNode:E.current,minZoom:h,maxZoom:d,translateExtent:u,viewport:c,onDraggingChange:R=>S.setState({paneDragging:R}),onPanZoomStart:(R,k)=>{const{onViewportChangeStart:T,onMoveStart:D}=S.getState();D==null||D(R,k),T==null||T(k)},onPanZoom:(R,k)=>{const{onViewportChange:T,onMove:D}=S.getState();D==null||D(R,k),T==null||T(k)},onPanZoomEnd:(R,k)=>{const{onViewportChangeEnd:T,onMoveEnd:D}=S.getState();D==null||D(R,k),T==null||T(k)}});const{x:G,y:A,zoom:P}=L.current.getViewport();return S.setState({panZoom:L.current,transform:[G,A,P],domNode:E.current.closest(".react-flow")}),()=>{var R;(R=L.current)==null||R.destroy()}}},[]),p.useEffect(()=>{var G;(G=L.current)==null||G.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:a,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:l,zoomActivationKeyPressed:U,preventScrolling:m,noPanClassName:N,userSelectionActive:j,noWheelClassName:x,lib:_,onTransformChange:F,connectionInProgress:M,selectionOnDrag:w,paneClickDistance:g})},[e,t,n,a,s,i,o,l,U,m,N,j,x,_,F,M,w,g]),r.jsx("div",{className:"react-flow__renderer",ref:E,style:am,children:y})}const GG=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function VG(){const{userSelectionActive:e,userSelectionRect:t}=gt(GG,Zt);return e&&t?r.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 kg=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},YG=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function WG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pu.Full,panOnDrag:a,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:o,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:m,children:y}){const x=Vt(),{userSelectionActive:N,elementsSelectable:b,dragging:v,connectionInProgress:g}=gt(YG,Zt),w=b&&(e||N),S=p.useRef(null),E=p.useRef(),j=p.useRef(new Set),_=p.useRef(new Set),M=p.useRef(!1),U=T=>{if(M.current||g){M.current=!1;return}c==null||c(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},L=T=>{if(Array.isArray(a)&&(a!=null&&a.includes(2))){T.preventDefault();return}u==null||u(T)},F=h?T=>h(T):void 0,G=T=>{M.current&&(T.stopPropagation(),M.current=!1)},A=T=>{var Y,ae;const{domNode:D}=x.getState();if(E.current=D==null?void 0:D.getBoundingClientRect(),!E.current)return;const q=T.target===S.current;if(!q&&!!T.target.closest(".nokey")||!e||!(i&&q||t)||T.button!==0||!T.isPrimary)return;(ae=(Y=T.target)==null?void 0:Y.setPointerCapture)==null||ae.call(Y,T.pointerId),M.current=!1;const{x:z,y:W}=pr(T.nativeEvent,E.current);x.setState({userSelectionRect:{width:0,height:0,startX:z,startY:W,x:z,y:W}}),q||(T.stopPropagation(),T.preventDefault())},P=T=>{const{userSelectionRect:D,transform:q,nodeLookup:C,edgeLookup:I,connectionLookup:z,triggerNodeChanges:W,triggerEdgeChanges:Y,defaultEdgeOptions:ae,resetSelectedElements:ne}=x.getState();if(!E.current||!D)return;const{x:X,y:ie}=pr(T.nativeEvent,E.current),{startX:ve,startY:se}=D;if(!M.current){const $e=t?0:s;if(Math.hypot(X-ve,ie-se)<=$e)return;ne(),o==null||o(T)}M.current=!0;const ge={startX:ve,startY:se,x:X<ve?X:ve,y:ie<se?ie:se,width:Math.abs(X-ve),height:Math.abs(ie-se)},be=j.current,Ue=_.current;j.current=new Set(lS(C,ge,q,n===pu.Partial,!0).map($e=>$e.id)),_.current=new Set;const Be=(ae==null?void 0:ae.selectable)??!0;for(const $e of j.current){const Ye=z.get($e);if(Ye)for(const{edgeId:bt}of Ye.values()){const Ke=I.get(bt);Ke&&(Ke.selectable??Be)&&_.current.add(bt)}}if(!Fj(be,j.current)){const $e=Ll(C,j.current,!0);W($e)}if(!Fj(Ue,_.current)){const $e=Ll(I,_.current);Y($e)}x.setState({userSelectionRect:ge,userSelectionActive:!0,nodesSelectionActive:!1})},R=T=>{var D,q;T.button===0&&((q=(D=T.target)==null?void 0:D.releasePointerCapture)==null||q.call(D,T.pointerId),!N&&T.target===S.current&&x.getState().userSelectionRect&&(U==null||U(T)),x.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l==null||l(T),x.setState({nodesSelectionActive:j.current.size>0})))},k=a===!0||Array.isArray(a)&&a.includes(0);return r.jsxs("div",{className:vn(["react-flow__pane",{draggable:k,dragging:v,selection:e}]),onClick:w?void 0:kg(U,S),onContextMenu:kg(L,S),onWheel:kg(F,S),onPointerEnter:w?void 0:d,onPointerMove:w?P:f,onPointerUp:w?R:void 0,onPointerDownCapture:w?A:void 0,onClickCapture:w?G:void 0,onPointerLeave:m,ref:S,style:am,children:[y,r.jsx(VG,{})]})}function EN({id:e,store:t,unselect:n=!1,nodeRef:a}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Yr.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var h;return(h=a==null?void 0:a.current)==null?void 0:h.blur()})):s([e])}function ML({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:a,nodeId:s,isSelectable:i,nodeClickDistance:o}){const l=Vt(),[c,u]=p.useState(!1),h=p.useRef();return p.useEffect(()=>{h.current=wq({getStoreItems:()=>l.getState(),onNodeMouseDown:d=>{EN({id:d,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),p.useEffect(()=>{var d,f;if(t)(d=h.current)==null||d.destroy();else if(e.current)return(f=h.current)==null||f.update({noDragClassName:n,handleSelector:a,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:o}),()=>{var m;(m=h.current)==null||m.destroy()}},[n,a,t,i,e,s]),c}const XG=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function LL(){const e=Vt();return p.useCallback(n=>{const{nodeExtent:a,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:h}=e.getState(),d=new Map,f=XG(o),m=s?i[0]:5,y=s?i[1]:5,x=n.direction.x*m*n.factor,N=n.direction.y*y*n.factor;for(const[,b]of u){if(!f(b))continue;let v={x:b.internals.positionAbsolute.x+x,y:b.internals.positionAbsolute.y+N};s&&(v=Xu(v,i));const{position:g,positionAbsolute:w}=KM({nodeId:b.id,nextPosition:v,nodeLookup:u,nodeExtent:a,nodeOrigin:h,onError:l});b.position=g,b.internals.positionAbsolute=w,d.set(b.id,b)}c(d)},[])}const gS=p.createContext(null),KG=gS.Provider;gS.Consumer;const UL=()=>p.useContext(gS),ZG=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),QG=(e,t,n)=>a=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=a,{fromHandle:l,toHandle:c,isValid:u}=o,h=(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:h,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===gc.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:!!s,valid:h&&u}};function JG({type:e="source",position:t=Ve.Top,isValidConnection:n,isConnectable:a=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:l,children:c,className:u,onMouseDown:h,onTouchStart:d,...f},m){var P,R;const y=o||null,x=e==="target",N=Vt(),b=UL(),{connectOnClick:v,noPanClassName:g,rfId:w}=gt(ZG,Zt),{connectingFrom:S,connectingTo:E,clickConnecting:j,isPossibleEndHandle:_,connectionInProcess:M,clickConnectionInProcess:U,valid:L}=gt(QG(b,y,e),Zt);b||(R=(P=N.getState()).onError)==null||R.call(P,"010",Yr.error010());const F=k=>{const{defaultEdgeOptions:T,onConnect:D,hasDefaultEdges:q}=N.getState(),C={...T,...k};if(q){const{edges:I,setEdges:z}=N.getState();z(lL(C,I))}D==null||D(C),l==null||l(C)},G=k=>{if(!b)return;const T=rL(k.nativeEvent);if(s&&(T&&k.button===0||!T)){const D=N.getState();SN.onPointerDown(k.nativeEvent,{handleDomNode:k.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:x,handleId:y,nodeId:b,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:D.onConnectEnd,updateConnection:D.updateConnection,onConnect:F,isValidConnection:n||D.isValidConnection,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}T?h==null||h(k):d==null||d(k)},A=k=>{const{onClickConnectStart:T,onClickConnectEnd:D,connectionClickStartHandle:q,connectionMode:C,isValidConnection:I,lib:z,rfId:W,nodeLookup:Y,connection:ae}=N.getState();if(!b||!q&&!s)return;if(!q){T==null||T(k.nativeEvent,{nodeId:b,handleId:y,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:b,type:e,id:y}});return}const ne=nL(k.target),X=n||I,{connection:ie,isValid:ve}=SN.isValid(k.nativeEvent,{handle:{nodeId:b,id:y,type:e},connectionMode:C,fromNodeId:q.nodeId,fromHandleId:q.id||null,fromType:q.type,isValidConnection:X,flowId:W,doc:ne,lib:z,nodeLookup:Y});ve&&ie&&F(ie);const se=structuredClone(ae);delete se.inProgress,se.toPosition=se.toHandle?se.toHandle.position:null,D==null||D(k,se),N.setState({connectionClickStartHandle:null})};return r.jsx("div",{"data-handleid":y,"data-nodeid":b,"data-handlepos":t,"data-id":`${w}-${b}-${y}-${e}`,className:vn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,u,{source:!x,target:x,connectable:a,connectablestart:s,connectableend:i,clickconnecting:j,connectingfrom:S,connectingto:E,valid:L,connectionindicator:a&&(!M||_)&&(M||U?i:s)}]),onMouseDown:G,onTouchStart:G,onClick:v?A:void 0,ref:m,...f,children:c})}const _o=p.memo(DL(JG));function eV({data:e,isConnectable:t,sourcePosition:n=Ve.Bottom}){return r.jsxs(r.Fragment,{children:[e==null?void 0:e.label,r.jsx(_o,{type:"source",position:n,isConnectable:t})]})}function tV({data:e,isConnectable:t,targetPosition:n=Ve.Top,sourcePosition:a=Ve.Bottom}){return r.jsxs(r.Fragment,{children:[r.jsx(_o,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,r.jsx(_o,{type:"source",position:a,isConnectable:t})]})}function nV(){return null}function aV({data:e,isConnectable:t,targetPosition:n=Ve.Top}){return r.jsxs(r.Fragment,{children:[r.jsx(_o,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const dp={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},uT={input:eV,default:tV,output:aV,group:nV};function rV(e){var t,n,a,s;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??((a=e.style)==null?void 0:a.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const sV=e=>{const{width:t,height:n,x:a,y:s}=Wu(e.nodeLookup,{filter:i=>!!i.selected});return{width:fr(t)?t:null,height:fr(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${a}px,${s}px)`}};function iV({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const a=Vt(),{width:s,height:i,transformString:o,userSelectionActive:l}=gt(sV,Zt),c=LL(),u=p.useRef(null);if(p.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]),ML({nodeRef:u}),l||!s||!i)return null;const h=e?f=>{const m=a.getState().nodes.filter(y=>y.selected);e(f,m)}:void 0,d=f=>{Object.prototype.hasOwnProperty.call(dp,f.key)&&(f.preventDefault(),c({direction:dp[f.key],factor:f.shiftKey?4:1}))};return r.jsx("div",{className:vn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:r.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:s,height:i}})})}const hT=typeof window<"u"?window:void 0,oV=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function PL({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:h,selectionMode:d,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:x,zoomActivationKeyCode:N,elementsSelectable:b,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:M,translateExtent:U,minZoom:L,maxZoom:F,preventScrolling:G,onSelectionContextMenu:A,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:k,onViewportChange:T,isControlledViewport:D}){const{nodesSelectionActive:q,userSelectionActive:C}=gt(oV),I=xu(u,{target:hT}),z=xu(x,{target:hT}),W=z||_,Y=z||w,ae=h&&W!==!0,ne=I||C||ae;return zG({deleteKeyCode:c,multiSelectionKeyCode:y}),r.jsx(qG,{onPaneContextMenu:i,elementsSelectable:b,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:Y,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!I&&W,defaultViewport:M,translateExtent:U,minZoom:L,maxZoom:F,zoomActivationKeyCode:N,preventScrolling:G,noWheelClassName:P,noPanClassName:R,onViewportChange:T,isControlledViewport:D,paneClickDistance:l,selectionOnDrag:ae,children:r.jsxs(WG,{onSelectionStart:f,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:W,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:I,paneClickDistance:l,selectionOnDrag:ae,children:[e,q&&r.jsx(iV,{onSelectionContextMenu:A,noPanClassName:R,disableKeyboardA11y:k})]})})}PL.displayName="FlowRenderer";const lV=p.memo(PL),cV=e=>t=>e?lS(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 dV(e){return gt(p.useCallback(cV(e),[e]),Zt)}const uV=e=>e.updateNodeInternals;function hV(){const e=gt(uV),[t]=p.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const a=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");a.set(i,{id:i,nodeElement:s.target,force:!0})}),e(a)}));return p.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function fV({node:e,nodeType:t,hasDimensions:n,resizeObserver:a}){const s=Vt(),i=p.useRef(null),o=p.useRef(null),l=p.useRef(e.sourcePosition),c=p.useRef(e.targetPosition),u=p.useRef(t),h=n&&!!e.internals.handleBounds;return p.useEffect(()=>{i.current&&!e.hidden&&(!h||o.current!==i.current)&&(o.current&&(a==null||a.unobserve(o.current)),a==null||a.observe(i.current),o.current=i.current)},[h,e.hidden]),p.useEffect(()=>()=>{o.current&&(a==null||a.unobserve(o.current),o.current=null)},[]),p.useEffect(()=>{if(i.current){const d=u.current!==t,f=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(d||f||m)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function pV({id:e,onClick:t,onMouseEnter:n,onMouseMove:a,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:h,resizeObserver:d,noDragClassName:f,noPanClassName:m,disableKeyboardA11y:y,rfId:x,nodeTypes:N,nodeClickDistance:b,onError:v}){const{node:g,internals:w,isParent:S}=gt(X=>{const ie=X.nodeLookup.get(e),ve=X.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:ve}},Zt);let E=g.type||"default",j=(N==null?void 0:N[E])||uT[E];j===void 0&&(v==null||v("003",Yr.error003(E)),E="default",j=(N==null?void 0:N.default)||uT.default);const _=!!(g.draggable||l&&typeof g.draggable>"u"),M=!!(g.selectable||c&&typeof g.selectable>"u"),U=!!(g.connectable||u&&typeof g.connectable>"u"),L=!!(g.focusable||h&&typeof g.focusable>"u"),F=Vt(),G=eL(g),A=fV({node:g,nodeType:E,hasDimensions:G,resizeObserver:d}),P=ML({nodeRef:A,disabled:g.hidden||!_,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:b}),R=LL();if(g.hidden)return null;const k=qs(g),T=rV(g),D=M||_||t||n||a||s,q=n?X=>n(X,{...w.userNode}):void 0,C=a?X=>a(X,{...w.userNode}):void 0,I=s?X=>s(X,{...w.userNode}):void 0,z=i?X=>i(X,{...w.userNode}):void 0,W=o?X=>o(X,{...w.userNode}):void 0,Y=X=>{const{selectNodesOnDrag:ie,nodeDragThreshold:ve}=F.getState();M&&(!ie||!_||ve>0)&&EN({id:e,store:F,nodeRef:A}),t&&t(X,{...w.userNode})},ae=X=>{if(!(aL(X.nativeEvent)||y)){if(GM.includes(X.key)&&M){const ie=X.key==="Escape";EN({id:e,store:F,unselect:ie,nodeRef:A})}else if(_&&g.selected&&Object.prototype.hasOwnProperty.call(dp,X.key)){X.preventDefault();const{ariaLabelConfig:ie}=F.getState();F.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),R({direction:dp[X.key],factor:X.shiftKey?4:1})}}},ne=()=>{var Ue;if(y||!((Ue=A.current)!=null&&Ue.matches(":focus-visible")))return;const{transform:X,width:ie,height:ve,autoPanOnNodeFocus:se,setCenter:ge}=F.getState();if(!se)return;lS(new Map([[e,g]]),{x:0,y:0,width:ie,height:ve},X,!0).length>0||ge(g.position.x+k.width/2,g.position.y+k.height/2,{zoom:X[2]})};return r.jsx("div",{className:vn(["react-flow__node",`react-flow__node-${E}`,{[m]:_},g.className,{selected:g.selected,selectable:M,parent:S,draggable:_,dragging:P}]),ref:A,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:G?"visible":"hidden",...g.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:q,onMouseMove:C,onMouseLeave:I,onContextMenu:z,onClick:Y,onDoubleClick:W,onKeyDown:L?ae:void 0,tabIndex:L?0:void 0,onFocus:L?ne:void 0,role:g.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${CL}-${x}`,"aria-label":g.ariaLabel,...g.domAttributes,children:r.jsx(KG,{value:e,children:r.jsx(j,{id:e,data:g.data,type:E,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:g.selected??!1,selectable:M,draggable:_,deletable:g.deletable??!0,isConnectable:U,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:P,dragHandle:g.dragHandle,zIndex:w.z,parentId:g.parentId,...k})})})}var mV=p.memo(pV);const gV=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function FL(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:a,elementsSelectable:s,onError:i}=gt(gV,Zt),o=dV(e.onlyRenderVisibleElements),l=hV();return r.jsx("div",{className:"react-flow__nodes",style:am,children:o.map(c=>r.jsx(mV,{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:a,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}FL.displayName="NodeRenderer";const bV=p.memo(FL);function xV(e){return gt(p.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const a=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);i&&o&&aq({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&a.push(s.id)}return a},[e]),Zt)}const vV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fT={[op.Arrow]:vV,[op.ArrowClosed]:yV};function wV(e){const t=Vt();return p.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(fT,e)?fT[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Yr.error009(e)),null)},[e])}const NV=({id:e,type:t,color:n,width:a=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const c=wV(t);return c?r.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${a}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:r.jsx(c,{color:n,strokeWidth:o})}):null},BL=({defaultColor:e,rfId:t})=>{const n=gt(i=>i.edges),a=gt(i=>i.defaultEdgeOptions),s=p.useMemo(()=>dq(n,{id:t,defaultColor:e,defaultMarkerStart:a==null?void 0:a.markerStart,defaultMarkerEnd:a==null?void 0:a.markerEnd}),[n,a,t,e]);return s.length?r.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:r.jsx("defs",{children:s.map(i=>r.jsx(NV,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};BL.displayName="MarkerDefinitions";var SV=p.memo(BL);function zL({x:e,y:t,label:n,labelStyle:a,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...h}){const[d,f]=p.useState({x:1,y:0,width:0,height:0}),m=vn(["react-flow__edge-textwrapper",u]),y=p.useRef(null);return p.useEffect(()=>{if(y.current){const x=y.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?r.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:m,visibility:d.width?"visible":"hidden",...h,children:[s&&r.jsx("rect",{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),r.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:y,style:a,children:n}),c]}):null}zL.displayName="EdgeText";const EV=p.memo(zL);function rm({path:e,labelX:t,labelY:n,label:a,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...h}){return r.jsxs(r.Fragment,{children:[r.jsx("path",{...h,d:e,fill:"none",className:vn(["react-flow__edge-path",h.className])}),u?r.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,a&&fr(t)&&fr(n)?r.jsx(EV,{x:t,y:n,label:a,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function pT({pos:e,x1:t,y1:n,x2:a,y2:s}){return e===Ve.Left||e===Ve.Right?[.5*(t+a),n]:[t,.5*(n+s)]}function $L({sourceX:e,sourceY:t,sourcePosition:n=Ve.Bottom,targetX:a,targetY:s,targetPosition:i=Ve.Top}){const[o,l]=pT({pos:n,x1:e,y1:t,x2:a,y2:s}),[c,u]=pT({pos:i,x1:a,y1:s,x2:e,y2:t}),[h,d,f,m]=sL({sourceX:e,sourceY:t,targetX:a,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${o},${l} ${c},${u} ${a},${s}`,h,d,f,m]}function HL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,sourcePosition:o,targetPosition:l,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:b})=>{const[v,g,w]=$L({sourceX:n,sourceY:a,sourcePosition:o,targetX:s,targetY:i,targetPosition:l}),S=e.isInternal?void 0:t;return r.jsx(rm,{id:S,path:v,labelX:g,labelY:w,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:b})})}const jV=HL({isInternal:!1}),qL=HL({isInternal:!0});jV.displayName="SimpleBezierEdge";qL.displayName="SimpleBezierEdgeInternal";function GL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,sourcePosition:m=Ve.Bottom,targetPosition:y=Ve.Top,markerEnd:x,markerStart:N,pathOptions:b,interactionWidth:v})=>{const[g,w,S]=yN({sourceX:n,sourceY:a,sourcePosition:m,targetX:s,targetY:i,targetPosition:y,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset,stepPosition:b==null?void 0:b.stepPosition}),E=e.isInternal?void 0:t;return r.jsx(rm,{id:E,path:g,labelX:w,labelY:S,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:x,markerStart:N,interactionWidth:v})})}const VL=GL({isInternal:!1}),YL=GL({isInternal:!0});VL.displayName="SmoothStepEdge";YL.displayName="SmoothStepEdgeInternal";function WL(e){return p.memo(({id:t,...n})=>{var s;const a=e.isInternal?void 0:t;return r.jsx(VL,{...n,id:a,pathOptions:p.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const TV=WL({isInternal:!1}),XL=WL({isInternal:!0});TV.displayName="StepEdge";XL.displayName="StepEdgeInternal";function KL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,b,v]=cL({sourceX:n,sourceY:a,targetX:s,targetY:i}),g=e.isInternal?void 0:t;return r.jsx(rm,{id:g,path:N,labelX:b,labelY:v,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:m,markerStart:y,interactionWidth:x})})}const CV=KL({isInternal:!1}),ZL=KL({isInternal:!0});CV.displayName="StraightEdge";ZL.displayName="StraightEdgeInternal";function QL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,sourcePosition:o=Ve.Bottom,targetPosition:l=Ve.Top,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:b,interactionWidth:v})=>{const[g,w,S]=iL({sourceX:n,sourceY:a,sourcePosition:o,targetX:s,targetY:i,targetPosition:l,curvature:b==null?void 0:b.curvature}),E=e.isInternal?void 0:t;return r.jsx(rm,{id:E,path:g,labelX:w,labelY:S,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:v})})}const kV=QL({isInternal:!1}),JL=QL({isInternal:!0});kV.displayName="BezierEdge";JL.displayName="BezierEdgeInternal";const mT={default:JL,straight:ZL,step:XL,smoothstep:YL,simplebezier:qL},gT={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},AV=(e,t,n)=>n===Ve.Left?e-t:n===Ve.Right?e+t:e,_V=(e,t,n)=>n===Ve.Top?e-t:n===Ve.Bottom?e+t:e,bT="react-flow__edgeupdater";function xT({position:e,centerX:t,centerY:n,radius:a=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:l}){return r.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:vn([bT,`${bT}-${l}`]),cx:AV(t,a,e),cy:_V(n,a,e),r:a,stroke:"transparent",fill:"transparent"})}function RV({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:a,sourceY:s,targetX:i,targetY:o,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:h,onReconnectEnd:d,setReconnecting:f,setUpdateHover:m}){const y=Vt(),x=(w,S)=>{if(w.button!==0)return;const{autoPanOnConnect:E,domNode:j,isValidConnection:_,connectionMode:M,connectionRadius:U,lib:L,onConnectStart:F,onConnectEnd:G,cancelConnection:A,nodeLookup:P,rfId:R,panBy:k,updateConnection:T}=y.getState(),D=S.type==="target",q=(z,W)=>{f(!1),d==null||d(z,n,S.type,W)},C=z=>u==null?void 0:u(n,z),I=(z,W)=>{f(!0),h==null||h(w,n,S.type),F==null||F(z,W)};SN.onPointerDown(w.nativeEvent,{autoPanOnConnect:E,connectionMode:M,connectionRadius:U,domNode:j,handleId:S.id,nodeId:S.nodeId,nodeLookup:P,isTarget:D,edgeUpdaterType:S.type,lib:L,flowId:R,cancelConnection:A,panBy:k,isValidConnection:_,onConnect:C,onConnectStart:I,onConnectEnd:G,onReconnectEnd:q,updateConnection:T,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},N=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),b=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),g=()=>m(!1);return r.jsxs(r.Fragment,{children:[(e===!0||e==="source")&&r.jsx(xT,{position:l,centerX:a,centerY:s,radius:t,onMouseDown:N,onMouseEnter:v,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&r.jsx(xT,{position:c,centerX:i,centerY:o,radius:t,onMouseDown:b,onMouseEnter:v,onMouseOut:g,type:"target"})]})}function OV({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:a,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:h,onReconnect:d,onReconnectStart:f,onReconnectEnd:m,rfId:y,edgeTypes:x,noPanClassName:N,onError:b,disableKeyboardA11y:v}){let g=gt(ge=>ge.edgeLookup.get(e));const w=gt(ge=>ge.defaultEdgeOptions);g=w?{...w,...g}:g;let S=g.type||"default",E=(x==null?void 0:x[S])||mT[S];E===void 0&&(b==null||b("011",Yr.error011(S)),S="default",E=(x==null?void 0:x.default)||mT.default);const j=!!(g.focusable||t&&typeof g.focusable>"u"),_=typeof d<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),M=!!(g.selectable||a&&typeof g.selectable>"u"),U=p.useRef(null),[L,F]=p.useState(!1),[G,A]=p.useState(!1),P=Vt(),{zIndex:R,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I}=gt(p.useCallback(ge=>{const be=ge.nodeLookup.get(g.source),Ue=ge.nodeLookup.get(g.target);if(!be||!Ue)return{zIndex:g.zIndex,...gT};const Be=cq({id:e,sourceNode:be,targetNode:Ue,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:ge.connectionMode,onError:b});return{zIndex:nq({selected:g.selected,zIndex:g.zIndex,sourceNode:be,targetNode:Ue,elevateOnSelect:ge.elevateEdgesOnSelect}),...Be||gT}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),Zt),z=p.useMemo(()=>g.markerStart?`url('#${wN(g.markerStart,y)}')`:void 0,[g.markerStart,y]),W=p.useMemo(()=>g.markerEnd?`url('#${wN(g.markerEnd,y)}')`:void 0,[g.markerEnd,y]);if(g.hidden||k===null||T===null||D===null||q===null)return null;const Y=ge=>{var $e;const{addSelectedEdges:be,unselectNodesAndEdges:Ue,multiSelectionActive:Be}=P.getState();M&&(P.setState({nodesSelectionActive:!1}),g.selected&&Be?(Ue({nodes:[],edges:[g]}),($e=U.current)==null||$e.blur()):be([e])),s&&s(ge,g)},ae=i?ge=>{i(ge,{...g})}:void 0,ne=o?ge=>{o(ge,{...g})}:void 0,X=l?ge=>{l(ge,{...g})}:void 0,ie=c?ge=>{c(ge,{...g})}:void 0,ve=u?ge=>{u(ge,{...g})}:void 0,se=ge=>{var be;if(!v&&GM.includes(ge.key)&&M){const{unselectNodesAndEdges:Ue,addSelectedEdges:Be}=P.getState();ge.key==="Escape"?((be=U.current)==null||be.blur(),Ue({edges:[g]})):Be([e])}};return r.jsx("svg",{style:{zIndex:R},children:r.jsxs("g",{className:vn(["react-flow__edge",`react-flow__edge-${S}`,g.className,N,{selected:g.selected,animated:g.animated,inactive:!M&&!s,updating:L,selectable:M}]),onClick:Y,onDoubleClick:ae,onContextMenu:ne,onMouseEnter:X,onMouseMove:ie,onMouseLeave:ve,onKeyDown:j?se:void 0,tabIndex:j?0:void 0,role:g.ariaRole??(j?"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":j?`${kL}-${y}`:void 0,ref:U,...g.domAttributes,children:[!G&&r.jsx(E,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:M,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:z,markerEnd:W,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),_&&r.jsx(RV,{edge:g,isReconnectable:_,reconnectRadius:h,onReconnect:d,onReconnectStart:f,onReconnectEnd:m,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I,setUpdateHover:F,setReconnecting:A})]})})}var DV=p.memo(OV);const IV=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function e3({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:a,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:x}){const{edgesFocusable:N,edgesReconnectable:b,elementsSelectable:v,onError:g}=gt(IV,Zt),w=xV(t);return r.jsxs("div",{className:"react-flow__edges",children:[r.jsx(SV,{defaultColor:e,rfId:n}),w.map(S=>r.jsx(DV,{id:S,edgesFocusable:N,edgesReconnectable:b,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:h,reconnectRadius:d,onDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:g,edgeTypes:a,disableKeyboardA11y:x},S))]})}e3.displayName="EdgeRenderer";const MV=p.memo(e3),LV=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function UV({children:e}){const t=gt(LV);return r.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function PV(e){const t=mS(),n=p.useRef(!1);p.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const FV=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function BV(e){const t=gt(FV),n=Vt();return p.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function zV(e){return e.connection.inProgress?{...e.connection,to:Ku(e.connection.to,e.transform)}:{...e.connection}}function $V(e){return zV}function HV(e){const t=$V();return gt(t,Zt)}const qV=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function GV({containerStyle:e,style:t,type:n,component:a}){const{nodesConnectable:s,width:i,height:o,isValid:l,inProgress:c}=gt(qV,Zt);return!(i&&s&&c)?null:r.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:r.jsx("g",{className:vn(["react-flow__connection",WM(l)]),children:r.jsx(t3,{style:t,type:n,CustomComponent:a,isValid:l})})})}const t3=({style:e,type:t=Ni.Bezier,CustomComponent:n,isValid:a})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:l,fromPosition:c,to:u,toNode:h,toHandle:d,toPosition:f,pointer:m}=HV();if(!s)return;if(n)return r.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:WM(a),toNode:h,toHandle:d,pointer:m});let y="";const x={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Ni.Bezier:[y]=iL(x);break;case Ni.SimpleBezier:[y]=$L(x);break;case Ni.Step:[y]=yN({...x,borderRadius:0});break;case Ni.SmoothStep:[y]=yN(x);break;default:[y]=cL(x)}return r.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};t3.displayName="ConnectionLine";const VV={};function vT(e=VV){p.useRef(e),Vt(),p.useEffect(()=>{},[e])}function YV(){Vt(),p.useRef(!1),p.useEffect(()=>{},[])}function n3({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:a,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:x,connectionLineComponent:N,connectionLineContainerStyle:b,selectionKeyCode:v,selectionOnDrag:g,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:j,deleteKeyCode:_,onlyRenderVisibleElements:M,elementsSelectable:U,defaultViewport:L,translateExtent:F,minZoom:G,maxZoom:A,preventScrolling:P,defaultMarkerColor:R,zoomOnScroll:k,zoomOnPinch:T,panOnScroll:D,panOnScrollSpeed:q,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:z,onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneScroll:X,onPaneContextMenu:ie,paneClickDistance:ve,nodeClickDistance:se,onEdgeContextMenu:ge,onEdgeMouseEnter:be,onEdgeMouseMove:Ue,onEdgeMouseLeave:Be,reconnectRadius:$e,onReconnect:Ye,onReconnectStart:bt,onReconnectEnd:Ke,noDragClassName:de,noWheelClassName:Fe,noPanClassName:Ie,disableKeyboardA11y:Ae,nodeExtent:We,rfId:at,viewport:ft,onViewportChange:Yt}){return vT(e),vT(t),YV(),PV(n),BV(ft),r.jsx(lV,{onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:X,paneClickDistance:ve,deleteKeyCode:_,selectionKeyCode:v,selectionOnDrag:g,selectionMode:w,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:j,elementsSelectable:U,zoomOnScroll:k,zoomOnPinch:T,zoomOnDoubleClick:I,panOnScroll:D,panOnScrollSpeed:q,panOnScrollMode:C,panOnDrag:z,defaultViewport:L,translateExtent:F,minZoom:G,maxZoom:A,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:de,noWheelClassName:Fe,noPanClassName:Ie,disableKeyboardA11y:Ae,onViewportChange:Yt,isControlledViewport:!!ft,children:r.jsxs(UV,{children:[r.jsx(MV,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:Ye,onReconnectStart:bt,onReconnectEnd:Ke,onlyRenderVisibleElements:M,onEdgeContextMenu:ge,onEdgeMouseEnter:be,onEdgeMouseMove:Ue,onEdgeMouseLeave:Be,reconnectRadius:$e,defaultMarkerColor:R,noPanClassName:Ie,disableKeyboardA11y:Ae,rfId:at}),r.jsx(GV,{style:x,type:y,component:N,containerStyle:b}),r.jsx("div",{className:"react-flow__edgelabel-renderer"}),r.jsx(bV,{nodeTypes:e,onNodeClick:a,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:h,nodeClickDistance:se,onlyRenderVisibleElements:M,noPanClassName:Ie,noDragClassName:de,disableKeyboardA11y:Ae,nodeExtent:We,rfId:at}),r.jsx("div",{className:"react-flow__viewport-portal"})]})})}n3.displayName="GraphView";const WV=p.memo(n3),yT=({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:h,nodeExtent:d}={})=>{const f=new Map,m=new Map,y=new Map,x=new Map,N=a??t??[],b=n??e??[],v=h??[0,0],g=d??fu;hL(y,x,N);const w=NN(b,f,m,{nodeOrigin:v,nodeExtent:g,elevateNodesOnSelect:!1});let S=[0,0,1];if(o&&s&&i){const E=Wu(f,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:j,y:_,zoom:M}=cS(E,s,i,c,u,(l==null?void 0:l.padding)??.1);S=[j,_,M]}return{rfId:"1",width:s??0,height:i??0,transform:S,nodes:b,nodesInitialized:w,nodeLookup:f,parentLookup:m,edges:N,edgeLookup:x,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:a!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:fu,nodeExtent:g,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:gc.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:o??!1,fitViewOptions:l,fitViewResolver:null,connection:{...YM},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:K7,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:VM}},XV=({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:h,nodeExtent:d})=>fG((f,m)=>{async function y(){const{nodeLookup:x,panZoom:N,fitViewOptions:b,fitViewResolver:v,width:g,height:w,minZoom:S,maxZoom:E}=m();N&&(await W7({nodes:x,width:g,height:w,panZoom:N,minZoom:S,maxZoom:E},b),v==null||v.resolve(!0),f({fitViewResolver:null}))}return{...yT({nodes:e,edges:t,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:a}),setNodes:x=>{const{nodeLookup:N,parentLookup:b,nodeOrigin:v,elevateNodesOnSelect:g,fitViewQueued:w}=m(),S=NN(x,N,b,{nodeOrigin:v,nodeExtent:d,elevateNodesOnSelect:g,checkEquality:!0});w&&S?(y(),f({nodes:x,nodesInitialized:S,fitViewQueued:!1,fitViewOptions:void 0})):f({nodes:x,nodesInitialized:S})},setEdges:x=>{const{connectionLookup:N,edgeLookup:b}=m();hL(N,b,x),f({edges:x})},setDefaultNodesAndEdges:(x,N)=>{if(x){const{setNodes:b}=m();b(x),f({hasDefaultNodes:!0})}if(N){const{setEdges:b}=m();b(N),f({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:N,nodeLookup:b,parentLookup:v,domNode:g,nodeOrigin:w,nodeExtent:S,debug:E,fitViewQueued:j}=m(),{changes:_,updatedInternals:M}=bq(x,b,v,g,w,S);M&&(fq(b,v,{nodeOrigin:w,nodeExtent:S}),j?(y(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(_==null?void 0:_.length)>0&&(E&&console.log("React Flow: trigger node changes",_),N==null||N(_)))},updateNodePositions:(x,N=!1)=>{const b=[],v=[],{nodeLookup:g,triggerNodeChanges:w}=m();for(const[S,E]of x){const j=g.get(S),_=!!(j!=null&&j.expandParent&&(j!=null&&j.parentId)&&(E!=null&&E.position)),M={id:S,type:"position",position:_?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:N};_&&j.parentId&&b.push({id:S,parentId:j.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),v.push(M)}if(b.length>0){const{parentLookup:S,nodeOrigin:E}=m(),j=pS(b,g,S,E);v.push(...j)}w(v)},triggerNodeChanges:x=>{const{onNodesChange:N,setNodes:b,nodes:v,hasDefaultNodes:g,debug:w}=m();if(x!=null&&x.length){if(g){const S=RL(x,v);b(S)}w&&console.log("React Flow: trigger node changes",x),N==null||N(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:N,setEdges:b,edges:v,hasDefaultEdges:g,debug:w}=m();if(x!=null&&x.length){if(g){const S=OL(x,v);b(S)}w&&console.log("React Flow: trigger edge changes",x),N==null||N(x)}},addSelectedNodes:x=>{const{multiSelectionActive:N,edgeLookup:b,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:w}=m();if(N){const S=x.map(E=>po(E,!0));g(S);return}g(Ll(v,new Set([...x]),!0)),w(Ll(b))},addSelectedEdges:x=>{const{multiSelectionActive:N,edgeLookup:b,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:w}=m();if(N){const S=x.map(E=>po(E,!0));w(S);return}w(Ll(b,new Set([...x]))),g(Ll(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:N}={})=>{const{edges:b,nodes:v,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:S}=m(),E=x||v,j=N||b,_=E.map(U=>{const L=g.get(U.id);return L&&(L.selected=!1),po(U.id,!1)}),M=j.map(U=>po(U.id,!1));w(_),S(M)},setMinZoom:x=>{const{panZoom:N,maxZoom:b}=m();N==null||N.setScaleExtent([x,b]),f({minZoom:x})},setMaxZoom:x=>{const{panZoom:N,minZoom:b}=m();N==null||N.setScaleExtent([b,x]),f({maxZoom:x})},setTranslateExtent:x=>{var N;(N=m().panZoom)==null||N.setTranslateExtent(x),f({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:N,triggerNodeChanges:b,triggerEdgeChanges:v,elementsSelectable:g}=m();if(!g)return;const w=N.reduce((E,j)=>j.selected?[...E,po(j.id,!1)]:E,[]),S=x.reduce((E,j)=>j.selected?[...E,po(j.id,!1)]:E,[]);b(w),v(S)},setNodeExtent:x=>{const{nodes:N,nodeLookup:b,parentLookup:v,nodeOrigin:g,elevateNodesOnSelect:w,nodeExtent:S}=m();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(NN(N,b,v,{nodeOrigin:g,nodeExtent:x,elevateNodesOnSelect:w,checkEquality:!1}),f({nodeExtent:x}))},panBy:x=>{const{transform:N,width:b,height:v,panZoom:g,translateExtent:w}=m();return xq({delta:x,panZoom:g,transform:N,translateExtent:w,width:b,height:v})},setCenter:async(x,N,b)=>{const{width:v,height:g,maxZoom:w,panZoom:S}=m();if(!S)return Promise.resolve(!1);const E=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:w;return await S.setViewport({x:v/2-x*E,y:g/2-N*E,zoom:E},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...YM}})},updateConnection:x=>{f({connection:x})},reset:()=>f({...yT()})}},Object.is);function KV({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:a,initialWidth:s,initialHeight:i,initialMinZoom:o,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:h,nodeExtent:d,children:f}){const[m]=p.useState(()=>XV({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:u,minZoom:o,maxZoom:l,fitViewOptions:c,nodeOrigin:h,nodeExtent:d}));return r.jsx(pG,{value:m,children:r.jsx(UG,{children:f})})}function ZV({children:e,nodes:t,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:o,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:h,nodeOrigin:d,nodeExtent:f}){return p.useContext(tm)?r.jsx(r.Fragment,{children:e}):r.jsx(KV,{initialNodes:t,initialEdges:n,defaultNodes:a,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:h,nodeOrigin:d,nodeExtent:f,children:e})}const QV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function JV({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:h,onMoveStart:d,onMoveEnd:f,onConnect:m,onConnectStart:y,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:b,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:E,onNodeDragStart:j,onNodeDrag:_,onNodeDragStop:M,onNodesDelete:U,onEdgesDelete:L,onDelete:F,onSelectionChange:G,onSelectionDragStart:A,onSelectionDrag:P,onSelectionDragStop:R,onSelectionContextMenu:k,onSelectionStart:T,onSelectionEnd:D,onBeforeDelete:q,connectionMode:C,connectionLineType:I=Ni.Bezier,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:ae="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:X=!1,selectionMode:ie=pu.Full,panActivationKeyCode:ve="Space",multiSelectionKeyCode:se=gu()?"Meta":"Control",zoomActivationKeyCode:ge=gu()?"Meta":"Control",snapToGrid:be,snapGrid:Ue,onlyRenderVisibleElements:Be=!1,selectNodesOnDrag:$e,nodesDraggable:Ye,autoPanOnNodeFocus:bt,nodesConnectable:Ke,nodesFocusable:de,nodeOrigin:Fe=AL,edgesFocusable:Ie,edgesReconnectable:Ae,elementsSelectable:We=!0,defaultViewport:at=CG,minZoom:ft=.5,maxZoom:Yt=2,translateExtent:Wt=fu,preventScrolling:oe=!0,nodeExtent:_e,defaultMarkerColor:Ze="#b1b1b7",zoomOnScroll:K=!0,zoomOnPinch:pe=!0,panOnScroll:ye=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:ze=Ao.Free,zoomOnDoubleClick:tt=!0,panOnDrag:ee=!0,onPaneClick:ue,onPaneMouseEnter:Oe,onPaneMouseMove:xe,onPaneMouseLeave:Pe,onPaneScroll:Q,onPaneContextMenu:Z,paneClickDistance:je=1,nodeClickDistance:Qe=0,children:st,onReconnect:ct,onReconnectStart:it,onReconnectEnd:cn,onEdgeContextMenu:Tn,onEdgeDoubleClick:yn,onEdgeMouseEnter:nn,onEdgeMouseMove:ns,onEdgeMouseLeave:Dn,reconnectRadius:Hn=10,onNodesChange:rr,onEdgesChange:as,noDragClassName:el="nodrag",noWheelClassName:Ys="nowheel",noPanClassName:Pn="nopan",fitView:It,fitViewOptions:rs,connectOnClick:ss,attributionPosition:is,proOptions:Sr,defaultEdgeOptions:os,elevateNodesOnSelect:Er,elevateEdgesOnSelect:Ws,disableKeyboardA11y:fa=!1,autoPanOnConnect:Qn,autoPanOnNodeDrag:Pa,autoPanSpeed:Xs,connectionRadius:pa,isValidConnection:Jn,onError:sr,style:Ks,id:Zs,nodeDragThreshold:tl,connectionDragThreshold:Qs,viewport:no,onViewportChange:xt,width:jr,height:Tr,colorMode:Js="light",debug:ls,onScroll:ir,ariaLabelConfig:cs,...Fa},ao){const ds=Zs||"1",nl=RG(Js),we=p.useCallback(Ee=>{Ee.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ir==null||ir(Ee)},[ir]);return r.jsx("div",{"data-testid":"rf__wrapper",...Fa,onScroll:we,style:{...Ks,...QV},ref:ao,className:vn(["react-flow",s,nl]),id:Zs,role:"application",children:r.jsxs(ZV,{nodes:e,edges:t,width:jr,height:Tr,fitView:It,fitViewOptions:rs,minZoom:ft,maxZoom:Yt,nodeOrigin:Fe,nodeExtent:_e,children:[r.jsx(WV,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:o,connectionLineType:I,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:ne,selectionOnDrag:X,selectionMode:ie,deleteKeyCode:ae,multiSelectionKeyCode:se,panActivationKeyCode:ve,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Be,defaultViewport:at,translateExtent:Wt,minZoom:ft,maxZoom:Yt,preventScrolling:oe,zoomOnScroll:K,zoomOnPinch:pe,zoomOnDoubleClick:tt,panOnScroll:ye,panOnScrollSpeed:Te,panOnScrollMode:ze,panOnDrag:ee,onPaneClick:ue,onPaneMouseEnter:Oe,onPaneMouseMove:xe,onPaneMouseLeave:Pe,onPaneScroll:Q,onPaneContextMenu:Z,paneClickDistance:je,nodeClickDistance:Qe,onSelectionContextMenu:k,onSelectionStart:T,onSelectionEnd:D,onReconnect:ct,onReconnectStart:it,onReconnectEnd:cn,onEdgeContextMenu:Tn,onEdgeDoubleClick:yn,onEdgeMouseEnter:nn,onEdgeMouseMove:ns,onEdgeMouseLeave:Dn,reconnectRadius:Hn,defaultMarkerColor:Ze,noDragClassName:el,noWheelClassName:Ys,noPanClassName:Pn,rfId:ds,disableKeyboardA11y:fa,nodeExtent:_e,viewport:no,onViewportChange:xt}),r.jsx(_G,{nodes:e,edges:t,defaultNodes:n,defaultEdges:a,onConnect:m,onConnectStart:y,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:b,nodesDraggable:Ye,autoPanOnNodeFocus:bt,nodesConnectable:Ke,nodesFocusable:de,edgesFocusable:Ie,edgesReconnectable:Ae,elementsSelectable:We,elevateNodesOnSelect:Er,elevateEdgesOnSelect:Ws,minZoom:ft,maxZoom:Yt,nodeExtent:_e,onNodesChange:rr,onEdgesChange:as,snapToGrid:be,snapGrid:Ue,connectionMode:C,translateExtent:Wt,connectOnClick:ss,defaultEdgeOptions:os,fitView:It,fitViewOptions:rs,onNodesDelete:U,onEdgesDelete:L,onDelete:F,onNodeDragStart:j,onNodeDrag:_,onNodeDragStop:M,onSelectionDrag:P,onSelectionDragStart:A,onSelectionDragStop:R,onMove:h,onMoveStart:d,onMoveEnd:f,noPanClassName:Pn,nodeOrigin:Fe,rfId:ds,autoPanOnConnect:Qn,autoPanOnNodeDrag:Pa,autoPanSpeed:Xs,onError:sr,connectionRadius:pa,isValidConnection:Jn,selectNodesOnDrag:$e,nodeDragThreshold:tl,connectionDragThreshold:Qs,onBeforeDelete:q,debug:ls,ariaLabelConfig:cs}),r.jsx(TG,{onSelectionChange:G}),st,r.jsx(wG,{proOptions:Sr,position:is}),r.jsx(yG,{rfId:ds,disableKeyboardA11y:fa})]})})}var eY=DL(JV);function tY(e){const[t,n]=p.useState(e),a=p.useCallback(s=>n(i=>RL(s,i)),[]);return[t,n,a]}function nY(e){const[t,n]=p.useState(e),a=p.useCallback(s=>n(i=>OL(s,i)),[]);return[t,n,a]}function aY({dimensions:e,lineWidth:t,variant:n,className:a}){return r.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:vn(["react-flow__background-pattern",n,a])})}function rY({radius:e,className:t}){return r.jsx("circle",{cx:e,cy:e,r:e,className:vn(["react-flow__background-pattern","dots",t])})}var Is;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Is||(Is={}));const sY={[Is.Dots]:1,[Is.Lines]:1,[Is.Cross]:6},iY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function a3({id:e,variant:t=Is.Dots,gap:n=20,size:a,lineWidth:s=1,offset:i=0,color:o,bgColor:l,style:c,className:u,patternClassName:h}){const d=p.useRef(null),{transform:f,patternId:m}=gt(iY,Zt),y=a||sY[t],x=t===Is.Dots,N=t===Is.Cross,b=Array.isArray(n)?n:[n,n],v=[b[0]*f[2]||1,b[1]*f[2]||1],g=y*f[2],w=Array.isArray(i)?i:[i,i],S=N?[g,g]:v,E=[w[0]*f[2]||1+S[0]/2,w[1]*f[2]||1+S[1]/2],j=`${m}${e||""}`;return r.jsxs("svg",{className:vn(["react-flow__background",u]),style:{...c,...am,"--xy-background-color-props":l,"--xy-background-pattern-color-props":o},ref:d,"data-testid":"rf__background",children:[r.jsx("pattern",{id:j,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:x?r.jsx(rY,{radius:g/2,className:h}):r.jsx(aY,{dimensions:S,lineWidth:s,variant:t,className:h})}),r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}a3.displayName="Background";const oY=p.memo(a3);function lY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function cY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r.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 uY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.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 hY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.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 Mh({children:e,className:t,...n}){return r.jsx("button",{type:"button",className:vn(["react-flow__controls-button",t]),...n,children:e})}const fY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function r3({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:a=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:l,onInteractiveChange:c,className:u,children:h,position:d="bottom-left",orientation:f="vertical","aria-label":m}){const y=Vt(),{isInteractive:x,minZoomReached:N,maxZoomReached:b,ariaLabelConfig:v}=gt(fY,Zt),{zoomIn:g,zoomOut:w,fitView:S}=mS(),E=()=>{g(),i==null||i()},j=()=>{w(),o==null||o()},_=()=>{S(s),l==null||l()},M=()=>{y.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},U=f==="horizontal"?"horizontal":"vertical";return r.jsxs(nm,{className:vn(["react-flow__controls",U,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&r.jsxs(r.Fragment,{children:[r.jsx(Mh,{onClick:E,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:b,children:r.jsx(lY,{})}),r.jsx(Mh,{onClick:j,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:N,children:r.jsx(cY,{})})]}),n&&r.jsx(Mh,{className:"react-flow__controls-fitview",onClick:_,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:r.jsx(dY,{})}),a&&r.jsx(Mh,{className:"react-flow__controls-interactive",onClick:M,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:x?r.jsx(hY,{}):r.jsx(uY,{})}),h]})}r3.displayName="Controls";const pY=p.memo(r3);function mY({id:e,x:t,y:n,width:a,height:s,style:i,color:o,strokeColor:l,strokeWidth:c,className:u,borderRadius:h,shapeRendering:d,selected:f,onClick:m}){const{background:y,backgroundColor:x}=i||{},N=o||y||x;return r.jsx("rect",{className:vn(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:h,ry:h,width:a,height:s,style:{fill:N,stroke:l,strokeWidth:c},shapeRendering:d,onClick:m?b=>m(b,e):void 0})}const gY=p.memo(mY),bY=e=>e.nodes.map(t=>t.id),Ag=e=>e instanceof Function?e:()=>e;function xY({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:a=5,nodeStrokeWidth:s,nodeComponent:i=gY,onClick:o}){const l=gt(bY,Zt),c=Ag(t),u=Ag(e),h=Ag(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r.jsx(r.Fragment,{children:l.map(f=>r.jsx(yY,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:h,nodeBorderRadius:a,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:d},f))})}function vY({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:a,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:l,onClick:c}){const{node:u,x:h,y:d,width:f,height:m}=gt(y=>{const{internals:x}=y.nodeLookup.get(e),N=x.userNode,{x:b,y:v}=x.positionAbsolute,{width:g,height:w}=qs(N);return{node:N,x:b,y:v,width:g,height:w}},Zt);return!u||u.hidden||!eL(u)?null:r.jsx(l,{x:h,y:d,width:f,height:m,style:u.style,selected:!!u.selected,className:a(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:o,onClick:c,id:u.id})}const yY=p.memo(vY);var wY=p.memo(xY);const NY=200,SY=150,EY=e=>!e.hidden,jY=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?JM(Wu(e.nodeLookup,{filter:EY}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},TY="react-flow__minimap-desc";function s3({style:e,className:t,nodeStrokeColor:n,nodeColor:a,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:h,maskStrokeWidth:d,position:f="bottom-right",onClick:m,onNodeClick:y,pannable:x=!1,zoomable:N=!1,ariaLabel:b,inversePan:v,zoomStep:g=1,offsetScale:w=5}){const S=Vt(),E=p.useRef(null),{boundingRect:j,viewBB:_,rfId:M,panZoom:U,translateExtent:L,flowWidth:F,flowHeight:G,ariaLabelConfig:A}=gt(jY,Zt),P=(e==null?void 0:e.width)??NY,R=(e==null?void 0:e.height)??SY,k=j.width/P,T=j.height/R,D=Math.max(k,T),q=D*P,C=D*R,I=w*D,z=j.x-(q-j.width)/2-I,W=j.y-(C-j.height)/2-I,Y=q+I*2,ae=C+I*2,ne=`${TY}-${M}`,X=p.useRef(0),ie=p.useRef();X.current=D,p.useEffect(()=>{if(E.current&&U)return ie.current=Cq({domNode:E.current,panZoom:U,getTransform:()=>S.getState().transform,getViewScale:()=>X.current}),()=>{var be;(be=ie.current)==null||be.destroy()}},[U]),p.useEffect(()=>{var be;(be=ie.current)==null||be.update({translateExtent:L,width:F,height:G,inversePan:v,pannable:x,zoomStep:g,zoomable:N})},[x,N,v,g,L,F,G]);const ve=m?be=>{var $e;const[Ue,Be]=(($e=ie.current)==null?void 0:$e.pointer(be))||[0,0];m(be,{x:Ue,y:Be})}:void 0,se=y?p.useCallback((be,Ue)=>{const Be=S.getState().nodeLookup.get(Ue).internals.userNode;y(be,Be)},[]):void 0,ge=b??A["minimap.ariaLabel"];return r.jsx(nm,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*D:void 0,"--xy-minimap-node-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:vn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:r.jsxs("svg",{width:P,height:R,viewBox:`${z} ${W} ${Y} ${ae}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:E,onClick:ve,children:[ge&&r.jsx("title",{id:ne,children:ge}),r.jsx(wY,{onClick:se,nodeColor:a,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:l}),r.jsx("path",{className:"react-flow__minimap-mask",d:`M${z-I},${W-I}h${Y+I*2}v${ae+I*2}h${-Y-I*2}z
|
|
97
|
+
`)),h=u.reduce((d,f)=>d.concat(...f),[]);return[u,h]}return[[],[]]},[e]);return p.useEffect(()=>{const c=(t==null?void 0:t.target)??aT,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=m=>{var N,b;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!u)&&aL(m))return!1;const x=sT(m.code,l);if(i.current.add(m[x]),rT(o,i.current,!1)){const v=((b=(N=m.composedPath)==null?void 0:N.call(m))==null?void 0:b[0])||m.target,g=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!g)&&m.preventDefault(),a(!0)}},d=m=>{const y=sT(m.code,l);rT(o,i.current,!0)?(a(!1),i.current.clear()):i.current.delete(m[y]),m.key==="Meta"&&i.current.clear(),s.current=!1},f=()=>{i.current.clear(),a(!1)};return c==null||c.addEventListener("keydown",h),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",h),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,a]),n}function rT(e,t,n){return e.filter(a=>n||a.length===t.size).some(a=>a.every(s=>t.has(s)))}function sT(e,t){return t.includes(e)?"code":"key"}const OG=()=>{const e=Vt();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:a}=e.getState();return a?a.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[a,s,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??a,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,a]=e.getState().transform;return{x:t,y:n,zoom:a}},setCenter:async(t,n,a)=>e.getState().setCenter(t,n,a),fitBounds:async(t,n)=>{const{width:a,height:s,minZoom:i,maxZoom:o,panZoom:l}=e.getState(),c=cS(t,a,s,i,o,(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:a,snapGrid:s,snapToGrid:i,domNode:o}=e.getState();if(!o)return t;const{x:l,y:c}=o.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},h=n.snapGrid??s,d=n.snapToGrid??i;return Ku(u,a,d,h)},flowToScreenPosition:t=>{const{transform:n,domNode:a}=e.getState();if(!a)return t;const{x:s,y:i}=a.getBoundingClientRect(),o=cp(t,n);return{x:o.x+s,y:o.y+i}}}),[])};function _L(e,t){const n=[],a=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")a.set(i.id,[i]);else{const o=a.get(i.id);o?o.push(i):a.set(i.id,[i])}for(const i of t){const o=a.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const l={...i};for(const c of o)DG(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function DG(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 RL(e,t){return _L(e,t)}function OL(e,t){return _L(e,t)}function po(e,t){return{id:e,type:"select",selected:t}}function Ll(e,t=new Set,n=!1){const a=[];for(const[s,i]of e){const o=t.has(s);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),a.push(po(i.id,o)))}return a}function iT({items:e=[],lookup:t}){var s;const n=[],a=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const l=t.get(o.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)a.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function oT(e){return{id:e.id,type:"remove"}}const lT=e=>q7(e),IG=e=>XM(e);function DL(e){return p.forwardRef(e)}const MG=typeof window<"u"?p.useLayoutEffect:p.useEffect;function cT(e){const[t,n]=p.useState(BigInt(0)),[a]=p.useState(()=>LG(()=>n(s=>s+BigInt(1))));return MG(()=>{const s=a.get();s.length&&(e(s),a.reset())},[t]),a}function LG(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const IL=p.createContext(null);function UG({children:e}){const t=Vt(),n=p.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:h,onNodesChange:d,nodeLookup:f,fitViewQueued:m}=t.getState();let y=c;for(const N of l)y=typeof N=="function"?N(y):N;const x=iT({items:y,lookup:f});h&&u(y),x.length>0?d==null||d(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:b,setNodes:v}=t.getState();N&&v(b)})},[]),a=cT(n),s=p.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:h,onEdgesChange:d,edgeLookup:f}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;h?u(m):d&&d(iT({items:m,lookup:f}))},[]),i=cT(s),o=p.useMemo(()=>({nodeQueue:a,edgeQueue:i}),[]);return r.jsx(IL.Provider,{value:o,children:e})}function PG(){const e=p.useContext(IL);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const FG=e=>!!e.panZoom;function mS(){const e=OG(),t=Vt(),n=PG(),a=gt(FG),s=p.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),o=d=>{n.nodeQueue.push(d)},l=d=>{n.edgeQueue.push(d)},c=d=>{var b,v;const{nodeLookup:f,nodeOrigin:m}=t.getState(),y=lT(d)?d:f.get(d.id),x=y.parentId?tL(y.position,y.measured,y.parentId,f,m):y.position,N={...y,position:x,width:((b=y.measured)==null?void 0:b.width)??y.width,height:((v=y.measured)==null?void 0:v.height)??y.height};return xc(N)},u=(d,f,m={replace:!1})=>{o(y=>y.map(x=>{if(x.id===d){const N=typeof f=="function"?f(x):f;return m.replace&&lT(N)?N:{...x,...N}}return x}))},h=(d,f,m={replace:!1})=>{l(y=>y.map(x=>{if(x.id===d){const N=typeof f=="function"?f(x):f;return m.replace&&IG(N)?N:{...x,...N}}return x}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:o,setEdges:l,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(m=>[...m,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(m=>[...m,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:m}=t.getState(),[y,x,N]=m;return{nodes:d.map(b=>({...b})),edges:f.map(b=>({...b})),viewport:{x:y,y:x,zoom:N}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:m,edges:y,onNodesDelete:x,onEdgesDelete:N,triggerNodeChanges:b,triggerEdgeChanges:v,onDelete:g,onBeforeDelete:w}=t.getState(),{nodes:S,edges:E}=await X7({nodesToRemove:d,edgesToRemove:f,nodes:m,edges:y,onBeforeDelete:w}),j=E.length>0,_=S.length>0;if(j){const M=E.map(oT);N==null||N(E),v(M)}if(_){const M=S.map(oT);x==null||x(S),b(M)}return(_||j)&&(g==null||g({nodes:S,edges:E})),{deletedNodes:S,deletedEdges:E}},getIntersectingNodes:(d,f=!0,m)=>{const y=Pj(d),x=y?d:c(d),N=m!==void 0;return x?(m||t.getState().nodes).filter(b=>{const v=t.getState().nodeLookup.get(b.id);if(v&&!y&&(b.id===d.id||!v.internals.positionAbsolute))return!1;const g=xc(N?b:v),w=mu(g,x);return f&&w>0||w>=g.width*g.height||w>=x.width*x.height}):[]},isNodeIntersecting:(d,f,m=!0)=>{const x=Pj(d)?d:c(d);if(!x)return!1;const N=mu(x,f);return m&&N>0||N>=f.width*f.height||N>=x.width*x.height},updateNode:u,updateNodeData:(d,f,m={replace:!1})=>{u(d,y=>{const x=typeof f=="function"?f(y):f;return m.replace?{...y,data:x}:{...y,data:{...y.data,...x}}},m)},updateEdge:h,updateEdgeData:(d,f,m={replace:!1})=>{h(d,y=>{const x=typeof f=="function"?f(y):f;return m.replace?{...y,data:x}:{...y,data:{...y.data,...x}}},m)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:m}=t.getState();return G7(d,{nodeLookup:f,nodeOrigin:m})},getHandleConnections:({type:d,id:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${d}${f?`-${f}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:y.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??J7();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(m=>[...m]),f.promise}}},[]);return p.useMemo(()=>({...s,...e,viewportInitialized:a}),[a])}const dT=e=>e.selected,BG=typeof window<"u"?window:void 0;function zG({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Vt(),{deleteElements:a}=mS(),s=xu(e,{actInsideInputWithModifier:!1}),i=xu(t,{target:BG});p.useEffect(()=>{if(s){const{edges:o,nodes:l}=n.getState();a({nodes:l.filter(dT),edges:o.filter(dT)}),n.setState({nodesSelectionActive:!1})}},[s]),p.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function $G(e){const t=Vt();p.useEffect(()=>{const n=()=>{var s,i,o,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const a=dS(e.current);(a.height===0||a.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",Yr.error004())),t.setState({width:a.width||500,height:a.height||500})};if(e.current){n(),window.addEventListener("resize",n);const a=new ResizeObserver(()=>n());return a.observe(e.current),()=>{window.removeEventListener("resize",n),a&&e.current&&a.unobserve(e.current)}}},[])}const am={position:"absolute",width:"100%",height:"100%",top:0,left:0},HG=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function qG({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Ao.Free,zoomOnDoubleClick:o=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:h,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:m=!0,children:y,noWheelClassName:x,noPanClassName:N,onViewportChange:b,isControlledViewport:v,paneClickDistance:g,selectionOnDrag:w}){const S=Vt(),E=p.useRef(null),{userSelectionActive:j,lib:_,connectionInProgress:M}=gt(HG,Zt),U=xu(f),L=p.useRef();$G(E);const F=p.useCallback(G=>{b==null||b({x:G[0],y:G[1],zoom:G[2]}),v||S.setState({transform:G})},[b,v]);return p.useEffect(()=>{if(E.current){L.current=Mq({domNode:E.current,minZoom:h,maxZoom:d,translateExtent:u,viewport:c,onDraggingChange:R=>S.setState({paneDragging:R}),onPanZoomStart:(R,k)=>{const{onViewportChangeStart:T,onMoveStart:D}=S.getState();D==null||D(R,k),T==null||T(k)},onPanZoom:(R,k)=>{const{onViewportChange:T,onMove:D}=S.getState();D==null||D(R,k),T==null||T(k)},onPanZoomEnd:(R,k)=>{const{onViewportChangeEnd:T,onMoveEnd:D}=S.getState();D==null||D(R,k),T==null||T(k)}});const{x:G,y:A,zoom:P}=L.current.getViewport();return S.setState({panZoom:L.current,transform:[G,A,P],domNode:E.current.closest(".react-flow")}),()=>{var R;(R=L.current)==null||R.destroy()}}},[]),p.useEffect(()=>{var G;(G=L.current)==null||G.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:a,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:l,zoomActivationKeyPressed:U,preventScrolling:m,noPanClassName:N,userSelectionActive:j,noWheelClassName:x,lib:_,onTransformChange:F,connectionInProgress:M,selectionOnDrag:w,paneClickDistance:g})},[e,t,n,a,s,i,o,l,U,m,N,j,x,_,F,M,w,g]),r.jsx("div",{className:"react-flow__renderer",ref:E,style:am,children:y})}const GG=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function VG(){const{userSelectionActive:e,userSelectionRect:t}=gt(GG,Zt);return e&&t?r.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 kg=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},YG=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function WG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pu.Full,panOnDrag:a,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:o,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:m,children:y}){const x=Vt(),{userSelectionActive:N,elementsSelectable:b,dragging:v,connectionInProgress:g}=gt(YG,Zt),w=b&&(e||N),S=p.useRef(null),E=p.useRef(),j=p.useRef(new Set),_=p.useRef(new Set),M=p.useRef(!1),U=T=>{if(M.current||g){M.current=!1;return}c==null||c(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},L=T=>{if(Array.isArray(a)&&(a!=null&&a.includes(2))){T.preventDefault();return}u==null||u(T)},F=h?T=>h(T):void 0,G=T=>{M.current&&(T.stopPropagation(),M.current=!1)},A=T=>{var Y,ae;const{domNode:D}=x.getState();if(E.current=D==null?void 0:D.getBoundingClientRect(),!E.current)return;const q=T.target===S.current;if(!q&&!!T.target.closest(".nokey")||!e||!(i&&q||t)||T.button!==0||!T.isPrimary)return;(ae=(Y=T.target)==null?void 0:Y.setPointerCapture)==null||ae.call(Y,T.pointerId),M.current=!1;const{x:z,y:W}=pr(T.nativeEvent,E.current);x.setState({userSelectionRect:{width:0,height:0,startX:z,startY:W,x:z,y:W}}),q||(T.stopPropagation(),T.preventDefault())},P=T=>{const{userSelectionRect:D,transform:q,nodeLookup:C,edgeLookup:I,connectionLookup:z,triggerNodeChanges:W,triggerEdgeChanges:Y,defaultEdgeOptions:ae,resetSelectedElements:ne}=x.getState();if(!E.current||!D)return;const{x:X,y:ie}=pr(T.nativeEvent,E.current),{startX:ve,startY:se}=D;if(!M.current){const $e=t?0:s;if(Math.hypot(X-ve,ie-se)<=$e)return;ne(),o==null||o(T)}M.current=!0;const ge={startX:ve,startY:se,x:X<ve?X:ve,y:ie<se?ie:se,width:Math.abs(X-ve),height:Math.abs(ie-se)},be=j.current,Ue=_.current;j.current=new Set(lS(C,ge,q,n===pu.Partial,!0).map($e=>$e.id)),_.current=new Set;const Be=(ae==null?void 0:ae.selectable)??!0;for(const $e of j.current){const Ye=z.get($e);if(Ye)for(const{edgeId:bt}of Ye.values()){const Ke=I.get(bt);Ke&&(Ke.selectable??Be)&&_.current.add(bt)}}if(!Fj(be,j.current)){const $e=Ll(C,j.current,!0);W($e)}if(!Fj(Ue,_.current)){const $e=Ll(I,_.current);Y($e)}x.setState({userSelectionRect:ge,userSelectionActive:!0,nodesSelectionActive:!1})},R=T=>{var D,q;T.button===0&&((q=(D=T.target)==null?void 0:D.releasePointerCapture)==null||q.call(D,T.pointerId),!N&&T.target===S.current&&x.getState().userSelectionRect&&(U==null||U(T)),x.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l==null||l(T),x.setState({nodesSelectionActive:j.current.size>0})))},k=a===!0||Array.isArray(a)&&a.includes(0);return r.jsxs("div",{className:vn(["react-flow__pane",{draggable:k,dragging:v,selection:e}]),onClick:w?void 0:kg(U,S),onContextMenu:kg(L,S),onWheel:kg(F,S),onPointerEnter:w?void 0:d,onPointerMove:w?P:f,onPointerUp:w?R:void 0,onPointerDownCapture:w?A:void 0,onClickCapture:w?G:void 0,onPointerLeave:m,ref:S,style:am,children:[y,r.jsx(VG,{})]})}function EN({id:e,store:t,unselect:n=!1,nodeRef:a}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Yr.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var h;return(h=a==null?void 0:a.current)==null?void 0:h.blur()})):s([e])}function ML({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:a,nodeId:s,isSelectable:i,nodeClickDistance:o}){const l=Vt(),[c,u]=p.useState(!1),h=p.useRef();return p.useEffect(()=>{h.current=wq({getStoreItems:()=>l.getState(),onNodeMouseDown:d=>{EN({id:d,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),p.useEffect(()=>{var d,f;if(t)(d=h.current)==null||d.destroy();else if(e.current)return(f=h.current)==null||f.update({noDragClassName:n,handleSelector:a,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:o}),()=>{var m;(m=h.current)==null||m.destroy()}},[n,a,t,i,e,s]),c}const XG=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function LL(){const e=Vt();return p.useCallback(n=>{const{nodeExtent:a,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:h}=e.getState(),d=new Map,f=XG(o),m=s?i[0]:5,y=s?i[1]:5,x=n.direction.x*m*n.factor,N=n.direction.y*y*n.factor;for(const[,b]of u){if(!f(b))continue;let v={x:b.internals.positionAbsolute.x+x,y:b.internals.positionAbsolute.y+N};s&&(v=Xu(v,i));const{position:g,positionAbsolute:w}=KM({nodeId:b.id,nextPosition:v,nodeLookup:u,nodeExtent:a,nodeOrigin:h,onError:l});b.position=g,b.internals.positionAbsolute=w,d.set(b.id,b)}c(d)},[])}const gS=p.createContext(null),KG=gS.Provider;gS.Consumer;const UL=()=>p.useContext(gS),ZG=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),QG=(e,t,n)=>a=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=a,{fromHandle:l,toHandle:c,isValid:u}=o,h=(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:h,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===gc.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:!!s,valid:h&&u}};function JG({type:e="source",position:t=Ve.Top,isValidConnection:n,isConnectable:a=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:l,children:c,className:u,onMouseDown:h,onTouchStart:d,...f},m){var P,R;const y=o||null,x=e==="target",N=Vt(),b=UL(),{connectOnClick:v,noPanClassName:g,rfId:w}=gt(ZG,Zt),{connectingFrom:S,connectingTo:E,clickConnecting:j,isPossibleEndHandle:_,connectionInProcess:M,clickConnectionInProcess:U,valid:L}=gt(QG(b,y,e),Zt);b||(R=(P=N.getState()).onError)==null||R.call(P,"010",Yr.error010());const F=k=>{const{defaultEdgeOptions:T,onConnect:D,hasDefaultEdges:q}=N.getState(),C={...T,...k};if(q){const{edges:I,setEdges:z}=N.getState();z(lL(C,I))}D==null||D(C),l==null||l(C)},G=k=>{if(!b)return;const T=rL(k.nativeEvent);if(s&&(T&&k.button===0||!T)){const D=N.getState();SN.onPointerDown(k.nativeEvent,{handleDomNode:k.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:x,handleId:y,nodeId:b,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:D.onConnectEnd,updateConnection:D.updateConnection,onConnect:F,isValidConnection:n||D.isValidConnection,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}T?h==null||h(k):d==null||d(k)},A=k=>{const{onClickConnectStart:T,onClickConnectEnd:D,connectionClickStartHandle:q,connectionMode:C,isValidConnection:I,lib:z,rfId:W,nodeLookup:Y,connection:ae}=N.getState();if(!b||!q&&!s)return;if(!q){T==null||T(k.nativeEvent,{nodeId:b,handleId:y,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:b,type:e,id:y}});return}const ne=nL(k.target),X=n||I,{connection:ie,isValid:ve}=SN.isValid(k.nativeEvent,{handle:{nodeId:b,id:y,type:e},connectionMode:C,fromNodeId:q.nodeId,fromHandleId:q.id||null,fromType:q.type,isValidConnection:X,flowId:W,doc:ne,lib:z,nodeLookup:Y});ve&&ie&&F(ie);const se=structuredClone(ae);delete se.inProgress,se.toPosition=se.toHandle?se.toHandle.position:null,D==null||D(k,se),N.setState({connectionClickStartHandle:null})};return r.jsx("div",{"data-handleid":y,"data-nodeid":b,"data-handlepos":t,"data-id":`${w}-${b}-${y}-${e}`,className:vn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,u,{source:!x,target:x,connectable:a,connectablestart:s,connectableend:i,clickconnecting:j,connectingfrom:S,connectingto:E,valid:L,connectionindicator:a&&(!M||_)&&(M||U?i:s)}]),onMouseDown:G,onTouchStart:G,onClick:v?A:void 0,ref:m,...f,children:c})}const _o=p.memo(DL(JG));function eV({data:e,isConnectable:t,sourcePosition:n=Ve.Bottom}){return r.jsxs(r.Fragment,{children:[e==null?void 0:e.label,r.jsx(_o,{type:"source",position:n,isConnectable:t})]})}function tV({data:e,isConnectable:t,targetPosition:n=Ve.Top,sourcePosition:a=Ve.Bottom}){return r.jsxs(r.Fragment,{children:[r.jsx(_o,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,r.jsx(_o,{type:"source",position:a,isConnectable:t})]})}function nV(){return null}function aV({data:e,isConnectable:t,targetPosition:n=Ve.Top}){return r.jsxs(r.Fragment,{children:[r.jsx(_o,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const dp={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},uT={input:eV,default:tV,output:aV,group:nV};function rV(e){var t,n,a,s;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??((a=e.style)==null?void 0:a.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const sV=e=>{const{width:t,height:n,x:a,y:s}=Wu(e.nodeLookup,{filter:i=>!!i.selected});return{width:fr(t)?t:null,height:fr(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${a}px,${s}px)`}};function iV({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const a=Vt(),{width:s,height:i,transformString:o,userSelectionActive:l}=gt(sV,Zt),c=LL(),u=p.useRef(null);if(p.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]),ML({nodeRef:u}),l||!s||!i)return null;const h=e?f=>{const m=a.getState().nodes.filter(y=>y.selected);e(f,m)}:void 0,d=f=>{Object.prototype.hasOwnProperty.call(dp,f.key)&&(f.preventDefault(),c({direction:dp[f.key],factor:f.shiftKey?4:1}))};return r.jsx("div",{className:vn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:r.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:s,height:i}})})}const hT=typeof window<"u"?window:void 0,oV=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function PL({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:h,selectionMode:d,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:x,zoomActivationKeyCode:N,elementsSelectable:b,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:M,translateExtent:U,minZoom:L,maxZoom:F,preventScrolling:G,onSelectionContextMenu:A,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:k,onViewportChange:T,isControlledViewport:D}){const{nodesSelectionActive:q,userSelectionActive:C}=gt(oV),I=xu(u,{target:hT}),z=xu(x,{target:hT}),W=z||_,Y=z||w,ae=h&&W!==!0,ne=I||C||ae;return zG({deleteKeyCode:c,multiSelectionKeyCode:y}),r.jsx(qG,{onPaneContextMenu:i,elementsSelectable:b,zoomOnScroll:v,zoomOnPinch:g,panOnScroll:Y,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!I&&W,defaultViewport:M,translateExtent:U,minZoom:L,maxZoom:F,zoomActivationKeyCode:N,preventScrolling:G,noWheelClassName:P,noPanClassName:R,onViewportChange:T,isControlledViewport:D,paneClickDistance:l,selectionOnDrag:ae,children:r.jsxs(WG,{onSelectionStart:f,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:W,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:I,paneClickDistance:l,selectionOnDrag:ae,children:[e,q&&r.jsx(iV,{onSelectionContextMenu:A,noPanClassName:R,disableKeyboardA11y:k})]})})}PL.displayName="FlowRenderer";const lV=p.memo(PL),cV=e=>t=>e?lS(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 dV(e){return gt(p.useCallback(cV(e),[e]),Zt)}const uV=e=>e.updateNodeInternals;function hV(){const e=gt(uV),[t]=p.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const a=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");a.set(i,{id:i,nodeElement:s.target,force:!0})}),e(a)}));return p.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function fV({node:e,nodeType:t,hasDimensions:n,resizeObserver:a}){const s=Vt(),i=p.useRef(null),o=p.useRef(null),l=p.useRef(e.sourcePosition),c=p.useRef(e.targetPosition),u=p.useRef(t),h=n&&!!e.internals.handleBounds;return p.useEffect(()=>{i.current&&!e.hidden&&(!h||o.current!==i.current)&&(o.current&&(a==null||a.unobserve(o.current)),a==null||a.observe(i.current),o.current=i.current)},[h,e.hidden]),p.useEffect(()=>()=>{o.current&&(a==null||a.unobserve(o.current),o.current=null)},[]),p.useEffect(()=>{if(i.current){const d=u.current!==t,f=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(d||f||m)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function pV({id:e,onClick:t,onMouseEnter:n,onMouseMove:a,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:h,resizeObserver:d,noDragClassName:f,noPanClassName:m,disableKeyboardA11y:y,rfId:x,nodeTypes:N,nodeClickDistance:b,onError:v}){const{node:g,internals:w,isParent:S}=gt(X=>{const ie=X.nodeLookup.get(e),ve=X.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:ve}},Zt);let E=g.type||"default",j=(N==null?void 0:N[E])||uT[E];j===void 0&&(v==null||v("003",Yr.error003(E)),E="default",j=(N==null?void 0:N.default)||uT.default);const _=!!(g.draggable||l&&typeof g.draggable>"u"),M=!!(g.selectable||c&&typeof g.selectable>"u"),U=!!(g.connectable||u&&typeof g.connectable>"u"),L=!!(g.focusable||h&&typeof g.focusable>"u"),F=Vt(),G=eL(g),A=fV({node:g,nodeType:E,hasDimensions:G,resizeObserver:d}),P=ML({nodeRef:A,disabled:g.hidden||!_,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:b}),R=LL();if(g.hidden)return null;const k=qs(g),T=rV(g),D=M||_||t||n||a||s,q=n?X=>n(X,{...w.userNode}):void 0,C=a?X=>a(X,{...w.userNode}):void 0,I=s?X=>s(X,{...w.userNode}):void 0,z=i?X=>i(X,{...w.userNode}):void 0,W=o?X=>o(X,{...w.userNode}):void 0,Y=X=>{const{selectNodesOnDrag:ie,nodeDragThreshold:ve}=F.getState();M&&(!ie||!_||ve>0)&&EN({id:e,store:F,nodeRef:A}),t&&t(X,{...w.userNode})},ae=X=>{if(!(aL(X.nativeEvent)||y)){if(GM.includes(X.key)&&M){const ie=X.key==="Escape";EN({id:e,store:F,unselect:ie,nodeRef:A})}else if(_&&g.selected&&Object.prototype.hasOwnProperty.call(dp,X.key)){X.preventDefault();const{ariaLabelConfig:ie}=F.getState();F.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),R({direction:dp[X.key],factor:X.shiftKey?4:1})}}},ne=()=>{var Ue;if(y||!((Ue=A.current)!=null&&Ue.matches(":focus-visible")))return;const{transform:X,width:ie,height:ve,autoPanOnNodeFocus:se,setCenter:ge}=F.getState();if(!se)return;lS(new Map([[e,g]]),{x:0,y:0,width:ie,height:ve},X,!0).length>0||ge(g.position.x+k.width/2,g.position.y+k.height/2,{zoom:X[2]})};return r.jsx("div",{className:vn(["react-flow__node",`react-flow__node-${E}`,{[m]:_},g.className,{selected:g.selected,selectable:M,parent:S,draggable:_,dragging:P}]),ref:A,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:G?"visible":"hidden",...g.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:q,onMouseMove:C,onMouseLeave:I,onContextMenu:z,onClick:Y,onDoubleClick:W,onKeyDown:L?ae:void 0,tabIndex:L?0:void 0,onFocus:L?ne:void 0,role:g.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${CL}-${x}`,"aria-label":g.ariaLabel,...g.domAttributes,children:r.jsx(KG,{value:e,children:r.jsx(j,{id:e,data:g.data,type:E,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:g.selected??!1,selectable:M,draggable:_,deletable:g.deletable??!0,isConnectable:U,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:P,dragHandle:g.dragHandle,zIndex:w.z,parentId:g.parentId,...k})})})}var mV=p.memo(pV);const gV=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function FL(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:a,elementsSelectable:s,onError:i}=gt(gV,Zt),o=dV(e.onlyRenderVisibleElements),l=hV();return r.jsx("div",{className:"react-flow__nodes",style:am,children:o.map(c=>r.jsx(mV,{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:a,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}FL.displayName="NodeRenderer";const bV=p.memo(FL);function xV(e){return gt(p.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const a=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);i&&o&&aq({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&a.push(s.id)}return a},[e]),Zt)}const vV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fT={[op.Arrow]:vV,[op.ArrowClosed]:yV};function wV(e){const t=Vt();return p.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(fT,e)?fT[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Yr.error009(e)),null)},[e])}const NV=({id:e,type:t,color:n,width:a=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const c=wV(t);return c?r.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${a}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:r.jsx(c,{color:n,strokeWidth:o})}):null},BL=({defaultColor:e,rfId:t})=>{const n=gt(i=>i.edges),a=gt(i=>i.defaultEdgeOptions),s=p.useMemo(()=>dq(n,{id:t,defaultColor:e,defaultMarkerStart:a==null?void 0:a.markerStart,defaultMarkerEnd:a==null?void 0:a.markerEnd}),[n,a,t,e]);return s.length?r.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:r.jsx("defs",{children:s.map(i=>r.jsx(NV,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};BL.displayName="MarkerDefinitions";var SV=p.memo(BL);function zL({x:e,y:t,label:n,labelStyle:a,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...h}){const[d,f]=p.useState({x:1,y:0,width:0,height:0}),m=vn(["react-flow__edge-textwrapper",u]),y=p.useRef(null);return p.useEffect(()=>{if(y.current){const x=y.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?r.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:m,visibility:d.width?"visible":"hidden",...h,children:[s&&r.jsx("rect",{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),r.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:y,style:a,children:n}),c]}):null}zL.displayName="EdgeText";const EV=p.memo(zL);function rm({path:e,labelX:t,labelY:n,label:a,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...h}){return r.jsxs(r.Fragment,{children:[r.jsx("path",{...h,d:e,fill:"none",className:vn(["react-flow__edge-path",h.className])}),u?r.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,a&&fr(t)&&fr(n)?r.jsx(EV,{x:t,y:n,label:a,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function pT({pos:e,x1:t,y1:n,x2:a,y2:s}){return e===Ve.Left||e===Ve.Right?[.5*(t+a),n]:[t,.5*(n+s)]}function $L({sourceX:e,sourceY:t,sourcePosition:n=Ve.Bottom,targetX:a,targetY:s,targetPosition:i=Ve.Top}){const[o,l]=pT({pos:n,x1:e,y1:t,x2:a,y2:s}),[c,u]=pT({pos:i,x1:a,y1:s,x2:e,y2:t}),[h,d,f,m]=sL({sourceX:e,sourceY:t,targetX:a,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${o},${l} ${c},${u} ${a},${s}`,h,d,f,m]}function HL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,sourcePosition:o,targetPosition:l,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:b})=>{const[v,g,w]=$L({sourceX:n,sourceY:a,sourcePosition:o,targetX:s,targetY:i,targetPosition:l}),S=e.isInternal?void 0:t;return r.jsx(rm,{id:S,path:v,labelX:g,labelY:w,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:b})})}const jV=HL({isInternal:!1}),qL=HL({isInternal:!0});jV.displayName="SimpleBezierEdge";qL.displayName="SimpleBezierEdgeInternal";function GL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,sourcePosition:m=Ve.Bottom,targetPosition:y=Ve.Top,markerEnd:x,markerStart:N,pathOptions:b,interactionWidth:v})=>{const[g,w,S]=yN({sourceX:n,sourceY:a,sourcePosition:m,targetX:s,targetY:i,targetPosition:y,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset,stepPosition:b==null?void 0:b.stepPosition}),E=e.isInternal?void 0:t;return r.jsx(rm,{id:E,path:g,labelX:w,labelY:S,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:x,markerStart:N,interactionWidth:v})})}const VL=GL({isInternal:!1}),YL=GL({isInternal:!0});VL.displayName="SmoothStepEdge";YL.displayName="SmoothStepEdgeInternal";function WL(e){return p.memo(({id:t,...n})=>{var s;const a=e.isInternal?void 0:t;return r.jsx(VL,{...n,id:a,pathOptions:p.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const TV=WL({isInternal:!1}),XL=WL({isInternal:!0});TV.displayName="StepEdge";XL.displayName="StepEdgeInternal";function KL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,b,v]=cL({sourceX:n,sourceY:a,targetX:s,targetY:i}),g=e.isInternal?void 0:t;return r.jsx(rm,{id:g,path:N,labelX:b,labelY:v,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:h,labelBgBorderRadius:d,style:f,markerEnd:m,markerStart:y,interactionWidth:x})})}const CV=KL({isInternal:!1}),ZL=KL({isInternal:!0});CV.displayName="StraightEdge";ZL.displayName="StraightEdgeInternal";function QL(e){return p.memo(({id:t,sourceX:n,sourceY:a,targetX:s,targetY:i,sourcePosition:o=Ve.Bottom,targetPosition:l=Ve.Top,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:b,interactionWidth:v})=>{const[g,w,S]=iL({sourceX:n,sourceY:a,sourcePosition:o,targetX:s,targetY:i,targetPosition:l,curvature:b==null?void 0:b.curvature}),E=e.isInternal?void 0:t;return r.jsx(rm,{id:E,path:g,labelX:w,labelY:S,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:v})})}const kV=QL({isInternal:!1}),JL=QL({isInternal:!0});kV.displayName="BezierEdge";JL.displayName="BezierEdgeInternal";const mT={default:JL,straight:ZL,step:XL,smoothstep:YL,simplebezier:qL},gT={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},AV=(e,t,n)=>n===Ve.Left?e-t:n===Ve.Right?e+t:e,_V=(e,t,n)=>n===Ve.Top?e-t:n===Ve.Bottom?e+t:e,bT="react-flow__edgeupdater";function xT({position:e,centerX:t,centerY:n,radius:a=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:l}){return r.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:vn([bT,`${bT}-${l}`]),cx:AV(t,a,e),cy:_V(n,a,e),r:a,stroke:"transparent",fill:"transparent"})}function RV({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:a,sourceY:s,targetX:i,targetY:o,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:h,onReconnectEnd:d,setReconnecting:f,setUpdateHover:m}){const y=Vt(),x=(w,S)=>{if(w.button!==0)return;const{autoPanOnConnect:E,domNode:j,isValidConnection:_,connectionMode:M,connectionRadius:U,lib:L,onConnectStart:F,onConnectEnd:G,cancelConnection:A,nodeLookup:P,rfId:R,panBy:k,updateConnection:T}=y.getState(),D=S.type==="target",q=(z,W)=>{f(!1),d==null||d(z,n,S.type,W)},C=z=>u==null?void 0:u(n,z),I=(z,W)=>{f(!0),h==null||h(w,n,S.type),F==null||F(z,W)};SN.onPointerDown(w.nativeEvent,{autoPanOnConnect:E,connectionMode:M,connectionRadius:U,domNode:j,handleId:S.id,nodeId:S.nodeId,nodeLookup:P,isTarget:D,edgeUpdaterType:S.type,lib:L,flowId:R,cancelConnection:A,panBy:k,isValidConnection:_,onConnect:C,onConnectStart:I,onConnectEnd:G,onReconnectEnd:q,updateConnection:T,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},N=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),b=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),g=()=>m(!1);return r.jsxs(r.Fragment,{children:[(e===!0||e==="source")&&r.jsx(xT,{position:l,centerX:a,centerY:s,radius:t,onMouseDown:N,onMouseEnter:v,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&r.jsx(xT,{position:c,centerX:i,centerY:o,radius:t,onMouseDown:b,onMouseEnter:v,onMouseOut:g,type:"target"})]})}function OV({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:a,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:h,onReconnect:d,onReconnectStart:f,onReconnectEnd:m,rfId:y,edgeTypes:x,noPanClassName:N,onError:b,disableKeyboardA11y:v}){let g=gt(ge=>ge.edgeLookup.get(e));const w=gt(ge=>ge.defaultEdgeOptions);g=w?{...w,...g}:g;let S=g.type||"default",E=(x==null?void 0:x[S])||mT[S];E===void 0&&(b==null||b("011",Yr.error011(S)),S="default",E=(x==null?void 0:x.default)||mT.default);const j=!!(g.focusable||t&&typeof g.focusable>"u"),_=typeof d<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),M=!!(g.selectable||a&&typeof g.selectable>"u"),U=p.useRef(null),[L,F]=p.useState(!1),[G,A]=p.useState(!1),P=Vt(),{zIndex:R,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I}=gt(p.useCallback(ge=>{const be=ge.nodeLookup.get(g.source),Ue=ge.nodeLookup.get(g.target);if(!be||!Ue)return{zIndex:g.zIndex,...gT};const Be=cq({id:e,sourceNode:be,targetNode:Ue,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:ge.connectionMode,onError:b});return{zIndex:nq({selected:g.selected,zIndex:g.zIndex,sourceNode:be,targetNode:Ue,elevateOnSelect:ge.elevateEdgesOnSelect}),...Be||gT}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),Zt),z=p.useMemo(()=>g.markerStart?`url('#${wN(g.markerStart,y)}')`:void 0,[g.markerStart,y]),W=p.useMemo(()=>g.markerEnd?`url('#${wN(g.markerEnd,y)}')`:void 0,[g.markerEnd,y]);if(g.hidden||k===null||T===null||D===null||q===null)return null;const Y=ge=>{var $e;const{addSelectedEdges:be,unselectNodesAndEdges:Ue,multiSelectionActive:Be}=P.getState();M&&(P.setState({nodesSelectionActive:!1}),g.selected&&Be?(Ue({nodes:[],edges:[g]}),($e=U.current)==null||$e.blur()):be([e])),s&&s(ge,g)},ae=i?ge=>{i(ge,{...g})}:void 0,ne=o?ge=>{o(ge,{...g})}:void 0,X=l?ge=>{l(ge,{...g})}:void 0,ie=c?ge=>{c(ge,{...g})}:void 0,ve=u?ge=>{u(ge,{...g})}:void 0,se=ge=>{var be;if(!v&&GM.includes(ge.key)&&M){const{unselectNodesAndEdges:Ue,addSelectedEdges:Be}=P.getState();ge.key==="Escape"?((be=U.current)==null||be.blur(),Ue({edges:[g]})):Be([e])}};return r.jsx("svg",{style:{zIndex:R},children:r.jsxs("g",{className:vn(["react-flow__edge",`react-flow__edge-${S}`,g.className,N,{selected:g.selected,animated:g.animated,inactive:!M&&!s,updating:L,selectable:M}]),onClick:Y,onDoubleClick:ae,onContextMenu:ne,onMouseEnter:X,onMouseMove:ie,onMouseLeave:ve,onKeyDown:j?se:void 0,tabIndex:j?0:void 0,role:g.ariaRole??(j?"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":j?`${kL}-${y}`:void 0,ref:U,...g.domAttributes,children:[!G&&r.jsx(E,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:M,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:z,markerEnd:W,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),_&&r.jsx(RV,{edge:g,isReconnectable:_,reconnectRadius:h,onReconnect:d,onReconnectStart:f,onReconnectEnd:m,sourceX:k,sourceY:T,targetX:D,targetY:q,sourcePosition:C,targetPosition:I,setUpdateHover:F,setReconnecting:A})]})})}var DV=p.memo(OV);const IV=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function e3({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:a,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:x}){const{edgesFocusable:N,edgesReconnectable:b,elementsSelectable:v,onError:g}=gt(IV,Zt),w=xV(t);return r.jsxs("div",{className:"react-flow__edges",children:[r.jsx(SV,{defaultColor:e,rfId:n}),w.map(S=>r.jsx(DV,{id:S,edgesFocusable:N,edgesReconnectable:b,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:h,reconnectRadius:d,onDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:g,edgeTypes:a,disableKeyboardA11y:x},S))]})}e3.displayName="EdgeRenderer";const MV=p.memo(e3),LV=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function UV({children:e}){const t=gt(LV);return r.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function PV(e){const t=mS(),n=p.useRef(!1);p.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const FV=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function BV(e){const t=gt(FV),n=Vt();return p.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function zV(e){return e.connection.inProgress?{...e.connection,to:Ku(e.connection.to,e.transform)}:{...e.connection}}function $V(e){return zV}function HV(e){const t=$V();return gt(t,Zt)}const qV=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function GV({containerStyle:e,style:t,type:n,component:a}){const{nodesConnectable:s,width:i,height:o,isValid:l,inProgress:c}=gt(qV,Zt);return!(i&&s&&c)?null:r.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:r.jsx("g",{className:vn(["react-flow__connection",WM(l)]),children:r.jsx(t3,{style:t,type:n,CustomComponent:a,isValid:l})})})}const t3=({style:e,type:t=Ni.Bezier,CustomComponent:n,isValid:a})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:l,fromPosition:c,to:u,toNode:h,toHandle:d,toPosition:f,pointer:m}=HV();if(!s)return;if(n)return r.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:WM(a),toNode:h,toHandle:d,pointer:m});let y="";const x={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Ni.Bezier:[y]=iL(x);break;case Ni.SimpleBezier:[y]=$L(x);break;case Ni.Step:[y]=yN({...x,borderRadius:0});break;case Ni.SmoothStep:[y]=yN(x);break;default:[y]=cL(x)}return r.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};t3.displayName="ConnectionLine";const VV={};function vT(e=VV){p.useRef(e),Vt(),p.useEffect(()=>{},[e])}function YV(){Vt(),p.useRef(!1),p.useEffect(()=>{},[])}function n3({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:a,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:x,connectionLineComponent:N,connectionLineContainerStyle:b,selectionKeyCode:v,selectionOnDrag:g,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:j,deleteKeyCode:_,onlyRenderVisibleElements:M,elementsSelectable:U,defaultViewport:L,translateExtent:F,minZoom:G,maxZoom:A,preventScrolling:P,defaultMarkerColor:R,zoomOnScroll:k,zoomOnPinch:T,panOnScroll:D,panOnScrollSpeed:q,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:z,onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneScroll:X,onPaneContextMenu:ie,paneClickDistance:ve,nodeClickDistance:se,onEdgeContextMenu:ge,onEdgeMouseEnter:be,onEdgeMouseMove:Ue,onEdgeMouseLeave:Be,reconnectRadius:$e,onReconnect:Ye,onReconnectStart:bt,onReconnectEnd:Ke,noDragClassName:de,noWheelClassName:Fe,noPanClassName:Ie,disableKeyboardA11y:Ae,nodeExtent:We,rfId:at,viewport:ft,onViewportChange:Yt}){return vT(e),vT(t),YV(),PV(n),BV(ft),r.jsx(lV,{onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:ae,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:X,paneClickDistance:ve,deleteKeyCode:_,selectionKeyCode:v,selectionOnDrag:g,selectionMode:w,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:j,elementsSelectable:U,zoomOnScroll:k,zoomOnPinch:T,zoomOnDoubleClick:I,panOnScroll:D,panOnScrollSpeed:q,panOnScrollMode:C,panOnDrag:z,defaultViewport:L,translateExtent:F,minZoom:G,maxZoom:A,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:de,noWheelClassName:Fe,noPanClassName:Ie,disableKeyboardA11y:Ae,onViewportChange:Yt,isControlledViewport:!!ft,children:r.jsxs(UV,{children:[r.jsx(MV,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:Ye,onReconnectStart:bt,onReconnectEnd:Ke,onlyRenderVisibleElements:M,onEdgeContextMenu:ge,onEdgeMouseEnter:be,onEdgeMouseMove:Ue,onEdgeMouseLeave:Be,reconnectRadius:$e,defaultMarkerColor:R,noPanClassName:Ie,disableKeyboardA11y:Ae,rfId:at}),r.jsx(GV,{style:x,type:y,component:N,containerStyle:b}),r.jsx("div",{className:"react-flow__edgelabel-renderer"}),r.jsx(bV,{nodeTypes:e,onNodeClick:a,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:h,nodeClickDistance:se,onlyRenderVisibleElements:M,noPanClassName:Ie,noDragClassName:de,disableKeyboardA11y:Ae,nodeExtent:We,rfId:at}),r.jsx("div",{className:"react-flow__viewport-portal"})]})})}n3.displayName="GraphView";const WV=p.memo(n3),yT=({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:h,nodeExtent:d}={})=>{const f=new Map,m=new Map,y=new Map,x=new Map,N=a??t??[],b=n??e??[],v=h??[0,0],g=d??fu;hL(y,x,N);const w=NN(b,f,m,{nodeOrigin:v,nodeExtent:g,elevateNodesOnSelect:!1});let S=[0,0,1];if(o&&s&&i){const E=Wu(f,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:j,y:_,zoom:M}=cS(E,s,i,c,u,(l==null?void 0:l.padding)??.1);S=[j,_,M]}return{rfId:"1",width:s??0,height:i??0,transform:S,nodes:b,nodesInitialized:w,nodeLookup:f,parentLookup:m,edges:N,edgeLookup:x,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:a!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:fu,nodeExtent:g,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:gc.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:o??!1,fitViewOptions:l,fitViewResolver:null,connection:{...YM},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:K7,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:VM}},XV=({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:h,nodeExtent:d})=>fG((f,m)=>{async function y(){const{nodeLookup:x,panZoom:N,fitViewOptions:b,fitViewResolver:v,width:g,height:w,minZoom:S,maxZoom:E}=m();N&&(await W7({nodes:x,width:g,height:w,panZoom:N,minZoom:S,maxZoom:E},b),v==null||v.resolve(!0),f({fitViewResolver:null}))}return{...yT({nodes:e,edges:t,width:s,height:i,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:a}),setNodes:x=>{const{nodeLookup:N,parentLookup:b,nodeOrigin:v,elevateNodesOnSelect:g,fitViewQueued:w}=m(),S=NN(x,N,b,{nodeOrigin:v,nodeExtent:d,elevateNodesOnSelect:g,checkEquality:!0});w&&S?(y(),f({nodes:x,nodesInitialized:S,fitViewQueued:!1,fitViewOptions:void 0})):f({nodes:x,nodesInitialized:S})},setEdges:x=>{const{connectionLookup:N,edgeLookup:b}=m();hL(N,b,x),f({edges:x})},setDefaultNodesAndEdges:(x,N)=>{if(x){const{setNodes:b}=m();b(x),f({hasDefaultNodes:!0})}if(N){const{setEdges:b}=m();b(N),f({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:N,nodeLookup:b,parentLookup:v,domNode:g,nodeOrigin:w,nodeExtent:S,debug:E,fitViewQueued:j}=m(),{changes:_,updatedInternals:M}=bq(x,b,v,g,w,S);M&&(fq(b,v,{nodeOrigin:w,nodeExtent:S}),j?(y(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(_==null?void 0:_.length)>0&&(E&&console.log("React Flow: trigger node changes",_),N==null||N(_)))},updateNodePositions:(x,N=!1)=>{const b=[],v=[],{nodeLookup:g,triggerNodeChanges:w}=m();for(const[S,E]of x){const j=g.get(S),_=!!(j!=null&&j.expandParent&&(j!=null&&j.parentId)&&(E!=null&&E.position)),M={id:S,type:"position",position:_?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:N};_&&j.parentId&&b.push({id:S,parentId:j.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),v.push(M)}if(b.length>0){const{parentLookup:S,nodeOrigin:E}=m(),j=pS(b,g,S,E);v.push(...j)}w(v)},triggerNodeChanges:x=>{const{onNodesChange:N,setNodes:b,nodes:v,hasDefaultNodes:g,debug:w}=m();if(x!=null&&x.length){if(g){const S=RL(x,v);b(S)}w&&console.log("React Flow: trigger node changes",x),N==null||N(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:N,setEdges:b,edges:v,hasDefaultEdges:g,debug:w}=m();if(x!=null&&x.length){if(g){const S=OL(x,v);b(S)}w&&console.log("React Flow: trigger edge changes",x),N==null||N(x)}},addSelectedNodes:x=>{const{multiSelectionActive:N,edgeLookup:b,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:w}=m();if(N){const S=x.map(E=>po(E,!0));g(S);return}g(Ll(v,new Set([...x]),!0)),w(Ll(b))},addSelectedEdges:x=>{const{multiSelectionActive:N,edgeLookup:b,nodeLookup:v,triggerNodeChanges:g,triggerEdgeChanges:w}=m();if(N){const S=x.map(E=>po(E,!0));w(S);return}w(Ll(b,new Set([...x]))),g(Ll(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:N}={})=>{const{edges:b,nodes:v,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:S}=m(),E=x||v,j=N||b,_=E.map(U=>{const L=g.get(U.id);return L&&(L.selected=!1),po(U.id,!1)}),M=j.map(U=>po(U.id,!1));w(_),S(M)},setMinZoom:x=>{const{panZoom:N,maxZoom:b}=m();N==null||N.setScaleExtent([x,b]),f({minZoom:x})},setMaxZoom:x=>{const{panZoom:N,minZoom:b}=m();N==null||N.setScaleExtent([b,x]),f({maxZoom:x})},setTranslateExtent:x=>{var N;(N=m().panZoom)==null||N.setTranslateExtent(x),f({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:N,triggerNodeChanges:b,triggerEdgeChanges:v,elementsSelectable:g}=m();if(!g)return;const w=N.reduce((E,j)=>j.selected?[...E,po(j.id,!1)]:E,[]),S=x.reduce((E,j)=>j.selected?[...E,po(j.id,!1)]:E,[]);b(w),v(S)},setNodeExtent:x=>{const{nodes:N,nodeLookup:b,parentLookup:v,nodeOrigin:g,elevateNodesOnSelect:w,nodeExtent:S}=m();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(NN(N,b,v,{nodeOrigin:g,nodeExtent:x,elevateNodesOnSelect:w,checkEquality:!1}),f({nodeExtent:x}))},panBy:x=>{const{transform:N,width:b,height:v,panZoom:g,translateExtent:w}=m();return xq({delta:x,panZoom:g,transform:N,translateExtent:w,width:b,height:v})},setCenter:async(x,N,b)=>{const{width:v,height:g,maxZoom:w,panZoom:S}=m();if(!S)return Promise.resolve(!1);const E=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:w;return await S.setViewport({x:v/2-x*E,y:g/2-N*E,zoom:E},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...YM}})},updateConnection:x=>{f({connection:x})},reset:()=>f({...yT()})}},Object.is);function KV({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:a,initialWidth:s,initialHeight:i,initialMinZoom:o,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:h,nodeExtent:d,children:f}){const[m]=p.useState(()=>XV({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,width:s,height:i,fitView:u,minZoom:o,maxZoom:l,fitViewOptions:c,nodeOrigin:h,nodeExtent:d}));return r.jsx(pG,{value:m,children:r.jsx(UG,{children:f})})}function ZV({children:e,nodes:t,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:o,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:h,nodeOrigin:d,nodeExtent:f}){return p.useContext(tm)?r.jsx(r.Fragment,{children:e}):r.jsx(KV,{initialNodes:t,initialEdges:n,defaultNodes:a,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:h,nodeOrigin:d,nodeExtent:f,children:e})}const QV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function JV({nodes:e,edges:t,defaultNodes:n,defaultEdges:a,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:h,onMoveStart:d,onMoveEnd:f,onConnect:m,onConnectStart:y,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:b,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:E,onNodeDragStart:j,onNodeDrag:_,onNodeDragStop:M,onNodesDelete:U,onEdgesDelete:L,onDelete:F,onSelectionChange:G,onSelectionDragStart:A,onSelectionDrag:P,onSelectionDragStop:R,onSelectionContextMenu:k,onSelectionStart:T,onSelectionEnd:D,onBeforeDelete:q,connectionMode:C,connectionLineType:I=Ni.Bezier,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:ae="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:X=!1,selectionMode:ie=pu.Full,panActivationKeyCode:ve="Space",multiSelectionKeyCode:se=gu()?"Meta":"Control",zoomActivationKeyCode:ge=gu()?"Meta":"Control",snapToGrid:be,snapGrid:Ue,onlyRenderVisibleElements:Be=!1,selectNodesOnDrag:$e,nodesDraggable:Ye,autoPanOnNodeFocus:bt,nodesConnectable:Ke,nodesFocusable:de,nodeOrigin:Fe=AL,edgesFocusable:Ie,edgesReconnectable:Ae,elementsSelectable:We=!0,defaultViewport:at=CG,minZoom:ft=.5,maxZoom:Yt=2,translateExtent:Wt=fu,preventScrolling:oe=!0,nodeExtent:_e,defaultMarkerColor:Ze="#b1b1b7",zoomOnScroll:K=!0,zoomOnPinch:pe=!0,panOnScroll:ye=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:ze=Ao.Free,zoomOnDoubleClick:tt=!0,panOnDrag:ee=!0,onPaneClick:ue,onPaneMouseEnter:Oe,onPaneMouseMove:xe,onPaneMouseLeave:Pe,onPaneScroll:Q,onPaneContextMenu:Z,paneClickDistance:je=1,nodeClickDistance:Qe=0,children:st,onReconnect:ct,onReconnectStart:it,onReconnectEnd:cn,onEdgeContextMenu:Tn,onEdgeDoubleClick:yn,onEdgeMouseEnter:nn,onEdgeMouseMove:ns,onEdgeMouseLeave:Dn,reconnectRadius:Hn=10,onNodesChange:rr,onEdgesChange:as,noDragClassName:el="nodrag",noWheelClassName:Ys="nowheel",noPanClassName:Pn="nopan",fitView:It,fitViewOptions:rs,connectOnClick:ss,attributionPosition:is,proOptions:Sr,defaultEdgeOptions:os,elevateNodesOnSelect:Er,elevateEdgesOnSelect:Ws,disableKeyboardA11y:fa=!1,autoPanOnConnect:Qn,autoPanOnNodeDrag:Pa,autoPanSpeed:Xs,connectionRadius:pa,isValidConnection:Jn,onError:sr,style:Ks,id:Zs,nodeDragThreshold:tl,connectionDragThreshold:Qs,viewport:no,onViewportChange:xt,width:jr,height:Tr,colorMode:Js="light",debug:ls,onScroll:ir,ariaLabelConfig:cs,...Fa},ao){const ds=Zs||"1",nl=RG(Js),we=p.useCallback(Se=>{Se.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ir==null||ir(Se)},[ir]);return r.jsx("div",{"data-testid":"rf__wrapper",...Fa,onScroll:we,style:{...Ks,...QV},ref:ao,className:vn(["react-flow",s,nl]),id:Zs,role:"application",children:r.jsxs(ZV,{nodes:e,edges:t,width:jr,height:Tr,fitView:It,fitViewOptions:rs,minZoom:ft,maxZoom:Yt,nodeOrigin:Fe,nodeExtent:_e,children:[r.jsx(WV,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:o,connectionLineType:I,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:ne,selectionOnDrag:X,selectionMode:ie,deleteKeyCode:ae,multiSelectionKeyCode:se,panActivationKeyCode:ve,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Be,defaultViewport:at,translateExtent:Wt,minZoom:ft,maxZoom:Yt,preventScrolling:oe,zoomOnScroll:K,zoomOnPinch:pe,zoomOnDoubleClick:tt,panOnScroll:ye,panOnScrollSpeed:Te,panOnScrollMode:ze,panOnDrag:ee,onPaneClick:ue,onPaneMouseEnter:Oe,onPaneMouseMove:xe,onPaneMouseLeave:Pe,onPaneScroll:Q,onPaneContextMenu:Z,paneClickDistance:je,nodeClickDistance:Qe,onSelectionContextMenu:k,onSelectionStart:T,onSelectionEnd:D,onReconnect:ct,onReconnectStart:it,onReconnectEnd:cn,onEdgeContextMenu:Tn,onEdgeDoubleClick:yn,onEdgeMouseEnter:nn,onEdgeMouseMove:ns,onEdgeMouseLeave:Dn,reconnectRadius:Hn,defaultMarkerColor:Ze,noDragClassName:el,noWheelClassName:Ys,noPanClassName:Pn,rfId:ds,disableKeyboardA11y:fa,nodeExtent:_e,viewport:no,onViewportChange:xt}),r.jsx(_G,{nodes:e,edges:t,defaultNodes:n,defaultEdges:a,onConnect:m,onConnectStart:y,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:b,nodesDraggable:Ye,autoPanOnNodeFocus:bt,nodesConnectable:Ke,nodesFocusable:de,edgesFocusable:Ie,edgesReconnectable:Ae,elementsSelectable:We,elevateNodesOnSelect:Er,elevateEdgesOnSelect:Ws,minZoom:ft,maxZoom:Yt,nodeExtent:_e,onNodesChange:rr,onEdgesChange:as,snapToGrid:be,snapGrid:Ue,connectionMode:C,translateExtent:Wt,connectOnClick:ss,defaultEdgeOptions:os,fitView:It,fitViewOptions:rs,onNodesDelete:U,onEdgesDelete:L,onDelete:F,onNodeDragStart:j,onNodeDrag:_,onNodeDragStop:M,onSelectionDrag:P,onSelectionDragStart:A,onSelectionDragStop:R,onMove:h,onMoveStart:d,onMoveEnd:f,noPanClassName:Pn,nodeOrigin:Fe,rfId:ds,autoPanOnConnect:Qn,autoPanOnNodeDrag:Pa,autoPanSpeed:Xs,onError:sr,connectionRadius:pa,isValidConnection:Jn,selectNodesOnDrag:$e,nodeDragThreshold:tl,connectionDragThreshold:Qs,onBeforeDelete:q,debug:ls,ariaLabelConfig:cs}),r.jsx(TG,{onSelectionChange:G}),st,r.jsx(wG,{proOptions:Sr,position:is}),r.jsx(yG,{rfId:ds,disableKeyboardA11y:fa})]})})}var eY=DL(JV);function tY(e){const[t,n]=p.useState(e),a=p.useCallback(s=>n(i=>RL(s,i)),[]);return[t,n,a]}function nY(e){const[t,n]=p.useState(e),a=p.useCallback(s=>n(i=>OL(s,i)),[]);return[t,n,a]}function aY({dimensions:e,lineWidth:t,variant:n,className:a}){return r.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:vn(["react-flow__background-pattern",n,a])})}function rY({radius:e,className:t}){return r.jsx("circle",{cx:e,cy:e,r:e,className:vn(["react-flow__background-pattern","dots",t])})}var Is;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Is||(Is={}));const sY={[Is.Dots]:1,[Is.Lines]:1,[Is.Cross]:6},iY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function a3({id:e,variant:t=Is.Dots,gap:n=20,size:a,lineWidth:s=1,offset:i=0,color:o,bgColor:l,style:c,className:u,patternClassName:h}){const d=p.useRef(null),{transform:f,patternId:m}=gt(iY,Zt),y=a||sY[t],x=t===Is.Dots,N=t===Is.Cross,b=Array.isArray(n)?n:[n,n],v=[b[0]*f[2]||1,b[1]*f[2]||1],g=y*f[2],w=Array.isArray(i)?i:[i,i],S=N?[g,g]:v,E=[w[0]*f[2]||1+S[0]/2,w[1]*f[2]||1+S[1]/2],j=`${m}${e||""}`;return r.jsxs("svg",{className:vn(["react-flow__background",u]),style:{...c,...am,"--xy-background-color-props":l,"--xy-background-pattern-color-props":o},ref:d,"data-testid":"rf__background",children:[r.jsx("pattern",{id:j,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:x?r.jsx(rY,{radius:g/2,className:h}):r.jsx(aY,{dimensions:S,lineWidth:s,variant:t,className:h})}),r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}a3.displayName="Background";const oY=p.memo(a3);function lY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function cY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r.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 uY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.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 hY(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.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 Mh({children:e,className:t,...n}){return r.jsx("button",{type:"button",className:vn(["react-flow__controls-button",t]),...n,children:e})}const fY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function r3({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:a=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:l,onInteractiveChange:c,className:u,children:h,position:d="bottom-left",orientation:f="vertical","aria-label":m}){const y=Vt(),{isInteractive:x,minZoomReached:N,maxZoomReached:b,ariaLabelConfig:v}=gt(fY,Zt),{zoomIn:g,zoomOut:w,fitView:S}=mS(),E=()=>{g(),i==null||i()},j=()=>{w(),o==null||o()},_=()=>{S(s),l==null||l()},M=()=>{y.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},U=f==="horizontal"?"horizontal":"vertical";return r.jsxs(nm,{className:vn(["react-flow__controls",U,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&r.jsxs(r.Fragment,{children:[r.jsx(Mh,{onClick:E,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:b,children:r.jsx(lY,{})}),r.jsx(Mh,{onClick:j,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:N,children:r.jsx(cY,{})})]}),n&&r.jsx(Mh,{className:"react-flow__controls-fitview",onClick:_,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:r.jsx(dY,{})}),a&&r.jsx(Mh,{className:"react-flow__controls-interactive",onClick:M,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:x?r.jsx(hY,{}):r.jsx(uY,{})}),h]})}r3.displayName="Controls";const pY=p.memo(r3);function mY({id:e,x:t,y:n,width:a,height:s,style:i,color:o,strokeColor:l,strokeWidth:c,className:u,borderRadius:h,shapeRendering:d,selected:f,onClick:m}){const{background:y,backgroundColor:x}=i||{},N=o||y||x;return r.jsx("rect",{className:vn(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:h,ry:h,width:a,height:s,style:{fill:N,stroke:l,strokeWidth:c},shapeRendering:d,onClick:m?b=>m(b,e):void 0})}const gY=p.memo(mY),bY=e=>e.nodes.map(t=>t.id),Ag=e=>e instanceof Function?e:()=>e;function xY({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:a=5,nodeStrokeWidth:s,nodeComponent:i=gY,onClick:o}){const l=gt(bY,Zt),c=Ag(t),u=Ag(e),h=Ag(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r.jsx(r.Fragment,{children:l.map(f=>r.jsx(yY,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:h,nodeBorderRadius:a,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:d},f))})}function vY({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:a,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:l,onClick:c}){const{node:u,x:h,y:d,width:f,height:m}=gt(y=>{const{internals:x}=y.nodeLookup.get(e),N=x.userNode,{x:b,y:v}=x.positionAbsolute,{width:g,height:w}=qs(N);return{node:N,x:b,y:v,width:g,height:w}},Zt);return!u||u.hidden||!eL(u)?null:r.jsx(l,{x:h,y:d,width:f,height:m,style:u.style,selected:!!u.selected,className:a(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:o,onClick:c,id:u.id})}const yY=p.memo(vY);var wY=p.memo(xY);const NY=200,SY=150,EY=e=>!e.hidden,jY=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?JM(Wu(e.nodeLookup,{filter:EY}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},TY="react-flow__minimap-desc";function s3({style:e,className:t,nodeStrokeColor:n,nodeColor:a,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:h,maskStrokeWidth:d,position:f="bottom-right",onClick:m,onNodeClick:y,pannable:x=!1,zoomable:N=!1,ariaLabel:b,inversePan:v,zoomStep:g=1,offsetScale:w=5}){const S=Vt(),E=p.useRef(null),{boundingRect:j,viewBB:_,rfId:M,panZoom:U,translateExtent:L,flowWidth:F,flowHeight:G,ariaLabelConfig:A}=gt(jY,Zt),P=(e==null?void 0:e.width)??NY,R=(e==null?void 0:e.height)??SY,k=j.width/P,T=j.height/R,D=Math.max(k,T),q=D*P,C=D*R,I=w*D,z=j.x-(q-j.width)/2-I,W=j.y-(C-j.height)/2-I,Y=q+I*2,ae=C+I*2,ne=`${TY}-${M}`,X=p.useRef(0),ie=p.useRef();X.current=D,p.useEffect(()=>{if(E.current&&U)return ie.current=Cq({domNode:E.current,panZoom:U,getTransform:()=>S.getState().transform,getViewScale:()=>X.current}),()=>{var be;(be=ie.current)==null||be.destroy()}},[U]),p.useEffect(()=>{var be;(be=ie.current)==null||be.update({translateExtent:L,width:F,height:G,inversePan:v,pannable:x,zoomStep:g,zoomable:N})},[x,N,v,g,L,F,G]);const ve=m?be=>{var $e;const[Ue,Be]=(($e=ie.current)==null?void 0:$e.pointer(be))||[0,0];m(be,{x:Ue,y:Be})}:void 0,se=y?p.useCallback((be,Ue)=>{const Be=S.getState().nodeLookup.get(Ue).internals.userNode;y(be,Be)},[]):void 0,ge=b??A["minimap.ariaLabel"];return r.jsx(nm,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*D:void 0,"--xy-minimap-node-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:vn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:r.jsxs("svg",{width:P,height:R,viewBox:`${z} ${W} ${Y} ${ae}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:E,onClick:ve,children:[ge&&r.jsx("title",{id:ne,children:ge}),r.jsx(wY,{onClick:se,nodeColor:a,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:l}),r.jsx("path",{className:"react-flow__minimap-mask",d:`M${z-I},${W-I}h${Y+I*2}v${ae+I*2}h${-Y-I*2}z
|
|
98
98
|
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}s3.displayName="MiniMap";const CY=p.memo(s3),kY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,AY={[yc.Line]:"right",[yc.Handle]:"bottom-right"};function _Y({nodeId:e,position:t,variant:n=yc.Handle,className:a,style:s=void 0,children:i,color:o,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:m=!0,shouldResize:y,onResizeStart:x,onResize:N,onResizeEnd:b}){const v=UL(),g=typeof e=="string"?e:v,w=Vt(),S=p.useRef(null),E=n===yc.Handle,j=gt(p.useCallback(kY(E&&m),[E,m]),Zt),_=p.useRef(null),M=t??AY[n];p.useEffect(()=>{if(!(!S.current||!g))return _.current||(_.current=zq({domNode:S.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:L,transform:F,snapGrid:G,snapToGrid:A,nodeOrigin:P,domNode:R}=w.getState();return{nodeLookup:L,transform:F,snapGrid:G,snapToGrid:A,nodeOrigin:P,paneDomNode:R}},onChange:(L,F)=>{const{triggerNodeChanges:G,nodeLookup:A,parentLookup:P,nodeOrigin:R}=w.getState(),k=[],T={x:L.x,y:L.y},D=A.get(g);if(D&&D.expandParent&&D.parentId){const q=D.origin??R,C=L.width??D.measured.width??0,I=L.height??D.measured.height??0,z={id:D.id,parentId:D.parentId,rect:{width:C,height:I,...tL({x:L.x??D.position.x,y:L.y??D.position.y},{width:C,height:I},D.parentId,A,q)}},W=pS([z],A,P,R);k.push(...W),T.x=L.x?Math.max(q[0]*C,L.x):void 0,T.y=L.y?Math.max(q[1]*I,L.y):void 0}if(T.x!==void 0&&T.y!==void 0){const q={id:g,type:"position",position:{...T}};k.push(q)}if(L.width!==void 0&&L.height!==void 0){const C={id:g,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};k.push(C)}for(const q of F){const C={...q,type:"position"};k.push(C)}G(k)},onEnd:({width:L,height:F})=>{const G={id:g,type:"dimensions",resizing:!1,dimensions:{width:L,height:F}};w.getState().triggerNodeChanges([G])}})),_.current.update({controlPosition:M,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:h},keepAspectRatio:d,resizeDirection:f,onResizeStart:x,onResize:N,onResizeEnd:b,shouldResize:y}),()=>{var L;(L=_.current)==null||L.destroy()}},[M,l,c,u,h,d,x,N,b,y]);const U=M.split("-");return r.jsx("div",{className:vn(["react-flow__resize-control","nodrag",...U,n,a]),ref:S,style:{...s,scale:j,...o&&{[E?"backgroundColor":"borderColor"]:o}},children:i})}p.memo(_Y);/**
|
|
99
99
|
* @license lucide-react v0.294.0 - ISC
|
|
100
100
|
*
|
|
@@ -516,7 +516,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
516
516
|
}
|
|
517
517
|
`;document.head.appendChild(RU);const Ne=p.forwardRef(({className:e,type:t,...n},a)=>r.jsx("input",{type:t,className:`flex h-10 w-full border border-dashed border-white/20 bg-black/30 px-3 py-2 text-sm text-white placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-white focus:border-white/40 disabled:cursor-not-allowed disabled:opacity-50 rounded-none ${e}`,ref:a,...n}));Ne.displayName="Input";const ce=p.forwardRef(({className:e,...t},n)=>r.jsx("label",{className:`text-sm font-light text-white ${e}`,ref:n,...t}));ce.displayName="Label";function OU({currentPage:e,totalPages:t,onPageChange:n,totalItems:a,startIndex:s,endIndex:i}){const o=()=>{const u=[],h=[];for(let d=Math.max(2,e-2);d<=Math.min(t-1,e+2);d++)u.push(d);return e-2>2?h.push(1,"..."):h.push(1),h.push(...u),e+2<t-1?h.push("...",t):t>1&&h.push(t),h};if(t<=1)return null;const l=o();return r.jsxs("div",{className:"flex items-center justify-between mt-6",children:[r.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",s+1," to ",Math.min(i,a)," of ",a," items"]}),r.jsxs("div",{className:"flex items-center space-x-1",children:[r.jsxs($,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:e===1,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[r.jsx(i3,{className:"w-4 h-4"}),"Previous"]}),l.map((c,u)=>{if(c==="...")return r.jsx($,{variant:"outline",size:"sm",disabled:!0,className:"border border-dashed border-white/20 text-white rounded-none",children:r.jsx(qY,{className:"w-4 h-4"})},`dots-${u}`);const h=c,d=e===h;return r.jsx($,{variant:d?"default":"outline",size:"sm",onClick:()=>n(h),className:d?"bg-white text-black rounded-none":"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:h},h)}),r.jsxs($,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===t,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["Next",r.jsx(bS,{className:"w-4 h-4"})]})]})]})}const sh=p.createContext({isOpen:!1,setIsOpen:()=>{}}),hn=p.forwardRef(({className:e,value:t,onValueChange:n,children:a,...s},i)=>{const[o,l]=p.useState(!1);return r.jsx(sh.Provider,{value:{value:t,onValueChange:n,isOpen:o,setIsOpen:l},children:r.jsx("div",{ref:i,className:`relative ${e}`,...s,children:a})})});hn.displayName="Select";const fn=p.forwardRef(({className:e,children:t,...n},a)=>{const{isOpen:s,setIsOpen:i}=p.useContext(sh);return r.jsxs("button",{ref:a,type:"button",className:`flex h-10 w-full items-center justify-between border bg-black/30 px-3 py-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-white focus:border-white/40 disabled:cursor-not-allowed disabled:opacity-50 rounded-none ${e}`,onClick:()=>i(!s),...n,children:[t,r.jsx(Zu,{className:`h-4 w-4 text-gray-400 transition-transform ${s?"rotate-180":""}`})]})});fn.displayName="SelectTrigger";const Bn=p.forwardRef(({className:e,placeholder:t,...n},a)=>{const{value:s}=p.useContext(sh);return r.jsx("span",{ref:a,className:`text-sm text-white ${e}`,...n,children:s||t})});Bn.displayName="SelectValue";const pn=p.forwardRef(({className:e,children:t,...n},a)=>{const{isOpen:s}=p.useContext(sh);return s?r.jsx("div",{ref:a,className:`absolute top-full left-0 right-0 z-[100] mt-1 border border-dashed border-white/20 bg-black rounded-none shadow-lg max-h-60 overflow-y-auto ${e}`,...n,children:t}):null});pn.displayName="SelectContent";const Le=p.forwardRef(({className:e,children:t,value:n,...a},s)=>{const{onValueChange:i,setIsOpen:o}=p.useContext(sh);return r.jsx("div",{ref:s,className:`px-3 py-2 text-sm text-white hover:bg-white/10 cursor-pointer ${e}`,onClick:()=>{i==null||i(n),o(!1)},...a,children:t})});Le.displayName="SelectItem";const DC=e=>{if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":Yn(t,"dd MMM yyyy; HH:mm")};function DU(){const e=yr(),{counts:t,refetchCounts:n}=pm(),[a,s]=p.useState([]),[i,o]=p.useState(!0),[l,c]=p.useState(null),[u,h]=p.useState(""),[d,f]=p.useState("all"),[m,y]=p.useState([]),[x,N]=p.useState(1),[b]=p.useState(20),[v,g]=p.useState(!1),[w,S]=p.useState(!1),[E,j]=p.useState(!1),[_,M]=p.useState(!1),[U,L]=p.useState(!1),[F,G]=p.useState(!1),[A,P]=p.useState(null),[R,k]=p.useState([]),[T,D]=p.useState(!1),[q,C]=p.useState({name:"",slug:""}),[I,z]=p.useState({name:"",slug:""});p.useEffect(()=>{ie();const oe=setInterval(()=>{l!=null&&l.enabled||ie()},2e3);return()=>clearInterval(oe)},[l==null?void 0:l.enabled]);const W=oe=>oe.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""),Y=oe=>{const _e=W(oe);C({name:oe,slug:_e})},ae=oe=>{C(_e=>({..._e,slug:W(oe)}))},ne=oe=>{const _e=W(oe);z({name:oe,slug:_e})},X=oe=>{z(_e=>({..._e,slug:W(oe)}))},ie=async()=>{try{const _e=await(await fetch("/api/plugins")).json(),Ze=(_e==null?void 0:_e.plugins).find(K=>K.id==="organization");c({enabled:!!Ze,availablePlugins:(_e==null?void 0:_e.plugins).map(K=>K.id),configPath:_e.configPath,organizationPlugin:(_e==null?void 0:_e.plugins).find(K=>K.id==="organization")}),Ze?await ve():o(!1)}catch(oe){console.error("Failed to check plugin status:",oe),c({enabled:!1,error:"Failed to check plugin status"}),o(!1)}},ve=async()=>{try{const _e=await(await fetch("/api/organizations?limit=10000")).json();console.log({lenght:_e.organizations.length}),s(_e.organizations||[])}catch(oe){console.error("Failed to fetch organizations:",oe),V.error("Failed to fetch organizations")}finally{o(!1)}},se=async oe=>{k([]),D(!0),k([{id:"start",type:"info",message:`Starting organization seeding process for ${oe} organizations...`,timestamp:new Date}]);try{const Ze=await(await fetch("/api/seed/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:oe})})).json();if(Ze.success){const K=Ze.results.map((ye,Te)=>ye.success?{id:`org-${Te}`,type:"progress",message:`Creating organization: ${ye.organization.name} (${ye.organization.slug})`,timestamp:new Date,status:"completed"}:{id:`org-${Te}`,type:"error",message:`Failed to create organization ${Te+1}: ${ye.error}`,timestamp:new Date});k(ye=>[...ye,...K]);const pe=Ze.results.filter(ye=>ye.success).length;k(ye=>[...ye,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${pe}/${oe} organizations successfully`,timestamp:new Date}]),await ve(),await n()}else k(K=>[...K,{id:"error",type:"error",message:`❌ Seeding failed: ${Ze.error||"Unknown error"}`,timestamp:new Date}])}catch(_e){k(Ze=>[...Ze,{id:"error",type:"error",message:`❌ Network error: ${_e}`,timestamp:new Date}])}finally{D(!1)}},ge=oe=>{P(oe),L(!0)},be=oe=>{P(oe),z({name:oe.name,slug:oe.slug}),j(!0)},Ue=oe=>{P(oe),M(!0)},Be=async()=>{if(!q.name){V.error("Please fill in the organization name");return}const oe=V.loading("Creating organization...");try{const Ze=await(await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q.name,slug:q.slug})})).json();Ze.success?(await ve(),g(!1),C({name:"",slug:""}),V.success("Organization created successfully!",{id:oe})):V.error(`Error creating organization: ${Ze.error||"Unknown error"}`,{id:oe})}catch(_e){console.error("Error creating organization:",_e),V.error("Error creating organization",{id:oe})}},$e=async()=>{if(!A){V.error("No organization selected");return}if(!I.name){V.error("Please fill in the organization name");return}const oe=V.loading("Updating organization...");try{const Ze=await(await fetch(`/api/organizations/${A.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I.name,slug:I.slug})})).json();Ze.success?(await ve(),j(!1),P(null),z({name:"",slug:""}),V.success("Organization updated successfully!",{id:oe})):V.error(`Error updating organization: ${Ze.error||"Unknown error"}`,{id:oe})}catch(_e){console.error("Error updating organization:",_e),V.error("Error updating organization",{id:oe})}},Ye=async()=>{if(!A){V.error("No organization selected");return}const oe=V.loading("Deleting organization...");try{const Ze=await(await fetch(`/api/organizations/${A.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();Ze.success?(await ve(),await n(),M(!1),P(null),V.success("Organization deleted successfully!",{id:oe})):V.error(`Error deleting organization: ${Ze.error||"Unknown error"}`,{id:oe})}catch(_e){console.error("Error deleting organization:",_e),V.error("Error deleting organization",{id:oe})}},bt=()=>{if(a.length===0){V.error("No organizations to export");return}const oe=["ID","Name","Slug","Created At","Updated At"],_e=a.map(Te=>[Te.id,Te.name||"",Te.slug||"",new Date(Te.createdAt).toLocaleString(),new Date(Te.updatedAt).toLocaleString()]),Ze=[oe.join(","),..._e.map(Te=>Te.map(ze=>`"${ze}"`).join(","))].join(`
|
|
518
518
|
`),K=new Blob([Ze],{type:"text/csv;charset=utf-8;"}),pe=document.createElement("a"),ye=URL.createObjectURL(K);pe.setAttribute("href",ye),pe.setAttribute("download",`organizations-export-${new Date().toISOString().split("T")[0]}.csv`),pe.style.visibility="hidden",document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),V.success(`Exported ${a.length} organizations to CSV`)},Ke=oe=>{m.some(_e=>_e.type===oe)||y([...m,{type:oe}])},de=oe=>{y(m.filter(_e=>_e.type!==oe))},Fe=()=>{y([])},Ie=(oe,_e)=>{y(Ze=>Ze.map(K=>K.type===oe?{...K,dateRange:_e}:K))},Ae=a.filter(oe=>{const _e=oe.name.toLowerCase().includes(u.toLowerCase())||oe.slug.toLowerCase().includes(u.toLowerCase());if(m.length===0)return _e;const Ze=m.every(K=>{var pe,ye,Te,ze;switch(K.type){case"createdAt":{if(!((pe=K.dateRange)!=null&&pe.from)&&!((ye=K.dateRange)!=null&&ye.to))return!0;const tt=new Date(oe.createdAt);return!((Te=K.dateRange)!=null&&Te.from&&K.dateRange.from>tt||(ze=K.dateRange)!=null&&ze.to&&K.dateRange.to<tt)}default:return!0}});return _e&&Ze}),We=Math.ceil(Ae.length/b),at=(x-1)*b,ft=at+b,Yt=Ae.slice(at,ft),Wt=oe=>{N(oe)};return i?r.jsx("div",{className:"flex min-h-screen items-center justify-center h-full",children:r.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[r.jsx(Ja,{className:"w-6 h-6 text-white animate-spin"}),r.jsx("div",{className:"text-white text-sm",children:"Loading organizations..."})]})}):l&&!l.enabled?r.jsxs("div",{className:"space-y-6 p-6",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-white font-light",children:"Organizations"}),r.jsx("p",{className:"text-gray-400 font-light text-sm mt-1 uppercase font-mono",children:"Manage your application organizations"})]})}),r.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:r.jsxs("div",{className:"flex items-start space-x-4",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx(Mr,{className:"w-12 h-12 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),r.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."}),r.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[r.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),r.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:r.jsxs("li",{children:["Import the plugin in your auth configuration file",l.configPath&&r.jsxs("span",{className:"text-gray-400",children:[" (",l.configPath,")"]}),":"]})}),r.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:r.jsxs("pre",{className:"text-sm text-gray-300",children:[r.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",r.jsx("span",{className:"text-blue-400",children:"from"})," ",r.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",r.jsx("br",{}),r.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",r.jsx("span",{className:"text-blue-400",children:"from"})," ",r.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",r.jsx("br",{}),r.jsx("span",{className:"text-blue-400",children:"export const"})," ",r.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",r.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",r.jsx("br",{}),r.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",r.jsx("br",{}),r.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",r.jsx("br",{}),r.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),r.jsx("br",{}),r.jsx("span",{className:"pl-10",children:"]"})," ",r.jsx("br",{}),"}",") ",r.jsx("br",{})]})}),r.jsx("div",{className:"mt-4",children:r.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),r.jsx("div",{className:"mt-2",children:r.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),l.availablePlugins&&l.availablePlugins.length>0&&r.jsx("div",{className:"mb-4",children:r.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",l.availablePlugins.join(", ")]})}),r.jsx($,{onClick:ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),r.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",r.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"})]})]})]})})]}):r.jsxs("div",{className:"space-y-6 p-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:["Organizations",r.jsx("sup",{className:"text-xs text-gray-500 ml-1 mt-0 inline-flex items-baseline",children:r.jsx(An,{value:t.organizations??0,className:"text-white font-mono text-sm",prefix:r.jsx("span",{className:"mr-1 text-gray-500",children:"["}),suffix:r.jsx("span",{className:"ml-1 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]}),r.jsx("p",{className:"text-gray-400 font-light text-sm mt-1 uppercase font-mono",children:"Manage your organizations and teams"})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:bt,children:[r.jsx(Ul,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>G(!0),children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed"]}),r.jsxs($,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>g(!0),children:[r.jsx(Pi,{className:"w-4 h-4 mr-2"}),"Add Organization"]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Fo,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),r.jsx(Ne,{placeholder:"Search organizations...",value:u,onChange:oe=>h(oe.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsx("div",{className:"flex items-center space-x-2",children:r.jsxs(hn,{value:"",onValueChange:Ke,children:[r.jsx(fn,{className:"w-[180px]",children:r.jsxs("div",{className:"flex mr-3 items-center space-x-2",children:[r.jsx(Pi,{className:"w-4 h-4"}),r.jsx("span",{children:"Add Filter"})]})}),r.jsx(pn,{children:!m.some(oe=>oe.type==="createdAt")&&r.jsx(Le,{value:"createdAt",children:"Created Date"})})]})}),m.length>0&&r.jsx("div",{className:"flex items-center space-x-2",children:r.jsx($,{onClick:Fe,children:"Clear all"})})]}),m.length>0&&r.jsx("div",{className:"space-y-3",children:r.jsx("div",{className:"flex flex-wrap gap-3",children:m.map(oe=>{var _e,Ze,K,pe;return r.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 bg-white/10 border border-white/20 rounded-sm",children:[r.jsx(xS,{className:"w-3 h-3 text-white"}),oe.type==="createdAt"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Created:"}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(_e=oe.dateRange)!=null&&_e.from?Yn(oe.dateRange.from,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(Ze=oe.dateRange)==null?void 0:Ze.from,onSelect:ye=>{var Te;return Ie("createdAt",{from:ye,to:(Te=oe.dateRange)==null?void 0:Te.to})},initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(K=oe.dateRange)!=null&&K.to?Yn(oe.dateRange.to,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(pe=oe.dateRange)==null?void 0:pe.to,onSelect:ye=>{var Te;return Ie("createdAt",{from:(Te=oe.dateRange)==null?void 0:Te.from,to:ye})},initialFocus:!0,disabled:ye=>{var Te;return(Te=oe.dateRange)!=null&&Te.from?ye<oe.dateRange.from:!1},className:"rounded-none"})})]})]}),r.jsx("button",{onClick:()=>de(oe.type),className:"ml-1 hover:bg-white/20 rounded-full p-0.5",children:r.jsx(en,{className:"w-3 h-3 text-white"})})]},oe.type)})})})]}),r.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Organization"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Slug"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),r.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),r.jsx("tbody",{children:Ae.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:4,className:"py-12 px-4 text-center",children:r.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[r.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Mr,{className:"w-8 h-8 text-white/50"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium text-lg",children:"No organizations found"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:u||d!=="all"?"Try adjusting your search or filter criteria":"Get started by creating your first organization"})]}),!u&&d==="all"&&r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{onClick:()=>g(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[r.jsx(Pi,{className:"w-4 h-4 mr-2"}),"Create Organization"]}),r.jsxs($,{onClick:()=>G(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):Yt.map(oe=>r.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>e(`/organizations/${oe.id}`),children:[r.jsx("td",{className:"py-4 px-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Mr,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:oe.name}),r.jsx(on,{id:oe.id})]})]})}),r.jsx("td",{className:"py-4 px-4 text-white",children:oe.slug}),r.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:r.jsxs("div",{className:"flex flex-col",children:[new Date(oe.createdAt).toLocaleDateString(),r.jsx("p",{className:"text-xs",children:new Date(oe.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),r.jsx("td",{className:"py-4 px-4 text-right",children:r.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:_e=>{_e.stopPropagation(),ge(oe)},children:r.jsx(Ms,{className:"w-4 h-4"})}),r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:_e=>{_e.stopPropagation(),be(oe)},children:r.jsx(Po,{className:"w-4 h-4"})}),r.jsx($,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:_e=>{_e.stopPropagation(),Ue(oe)},children:r.jsx(Qu,{className:"w-4 h-4"})})]})})]},oe.id))})]})}),r.jsx(OU,{currentPage:x,totalPages:We,onPageChange:Wt,totalItems:Ae.length,startIndex:at,endIndex:ft})]}),F&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"overflow-x-hidden bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(Mr,{className:"inline mr-2 w-3.5 h-3.5 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Organizations"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>G(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"organization-count",className:"text-sm text-gray-400 font-light",children:"Number of organizations"}),r.jsx(Ne,{id:"organization-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"})]}),r.jsx($,{onClick:()=>{var _e;const oe=parseInt(((_e=document.getElementById("organization-count"))==null?void 0:_e.value)||"5",10);se(oe)},disabled:T,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:T?r.jsxs(r.Fragment,{children:[r.jsx(Ja,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Jt,{className:"w-3 h-3 mr-2"}),"Seed Organizations"]})})]})}),R.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"Organization Seeding Terminal",lines:R,isRunning:T,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>G(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),v&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Create Organization"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"create-name",value:q.name,onChange:oe=>Y(oe.target.value),placeholder:"e.g. Acme Corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-slug",className:"text-sm text-gray-400 font-light",children:"Slug"}),r.jsx(Ne,{id:"create-slug",value:q.slug,onChange:oe=>ae(oe.target.value),placeholder:"e.g. acme-corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Auto-generated from name. You can edit it manually."})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{g(!1),C({name:"",slug:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Be,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),E&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:oe=>{oe.target===oe.currentTarget&&(j(!1),P(null),z({name:"",slug:""}))},children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-xl rounded-none",onClick:oe=>oe.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Organization"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{j(!1),P(null),z({name:"",slug:""})},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Mr,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"text-white inline-flex font-light",children:[A.name,r.jsx(on,{id:A.id,variant:"subscript",nonSliced:!0})]}),r.jsx("div",{className:"text-sm text-gray-400",children:A.slug})]})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"edit-name",value:I.name,onChange:oe=>ne(oe.target.value),placeholder:"e.g. Acme Corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-slug",className:"text-sm text-gray-400 font-light",children:"Slug"}),r.jsx(Ne,{id:"edit-slug",value:I.slug,onChange:oe=>X(oe.target.value),placeholder:"e.g. acme-corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Auto-generated from name. You can edit it manually."})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{j(!1),z({name:"",slug:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:$e,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),_&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Organization"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>M(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Mr,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"text-white inline-flex font-light",children:[A.name,r.jsx(on,{id:A.id,variant:"subscript",nonSliced:!0})]}),r.jsx("div",{className:"text-sm text-gray-400",children:A.slug})]})]}),r.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this organization? This action cannot be undone."})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>M(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ye,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),U&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-white/15 rounded-none w-full max-w-xl p-6 shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"flex flex-col gap-2",children:r.jsx("h3",{className:"text-lg text-white font-light uppercase font-mono",children:"Organization Details"})}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>L(!1),className:"text-gray-400 -mt-2 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex flex-col items-center justify-center mt-2",children:[r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"}),r.jsx("div",{className:"relative z-20 h-4 w-[calc(100%+3rem)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#ffffff,#ffffff_1px,transparent_1px,transparent_6px)] opacity-[7%]"}),r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"})]}),r.jsxs("div",{className:"space-y-6 mt-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-14 h-14 rounded-none border border-dashed border-white/15 bg-white/10 flex items-center justify-center",children:r.jsx(Mr,{className:"w-7 h-7 text-white"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium leading-tight flex items-center gap-2",children:[r.jsx("span",{children:A.name}),r.jsx(on,{id:A.id,variant:"subscript",nonSliced:!0})]}),r.jsx("div",{className:"text-sm text-gray-400",children:A.slug})]})]}),r.jsx("div",{className:"space-y-2 text-sm",children:[{label:"Created",value:DC(A.createdAt)},{label:"Updated",value:DC(A.updatedAt)}].map(oe=>r.jsxs("div",{className:"flex items-center justify-between border border-dashed border-white/15 bg-black/90 px-3 py-2 rounded-none",children:[r.jsx("div",{className:"text-[11px] font-mono font-light uppercase tracking-wide text-gray-400",children:oe.label}),r.jsx("div",{className:"text-sm text-white text-right break-words max-w-[60%]",children:oe.value})]},oe.label))})]}),r.jsxs("div",{className:"flex justify-end gap-3 mt-8",children:[r.jsx($,{onClick:()=>L(!1),className:"border border-white/20 bg-white/5 text-white hover:bg-white/10 rounded-none",children:"Close"}),r.jsx($,{onClick:()=>{L(!1),e(`/organizations/${A.id}`)},className:"border border-white/20 bg-white text-black hover:bg-white/90 rounded-none",children:"View Details"})]})]})})]})}const nb=e=>{if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":Yn(t,"dd MMM yyyy; HH:mm")};function IU(){const e=yr(),{counts:t,refetchCounts:n}=pm(),[a,s]=p.useState([]),[i,o]=p.useState(!0),[l,c]=p.useState(""),[u,h]=p.useState([]),[d,f]=p.useState(1),[m]=p.useState(20),[y,x]=p.useState(!1),[N,b]=p.useState(!1),[v,g]=p.useState(!1),[w,S]=p.useState(!1),[E,j]=p.useState(!1),[_,M]=p.useState(!1),[U,L]=p.useState(!1),[F,G]=p.useState(!1),[A,P]=p.useState(null),[R,k]=p.useState(null),[T,D]=p.useState(""),[q,C]=p.useState(),[I,z]=p.useState(!1),[W,Y]=p.useState(""),[ae,ne]=p.useState(""),[X,ie]=p.useState(""),[ve,se]=p.useState([]),[ge,be]=p.useState(!1),Ue=p.useCallback(async()=>{try{const ue=await(await fetch("/api/users?limit=10000")).json();s(ue.users||[])}catch{}finally{o(!1)}},[]),Be=p.useCallback(async()=>{try{const ue=await(await fetch("/api/admin/status")).json();z(ue.enabled)}catch{z(!1)}},[]);p.useEffect(()=>{Ue(),Be();const ee=()=>{R&&k(null)};return document.addEventListener("click",ee),()=>document.removeEventListener("click",ee)},[R,Be,Ue]),p.useEffect(()=>(w?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[w,A]);const $e=async(ee,ue)=>{se([]),be(!0),se([{id:"start",type:"info",message:`Starting user seeding process for ${ee} users...`,timestamp:new Date}]);try{const xe=await(await fetch("/api/seed/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:ee,role:ue||void 0})})).json();if(xe.success){const Pe=xe.results.map((Z,je)=>Z.success?{id:`user-${je}`,type:"progress",message:`Creating user: ${Z.user.name} (${Z.user.email})`,timestamp:new Date,status:"completed"}:{id:`user-${je}`,type:"error",message:`Failed to create user ${je+1}: ${Z.error}`,timestamp:new Date});se(Z=>[...Z,...Pe]);const Q=xe.results.filter(Z=>Z.success).length;se(Z=>[...Z,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${Q}/${ee} users successfully`,timestamp:new Date}]),await Ue(),await n()}else se(Pe=>[...Pe,{id:"error",type:"error",message:`❌ Seeding failed: ${xe.error||"Unknown error"}`,timestamp:new Date}])}catch(Oe){se(xe=>[...xe,{id:"error",type:"error",message:`❌ Network error: ${Oe}`,timestamp:new Date}])}finally{be(!1)}},Ye=ee=>{P(ee),S(!0)},bt=ee=>{P(ee),Y(ee.role||""),b(!0)},Ke=ee=>{P(ee),g(!0)},de=async()=>{var Pe,Q,Z;const ee=(Pe=document.getElementById("create-name"))==null?void 0:Pe.value,ue=(Q=document.getElementById("create-email"))==null?void 0:Q.value,Oe=(Z=document.getElementById("create-password"))==null?void 0:Z.value;if(!ee||!ue||!Oe){V.error("Please fill in all fields");return}const xe=V.loading("Creating user...");try{const Qe=await(await fetch("/api/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ee,email:ue,password:Oe,role:X||null})})).json();Qe.success?(await Ue(),x(!1),ie(""),document.getElementById("create-name").value="",document.getElementById("create-email").value="",document.getElementById("create-password").value="",V.success("User created successfully!",{id:xe})):V.error(`Error creating user: ${Qe.error||"Unknown error"}`,{id:xe})}catch{V.error("Error creating user",{id:xe})}},Fe=async()=>{var xe,Pe;if(!A){V.error("No user selected");return}const ee=(xe=document.getElementById("edit-name"))==null?void 0:xe.value,ue=(Pe=document.getElementById("edit-email"))==null?void 0:Pe.value;if(!ee||!ue){V.error("Please fill in all fields");return}const Oe=V.loading("Updating user...");try{const Z=await(await fetch(`/api/users/${A.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ee,email:ue,role:W||null})})).json();Z.success?(await Ue(),b(!1),P(null),Y(""),V.success("User updated successfully!",{id:Oe})):V.error(`Error updating user: ${Z.error||"Unknown error"}`,{id:Oe})}catch{V.error("Error updating user",{id:Oe})}},Ie=async()=>{if(!A){V.error("No user selected");return}const ee=V.loading("Deleting user...");try{const Oe=await(await fetch(`/api/users/${A.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();Oe.success?(await Ue(),await n(),g(!1),P(null),V.success("User deleted successfully!",{id:ee})):V.error(`Error deleting user: ${Oe.error||"Unknown error"}`,{id:ee})}catch{V.error("Error deleting user",{id:ee})}},Ae=async()=>{if(!A)return;if(!I){V.error("Admin plugin is not enabled");return}const ee=V.loading("Banning user...");try{const ue=await fetch("/api/admin/ban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:A.id,banReason:T||"No reason provided",banExpiresIn:q})}),Oe=await ue.json();ue.ok?(V.success("User banned successfully!",{id:ee}),M(!1),D(""),C(void 0),P(null),k(null),Ue()):V.error(`Error banning user: ${Oe.error||Oe.message||"Unknown error"}`,{id:ee})}catch{V.error("Error banning user",{id:ee})}},We=async()=>{if(!A)return;if(!I){V.error("Admin plugin is not enabled");return}const ee=V.loading("Unbanning user...");try{const ue=await fetch("/api/admin/unban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:A.id})}),Oe=await ue.json();ue.ok?(V.success("User unbanned successfully!",{id:ee}),L(!1),P(null),k(null),Ue()):V.error(`Error unbanning user: ${Oe.error||Oe.message||"Unknown error"}`,{id:ee})}catch{V.error("Error unbanning user",{id:ee})}},at=async()=>{var Oe;if(!A){V.error("No user selected");return}const ee=(Oe=document.getElementById("update-password"))==null?void 0:Oe.value;if(!ee){V.error("Please enter a new password");return}const ue=V.loading("Updating password...");try{const xe=await fetch(`/api/users/${A.id}/password`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:ee})}),Pe=await xe.json();xe.ok&&Pe.success?(V.success("Password updated successfully!",{id:ue}),G(!1),P(null),document.getElementById("update-password").value=""):V.error(`Error updating password: ${Pe.error||"Unknown error"}`,{id:ue})}catch{V.error("Error updating password",{id:ue})}},ft=()=>{if(a.length===0){V.error("No users to export");return}const ee=["ID","Name","Email","Email Verified","Created At","Updated At"],ue=a.map(Z=>[Z.id,Z.name||"",Z.email||"",!!Z.emailVerified,new Date(Z.createdAt).toLocaleString(),new Date(Z.updatedAt).toLocaleString()]),Oe=[ee.join(","),...ue.map(Z=>Z.map(je=>`"${je}"`).join(","))].join(`
|
|
519
|
-
`),xe=new Blob([Oe],{type:"text/csv;charset=utf-8;"}),Pe=document.createElement("a"),Q=URL.createObjectURL(xe);Pe.setAttribute("href",Q),Pe.setAttribute("download",`users-export-${new Date().toISOString().split("T")[0]}.csv`),Pe.style.visibility="hidden",document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),V.success(`Exported ${a.length} users to CSV`)},Yt=ee=>{u.some(Oe=>Oe.type===ee)||(h(Oe=>[...Oe,{type:ee}]),f(1))},Wt=ee=>{h(ue=>ue.filter(Oe=>Oe.type!==ee)),f(1)},oe=(ee,ue)=>{h(Oe=>Oe.map(xe=>xe.type===ee?{...xe,value:ue}:xe))},_e=(ee,ue)=>{h(Oe=>Oe.map(xe=>xe.type===ee?{...xe,dateRange:ue}:xe))},Ze=a.filter(ee=>{const ue=ee.name.toLowerCase().includes(l.toLowerCase())||ee.email.toLowerCase().includes(l.toLowerCase());if(u.length===0)return ue;const Oe=u.every(xe=>{var Pe,Q,Z,je,Qe;switch(xe.type){case"emailVerified":return xe.value===void 0?!0:ee.emailVerified===(xe.value==="true");case"banned":return xe.value===void 0?!0:ee.banned===(xe.value==="true");case"active":return ee.banned!==!0;case"createdAt":{if(!((Pe=xe.dateRange)!=null&&Pe.from)&&!((Q=xe.dateRange)!=null&&Q.to))return!0;const st=new Date(ee.createdAt);return!((Z=xe.dateRange)!=null&&Z.from&&xe.dateRange.from>st||(je=xe.dateRange)!=null&&je.to&&xe.dateRange.to<st)}case"role":return xe.value?(Qe=ee.role)==null?void 0:Qe.toLowerCase().includes(xe.value.toLowerCase()):!0;default:return!0}});return ue&&Oe}),K=a.filter(ee=>ee.banned).length,pe=Math.ceil(Ze.length/m),ye=(d-1)*m,Te=ye+m,ze=Ze.slice(ye,Te),tt=ee=>{f(ee)};return i?r.jsx("div",{className:"flex min-h-screen items-center justify-center h-full",children:r.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[r.jsx(Ja,{className:"w-6 h-6 text-white animate-spin"}),r.jsx("div",{className:"text-white text-sm",children:"Loading users..."})]})}):r.jsxs("div",{className:"space-y-6 p-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:["Users",r.jsx("sup",{className:"text-xs text-gray-500 ml-1 mt-0 inline-flex items-baseline",children:r.jsx(An,{value:t.users??0,className:"text-white font-mono text-sm",prefix:r.jsx("span",{className:"mr-1 text-gray-500",children:"["}),suffix:r.jsx("span",{className:"ml-1 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]}),r.jsx("p",{className:"text-gray-400 font-light text-sm mt-1 uppercase font-mono",children:"Manage your application users"}),r.jsx("div",{className:"flex items-center space-x-4 mt-2",children:K>0&&r.jsxs("span",{className:"text-sm text-red-400 flex items-center space-x-1",children:[r.jsx(Lh,{className:"w-3 h-3"}),r.jsxs("span",{children:[K," Banned"]})]})})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:ft,children:[r.jsx(Ul,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>j(!0),children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed"]}),r.jsxs($,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>x(!0),children:[r.jsx(CN,{className:"w-4 h-4 mr-2"}),"Add User"]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Fo,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),r.jsx(Ne,{placeholder:"Search users...",value:l,onChange:ee=>c(ee.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsx("div",{className:"flex items-center space-x-2",children:r.jsxs(hn,{value:"",onValueChange:Yt,children:[r.jsx(fn,{className:"w-[180px]",children:r.jsxs("div",{className:"flex mr-3 items-center space-x-2",children:[r.jsx(Pi,{className:"w-4 h-4"}),r.jsx("span",{children:"Add Filter"})]})}),r.jsxs(pn,{children:[!u.some(ee=>ee.type==="emailVerified")&&r.jsx(Le,{value:"emailVerified",children:"Email Verified"}),!u.some(ee=>ee.type==="banned")&&r.jsx(Le,{value:"banned",children:"Banned Status"}),!u.some(ee=>ee.type==="createdAt")&&r.jsx(Le,{value:"createdAt",children:"Created Date"}),!u.some(ee=>ee.type==="role")&&r.jsx(Le,{value:"role",children:"Role"})]})]})}),u.length>0&&r.jsx("div",{className:"flex items-center space-x-2",children:r.jsx($,{onClick:()=>h([]),className:"",children:"Clear all"})})]}),u.length>0&&r.jsx("div",{className:"space-y-3",children:r.jsx("div",{className:"flex flex-wrap gap-3",children:u.map(ee=>{var ue,Oe,xe,Pe;return r.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 bg-white/10 border border-white/20 rounded-sm",children:[r.jsx(xS,{className:"w-3 h-3 text-white"}),ee.type==="emailVerified"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Email Verified:"}),r.jsxs(hn,{value:ee.value||"",onValueChange:Q=>oe("emailVerified",Q),children:[r.jsx(fn,{className:"h-7 w-24 text-xs",children:r.jsx("span",{children:ee.value==="true"?"True":ee.value==="false"?"False":"Select"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"true",children:"True"}),r.jsx(Le,{value:"false",children:"False"})]})]})]}),ee.type==="banned"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Banned:"}),r.jsxs(hn,{value:ee.value||"",onValueChange:Q=>oe("banned",Q),children:[r.jsx(fn,{className:"h-7 w-24 text-xs",children:r.jsx("span",{children:ee.value==="true"?"Yes":ee.value==="false"?"No":"Select"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"true",children:"Yes"}),r.jsx(Le,{value:"false",children:"No"})]})]})]}),ee.type==="createdAt"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Created:"}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(ue=ee.dateRange)!=null&&ue.from?Yn(ee.dateRange.from,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(Oe=ee.dateRange)==null?void 0:Oe.from,onSelect:Q=>{var Z;return _e("createdAt",{from:Q,to:(Z=ee.dateRange)==null?void 0:Z.to})},initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(xe=ee.dateRange)!=null&&xe.to?Yn(ee.dateRange.to,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(Pe=ee.dateRange)==null?void 0:Pe.to,onSelect:Q=>{var Z;return _e("createdAt",{from:(Z=ee.dateRange)==null?void 0:Z.from,to:Q})},initialFocus:!0,disabled:Q=>{var Z;return(Z=ee.dateRange)!=null&&Z.from?Q<ee.dateRange.from:!1},className:"rounded-none"})})]})]}),ee.type==="role"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Role:"}),r.jsx(Ne,{type:"text",value:ee.value||"",onChange:Q=>oe("role",Q.target.value),className:"h-7 w-32 text-xs bg-black border-white/20 text-white",placeholder:"Enter role..."})]}),r.jsx("button",{onClick:()=>Wt(ee.type),className:"ml-1 hover:bg-white/20 rounded-full p-0.5",children:r.jsx(en,{className:"w-3 h-3 text-white"})})]},ee.type)})})})]}),r.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[r.jsx("div",{className:"overflow-x-auto overflow-y-hidden",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email Status"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),r.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),r.jsx("tbody",{children:ze.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"py-12 px-4 text-center",children:r.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[r.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Bo,{className:"w-8 h-8 text-white/50"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium text-lg",children:"No users found"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:l||u.length>0?"Try adjusting your search or filter criteria":"Get started by creating your first user or seeding some data"})]}),!l&&u.length===0&&r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{onClick:()=>x(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[r.jsx(CN,{className:"w-4 h-4 mr-2"}),"Create User"]}),r.jsxs($,{onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):ze.map(ee=>r.jsxs("tr",{className:`border-b border-dashed hover:bg-white/5 cursor-pointer ${ee.banned?"border-red-500/30 bg-red-500/5":"border-white/5"}`,onClick:()=>e(`/users/${ee.id}`),children:[r.jsx("td",{className:"py-4 px-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:ee.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${ee.id}`,alt:ee.name,className:`w-10 h-10 rounded-none border border-dashed ${ee.banned?"border-red-400/50 opacity-60":"border-white/20"}`}),ee.banned&&r.jsx("div",{className:"absolute -top-1 -right-1 bg-red-500 rounded-full p-0.5",children:r.jsx(Lh,{className:"w-3 h-3 text-white"})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"text-white font-light",children:ee.name}),ee.banned&&r.jsxs("span",{className:"relative group inline-block",children:[r.jsx("span",{className:"px-2 py-0.5 text-[10px] font-semibold bg-red-500/20 border border-red-500/50 text-red-400 rounded-sm uppercase tracking-wide cursor-help",children:"Banned"}),ee.banReason&&r.jsxs("span",{className:"absolute left-1/2 -translate-x-1/2 bottom-full mb-1.5 px-2 py-1 text-[10px] font-mono text-gray-300 bg-black border border-dashed border-white/20 rounded-none whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-150 pointer-events-none z-50",children:[ee.banReason,r.jsx("span",{className:"absolute left-1/2 -translate-x-1/2 top-full w-0 h-0 border-l-[4px] border-r-[4px] border-t-[4px] border-transparent border-t-white/20"})]})]})]}),r.jsx("div",{className:"text-sm text-gray-400 mt-0.5",children:ee.email})]})]})}),r.jsx("td",{className:"py-4 px-4",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[ee.emailVerified?r.jsx(yu,{className:"w-4 h-4 text-green-400"}):r.jsx(Sc,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-sm text-gray-400",children:ee.emailVerified?"Verified":"Not Verified"})]})}),r.jsx("td",{className:"py-4 px-4",children:ee.role?r.jsx("span",{className:"px-2 py-1 text-xs font-mono uppercase bg-white/5 border border-dashed border-white/15 text-white/80 rounded-sm tracking-wide",children:ee.role}):r.jsx("span",{className:"text-sm text-gray-500",children:"—"})}),r.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:r.jsxs("div",{className:"flex flex-col",children:[new Date(ee.createdAt).toLocaleDateString(),r.jsx("p",{className:"text-xs",children:new Date(ee.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),r.jsx("td",{className:"py-4 px-4 text-right",children:r.jsxs("div",{className:"relative flex items-center justify-end",children:[r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:ue=>{ue.stopPropagation(),k(R===ee.id?null:ee.id)},children:r.jsx(l3,{className:"w-4 h-4"})}),R===ee.id&&r.jsxs("div",{className:"absolute z-[999] right-0 top-full mt-1 w-48 bg-black border border-white/20 rounded-none shadow-lg",onClick:ue=>ue.stopPropagation(),children:[r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),Ye(ee)},children:[r.jsx(Ms,{className:"w-4 h-4"}),r.jsx("span",{children:"View"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),bt(ee)},children:[r.jsx(Po,{className:"w-4 h-4"}),r.jsx("span",{children:"Edit User"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),P(ee),G(!0)},children:[r.jsx(Mn,{className:"w-4 h-4"}),r.jsx("span",{children:"Update Password"})]}),I&&(ee.banned?r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-green-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),P(ee),L(!0),k(null)},children:[r.jsx(Lh,{className:"w-4 h-4"}),r.jsx("span",{children:"Unban User"})]}):r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-yellow-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),P(ee),M(!0),k(null)},children:[r.jsx(Lh,{className:"w-4 h-4"}),r.jsx("span",{children:"Ban User"})]})),r.jsx("div",{className:"border-t border-white/10 my-1"}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),Ke(ee)},children:[r.jsx(Qu,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete User"})]})]})]})})]},ee.id))})]})}),r.jsx(OU,{currentPage:d,totalPages:pe,onPageChange:tt,totalItems:Ze.length,startIndex:ye,endIndex:Te})]}),E&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"overflow-x-hidden bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(Bo,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed User"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{j(!1),ne("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center space-x-2"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center space-x-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"user-count",className:"text-sm text-gray-400 font-light",children:"Number of users"}),r.jsx(Ne,{id:"user-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"})]})}),r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"seed-role",className:"text-sm text-gray-400 font-light",children:"Role (optional)"}),r.jsxs(hn,{className:"bg-black text-white",value:ae,onValueChange:ne,children:[r.jsx(fn,{id:"seed-role",className:"mt-1 border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role (optional)"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"}),r.jsx(Le,{value:"mix",children:"Mix (Random)"})]})]})]}),r.jsx($,{onClick:()=>{var ue;const ee=parseInt(((ue=document.getElementById("user-count"))==null?void 0:ue.value)||"5",10);$e(ee,ae||void 0)},disabled:ge,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ge?r.jsxs(r.Fragment,{children:[r.jsx(Ja,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Jt,{className:"w-3 h-3 mr-2"}),"Seed Users"]})})]})]}),ve.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"User Seeding Terminal",lines:ve,isRunning:ge,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>{j(!1),ne("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),y&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-white/10 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Create User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{x(!1),ie("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"create-name",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-email",className:"text-sm text-gray-400 font-light",children:"Email"}),r.jsx(Ne,{id:"create-email",type:"email",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-password",className:"text-sm text-gray-400 font-light",children:"Password"}),r.jsx(Ne,{id:"create-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-role",className:"text-sm text-gray-400 font-light",children:"Role"}),r.jsxs(hn,{className:"bg-black text-white",value:X,onValueChange:ie,children:[r.jsx(fn,{id:"create-role",className:"mt-1 border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{x(!1),ie("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:de,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),N&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{b(!1),Y("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"edit-name",defaultValue:A.name,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-email",className:"text-sm text-gray-400 font-light",children:"Email"}),r.jsx(Ne,{id:"edit-email",type:"email",defaultValue:A.email,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-role",className:"text-sm text-gray-400 font-light",children:"Role"}),r.jsxs(hn,{value:W,onValueChange:Y,children:[r.jsx(fn,{id:"edit-role",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{b(!1),Y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),v&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ie,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-white/15 rounded-none w-full max-w-lg p-6 shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"flex flex-col gap-2",children:r.jsx("h3",{className:"text-lg text-white font-light uppercase font-mono",children:"User Details"})}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"text-gray-400 -mt-2 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex flex-col items-center justify-center mt-2",children:[r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"}),r.jsx("div",{className:"relative z-20 h-4 w-[calc(100%+3rem)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#ffffff,#ffffff_1px,transparent_1px,transparent_6px)] opacity-[7%]"}),r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"})]}),r.jsxs("div",{className:"space-y-6 mt-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-14 h-14 rounded-none border border-dashed border-white/15"}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium leading-tight flex items-center gap-2",children:[r.jsx("span",{children:A.name}),r.jsx(on,{id:A.id,variant:"subscript",nonSliced:!0})]}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsx("div",{className:"space-y-2 text-sm",children:[{label:"Email Verified",value:A.emailVerified?"Yes":"No"},{label:"Role",value:A.role||"—"},{label:"Banned",value:A.banned?"Yes":"No"},{label:"Ban Reason",value:A.banReason||"—"},{label:"Ban Expires",value:nb(A.banExpires)},{label:"Created",value:nb(A.createdAt)},{label:"Updated",value:nb(A.updatedAt)}].map(ee=>r.jsxs("div",{className:"flex items-center justify-between border border-dashed border-white/15 bg-black/90 px-3 py-2 rounded-none",children:[r.jsx("div",{className:"text-[11px] font-mono font-light uppercase tracking-wide text-gray-400",children:ee.label}),r.jsx("div",{className:"text-sm text-white text-right break-words max-w-[60%]",children:ee.value})]},ee.label))})]}),r.jsxs("div",{className:"flex justify-end gap-3 mt-8",children:[r.jsx($,{onClick:()=>S(!1),className:"border border-white/20 bg-white/5 text-white hover:bg-white/10 rounded-none",children:"Close"}),r.jsx($,{onClick:()=>{S(!1),e(`/users/${A.id}`)},className:"border border-white/20 bg-white text-black hover:bg-white/90 rounded-none",children:"View Details"})]})]})}),_&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-red-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),r.jsxs("p",{className:"text-gray-400 mb-4",children:["Ban ",r.jsx("strong",{children:A.name})," from accessing the system."]}),r.jsxs("div",{className:"space-y-4 mb-6",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banReason",className:"text-white",children:"Ban Reason"}),r.jsx(Ne,{id:"banReason",value:T,onChange:ee=>D(ee.target.value),placeholder:"Enter reason for ban (optional)",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banExpires",className:"text-white",children:"Ban Duration (seconds)"}),r.jsx(Ne,{id:"banExpires",type:"number",value:q||"",onChange:ee=>C(ee.target.value?Number(ee.target.value):void 0),placeholder:"Leave empty for permanent ban",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Examples: 3600 (1 hour), 86400 (1 day), 604800 (1 week)"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{M(!1),D(""),C(void 0),P(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ae,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),U&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-dashed border-green-400/50 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Unban User"}),r.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to unban ",r.jsx("strong",{children:A.name}),"? This will restore their access to the system."]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{L(!1),P(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:We,className:"bg-green-600 text-white hover:bg-green-700 rounded-none",children:"Unban User"})]})]})}),F&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Update Password"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{G(!1),P(null),document.getElementById("update-password").value=""},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"update-password",className:"text-sm text-gray-400 font-light",children:"New Password"}),r.jsx(Ne,{id:"update-password",type:"password",placeholder:"Enter new password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{G(!1),P(null),document.getElementById("update-password").value=""},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:at,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Password"})]})]})})]})}const gd=[{id:"signups",label:"Signups",analyticsKey:"newUsers",barClass:"bg-white/25 border border-white/10",dotClass:"bg-white/25"},{id:"logins",label:"Logins",analyticsKey:"activeUsers",barClass:"bg-white/20 border border-white/10",dotClass:"bg-white/20"},{id:"organizations",label:"Organizations",analyticsKey:"organizations",barClass:"bg-white/15 border border-white/10",dotClass:"bg-white/15"},{id:"teams",label:"Teams",analyticsKey:"teams",barClass:"bg-white/10 border border-white/10",dotClass:"bg-white/10"},{id:"sessions",label:"Sessions",analyticsKey:"sessions",barClass:"bg-white/5 border border-white/10",dotClass:"bg-white/5"}];function Pae(){const[e]=p.useState("overview"),[t,n]=p.useState(!1),[a,s]=p.useState(0),[i,o]=p.useState(0),[l,c]=p.useState("1D"),[u,h]=p.useState("1D"),[d,f]=p.useState(null),[m,y]=p.useState(!1),[x,N]=p.useState("Daily"),[b,v]=p.useState("Daily"),[g,w]=p.useState("Daily"),[S,E]=p.useState("Daily"),[j,_]=p.useState(!1),[M,U]=p.useState(!1),[L,F]=p.useState(!1),[G,A]=p.useState(!1),[P,R]=p.useState(null),[k,T]=p.useState(null),[D,q]=p.useState(null),[C,I]=p.useState(null),[z,W]=p.useState(null),[Y,ae]=p.useState(void 0),[ne,X]=p.useState(void 0),[ie,ve]=p.useState(void 0),[se,ge]=p.useState(void 0),[be,Ue]=p.useState(void 0),[Be,$e]=p.useState(void 0),[Ye,bt]=p.useState(void 0),[Ke,de]=p.useState(void 0),[Fe,Ie]=p.useState([]),[Ae,We]=p.useState([]),[at,ft]=p.useState(0),[Yt,Wt]=p.useState([]),[oe,_e]=p.useState([]),[Ze,K]=p.useState(0),[pe,ye]=p.useState(0),[Te,ze]=p.useState(0),[tt,ee]=p.useState(0),[ue,Oe]=p.useState(0),[xe,Pe]=p.useState(!1),[Q,Z]=p.useState(!1),[je,Qe]=p.useState({signups:[],logins:[],organizations:[],teams:[],sessions:[]}),[st,ct]=p.useState([]),[it,cn]=p.useState(!1),[Tn,yn]=p.useState(0),[nn,ns]=p.useState(0),[Dn,Hn]=p.useState(0),[rr,as]=p.useState(0),[el,Ys]=p.useState(0),[Pn,It]=p.useState([]),[rs,ss]=p.useState(0),[is,Sr]=p.useState(0),[os,Er]=p.useState(0),{counts:Ws,loading:fa}=pm(),Qn=yr(),Pa=["Daily","Weekly","Monthly","Yearly","Custom"],Xs={Daily:"1D",Weekly:"1W",Monthly:"1M",Yearly:"1Y",Custom:"Custom"},pa=p.useMemo(()=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),[]),Jn=we=>we==null?"...":pa.format(Number(we)),sr=we=>we==null?"...":Number(we).toLocaleString(),Ks=p.useMemo(()=>gd.reduce((we,Ee)=>(we[Ee.id]=(je[Ee.id]||[]).reduce((Re,fe)=>Re+fe,0),we),{}),[je]),Zs=p.useMemo(()=>Object.values(Ks).reduce((we,Ee)=>we+Ee,0),[Ks]),tl=(we,Ee)=>{const Re=we.currentTarget.getBoundingClientRect();I(Ee),W({x:Re.left+Re.width/2,y:Re.top})},no=(()=>{const we=[];return P!=null&&P.isOutdated?we.push({id:"version-check",title:`Update Better-Auth to v${P.latest}`,severity:"high",date:new Date().toISOString().split("T")[0],description:"Your current version is outdated. Update to the latest version to get the latest security fixes, features, and improvements. Run: `pnpm install better-auth@latest`",affectedComponents:["All Components"],status:"pending",cve:""}):P&&we.push({id:"version-check",title:"Better-Auth is Up to date",severity:"low",date:new Date().toISOString().split("T")[0],description:"You are running the latest version of better-auth. Great job keeping your dependencies up to date!",affectedComponents:["All Components"],status:"applied",cve:""}),we.push(),we.push({id:"3",title:"Rate Limiting Configuration",severity:"medium",date:new Date().toISOString().split("T")[0],description:"Configure rate limiting for authentication endpoints to prevent brute force attacks. Better-auth provides built-in rate limiting middleware.",affectedComponents:["Auth Endpoints"],status:"pending"}),we})(),xt=p.useCallback(async(we,Ee,Re,fe)=>{try{const Ce=new URLSearchParams({type:we,period:Ee});return Re&&Ce.append("from",Re.toISOString()),fe&&Ce.append("to",fe.toISOString()),await(await fetch(`/api/analytics?${Ce.toString()}`)).json()}catch{return null}},[]);p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/users/all")).json();Re!=null&&Re.success&&Re.users&&It(Re.users)}catch{It([])}})()},[]),p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/stats")).json();Re&&s(Re.activeUsers||0)}catch{s(0)}})()},[]),p.useEffect(()=>{(async()=>{const Ee=await xt("users",l,Y,ne);Ee&&(Ie(Ee.data||[]),We(Ee.labels||[]),ft(Ee.percentageChange||0))})()},[l,Y,ne,xt]),p.useEffect(()=>{if(Pn.length===0){ss(0),Sr(0);return}const we=new Date;let Ee,Re=we,fe,Ce;if(b==="Custom"){if(!ie||!se){ss(0),Sr(0);return}Ee=new Date(ie),Re=new Date(se),Re.setHours(23,59,59,999);const Ut=Re.getTime()-Ee.getTime();Ce=new Date(Ee.getTime()-1),fe=new Date(Ce.getTime()-Ut)}else switch(b){case"Daily":Ee=new Date(we),Ee.setHours(0,0,0,0),Ce=new Date(Ee.getTime()-1),fe=new Date(Ce.getTime()-24*60*60*1e3);break;case"Weekly":Ee=new Date(we),Ee.setDate(we.getDate()-we.getDay()),Ee.setHours(0,0,0,0),Ce=new Date(Ee.getTime()-1),fe=new Date(Ce.getTime()-7*24*60*60*1e3);break;case"Monthly":Ee=new Date(we.getFullYear(),we.getMonth(),1),Ee.setHours(0,0,0,0),Ce=new Date(Ee.getTime()-1),fe=new Date(we.getFullYear(),we.getMonth()-1,1),fe.setHours(0,0,0,0);break;case"Yearly":Ee=new Date(we.getFullYear(),0,1),Ee.setHours(0,0,0,0),Ce=new Date(Ee.getTime()-1),fe=new Date(we.getFullYear()-1,0,1),fe.setHours(0,0,0,0);break;default:ss(0),Sr(0);return}const De=Pn.filter(Ut=>{if(!Ut.createdAt)return!1;const ea=new Date(Ut.createdAt);return ea>=Ee&&ea<=Re}),ke=Pn.filter(Ut=>{if(!Ut.createdAt)return!1;const ea=new Date(Ut.createdAt);return ea>=fe&&ea<=Ce}),Se=De.length,qe=ke.length;let Lt=0;qe>0?Lt=(Se-qe)/qe*100:Se>0&&(Lt=100),ss(Se),Sr(Lt)},[Pn,b,ie,se]),p.useEffect(()=>{(async()=>{if(!(u==="Custom"&&(!ie||!se))){cn(!0);try{const[Ee,Re,fe,Ce,De]=await Promise.all([xt("newUsers",u,ie,se),xt("activeUsers",u,ie,se),xt("organizations",u,ie,se),xt("teams",u,ie,se),xt("sessions",u,ie,se)]);Ee&&(Wt(Ee.data||[]),_e(Ee.labels||[])),Qe({signups:(Ee==null?void 0:Ee.data)||[],logins:(Re==null?void 0:Re.data)||[],organizations:(fe==null?void 0:fe.data)||[],teams:(Ce==null?void 0:Ce.data)||[],sessions:(De==null?void 0:De.data)||[]}),ct((Ee==null?void 0:Ee.labels)||(Re==null?void 0:Re.labels)||(fe==null?void 0:fe.labels)||(Ce==null?void 0:Ce.labels)||(De==null?void 0:De.labels)||[])}finally{cn(!1)}}})()},[u,ie,se,xt]),p.useEffect(()=>{(async()=>{const Ee=await xt("activeUsers","1D");Ee&&K(Ee.percentageChange||0)})()},[xt]),p.useEffect(()=>{(async()=>{const Ee=Xs[g]||"1D",Re=Ee==="Custom";if(!(Re&&(!be||!Be))){Pe(!0);try{const fe=await xt("organizations",Ee,Re?be:void 0,Re?Be:void 0);fe&&(ee(fe.total||0),ye(fe.percentageChange||0))}catch{ee(0),ye(0)}finally{Pe(!1)}}})()},[g,be,Be,xt]),p.useEffect(()=>{(async()=>{const Ee=Xs[S]||"1D",Re=Ee==="Custom";if(!(Re&&(!Ye||!Ke))){Z(!0);try{const fe=await xt("teams",Ee,Re?Ye:void 0,Re?Ke:void 0);fe&&(Oe(fe.total||0),ze(fe.percentageChange||0))}catch{Oe(0),ze(0)}finally{Z(!1)}}})()},[S,Ye,Ke,xt]),p.useEffect(()=>{(async()=>{const Ee=await xt("users","1D");Ee&&yn(Ee.percentageChange||0);const Re=await xt("organizations","1D");Re&&ns(Re.percentageChange||0);const fe=await xt("activeUsers","1D");fe&&Hn(fe.percentageChange||0);const[Ce,De,ke,Se,qe]=await Promise.all([xt("newUsers","1D"),xt("activeUsers","1D"),xt("organizations","1D"),xt("teams","1D"),xt("sessions","1D")]);Ce?(o(Ce.total||0),Er(Ce.percentageChange||0)):(o(0),Er(0));const Ut=[(Ce==null?void 0:Ce.total)||0,(De==null?void 0:De.total)||0,(ke==null?void 0:ke.total)||0,(Se==null?void 0:Se.total)||0,(qe==null?void 0:qe.total)||0].reduce((Cr,kr)=>Cr+kr,0);Ys(Ut);const ma=[(Ce==null?void 0:Ce.previousTotal)||0,(De==null?void 0:De.previousTotal)||0,(ke==null?void 0:ke.previousTotal)||0,(Se==null?void 0:Se.previousTotal)||0,(qe==null?void 0:qe.previousTotal)||0].reduce((Cr,kr)=>Cr+kr,0);if(ma>0){const Cr=(Ut-ma)/ma*100;as(Cr)}else Ut>0?as(100):as(0)})()},[xt]),p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/version-check")).json();Re&&R({current:Re.current||"1.0.0",latest:Re.latest||"1.0.0",isOutdated:Re.isOutdated||!1})}catch{try{const Ce=(await(await fetch("/api/package-info")).json()).betterAuthVersion||"1.0.0",De="1.5.0";R({current:Ce,latest:De,isOutdated:Ce!==De})}catch{R({current:"1.0.0",latest:"1.5.0",isOutdated:!0})}}})()},[]);const jr=we=>{switch(we){case"critical":return"bg-white/10 text-white border-white/20";case"high":return"bg-white/10 text-white border-white/20";case"medium":return"bg-white/10 text-gray-300 border-white/20";case"low":return"bg-white/10 text-gray-400 border-white/20";default:return"bg-white/10 text-gray-400 border-white/20"}},Tr=we=>{switch(we){case"applied":return"bg-white/10 text-white border-white/20";case"scheduled":return"bg-white/10 text-gray-300 border-white/20";case"pending":return"bg-white/10 text-gray-400 border-white/20";default:return"bg-white/10 text-gray-400 border-white/20"}},Js=we=>{f(we),y(!0)},ls=()=>{y(!1),setTimeout(()=>f(null),300)},ir=()=>{if(!Pn||Pn.length===0)return 0;const we=Pn.reduce((fe,Ce)=>{const De=Ce!=null&&Ce.createdAt?new Date(Ce.createdAt):null;return!De||Number.isNaN(De.getTime())?fe:fe?De<fe?De:fe:De},null);if(!we)return 0;const Ee=new Date,Re=(Ee.getFullYear()-we.getFullYear())*12+(Ee.getMonth()-we.getMonth())+1;return Math.max(Re,0)},cs=()=>{const we=ir();if(we<=0)return{labels:Array.from({length:12},(De,ke)=>`Week ${ke+1}`),expectedLength:12};if(we<3)return{labels:Array.from({length:12},(De,ke)=>`Week ${ke+1}`),expectedLength:12};if(we<=12){const ke=Pn.reduce((qe,Lt)=>{const Ut=Lt!=null&&Lt.createdAt?new Date(Lt.createdAt):null;return!Ut||Number.isNaN(Ut.getTime())?qe:qe?Ut<qe?Ut:qe:Ut},null)||new Date,Se=Array.from({length:12},(qe,Lt)=>new Date(ke.getFullYear(),ke.getMonth()+Lt,1).toLocaleDateString("en-US",{month:"short"}));return{labels:Se,expectedLength:Se.length}}const Ee=Math.max(1,Math.ceil(we/12)),fe=(Pn.reduce((De,ke)=>{const Se=ke!=null&&ke.createdAt?new Date(ke.createdAt):null;return!Se||Number.isNaN(Se.getTime())?De:De?Se<De?Se:De:Se},null)||new Date).getFullYear(),Ce=Array.from({length:Ee},(De,ke)=>`${fe+ke}`);return{labels:Ce,expectedLength:Ce.length}},Fa=(we,Ee="users")=>{const Re=Ee==="users"?Ae:Ee==="newUsers"?oe:st,fe={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7};if(we==="ALL"){if(Ee==="users"||Ee==="activity"){const{labels:ke}=cs();return ke}return[]}const Ce=fe[we]||7;if(Re&&Re.length>0&&Re.length===Ce)return we==="1D"?Re.filter((ke,Se)=>Se%4===0).map(ke=>{const Se=parseInt(ke.replace("h",""),10);return Se===0?"12am":Se<12?`${Se}am`:Se===12?"12pm":`${Se-12}pm`}):we==="1W"?Re.map(ke=>ke.length>3?ke.substring(0,3):ke):we==="1M"?Re.map(ke=>{const Se=ke.split(" ");return Se.length>=2?Se[1]:ke}):we==="1Y"||we==="3M"||we==="6M"?Re.map(ke=>ke.length>3?ke.substring(0,3):ke):Re.map(ke=>ke.length>3?ke.substring(0,3):ke);const De=new Date;switch(we){case"1D":return["12am","4am","8am","12pm","4pm","8pm"];case"1W":return Array.from({length:7},(ke,Se)=>new Date(De.getTime()-(6-Se)*24*60*60*1e3).toLocaleDateString("en-US",{weekday:"short"}));case"1M":return Array.from({length:30},(ke,Se)=>new Date(De.getTime()-(29-Se)*24*60*60*1e3).getDate().toString());case"3M":return Array.from({length:3},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(2-Se),1).toLocaleDateString("en-US",{month:"short"}));case"6M":return Array.from({length:6},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(5-Se),1).toLocaleDateString("en-US",{month:"short"}));case"1Y":return Array.from({length:12},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(11-Se),1).toLocaleDateString("en-US",{month:"short"}));case"ALL":return Array.from({length:7},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(6-Se),1).toLocaleDateString("en-US",{month:"short"}));default:return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]}},ao=(we,Ee="users")=>{const Re=Ee==="users"?Ae:oe;let Ce={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7}[we]||7;if(we==="ALL"&&Ee==="users"){const{labels:ke,expectedLength:Se}=cs();return Ce=Se||Ce,Re&&Re.length===ke.length,ke}if(we==="ALL"&&Ee!=="users")return[];if(Re&&Re.length>0&&Re.length===Ce)return we==="1D"?Re.map(ke=>{const Se=parseInt(ke.replace("h",""),10);return Se===0?"12am":Se<12?`${Se}am`:Se===12?"12pm":`${Se-12}pm`}):we==="1Y"||we==="3M"||we==="6M"?Re.map(ke=>{const Se=["January","February","March","April","May","June","July","August","September","October","November","December"],Lt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].indexOf(ke);return Lt!==-1?Se[Lt]:ke}):Re;const De=new Date;switch(we){case"1D":return Array.from({length:24},(ke,Se)=>{const qe=new Date;return qe.setHours(Se,0,0,0),qe.toLocaleTimeString("en-US",{hour:"numeric",hour12:!0})});case"1W":return Array.from({length:7},(ke,Se)=>new Date(De.getTime()-(6-Se)*24*60*60*1e3).toLocaleDateString("en-US",{weekday:"long"}));case"1M":return Array.from({length:30},(ke,Se)=>{const qe=new Date(De.getTime()-(29-Se)*24*60*60*1e3),Lt=qe.toLocaleDateString("en-US",{month:"short"}),Ut=qe.getDate();return`${Lt} ${Ut}`});case"3M":return Array.from({length:3},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(2-Se),1).toLocaleDateString("en-US",{month:"long"}));case"6M":return Array.from({length:6},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(5-Se),1).toLocaleDateString("en-US",{month:"long"}));case"1Y":return Array.from({length:12},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(11-Se),1).toLocaleDateString("en-US",{month:"long"}));case"ALL":return Array.from({length:7},(ke,Se)=>new Date(De.getFullYear(),De.getMonth()-(6-Se),1).toLocaleDateString("en-US",{month:"long"}));default:return["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]}},ds=(we,Ee="users")=>{const Re=Ee==="users"?Fe:Yt;let Ce={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7}[we]||7;if(we==="ALL"&&Ee==="users"){const{expectedLength:qe}=cs();Ce=qe||Ce}if(we==="ALL"&&Ee==="activity"){const{expectedLength:qe}=cs();Ce=qe||Ce}if(!Re||Re.length===0)return Array(Ce).fill(0);const De=[...Re];for(;De.length<Ce;)De.push(0);const ke=De.slice(0,Ce),Se=Math.max(...ke,1);return ke.map(qe=>qe/Se*100)},nl=()=>{const we=u==="ALL"?Fa("ALL","activity"):st.length>0?st:Fa(u,"activity"),Ee=we.map((fe,Ce)=>gd.reduce((De,ke)=>{var Se;return De+(((Se=je[ke.id])==null?void 0:Se[Ce])??0)},0)),Re=Math.max(...Ee,1);return r.jsxs("div",{className:"space-y-6 min-h-screen h-full mt-5 flex-1 overflow-y-hidden overflow-x-hidden px-0",children:[r.jsx("div",{className:"px-6 overflow-hidden",children:r.jsxs("div",{className:"flex items-center justify-between gap-8 py-4 px-6 bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none overflow-x-auto relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ot,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Users"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.users)}),r.jsxs("div",{className:`flex items-center gap-1 ${Tn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${Tn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(Tn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ca,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Organizations"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.organizations)}),r.jsxs("div",{className:`flex items-center gap-1 ${nn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${nn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(nn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(jC,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Sessions"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.sessions)}),r.jsxs("div",{className:`flex items-center gap-1 ${Dn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${Dn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(Dn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(SC,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Activity Hits"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(el??0)}),r.jsxs("div",{className:`flex items-center gap-1 ${rr>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${rr<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(rr).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ot,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"New Users"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(i??0)}),r.jsxs("div",{className:`flex items-center gap-1 ${os>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${os<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(os).toFixed(1),"%"]})]})]})]})]})}),r.jsxs("div",{className:"px-6 pb-10 space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-sm text-white uppercase font-light",children:"TOTAL USER"}),r.jsx("div",{className:"flex items-center space-x-1 overflow-x-auto",children:["1D","1W","6M","1Y","ALL"].map(fe=>r.jsx("button",{onClick:()=>c(fe),className:`px-2 py-1 text-xs font-light transition-colors whitespace-nowrap ${l===fe?"bg-white/20 text-white border border-white/30":"text-gray-500 hover:text-white"}`,children:fe},fe))})]}),r.jsx("div",{className:"flex justify-between items-end mb-4",children:(()=>{const fe=ds(l,"users"),De=(Fe.length>0?Fe.slice(0,fe.length):Array(fe.length).fill(0)).reduce((ke,Se)=>ke+Se,0);return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-4xl text-white font-light",children:fa?"...":Jn(De)}),r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[r.jsx("svg",{className:`w-3 h-3 ${at>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${at>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(at).toFixed(1),"%"]})]})]})})()}),r.jsxs("div",{className:"space-y-2 relative",children:[(()=>{const fe=ds(l,"users"),Ce=Fe.length>0?Fe.slice(0,fe.length):Array(fe.length).fill(0),De=Math.max(...Ce,1),ke=Array.from({length:6},(Se,qe)=>De/5*(5-qe));return r.jsxs("div",{className:"flex gap-2",children:[r.jsx("div",{className:"flex flex-col justify-between h-48 text-xs text-gray-500 font-mono pt-0.5 pb-0.5",children:ke.map((Se,qe)=>r.jsx("span",{className:"leading-none",children:Jn(Math.round(Se))},qe))}),r.jsxs("div",{className:"flex-1 h-48 relative",children:[r.jsx("div",{className:"absolute inset-0 flex flex-col justify-between z-0",children:[0,1,2,3,4,5].map(Se=>r.jsx("div",{className:"w-full h-px bg-white/10",style:{opacity:.3}},Se))}),r.jsx("svg",{className:"w-full h-full absolute inset-0",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:r.jsx("defs",{children:r.jsxs("linearGradient",{id:"usersBarGradient",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[r.jsx("stop",{offset:"0%",style:{stopColor:"rgba(255, 255, 255, 0.3)",stopOpacity:1}}),r.jsx("stop",{offset:"100%",style:{stopColor:"rgba(255, 255, 255, 0.05)",stopOpacity:1}})]})})}),r.jsx("div",{className:"h-48 flex items-end justify-between space-x-1 relative z-10",children:fe.map((Se,qe)=>{const Lt=k===qe;return r.jsx("div",{className:"flex-1 transition-all duration-200 ease-out relative cursor-pointer group",style:{height:`${Se}%`,background:"url(#usersBarGradient)"},onMouseEnter:Ut=>{const ea=Ut.currentTarget.getBoundingClientRect(),ma=ea.left+ea.width/2,Cr=ea.top,kr=150,Hc=60,ch=Math.max(kr/2,Math.min(window.innerWidth-kr/2,ma)),al=Math.max(Hc+10,Math.min(window.innerHeight-10,Cr));T(qe),q({x:ch,y:al})},onMouseLeave:()=>{T(null),q(null)},children:r.jsx("div",{className:"w-full h-full",style:{background:"linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.285))",opacity:Lt?1:.8}})},qe)})}),k!==null&&D&&r.jsx("div",{className:"fixed z-50 pointer-events-none transition-all duration-200 ease-out animate-in fade-in",style:{left:`${D.x}px`,top:`${D.y}px`,transform:"translate(-50%, -100%)",maxWidth:"calc(100vw - 20px)"},children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-sm px-3 py-2 shadow-lg whitespace-nowrap",children:[r.jsx("div",{className:"text-xs text-gray-400 mb-1 font-mono uppercase",children:ao(l,"users")[k]}),r.jsxs("div",{className:"text-sm text-white font-sans font-medium",children:[Fe[k]!==void 0?Fe[k].toLocaleString():"0"," ",r.jsx("span",{className:"font-mono text-xs text-gray-400",children:"users"})]})]})})]})]})})(),r.jsx("div",{className:`flex justify-between ${l==="1M"?"text-[10px]":"text-xs"} text-gray-500 font-mono`,children:Fa(l,"users").map((fe,Ce)=>r.jsx("span",{className:"flex-1 text-center truncate",children:fe},Ce))})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm text-white uppercase font-light",children:"Activity Hits"}),r.jsx("p",{className:"text-4xl text-white font-light mt-1",children:it?"...":sr(Zs)}),r.jsx("p",{className:"text-xs text-gray-400",children:"Tracked events in selected period"})]}),r.jsx("div",{className:"flex items-center space-x-1 overflow-x-auto",children:["1D","1W","3M","6M","1Y","ALL"].map(fe=>r.jsx("button",{onClick:()=>h(fe),className:`px-2 py-1 text-xs font-light transition-colors whitespace-nowrap ${u===fe?"bg-white/20 text-white border border-white/30":"text-gray-500 hover:text-white"}`,children:fe},fe))})]}),r.jsxs("div",{className:"space-y-2 relative",children:[r.jsx("div",{className:"h-40 flex items-end gap-1",children:we.map((fe,Ce)=>{const De=Ee[Ce]||0;return r.jsx("div",{className:"flex-1 flex flex-col justify-end gap-[1px] h-full cursor-pointer",onMouseEnter:ke=>tl(ke,Ce),onMouseLeave:()=>{I(null),W(null)},children:gd.map(ke=>{var Lt;const Se=((Lt=je[ke.id])==null?void 0:Lt[Ce])??0,qe=De===0||Re===0?0:Math.max(Se/Re*100,Se>0?4:0);return r.jsx("div",{className:`w-full ${ke.barClass}`,style:{height:`${qe}%`}},`${ke.id}-${Ce}`)})},`${fe}-${Ce}`)})}),it&&r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center text-xs uppercase text-gray-400 pointer-events-none",children:"Loading activity..."}),C!==null&&z&&r.jsx("div",{className:"fixed z-50 pointer-events-none transition-all duration-200 ease-out animate-in fade-in",style:{left:`${z.x}px`,top:`${z.y}px`,transform:"translate(-50%, -100%)",maxWidth:"calc(100vw - 20px)"},children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-sm px-3 py-2 shadow-lg min-w-[180px]",children:[r.jsx("div",{className:"text-xs text-gray-400 mb-2 font-mono uppercase",children:we[C]||`Bucket ${C+1}`}),r.jsx("div",{className:"space-y-1",children:gd.map(fe=>{var Ce;return r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-300",children:[r.jsx("span",{className:`w-2 h-2 rounded-sm ${fe.dotClass}`}),fe.label]}),r.jsx("span",{className:"text-white font-medium",children:((Ce=je[fe.id])==null?void 0:Ce[C])??0})]},fe.id)})})]})}),r.jsx("div",{className:`flex justify-between ${u==="1M"?"text-[10px]":"text-xs"} text-gray-500 font-mono`,children:we.map((fe,Ce)=>r.jsx("span",{className:"flex-1 text-center truncate",children:fe},Ce))}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3 mt-4 pt-4 border-t border-white/10",children:gd.map(fe=>r.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-2 h-2 rounded-sm ${fe.dotClass}`}),fe.label]}),r.jsx("span",{className:"text-white font-medium",children:it?"...":sr(Ks[fe.id]||0)})]},fe.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-4 overflow-x-hidden",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>_(!j),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:x})]}),j&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{N(fe),_(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),x==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Y?Yn(Y,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Y,onSelect:ae,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),ne?Yn(ne,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:ne,onSelect:X,initialFocus:!0,disabled:fe=>Y?fe<Y:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Active Users"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Users with active session in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:sr(a)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 border-white/5 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${Ze>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${Ze>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(Ze).toFixed(1),"%"]})]})})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>U(!M),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:b})]}),M&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{v(fe),U(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),b==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),ie?Yn(ie,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:ie,onSelect:ve,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),se?Yn(se,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:se,onSelect:ge,initialFocus:!0,disabled:fe=>ie?fe<ie:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"New Users"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Newly registered Users in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:sr(rs)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${is>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",style:is<0?{transform:"rotate(180deg)"}:{},children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${is>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(is).toFixed(1),"%"]})]})})]})]})]}),r.jsxs("div",{className:"space-y-4 overflow-x-hidden",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>F(!L),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:g})]}),L&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{w(fe),F(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),g==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),be?Yn(be,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:be,onSelect:Ue,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Be?Yn(Be,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Be,onSelect:$e,initialFocus:!0,disabled:fe=>be?fe<be:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Organizations"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Total organizations in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:xe?"...":sr(tt)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${pe>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${pe>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(pe).toFixed(1),"%"]})]})})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>A(!G),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:S})]}),G&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{E(fe),A(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),S==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Ye?Yn(Ye,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Ye,onSelect:bt,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Ke?Yn(Ke,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Ke,onSelect:de,initialFocus:!0,disabled:fe=>Ye?fe<Ye:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Teams"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Total teams in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:Q?"...":sr(ue)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${Te>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${Te>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(Te).toFixed(1),"%"]})]})})]})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pt-4 overflow-hidden relative flex flex-col",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Mn,{className:"w-4 h-4 text-white/60"}),r.jsx("h4",{className:"text-xs text-gray-400 uppercase font-mono font-light",children:"Security Insights"})]})}),r.jsx("hr",{className:"-mx-10 -mt-1 border-white/10"}),r.jsxs("div",{className:"space-y-3 overflow-y-auto custom-scrollbar max-h-[400px]",children:[no.length===0&&r.jsx("div",{className:"text-sm flex items-center justify-center text-gray-400",children:r.jsxs("div",{className:"flex mt-5 items-center justify-center",children:[r.jsx(Mn,{className:"w-4 h-4 text-gray-400 mr-2"}),r.jsx("p",{className:"text-center",children:"No security insights found"})]})}),no.map((fe,Ce)=>r.jsx("div",{onClick:()=>Js(fe),className:"group py-2 border-b border-white/5 cursor-pointer transition-all duration-200 hover:border-white/20",style:{animation:`slideIn 0.3s ease-out ${Ce*.1}s both`},children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:r.jsx("span",{className:"text-sm text-white/90 font-light truncate group-hover:text-white transition-colors",children:fe.title})}),r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:`text-[9px] px-1.5 py-0.5 border rounded-sm uppercase font-mono ${jr(fe.severity)}`,children:fe.severity}),r.jsx("span",{className:`text-[9px] px-1.5 py-0.5 border rounded-sm capitalize font-mono ${Tr(fe.status)}`,children:fe.status})]})]}),r.jsx(vu,{className:"w-3.5 h-3.5 text-gray-500 group-hover:text-white transition-all flex-shrink-0 mt-0.5"})]})},fe.id))]})]})]})]})]})};return r.jsxs("div",{className:"h-screen bg-black text-white overflow-hidden flex flex-col",style:{overflowX:"hidden"},children:[r.jsx("div",{className:"flex-1 overflow-hidden",children:e==="overview"?nl():e==="users"?r.jsx(IU,{}):e==="organizations"?r.jsx(DU,{}):nl()}),t&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-3xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(jC,{className:"w-6 h-6 text-white"}),r.jsx("h3",{className:"text-lg text-white font-light",children:"Quick Actions"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("button",{onClick:()=>{n(!1),Qn("/users")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Ot,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View All Users"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Manage user accounts"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/organizations")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Ca,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View Organizations"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Manage organizations"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/sessions")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(SC,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View Sessions"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Monitor active sessions"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/database")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Rs,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Database Schema"}),r.jsx("p",{className:"text-sm text-gray-400",children:"View schema visualizer"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/settings")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(TU,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Settings"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Configure system"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/users")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(EU,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Search Users"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Find specific users"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]})]}),r.jsx("div",{className:"mt-6 pt-6 border-t border-dashed border-white/10",children:r.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-400",children:[r.jsx("span",{children:"Tip: Press Ctrl+K or Cmd+K for command palette"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(!1),className:"text-gray-400 hover:text-white rounded-none",children:"Close"})]})})]})}),m&&d&&r.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",style:{animation:"fadeIn 0.3s ease-out"},onClick:ls,children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-none max-w-2xl w-full max-h-[80vh] overflow-y-auto",style:{animation:"slideUp 0.3s ease-out"},onClick:we=>we.stopPropagation(),children:[r.jsx("div",{className:"sticky top-0 bg-black border-b border-white/10 p-6 z-10",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx(Mn,{className:"w-6 h-6 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light",children:d.title})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsxs("span",{className:`text-xs px-2 py-1 border rounded-none uppercase font-medium ${jr(d.severity)}`,children:[d.severity," Severity"]}),r.jsx("span",{className:`text-xs px-2 py-1 border rounded-none capitalize ${Tr(d.status)}`,children:d.status}),d.cve&&r.jsx("span",{className:"text-xs text-gray-400 font-mono bg-white/5 px-2 py-1 border border-white/10 rounded-none",children:d.cve})]})]}),r.jsx("button",{onClick:ls,className:"p-2 hover:bg-white/10 transition-colors rounded-none",children:r.jsx(dt,{className:"w-5 h-5 text-gray-400 hover:text-white"})})]})}),r.jsxs("div",{className:"p-6 space-y-6",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-2",children:"Release Date"}),r.jsx("p",{className:"text-white",children:new Date(d.date).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-2",children:"Description"}),d.description.includes("npm install")?r.jsxs("div",{children:[r.jsx("p",{className:"text-white leading-relaxed mb-3",children:d.description.split("Run:")[0]}),r.jsx("div",{className:"relative group",children:r.jsx("div",{className:"bg-black border border-white/20 rounded-none p-3 font-mono text-sm",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("code",{children:[r.jsx("span",{className:"text-green-400",children:"$"})," ",r.jsx("span",{className:"text-cyan-400",children:"npm"})," ",r.jsx("span",{className:"text-yellow-400",children:"install"})," ",r.jsx("span",{className:"text-white",children:"better-auth@latest"})]}),r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm install better-auth@latest"),V.success("Command copied to clipboard")},className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 hover:bg-white/10 rounded",title:"Copy command",children:r.jsx(xa,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})})})]}):r.jsx("p",{className:"text-white leading-relaxed",children:d.description})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-3",children:"Affected Components"}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:d.affectedComponents.map((we,Ee)=>r.jsxs("div",{className:"flex items-center gap-2 p-3 bg-white/5 border border-white/10 rounded-none",style:{animation:`slideIn 0.3s ease-out ${Ee*.1}s both`},children:[r.jsx("div",{className:"w-2 h-2 bg-white rounded-none flex-shrink-0"}),r.jsx("span",{className:"text-sm text-white",children:we})]},Ee))})]}),r.jsx("div",{className:"p-4 bg-white/5 border border-white/10 rounded-none",children:r.jsxs("div",{className:"flex items-start gap-3",children:[d.status==="applied"&&r.jsxs(r.Fragment,{children:[r.jsx(wp,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Patch Applied"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This security patch has been successfully applied to your system."})]})]}),d.status==="scheduled"&&r.jsxs(r.Fragment,{children:[r.jsx(jU,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Scheduled"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This patch is scheduled for deployment in the next maintenance window."})]})]}),d.status==="pending"&&r.jsxs(r.Fragment,{children:[r.jsx(bae,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Action Required"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This patch is pending review and requires manual approval before deployment."})]})]})]})}),r.jsx("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-white/10",children:r.jsx($,{variant:"ghost",onClick:ls,className:"text-gray-400 hover:text-white rounded-none",children:"Close"})})]})]})}),r.jsx("style",{children:`
|
|
519
|
+
`),xe=new Blob([Oe],{type:"text/csv;charset=utf-8;"}),Pe=document.createElement("a"),Q=URL.createObjectURL(xe);Pe.setAttribute("href",Q),Pe.setAttribute("download",`users-export-${new Date().toISOString().split("T")[0]}.csv`),Pe.style.visibility="hidden",document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),V.success(`Exported ${a.length} users to CSV`)},Yt=ee=>{u.some(Oe=>Oe.type===ee)||(h(Oe=>[...Oe,{type:ee}]),f(1))},Wt=ee=>{h(ue=>ue.filter(Oe=>Oe.type!==ee)),f(1)},oe=(ee,ue)=>{h(Oe=>Oe.map(xe=>xe.type===ee?{...xe,value:ue}:xe))},_e=(ee,ue)=>{h(Oe=>Oe.map(xe=>xe.type===ee?{...xe,dateRange:ue}:xe))},Ze=a.filter(ee=>{const ue=ee.name.toLowerCase().includes(l.toLowerCase())||ee.email.toLowerCase().includes(l.toLowerCase());if(u.length===0)return ue;const Oe=u.every(xe=>{var Pe,Q,Z,je,Qe;switch(xe.type){case"emailVerified":return xe.value===void 0?!0:ee.emailVerified===(xe.value==="true");case"banned":return xe.value===void 0?!0:ee.banned===(xe.value==="true");case"active":return ee.banned!==!0;case"createdAt":{if(!((Pe=xe.dateRange)!=null&&Pe.from)&&!((Q=xe.dateRange)!=null&&Q.to))return!0;const st=new Date(ee.createdAt);return!((Z=xe.dateRange)!=null&&Z.from&&xe.dateRange.from>st||(je=xe.dateRange)!=null&&je.to&&xe.dateRange.to<st)}case"role":return xe.value?(Qe=ee.role)==null?void 0:Qe.toLowerCase().includes(xe.value.toLowerCase()):!0;default:return!0}});return ue&&Oe}),K=a.filter(ee=>ee.banned).length,pe=Math.ceil(Ze.length/m),ye=(d-1)*m,Te=ye+m,ze=Ze.slice(ye,Te),tt=ee=>{f(ee)};return i?r.jsx("div",{className:"flex min-h-screen items-center justify-center h-full",children:r.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[r.jsx(Ja,{className:"w-6 h-6 text-white animate-spin"}),r.jsx("div",{className:"text-white text-sm",children:"Loading users..."})]})}):r.jsxs("div",{className:"space-y-6 p-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:["Users",r.jsx("sup",{className:"text-xs text-gray-500 ml-1 mt-0 inline-flex items-baseline",children:r.jsx(An,{value:t.users??0,className:"text-white font-mono text-sm",prefix:r.jsx("span",{className:"mr-1 text-gray-500",children:"["}),suffix:r.jsx("span",{className:"ml-1 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]}),r.jsx("p",{className:"text-gray-400 font-light text-sm mt-1 uppercase font-mono",children:"Manage your application users"}),r.jsx("div",{className:"flex items-center space-x-4 mt-2",children:K>0&&r.jsxs("span",{className:"text-sm text-red-400 flex items-center space-x-1",children:[r.jsx(Lh,{className:"w-3 h-3"}),r.jsxs("span",{children:[K," Banned"]})]})})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:ft,children:[r.jsx(Ul,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),r.jsxs($,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>j(!0),children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed"]}),r.jsxs($,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>x(!0),children:[r.jsx(CN,{className:"w-4 h-4 mr-2"}),"Add User"]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Fo,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),r.jsx(Ne,{placeholder:"Search users...",value:l,onChange:ee=>c(ee.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsx("div",{className:"flex items-center space-x-2",children:r.jsxs(hn,{value:"",onValueChange:Yt,children:[r.jsx(fn,{className:"w-[180px]",children:r.jsxs("div",{className:"flex mr-3 items-center space-x-2",children:[r.jsx(Pi,{className:"w-4 h-4"}),r.jsx("span",{children:"Add Filter"})]})}),r.jsxs(pn,{children:[!u.some(ee=>ee.type==="emailVerified")&&r.jsx(Le,{value:"emailVerified",children:"Email Verified"}),!u.some(ee=>ee.type==="banned")&&r.jsx(Le,{value:"banned",children:"Banned Status"}),!u.some(ee=>ee.type==="createdAt")&&r.jsx(Le,{value:"createdAt",children:"Created Date"}),!u.some(ee=>ee.type==="role")&&r.jsx(Le,{value:"role",children:"Role"})]})]})}),u.length>0&&r.jsx("div",{className:"flex items-center space-x-2",children:r.jsx($,{onClick:()=>h([]),className:"",children:"Clear all"})})]}),u.length>0&&r.jsx("div",{className:"space-y-3",children:r.jsx("div",{className:"flex flex-wrap gap-3",children:u.map(ee=>{var ue,Oe,xe,Pe;return r.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 bg-white/10 border border-white/20 rounded-sm",children:[r.jsx(xS,{className:"w-3 h-3 text-white"}),ee.type==="emailVerified"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Email Verified:"}),r.jsxs(hn,{value:ee.value||"",onValueChange:Q=>oe("emailVerified",Q),children:[r.jsx(fn,{className:"h-7 w-24 text-xs",children:r.jsx("span",{children:ee.value==="true"?"True":ee.value==="false"?"False":"Select"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"true",children:"True"}),r.jsx(Le,{value:"false",children:"False"})]})]})]}),ee.type==="banned"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Banned:"}),r.jsxs(hn,{value:ee.value||"",onValueChange:Q=>oe("banned",Q),children:[r.jsx(fn,{className:"h-7 w-24 text-xs",children:r.jsx("span",{children:ee.value==="true"?"Yes":ee.value==="false"?"No":"Select"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"true",children:"Yes"}),r.jsx(Le,{value:"false",children:"No"})]})]})]}),ee.type==="createdAt"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Created:"}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(ue=ee.dateRange)!=null&&ue.from?Yn(ee.dateRange.from,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(Oe=ee.dateRange)==null?void 0:Oe.from,onSelect:Q=>{var Z;return _e("createdAt",{from:Q,to:(Z=ee.dateRange)==null?void 0:Z.to})},initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-8 px-3 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(up,{className:"mr-1 h-3 w-3"}),(xe=ee.dateRange)!=null&&xe.to?Yn(ee.dateRange.to,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:(Pe=ee.dateRange)==null?void 0:Pe.to,onSelect:Q=>{var Z;return _e("createdAt",{from:(Z=ee.dateRange)==null?void 0:Z.from,to:Q})},initialFocus:!0,disabled:Q=>{var Z;return(Z=ee.dateRange)!=null&&Z.from?Q<ee.dateRange.from:!1},className:"rounded-none"})})]})]}),ee.type==="role"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white",children:"Role:"}),r.jsx(Ne,{type:"text",value:ee.value||"",onChange:Q=>oe("role",Q.target.value),className:"h-7 w-32 text-xs bg-black border-white/20 text-white",placeholder:"Enter role..."})]}),r.jsx("button",{onClick:()=>Wt(ee.type),className:"ml-1 hover:bg-white/20 rounded-full p-0.5",children:r.jsx(en,{className:"w-3 h-3 text-white"})})]},ee.type)})})})]}),r.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[r.jsx("div",{className:"overflow-x-auto overflow-y-hidden",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email Status"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),r.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),r.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),r.jsx("tbody",{children:ze.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"py-12 px-4 text-center",children:r.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[r.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:r.jsx(Bo,{className:"w-8 h-8 text-white/50"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium text-lg",children:"No users found"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:l||u.length>0?"Try adjusting your search or filter criteria":"Get started by creating your first user or seeding some data"})]}),!l&&u.length===0&&r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs($,{onClick:()=>x(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[r.jsx(CN,{className:"w-4 h-4 mr-2"}),"Create User"]}),r.jsxs($,{onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[r.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):ze.map(ee=>r.jsxs("tr",{className:`border-b border-dashed hover:bg-white/5 cursor-pointer ${ee.banned?"border-red-500/30 bg-red-500/5":"border-white/5"}`,onClick:()=>e(`/users/${ee.id}`),children:[r.jsx("td",{className:"py-4 px-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:ee.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${ee.id}`,alt:ee.name,className:`w-10 h-10 rounded-none border border-dashed ${ee.banned?"border-red-400/50 opacity-60":"border-white/20"}`}),ee.banned&&r.jsx("div",{className:"absolute -top-1 -right-1 bg-red-500 rounded-full p-0.5",children:r.jsx(Lh,{className:"w-3 h-3 text-white"})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"text-white font-light",children:ee.name}),ee.banned&&r.jsxs("span",{className:"relative group inline-block",children:[r.jsx("span",{className:"px-2 py-0.5 text-[10px] font-semibold bg-red-500/20 border border-red-500/50 text-red-400 rounded-sm uppercase tracking-wide cursor-help",children:"Banned"}),ee.banReason&&r.jsxs("span",{className:"absolute left-1/2 -translate-x-1/2 bottom-full mb-1.5 px-2 py-1 text-[10px] font-mono text-gray-300 bg-black border border-dashed border-white/20 rounded-none whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-150 pointer-events-none z-50",children:[ee.banReason,r.jsx("span",{className:"absolute left-1/2 -translate-x-1/2 top-full w-0 h-0 border-l-[4px] border-r-[4px] border-t-[4px] border-transparent border-t-white/20"})]})]})]}),r.jsx("div",{className:"text-sm text-gray-400 mt-0.5",children:ee.email})]})]})}),r.jsx("td",{className:"py-4 px-4",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[ee.emailVerified?r.jsx(yu,{className:"w-4 h-4 text-green-400"}):r.jsx(Sc,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-sm text-gray-400",children:ee.emailVerified?"Verified":"Not Verified"})]})}),r.jsx("td",{className:"py-4 px-4",children:ee.role?r.jsx("span",{className:"px-2 py-1 text-xs font-mono uppercase bg-white/5 border border-dashed border-white/15 text-white/80 rounded-sm tracking-wide",children:ee.role}):r.jsx("span",{className:"text-sm text-gray-500",children:"—"})}),r.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:r.jsxs("div",{className:"flex flex-col",children:[new Date(ee.createdAt).toLocaleDateString(),r.jsx("p",{className:"text-xs",children:new Date(ee.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),r.jsx("td",{className:"py-4 px-4 text-right",children:r.jsxs("div",{className:"relative flex items-center justify-end",children:[r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:ue=>{ue.stopPropagation(),k(R===ee.id?null:ee.id)},children:r.jsx(l3,{className:"w-4 h-4"})}),R===ee.id&&r.jsxs("div",{className:"absolute z-[999] right-0 top-full mt-1 w-48 bg-black border border-white/20 rounded-none shadow-lg",onClick:ue=>ue.stopPropagation(),children:[r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),Ye(ee)},children:[r.jsx(Ms,{className:"w-4 h-4"}),r.jsx("span",{children:"View"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),bt(ee)},children:[r.jsx(Po,{className:"w-4 h-4"}),r.jsx("span",{children:"Edit User"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),P(ee),G(!0)},children:[r.jsx(Mn,{className:"w-4 h-4"}),r.jsx("span",{children:"Update Password"})]}),I&&(ee.banned?r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-green-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),P(ee),L(!0),k(null)},children:[r.jsx(Lh,{className:"w-4 h-4"}),r.jsx("span",{children:"Unban User"})]}):r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-yellow-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),P(ee),M(!0),k(null)},children:[r.jsx(Lh,{className:"w-4 h-4"}),r.jsx("span",{children:"Ban User"})]})),r.jsx("div",{className:"border-t border-white/10 my-1"}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-white/10 flex items-center space-x-2",onClick:ue=>{ue.stopPropagation(),k(null),Ke(ee)},children:[r.jsx(Qu,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete User"})]})]})]})})]},ee.id))})]})}),r.jsx(OU,{currentPage:d,totalPages:pe,onPageChange:tt,totalItems:Ze.length,startIndex:ye,endIndex:Te})]}),E&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"overflow-x-hidden bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(Bo,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed User"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{j(!1),ne("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center space-x-2"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center space-x-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"user-count",className:"text-sm text-gray-400 font-light",children:"Number of users"}),r.jsx(Ne,{id:"user-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"})]})}),r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"seed-role",className:"text-sm text-gray-400 font-light",children:"Role (optional)"}),r.jsxs(hn,{className:"bg-black text-white",value:ae,onValueChange:ne,children:[r.jsx(fn,{id:"seed-role",className:"mt-1 border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role (optional)"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"}),r.jsx(Le,{value:"mix",children:"Mix (Random)"})]})]})]}),r.jsx($,{onClick:()=>{var ue;const ee=parseInt(((ue=document.getElementById("user-count"))==null?void 0:ue.value)||"5",10);$e(ee,ae||void 0)},disabled:ge,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ge?r.jsxs(r.Fragment,{children:[r.jsx(Ja,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Jt,{className:"w-3 h-3 mr-2"}),"Seed Users"]})})]})]}),ve.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"User Seeding Terminal",lines:ve,isRunning:ge,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>{j(!1),ne("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),y&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-white/10 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Create User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{x(!1),ie("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"create-name",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-email",className:"text-sm text-gray-400 font-light",children:"Email"}),r.jsx(Ne,{id:"create-email",type:"email",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-password",className:"text-sm text-gray-400 font-light",children:"Password"}),r.jsx(Ne,{id:"create-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"create-role",className:"text-sm text-gray-400 font-light",children:"Role"}),r.jsxs(hn,{className:"bg-black text-white",value:X,onValueChange:ie,children:[r.jsx(fn,{id:"create-role",className:"mt-1 border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{x(!1),ie("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:de,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),N&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{b(!1),Y("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),r.jsx(Ne,{id:"edit-name",defaultValue:A.name,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-email",className:"text-sm text-gray-400 font-light",children:"Email"}),r.jsx(Ne,{id:"edit-email",type:"email",defaultValue:A.email,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"edit-role",className:"text-sm text-gray-400 font-light",children:"Role"}),r.jsxs(hn,{value:W,onValueChange:Y,children:[r.jsx(fn,{id:"edit-role",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{b(!1),Y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),v&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ie,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-white/15 rounded-none w-full max-w-lg p-6 shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"flex flex-col gap-2",children:r.jsx("h3",{className:"text-lg text-white font-light uppercase font-mono",children:"User Details"})}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"text-gray-400 -mt-2 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex flex-col items-center justify-center mt-2",children:[r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"}),r.jsx("div",{className:"relative z-20 h-4 w-[calc(100%+3rem)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#ffffff,#ffffff_1px,transparent_1px,transparent_6px)] opacity-[7%]"}),r.jsx("hr",{className:"w-[calc(100%+3rem)] border-white/10 h-px"})]}),r.jsxs("div",{className:"space-y-6 mt-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-14 h-14 rounded-none border border-dashed border-white/15"}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium leading-tight flex items-center gap-2",children:[r.jsx("span",{children:A.name}),r.jsx(on,{id:A.id,variant:"subscript",nonSliced:!0})]}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsx("div",{className:"space-y-2 text-sm",children:[{label:"Email Verified",value:A.emailVerified?"Yes":"No"},{label:"Role",value:A.role||"—"},{label:"Banned",value:A.banned?"Yes":"No"},{label:"Ban Reason",value:A.banReason||"—"},{label:"Ban Expires",value:nb(A.banExpires)},{label:"Created",value:nb(A.createdAt)},{label:"Updated",value:nb(A.updatedAt)}].map(ee=>r.jsxs("div",{className:"flex items-center justify-between border border-dashed border-white/15 bg-black/90 px-3 py-2 rounded-none",children:[r.jsx("div",{className:"text-[11px] font-mono font-light uppercase tracking-wide text-gray-400",children:ee.label}),r.jsx("div",{className:"text-sm text-white text-right break-words max-w-[60%]",children:ee.value})]},ee.label))})]}),r.jsxs("div",{className:"flex justify-end gap-3 mt-8",children:[r.jsx($,{onClick:()=>S(!1),className:"border border-white/20 bg-white/5 text-white hover:bg-white/10 rounded-none",children:"Close"}),r.jsx($,{onClick:()=>{S(!1),e(`/users/${A.id}`)},className:"border border-white/20 bg-white text-black hover:bg-white/90 rounded-none",children:"View Details"})]})]})}),_&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-red-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),r.jsxs("p",{className:"text-gray-400 mb-4",children:["Ban ",r.jsx("strong",{children:A.name})," from accessing the system."]}),r.jsxs("div",{className:"space-y-4 mb-6",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banReason",className:"text-white",children:"Ban Reason"}),r.jsx(Ne,{id:"banReason",value:T,onChange:ee=>D(ee.target.value),placeholder:"Enter reason for ban (optional)",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banExpires",className:"text-white",children:"Ban Duration (seconds)"}),r.jsx(Ne,{id:"banExpires",type:"number",value:q||"",onChange:ee=>C(ee.target.value?Number(ee.target.value):void 0),placeholder:"Leave empty for permanent ban",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Examples: 3600 (1 hour), 86400 (1 day), 604800 (1 week)"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{M(!1),D(""),C(void 0),P(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ae,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),U&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-dashed border-green-400/50 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Unban User"}),r.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to unban ",r.jsx("strong",{children:A.name}),"? This will restore their access to the system."]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{L(!1),P(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:We,className:"bg-green-600 text-white hover:bg-green-700 rounded-none",children:"Unban User"})]})]})}),F&&A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Update Password"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{G(!1),P(null),document.getElementById("update-password").value=""},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(en,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("img",{src:A.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${A.id}`,alt:A.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:A.name}),r.jsx("div",{className:"text-sm text-gray-400",children:A.email})]})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"update-password",className:"text-sm text-gray-400 font-light",children:"New Password"}),r.jsx(Ne,{id:"update-password",type:"password",placeholder:"Enter new password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{G(!1),P(null),document.getElementById("update-password").value=""},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:at,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Password"})]})]})})]})}const gd=[{id:"signups",label:"Signups",analyticsKey:"newUsers",barClass:"bg-white/25 border border-white/10",dotClass:"bg-white/25"},{id:"logins",label:"Logins",analyticsKey:"activeUsers",barClass:"bg-white/20 border border-white/10",dotClass:"bg-white/20"},{id:"organizations",label:"Organizations",analyticsKey:"organizations",barClass:"bg-white/15 border border-white/10",dotClass:"bg-white/15"},{id:"teams",label:"Teams",analyticsKey:"teams",barClass:"bg-white/10 border border-white/10",dotClass:"bg-white/10"},{id:"sessions",label:"Sessions",analyticsKey:"sessions",barClass:"bg-white/5 border border-white/10",dotClass:"bg-white/5"}];function Pae(){const[e]=p.useState("overview"),[t,n]=p.useState(!1),[a,s]=p.useState(0),[i,o]=p.useState(0),[l,c]=p.useState("1D"),[u,h]=p.useState("1D"),[d,f]=p.useState(null),[m,y]=p.useState(!1),[x,N]=p.useState("Daily"),[b,v]=p.useState("Daily"),[g,w]=p.useState("Daily"),[S,E]=p.useState("Daily"),[j,_]=p.useState(!1),[M,U]=p.useState(!1),[L,F]=p.useState(!1),[G,A]=p.useState(!1),[P,R]=p.useState(null),[k,T]=p.useState(null),[D,q]=p.useState(null),[C,I]=p.useState(null),[z,W]=p.useState(null),[Y,ae]=p.useState(void 0),[ne,X]=p.useState(void 0),[ie,ve]=p.useState(void 0),[se,ge]=p.useState(void 0),[be,Ue]=p.useState(void 0),[Be,$e]=p.useState(void 0),[Ye,bt]=p.useState(void 0),[Ke,de]=p.useState(void 0),[Fe,Ie]=p.useState([]),[Ae,We]=p.useState([]),[at,ft]=p.useState(0),[Yt,Wt]=p.useState([]),[oe,_e]=p.useState([]),[Ze,K]=p.useState(0),[pe,ye]=p.useState(0),[Te,ze]=p.useState(0),[tt,ee]=p.useState(0),[ue,Oe]=p.useState(0),[xe,Pe]=p.useState(!1),[Q,Z]=p.useState(!1),[je,Qe]=p.useState({signups:[],logins:[],organizations:[],teams:[],sessions:[]}),[st,ct]=p.useState([]),[it,cn]=p.useState(!1),[Tn,yn]=p.useState(0),[nn,ns]=p.useState(0),[Dn,Hn]=p.useState(0),[rr,as]=p.useState(0),[el,Ys]=p.useState(0),[Pn,It]=p.useState([]),[rs,ss]=p.useState(0),[is,Sr]=p.useState(0),[os,Er]=p.useState(0),{counts:Ws,loading:fa}=pm(),Qn=yr(),Pa=["Daily","Weekly","Monthly","Yearly","Custom"],Xs={Daily:"1D",Weekly:"1W",Monthly:"1M",Yearly:"1Y",Custom:"Custom"},pa=p.useMemo(()=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),[]),Jn=we=>we==null?"...":pa.format(Number(we)),sr=we=>we==null?"...":Number(we).toLocaleString(),Ks=p.useMemo(()=>gd.reduce((we,Se)=>(we[Se.id]=(je[Se.id]||[]).reduce((Re,fe)=>Re+fe,0),we),{}),[je]),Zs=p.useMemo(()=>Object.values(Ks).reduce((we,Se)=>we+Se,0),[Ks]),tl=(we,Se)=>{const Re=we.currentTarget.getBoundingClientRect();I(Se),W({x:Re.left+Re.width/2,y:Re.top})},no=(()=>{const we=[];return P!=null&&P.isOutdated?we.push({id:"version-check",title:`Update Better-Auth to v${P.latest}`,severity:"high",date:new Date().toISOString().split("T")[0],description:"Your current version is outdated. Update to the latest version to get the latest security fixes, features, and improvements. Run: `pnpm install better-auth@latest`",affectedComponents:["All Components"],status:"pending",cve:""}):P&&we.push({id:"version-check",title:"Better-Auth is Up to date",severity:"low",date:new Date().toISOString().split("T")[0],description:"You are running the latest version of better-auth. Great job keeping your dependencies up to date!",affectedComponents:["All Components"],status:"applied",cve:""}),we.push(),we.push({id:"3",title:"Rate Limiting Configuration",severity:"medium",date:new Date().toISOString().split("T")[0],description:"Configure rate limiting for authentication endpoints to prevent brute force attacks. Better-auth provides built-in rate limiting middleware.",affectedComponents:["Auth Endpoints"],status:"pending"}),we.filter(Se=>Se.status!=="applied")})(),xt=p.useCallback(async(we,Se,Re,fe)=>{try{const Ce=new URLSearchParams({type:we,period:Se});return Re&&Ce.append("from",Re.toISOString()),fe&&Ce.append("to",fe.toISOString()),await(await fetch(`/api/analytics?${Ce.toString()}`)).json()}catch{return null}},[]);p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/users/all")).json();Re!=null&&Re.success&&Re.users&&It(Re.users)}catch{It([])}})()},[]),p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/stats")).json();Re&&s(Re.activeUsers||0)}catch{s(0)}})()},[]),p.useEffect(()=>{(async()=>{const Se=await xt("users",l,Y,ne);Se&&(Ie(Se.data||[]),We(Se.labels||[]),ft(Se.percentageChange||0))})()},[l,Y,ne,xt]),p.useEffect(()=>{if(Pn.length===0){ss(0),Sr(0);return}const we=new Date;let Se,Re=we,fe,Ce;if(b==="Custom"){if(!ie||!se){ss(0),Sr(0);return}Se=new Date(ie),Re=new Date(se),Re.setHours(23,59,59,999);const Ut=Re.getTime()-Se.getTime();Ce=new Date(Se.getTime()-1),fe=new Date(Ce.getTime()-Ut)}else switch(b){case"Daily":Se=new Date(we),Se.setHours(0,0,0,0),Ce=new Date(Se.getTime()-1),fe=new Date(Ce.getTime()-24*60*60*1e3);break;case"Weekly":Se=new Date(we),Se.setDate(we.getDate()-we.getDay()),Se.setHours(0,0,0,0),Ce=new Date(Se.getTime()-1),fe=new Date(Ce.getTime()-7*24*60*60*1e3);break;case"Monthly":Se=new Date(we.getFullYear(),we.getMonth(),1),Se.setHours(0,0,0,0),Ce=new Date(Se.getTime()-1),fe=new Date(we.getFullYear(),we.getMonth()-1,1),fe.setHours(0,0,0,0);break;case"Yearly":Se=new Date(we.getFullYear(),0,1),Se.setHours(0,0,0,0),Ce=new Date(Se.getTime()-1),fe=new Date(we.getFullYear()-1,0,1),fe.setHours(0,0,0,0);break;default:ss(0),Sr(0);return}const De=Pn.filter(Ut=>{if(!Ut.createdAt)return!1;const ea=new Date(Ut.createdAt);return ea>=Se&&ea<=Re}),ke=Pn.filter(Ut=>{if(!Ut.createdAt)return!1;const ea=new Date(Ut.createdAt);return ea>=fe&&ea<=Ce}),Ee=De.length,qe=ke.length;let Lt=0;qe>0?Lt=(Ee-qe)/qe*100:Ee>0&&(Lt=100),ss(Ee),Sr(Lt)},[Pn,b,ie,se]),p.useEffect(()=>{(async()=>{if(!(u==="Custom"&&(!ie||!se))){cn(!0);try{const[Se,Re,fe,Ce,De]=await Promise.all([xt("newUsers",u,ie,se),xt("activeUsers",u,ie,se),xt("organizations",u,ie,se),xt("teams",u,ie,se),xt("sessions",u,ie,se)]);Se&&(Wt(Se.data||[]),_e(Se.labels||[])),Qe({signups:(Se==null?void 0:Se.data)||[],logins:(Re==null?void 0:Re.data)||[],organizations:(fe==null?void 0:fe.data)||[],teams:(Ce==null?void 0:Ce.data)||[],sessions:(De==null?void 0:De.data)||[]}),ct((Se==null?void 0:Se.labels)||(Re==null?void 0:Re.labels)||(fe==null?void 0:fe.labels)||(Ce==null?void 0:Ce.labels)||(De==null?void 0:De.labels)||[])}finally{cn(!1)}}})()},[u,ie,se,xt]),p.useEffect(()=>{(async()=>{const Se=await xt("activeUsers","1D");Se&&K(Se.percentageChange||0)})()},[xt]),p.useEffect(()=>{(async()=>{const Se=Xs[g]||"1D",Re=Se==="Custom";if(!(Re&&(!be||!Be))){Pe(!0);try{const fe=await xt("organizations",Se,Re?be:void 0,Re?Be:void 0);fe&&(ee(fe.total||0),ye(fe.percentageChange||0))}catch{ee(0),ye(0)}finally{Pe(!1)}}})()},[g,be,Be,xt]),p.useEffect(()=>{(async()=>{const Se=Xs[S]||"1D",Re=Se==="Custom";if(!(Re&&(!Ye||!Ke))){Z(!0);try{const fe=await xt("teams",Se,Re?Ye:void 0,Re?Ke:void 0);fe&&(Oe(fe.total||0),ze(fe.percentageChange||0))}catch{Oe(0),ze(0)}finally{Z(!1)}}})()},[S,Ye,Ke,xt]),p.useEffect(()=>{(async()=>{const Se=await xt("users","1D");Se&&yn(Se.percentageChange||0);const Re=await xt("organizations","1D");Re&&ns(Re.percentageChange||0);const fe=await xt("activeUsers","1D");fe&&Hn(fe.percentageChange||0);const[Ce,De,ke,Ee,qe]=await Promise.all([xt("newUsers","1D"),xt("activeUsers","1D"),xt("organizations","1D"),xt("teams","1D"),xt("sessions","1D")]);Ce?(o(Ce.total||0),Er(Ce.percentageChange||0)):(o(0),Er(0));const Ut=[(Ce==null?void 0:Ce.total)||0,(De==null?void 0:De.total)||0,(ke==null?void 0:ke.total)||0,(Ee==null?void 0:Ee.total)||0,(qe==null?void 0:qe.total)||0].reduce((Cr,kr)=>Cr+kr,0);Ys(Ut);const ma=[(Ce==null?void 0:Ce.previousTotal)||0,(De==null?void 0:De.previousTotal)||0,(ke==null?void 0:ke.previousTotal)||0,(Ee==null?void 0:Ee.previousTotal)||0,(qe==null?void 0:qe.previousTotal)||0].reduce((Cr,kr)=>Cr+kr,0);if(ma>0){const Cr=(Ut-ma)/ma*100;as(Cr)}else Ut>0?as(100):as(0)})()},[xt]),p.useEffect(()=>{(async()=>{try{const Re=await(await fetch("/api/version-check")).json();Re&&R({current:Re.current||"1.0.0",latest:Re.latest||"1.0.0",isOutdated:Re.isOutdated||!1})}catch{try{const Ce=(await(await fetch("/api/package-info")).json()).betterAuthVersion||"1.0.0",De="1.5.0";R({current:Ce,latest:De,isOutdated:Ce!==De})}catch{R({current:"1.0.0",latest:"1.5.0",isOutdated:!0})}}})()},[]);const jr=we=>{switch(we){case"critical":return"bg-white/10 text-white border-white/20";case"high":return"bg-white/10 text-white border-white/20";case"medium":return"bg-white/10 text-gray-300 border-white/20";case"low":return"bg-white/10 text-gray-400 border-white/20";default:return"bg-white/10 text-gray-400 border-white/20"}},Tr=we=>{switch(we){case"applied":return"bg-white/10 text-white border-white/20";case"scheduled":return"bg-white/10 text-gray-300 border-white/20";case"pending":return"bg-white/10 text-gray-400 border-white/20";default:return"bg-white/10 text-gray-400 border-white/20"}},Js=we=>{f(we),y(!0)},ls=()=>{y(!1),setTimeout(()=>f(null),300)},ir=()=>{if(!Pn||Pn.length===0)return 0;const we=Pn.reduce((fe,Ce)=>{const De=Ce!=null&&Ce.createdAt?new Date(Ce.createdAt):null;return!De||Number.isNaN(De.getTime())?fe:fe?De<fe?De:fe:De},null);if(!we)return 0;const Se=new Date,Re=(Se.getFullYear()-we.getFullYear())*12+(Se.getMonth()-we.getMonth())+1;return Math.max(Re,0)},cs=()=>{const we=ir();if(we<=0)return{labels:Array.from({length:12},(De,ke)=>`Week ${ke+1}`),expectedLength:12};if(we<3)return{labels:Array.from({length:12},(De,ke)=>`Week ${ke+1}`),expectedLength:12};if(we<=12){const ke=Pn.reduce((qe,Lt)=>{const Ut=Lt!=null&&Lt.createdAt?new Date(Lt.createdAt):null;return!Ut||Number.isNaN(Ut.getTime())?qe:qe?Ut<qe?Ut:qe:Ut},null)||new Date,Ee=Array.from({length:12},(qe,Lt)=>new Date(ke.getFullYear(),ke.getMonth()+Lt,1).toLocaleDateString("en-US",{month:"short"}));return{labels:Ee,expectedLength:Ee.length}}const Se=Math.max(1,Math.ceil(we/12)),fe=(Pn.reduce((De,ke)=>{const Ee=ke!=null&&ke.createdAt?new Date(ke.createdAt):null;return!Ee||Number.isNaN(Ee.getTime())?De:De?Ee<De?Ee:De:Ee},null)||new Date).getFullYear(),Ce=Array.from({length:Se},(De,ke)=>`${fe+ke}`);return{labels:Ce,expectedLength:Ce.length}},Fa=(we,Se="users")=>{const Re=Se==="users"?Ae:Se==="newUsers"?oe:st,fe={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7};if(we==="ALL"){if(Se==="users"||Se==="activity"){const{labels:ke}=cs();return ke}return[]}const Ce=fe[we]||7;if(Re&&Re.length>0&&Re.length===Ce)return we==="1D"?Re.filter((ke,Ee)=>Ee%4===0).map(ke=>{const Ee=parseInt(ke.replace("h",""),10);return Ee===0?"12am":Ee<12?`${Ee}am`:Ee===12?"12pm":`${Ee-12}pm`}):we==="1W"?Re.map(ke=>ke.length>3?ke.substring(0,3):ke):we==="1M"?Re.map(ke=>{const Ee=ke.split(" ");return Ee.length>=2?Ee[1]:ke}):we==="1Y"||we==="3M"||we==="6M"?Re.map(ke=>ke.length>3?ke.substring(0,3):ke):Re.map(ke=>ke.length>3?ke.substring(0,3):ke);const De=new Date;switch(we){case"1D":return["12am","4am","8am","12pm","4pm","8pm"];case"1W":return Array.from({length:7},(ke,Ee)=>new Date(De.getTime()-(6-Ee)*24*60*60*1e3).toLocaleDateString("en-US",{weekday:"short"}));case"1M":return Array.from({length:30},(ke,Ee)=>new Date(De.getTime()-(29-Ee)*24*60*60*1e3).getDate().toString());case"3M":return Array.from({length:3},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(2-Ee),1).toLocaleDateString("en-US",{month:"short"}));case"6M":return Array.from({length:6},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(5-Ee),1).toLocaleDateString("en-US",{month:"short"}));case"1Y":return Array.from({length:12},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(11-Ee),1).toLocaleDateString("en-US",{month:"short"}));case"ALL":return Array.from({length:7},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(6-Ee),1).toLocaleDateString("en-US",{month:"short"}));default:return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]}},ao=(we,Se="users")=>{const Re=Se==="users"?Ae:oe;let Ce={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7}[we]||7;if(we==="ALL"&&Se==="users"){const{labels:ke,expectedLength:Ee}=cs();return Ce=Ee||Ce,Re&&Re.length===ke.length,ke}if(we==="ALL"&&Se!=="users")return[];if(Re&&Re.length>0&&Re.length===Ce)return we==="1D"?Re.map(ke=>{const Ee=parseInt(ke.replace("h",""),10);return Ee===0?"12am":Ee<12?`${Ee}am`:Ee===12?"12pm":`${Ee-12}pm`}):we==="1Y"||we==="3M"||we==="6M"?Re.map(ke=>{const Ee=["January","February","March","April","May","June","July","August","September","October","November","December"],Lt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].indexOf(ke);return Lt!==-1?Ee[Lt]:ke}):Re;const De=new Date;switch(we){case"1D":return Array.from({length:24},(ke,Ee)=>{const qe=new Date;return qe.setHours(Ee,0,0,0),qe.toLocaleTimeString("en-US",{hour:"numeric",hour12:!0})});case"1W":return Array.from({length:7},(ke,Ee)=>new Date(De.getTime()-(6-Ee)*24*60*60*1e3).toLocaleDateString("en-US",{weekday:"long"}));case"1M":return Array.from({length:30},(ke,Ee)=>{const qe=new Date(De.getTime()-(29-Ee)*24*60*60*1e3),Lt=qe.toLocaleDateString("en-US",{month:"short"}),Ut=qe.getDate();return`${Lt} ${Ut}`});case"3M":return Array.from({length:3},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(2-Ee),1).toLocaleDateString("en-US",{month:"long"}));case"6M":return Array.from({length:6},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(5-Ee),1).toLocaleDateString("en-US",{month:"long"}));case"1Y":return Array.from({length:12},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(11-Ee),1).toLocaleDateString("en-US",{month:"long"}));case"ALL":return Array.from({length:7},(ke,Ee)=>new Date(De.getFullYear(),De.getMonth()-(6-Ee),1).toLocaleDateString("en-US",{month:"long"}));default:return["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]}},ds=(we,Se="users")=>{const Re=Se==="users"?Fe:Yt;let Ce={"1D":24,"1W":7,"1M":30,"3M":3,"6M":6,"1Y":12,ALL:7}[we]||7;if(we==="ALL"&&Se==="users"){const{expectedLength:qe}=cs();Ce=qe||Ce}if(we==="ALL"&&Se==="activity"){const{expectedLength:qe}=cs();Ce=qe||Ce}if(!Re||Re.length===0)return Array(Ce).fill(0);const De=[...Re];for(;De.length<Ce;)De.push(0);const ke=De.slice(0,Ce),Ee=Math.max(...ke,1);return ke.map(qe=>qe/Ee*100)},nl=()=>{const we=u==="ALL"?Fa("ALL","activity"):st.length>0?st:Fa(u,"activity"),Se=we.map((fe,Ce)=>gd.reduce((De,ke)=>{var Ee;return De+(((Ee=je[ke.id])==null?void 0:Ee[Ce])??0)},0)),Re=Math.max(...Se,1);return r.jsxs("div",{className:"space-y-6 min-h-screen h-full mt-5 flex-1 overflow-y-hidden overflow-x-hidden px-0",children:[r.jsx("div",{className:"px-6 overflow-hidden",children:r.jsxs("div",{className:"flex items-center justify-between gap-8 py-4 px-6 bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none overflow-x-auto relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ot,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Users"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.users)}),r.jsxs("div",{className:`flex items-center gap-1 ${Tn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${Tn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(Tn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ca,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Organizations"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.organizations)}),r.jsxs("div",{className:`flex items-center gap-1 ${nn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${nn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(nn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(jC,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Sessions"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(Ws.sessions)}),r.jsxs("div",{className:`flex items-center gap-1 ${Dn>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${Dn<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(Dn).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(SC,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"Activity Hits"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(el??0)}),r.jsxs("div",{className:`flex items-center gap-1 ${rr>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${rr<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(rr).toFixed(1),"%"]})]})]})]}),r.jsx("div",{className:"h-8 w-[1px] bg-white/10"}),r.jsxs("div",{className:"flex items-center gap-3 min-w-fit",children:[r.jsx("div",{className:"w-10 h-10 rounded-none bg-white/5 border border-dashed border-white/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ot,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400 text-sm uppercase tracking-wide",children:"New Users"}),r.jsx("span",{className:"text-white text-lg font-medium",children:fa?"...":Jn(i??0)}),r.jsxs("div",{className:`flex items-center gap-1 ${os>=0?"text-green-500":"text-red-500"}`,children:[r.jsx("svg",{className:`w-3 h-3 ${os<0?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:"text-sm font-medium",children:[Math.abs(os).toFixed(1),"%"]})]})]})]})]})}),r.jsxs("div",{className:"px-6 pb-10 space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-sm text-white uppercase font-light",children:"TOTAL USER"}),r.jsx("div",{className:"flex items-center space-x-1 overflow-x-auto",children:["1D","1W","6M","1Y","ALL"].map(fe=>r.jsx("button",{onClick:()=>c(fe),className:`px-2 py-1 text-xs font-light transition-colors whitespace-nowrap ${l===fe?"bg-white/20 text-white border border-white/30":"text-gray-500 hover:text-white"}`,children:fe},fe))})]}),r.jsx("div",{className:"flex justify-between items-end mb-4",children:(()=>{const fe=ds(l,"users"),De=(Fe.length>0?Fe.slice(0,fe.length):Array(fe.length).fill(0)).reduce((ke,Ee)=>ke+Ee,0);return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-4xl text-white font-light",children:fa?"...":Jn(De)}),r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[r.jsx("svg",{className:`w-3 h-3 ${at>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${at>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(at).toFixed(1),"%"]})]})]})})()}),r.jsxs("div",{className:"space-y-2 relative",children:[(()=>{const fe=ds(l,"users"),Ce=Fe.length>0?Fe.slice(0,fe.length):Array(fe.length).fill(0),De=Math.max(...Ce,1),ke=Array.from({length:6},(Ee,qe)=>De/5*(5-qe));return r.jsxs("div",{className:"flex gap-2",children:[r.jsx("div",{className:"flex flex-col justify-between h-48 text-xs text-gray-500 font-mono pt-0.5 pb-0.5",children:ke.map((Ee,qe)=>r.jsx("span",{className:"leading-none",children:Jn(Math.round(Ee))},qe))}),r.jsxs("div",{className:"flex-1 h-48 relative",children:[r.jsx("div",{className:"absolute inset-0 flex flex-col justify-between z-0",children:[0,1,2,3,4,5].map(Ee=>r.jsx("div",{className:"w-full h-px bg-white/10",style:{opacity:.3}},Ee))}),r.jsx("svg",{className:"w-full h-full absolute inset-0",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:r.jsx("defs",{children:r.jsxs("linearGradient",{id:"usersBarGradient",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[r.jsx("stop",{offset:"0%",style:{stopColor:"rgba(255, 255, 255, 0.3)",stopOpacity:1}}),r.jsx("stop",{offset:"100%",style:{stopColor:"rgba(255, 255, 255, 0.05)",stopOpacity:1}})]})})}),r.jsx("div",{className:"h-48 flex items-end justify-between space-x-1 relative z-10",children:fe.map((Ee,qe)=>{const Lt=k===qe;return r.jsx("div",{className:"flex-1 transition-all duration-200 ease-out relative cursor-pointer group",style:{height:`${Ee}%`,background:"url(#usersBarGradient)"},onMouseEnter:Ut=>{const ea=Ut.currentTarget.getBoundingClientRect(),ma=ea.left+ea.width/2,Cr=ea.top,kr=150,Hc=60,ch=Math.max(kr/2,Math.min(window.innerWidth-kr/2,ma)),al=Math.max(Hc+10,Math.min(window.innerHeight-10,Cr));T(qe),q({x:ch,y:al})},onMouseLeave:()=>{T(null),q(null)},children:r.jsx("div",{className:"w-full h-full",style:{background:"linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.285))",opacity:Lt?1:.8}})},qe)})}),k!==null&&D&&r.jsx("div",{className:"fixed z-50 pointer-events-none transition-all duration-200 ease-out animate-in fade-in",style:{left:`${D.x}px`,top:`${D.y}px`,transform:"translate(-50%, -100%)",maxWidth:"calc(100vw - 20px)"},children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-sm px-3 py-2 shadow-lg whitespace-nowrap",children:[r.jsx("div",{className:"text-xs text-gray-400 mb-1 font-mono uppercase",children:ao(l,"users")[k]}),r.jsxs("div",{className:"text-sm text-white font-sans font-medium",children:[Fe[k]!==void 0?Fe[k].toLocaleString():"0"," ",r.jsx("span",{className:"font-mono text-xs text-gray-400",children:"users"})]})]})})]})]})})(),r.jsx("div",{className:`flex justify-between ${l==="1M"?"text-[10px]":"text-xs"} text-gray-500 font-mono`,children:Fa(l,"users").map((fe,Ce)=>r.jsx("span",{className:"flex-1 text-center truncate",children:fe},Ce))})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm text-white uppercase font-light",children:"Activity Hits"}),r.jsx("p",{className:"text-4xl text-white font-light mt-1",children:it?"...":sr(Zs)}),r.jsx("p",{className:"text-xs text-gray-400",children:"Tracked events in selected period"})]}),r.jsx("div",{className:"flex items-center space-x-1 overflow-x-auto",children:["1D","1W","3M","6M","1Y","ALL"].map(fe=>r.jsx("button",{onClick:()=>h(fe),className:`px-2 py-1 text-xs font-light transition-colors whitespace-nowrap ${u===fe?"bg-white/20 text-white border border-white/30":"text-gray-500 hover:text-white"}`,children:fe},fe))})]}),r.jsxs("div",{className:"space-y-2 relative",children:[r.jsx("div",{className:"h-40 flex items-end gap-1",children:we.map((fe,Ce)=>{const De=Se[Ce]||0;return r.jsx("div",{className:"flex-1 flex flex-col justify-end gap-[1px] h-full cursor-pointer",onMouseEnter:ke=>tl(ke,Ce),onMouseLeave:()=>{I(null),W(null)},children:gd.map(ke=>{var Lt;const Ee=((Lt=je[ke.id])==null?void 0:Lt[Ce])??0,qe=De===0||Re===0?0:Math.max(Ee/Re*100,Ee>0?4:0);return r.jsx("div",{className:`w-full ${ke.barClass}`,style:{height:`${qe}%`}},`${ke.id}-${Ce}`)})},`${fe}-${Ce}`)})}),it&&r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center text-xs uppercase text-gray-400 pointer-events-none",children:"Loading activity..."}),C!==null&&z&&r.jsx("div",{className:"fixed z-50 pointer-events-none transition-all duration-200 ease-out animate-in fade-in",style:{left:`${z.x}px`,top:`${z.y}px`,transform:"translate(-50%, -100%)",maxWidth:"calc(100vw - 20px)"},children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-sm px-3 py-2 shadow-lg min-w-[180px]",children:[r.jsx("div",{className:"text-xs text-gray-400 mb-2 font-mono uppercase",children:we[C]||`Bucket ${C+1}`}),r.jsx("div",{className:"space-y-1",children:gd.map(fe=>{var Ce;return r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-300",children:[r.jsx("span",{className:`w-2 h-2 rounded-sm ${fe.dotClass}`}),fe.label]}),r.jsx("span",{className:"text-white font-medium",children:((Ce=je[fe.id])==null?void 0:Ce[C])??0})]},fe.id)})})]})}),r.jsx("div",{className:`flex justify-between ${u==="1M"?"text-[10px]":"text-xs"} text-gray-500 font-mono`,children:we.map((fe,Ce)=>r.jsx("span",{className:"flex-1 text-center truncate",children:fe},Ce))}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3 mt-4 pt-4 border-t border-white/10",children:gd.map(fe=>r.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-2 h-2 rounded-sm ${fe.dotClass}`}),fe.label]}),r.jsx("span",{className:"text-white font-medium",children:it?"...":sr(Ks[fe.id]||0)})]},fe.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-4 overflow-x-hidden",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>_(!j),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:x})]}),j&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{N(fe),_(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),x==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Y?Yn(Y,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Y,onSelect:ae,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),ne?Yn(ne,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:ne,onSelect:X,initialFocus:!0,disabled:fe=>Y?fe<Y:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Active Users"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Users with active session in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:sr(a)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 border-white/5 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${Ze>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${Ze>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(Ze).toFixed(1),"%"]})]})})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>U(!M),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:b})]}),M&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{v(fe),U(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),b==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),ie?Yn(ie,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:ie,onSelect:ve,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),se?Yn(se,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:se,onSelect:ge,initialFocus:!0,disabled:fe=>ie?fe<ie:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"New Users"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Newly registered Users in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:sr(rs)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${is>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",style:is<0?{transform:"rotate(180deg)"}:{},children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${is>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(is).toFixed(1),"%"]})]})})]})]})]}),r.jsxs("div",{className:"space-y-4 overflow-x-hidden",children:[r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>F(!L),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:g})]}),L&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{w(fe),F(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),g==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),be?Yn(be,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:be,onSelect:Ue,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Be?Yn(Be,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Be,onSelect:$e,initialFocus:!0,disabled:fe=>be?fe<be:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Organizations"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Total organizations in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:xe?"...":sr(tt)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${pe>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${pe>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(pe).toFixed(1),"%"]})]})})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pb-2 relative",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsxs("div",{className:"flex items-center justify-between mb-2 relative -mt-2 pb-1",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>A(!G),className:"text-xs h-full font-mono uppercase text-gray-400 flex items-center space-x-1 hover:text-white transition-colors",children:[r.jsx(qh,{className:"w-3 h-3"}),r.jsx("span",{children:S})]}),G&&r.jsx("div",{className:"absolute top-6 left-0 w-[150px] z-10 bg-black border border-white/10 rounded-none shadow-lg",children:Pa.map(fe=>r.jsx("button",{onClick:()=>{E(fe),A(!1)},className:"block border-b border-dashed border-white/5 w-full text-left px-4 py-2 text-xs text-white hover:bg-white/10 transition-colors whitespace-nowrap",children:fe},fe))})]}),S==="Custom"&&r.jsxs("div",{className:"h-0 flex items-center gap-2",children:[r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Ye?Yn(Ye,"MMM dd yyyy"):"From"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Ye,onSelect:bt,initialFocus:!0,className:"rounded-none"})})]}),r.jsxs(Ga,{children:[r.jsx(Va,{asChild:!0,children:r.jsxs($,{variant:"outline",className:"h-6 px-2 text-xs font-mono uppercase text-gray-400 hover:text-white bg-transparent border-white/10 hover:bg-white/5",children:[r.jsx(cr,{className:"mr-1 h-3 w-3"}),Ke?Yn(Ke,"MMM dd yyyy"):"To"]})}),r.jsx(ja,{className:"w-auto p-0 bg-black border-white/10",children:r.jsx(qa,{mode:"single",selected:Ke,onSelect:de,initialFocus:!0,disabled:fe=>Ye?fe<Ye:!1,className:"rounded-none"})})]})]})]}),r.jsx("hr",{className:"mb-2 -mx-10 border-white/10"}),r.jsx("h4",{className:"text-md text-white/80 uppercase font-mono font-light mb-1",children:"Teams"}),r.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Total teams in the time frame"}),r.jsxs("div",{className:"flex pt-4 justify-between items-end",children:[r.jsx("p",{className:"text-3xl text-white font-light",children:Q?"...":sr(ue)}),r.jsx("div",{className:"mt-2 mb-1 flex items-center gap-2",children:r.jsxs("div",{className:"flex items-center -mr-5 gap-1 px-2 py-1 rounded-none",children:[r.jsx("svg",{className:`w-3 h-3 ${Te>=0?"text-green-500":"text-red-500 rotate-180"}`,viewBox:"0 0 12 12",fill:"currentColor",children:r.jsx("path",{d:"M6 0 L12 12 L0 12 Z"})}),r.jsxs("span",{className:`text-xs font-medium ${Te>=0?"text-green-500":"text-red-500"}`,children:[Math.abs(Te).toFixed(1),"%"]})]})})]})]})]}),r.jsxs("div",{className:"bg-gradient-to-b from-white/[4%] to-white/[2.5%] border border-white/10 rounded-none p-6 pt-4 overflow-hidden relative flex flex-col",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 left-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[12px] h-[0.5px] bg-white/20"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[0.5px] h-[12px] bg-white/20"}),r.jsx("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Mn,{className:"w-4 h-4 text-white/60"}),r.jsx("h4",{className:"text-xs text-gray-400 uppercase font-mono font-light",children:"Security Insights"})]})}),r.jsx("hr",{className:"-mx-10 -mt-1 border-white/10"}),r.jsxs("div",{className:"space-y-3 overflow-y-auto custom-scrollbar max-h-[400px]",children:[no.length===0&&r.jsx("div",{className:"text-sm flex items-center justify-center text-gray-400",children:r.jsxs("div",{className:"flex mt-5 items-center justify-center",children:[r.jsx(Mn,{className:"w-4 h-4 text-gray-400 mr-2"}),r.jsx("p",{className:"text-center",children:"No security insights found"})]})}),no.map((fe,Ce)=>r.jsx("div",{onClick:()=>Js(fe),className:"group py-2 border-b border-white/5 cursor-pointer transition-all duration-200 hover:border-white/20",style:{animation:`slideIn 0.3s ease-out ${Ce*.1}s both`},children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:r.jsx("span",{className:"text-sm text-white/90 font-light truncate group-hover:text-white transition-colors",children:fe.title})}),r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:`text-[9px] px-1.5 py-0.5 border rounded-sm uppercase font-mono ${jr(fe.severity)}`,children:fe.severity}),r.jsx("span",{className:`text-[9px] px-1.5 py-0.5 border rounded-sm capitalize font-mono ${Tr(fe.status)}`,children:fe.status})]})]}),r.jsx(vu,{className:"w-3.5 h-3.5 text-gray-500 group-hover:text-white transition-all flex-shrink-0 mt-0.5"})]})},fe.id))]})]})]})]})]})};return r.jsxs("div",{className:"h-screen bg-black text-white overflow-hidden flex flex-col",style:{overflowX:"hidden"},children:[r.jsx("div",{className:"flex-1 overflow-hidden",children:e==="overview"?nl():e==="users"?r.jsx(IU,{}):e==="organizations"?r.jsx(DU,{}):nl()}),t&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-3xl rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(jC,{className:"w-6 h-6 text-white"}),r.jsx("h3",{className:"text-lg text-white font-light",children:"Quick Actions"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("button",{onClick:()=>{n(!1),Qn("/users")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Ot,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View All Users"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Manage user accounts"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/organizations")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Ca,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View Organizations"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Manage organizations"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/sessions")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(SC,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"View Sessions"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Monitor active sessions"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/database")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(Rs,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Database Schema"}),r.jsx("p",{className:"text-sm text-gray-400",children:"View schema visualizer"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/settings")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(TU,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Settings"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Configure system"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]}),r.jsxs("button",{onClick:()=>{n(!1),Qn("/users")},className:"flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none hover:bg-black/50 transition-colors text-left group",children:[r.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:r.jsx(EU,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-light mb-1",children:"Search Users"}),r.jsx("p",{className:"text-sm text-gray-400",children:"Find specific users"})]}),r.jsx(bi,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]})]}),r.jsx("div",{className:"mt-6 pt-6 border-t border-dashed border-white/10",children:r.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-400",children:[r.jsx("span",{children:"Tip: Press Ctrl+K or Cmd+K for command palette"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(!1),className:"text-gray-400 hover:text-white rounded-none",children:"Close"})]})})]})}),m&&d&&r.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",style:{animation:"fadeIn 0.3s ease-out"},onClick:ls,children:r.jsxs("div",{className:"bg-black border border-white/20 rounded-none max-w-2xl w-full max-h-[80vh] overflow-y-auto",style:{animation:"slideUp 0.3s ease-out"},onClick:we=>we.stopPropagation(),children:[r.jsx("div",{className:"sticky top-0 bg-black border-b border-white/10 p-6 z-10",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx(Mn,{className:"w-6 h-6 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light",children:d.title})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsxs("span",{className:`text-xs px-2 py-1 border rounded-none uppercase font-medium ${jr(d.severity)}`,children:[d.severity," Severity"]}),r.jsx("span",{className:`text-xs px-2 py-1 border rounded-none capitalize ${Tr(d.status)}`,children:d.status}),d.cve&&r.jsx("span",{className:"text-xs text-gray-400 font-mono bg-white/5 px-2 py-1 border border-white/10 rounded-none",children:d.cve})]})]}),r.jsx("button",{onClick:ls,className:"p-2 hover:bg-white/10 transition-colors rounded-none",children:r.jsx(dt,{className:"w-5 h-5 text-gray-400 hover:text-white"})})]})}),r.jsxs("div",{className:"p-6 space-y-6",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-2",children:"Release Date"}),r.jsx("p",{className:"text-white",children:new Date(d.date).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-2",children:"Description"}),d.description.includes("npm install")?r.jsxs("div",{children:[r.jsx("p",{className:"text-white leading-relaxed mb-3",children:d.description.split("Run:")[0]}),r.jsx("div",{className:"relative group",children:r.jsx("div",{className:"bg-black border border-white/20 rounded-none p-3 font-mono text-sm",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("code",{children:[r.jsx("span",{className:"text-green-400",children:"$"})," ",r.jsx("span",{className:"text-cyan-400",children:"npm"})," ",r.jsx("span",{className:"text-yellow-400",children:"install"})," ",r.jsx("span",{className:"text-white",children:"better-auth@latest"})]}),r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm install better-auth@latest"),V.success("Command copied to clipboard")},className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 hover:bg-white/10 rounded",title:"Copy command",children:r.jsx(xa,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})})})]}):r.jsx("p",{className:"text-white leading-relaxed",children:d.description})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm text-gray-400 uppercase tracking-wide mb-3",children:"Affected Components"}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:d.affectedComponents.map((we,Se)=>r.jsxs("div",{className:"flex items-center gap-2 p-3 bg-white/5 border border-white/10 rounded-none",style:{animation:`slideIn 0.3s ease-out ${Se*.1}s both`},children:[r.jsx("div",{className:"w-2 h-2 bg-white rounded-none flex-shrink-0"}),r.jsx("span",{className:"text-sm text-white",children:we})]},Se))})]}),r.jsx("div",{className:"p-4 bg-white/5 border border-white/10 rounded-none",children:r.jsxs("div",{className:"flex items-start gap-3",children:[d.status==="applied"&&r.jsxs(r.Fragment,{children:[r.jsx(wp,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Patch Applied"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This security patch has been successfully applied to your system."})]})]}),d.status==="scheduled"&&r.jsxs(r.Fragment,{children:[r.jsx(jU,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Scheduled"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This patch is scheduled for deployment in the next maintenance window."})]})]}),d.status==="pending"&&r.jsxs(r.Fragment,{children:[r.jsx(bae,{className:"w-5 h-5 text-white flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h5",{className:"text-sm text-white font-medium mb-1",children:"Action Required"}),r.jsx("p",{className:"text-xs text-gray-400",children:"This patch is pending review and requires manual approval before deployment."})]})]})]})}),r.jsx("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-white/10",children:r.jsx($,{variant:"ghost",onClick:ls,className:"text-gray-400 hover:text-white rounded-none",children:"Close"})})]})]})}),r.jsx("style",{children:`
|
|
520
520
|
@keyframes fadeIn {
|
|
521
521
|
from {
|
|
522
522
|
opacity: 0;
|
|
@@ -1128,7 +1128,7 @@ migrateFromClerk()
|
|
|
1128
1128
|
process.exit(1);
|
|
1129
1129
|
});`},{id:"supabase",name:"Supabase",description:"Supabase Migration guide",docs:"https://better-auth.com/docs/migrations/supabase",logo:"",highlights:["Exports Supabase auth.users and auth.identities.","Preserves password hashes and metadata fields.","Supports incremental re-runs with idempotent operations."],disabled:!0},{id:"auth0",name:"Auth0",description:"Auth0 Migration guide",docs:"https://better-auth.com/docs/migrations/auth0",logo:"",highlights:["Uses Auth0 Management API bulk exports.","Keeps password hashes compatible with Better Auth adapters.","Migrates applications and roles to Better Auth format."],disabled:!0},{id:"nextauth",name:"NextAuth.js",description:"NextAuth.js Migration guide",docs:"https://better-auth.com/docs/migrations/nextauth",logo:"",highlights:["Reads users/accounts from your existing NextAuth database.","Moves refresh tokens and OAuth profiles into Better Auth.","Supports Prisma, MySQL, and Postgres NextAuth adapters."],disabled:!0},{id:"custom",name:"Custom Script",description:"Custom Migration guide",docs:"https://better-auth.com/docs/migrations/custom",highlights:["Use Better Auth SDK helpers to insert users safely.","Supports dry-run mode to validate before committing.","Perfect for bespoke data sources or ETL pipelines."],custom:!0}];function Qfe(){var kE,AE,_E,RE,OE,DE,IE,ME,LE;const[e,t]=U$(),[n,a]=p.useState(null),[s,i]=p.useState([]),[o,l]=p.useState(!1),[c,u]=p.useState(!1),[h,d]=p.useState([]),[f,m]=p.useState(""),[y,x]=p.useState(!1),[N,b]=p.useState(""),[v,g]=p.useState(dw),[w,S]=p.useState(!1),[E,j]=p.useState(""),[_,M]=p.useState(""),[U,L]=p.useState("SHA-256"),[F,G]=p.useState("hex"),[A,P]=p.useState(null),[R,k]=p.useState(!1),[T,D]=p.useState(!1),[q,C]=p.useState(!1),[I,z]=p.useState(null),[W,Y]=p.useState(new Set),[ae,ne]=p.useState(!1),[X,ie]=p.useState([]),[ve,se]=p.useState(new Set),[ge,be]=p.useState("json"),[Ue,Be]=p.useState("1000"),[$e,Ye]=p.useState(!1),[bt,Ke]=p.useState(!1),[de,Fe]=p.useState(""),[Ie,Ae]=p.useState(""),[We,at]=p.useState(null),[ft,Yt]=p.useState(!1),[Wt,oe]=p.useState(null),[_e,Ze]=p.useState(!1),[K,pe]=p.useState("api_key"),[ye,Te]=p.useState(""),[ze,tt]=p.useState(""),[ee,ue]=p.useState("15"),[Oe,xe]=p.useState(""),[Pe,Q]=p.useState(`{
|
|
1130
1130
|
|
|
1131
|
-
}`),[Z,je]=p.useState(null),[Qe,st]=p.useState(!1),[ct,it]=p.useState(!1),[cn,Tn]=p.useState("1"),[yn,nn]=p.useState([]),[ns,Dn]=p.useState(""),[Hn,rr]=p.useState(null),[as,el]=p.useState(!1),[Ys,Pn]=p.useState(""),[It,rs]=p.useState(null),[ss,is]=p.useState(!1),[Sr,os]=p.useState(!1),[Er,Ws]=p.useState(!1),[fa,Qn]=p.useState(""),[Pa,Xs]=p.useState("localhost:3000"),[pa,Jn]=p.useState(null),[sr,Ks]=p.useState(!1),[Zs,tl]=p.useState(!1),[Qs,no]=p.useState(!1),[xt,jr]=p.useState(null),[Tr,Js]=p.useState(!1),[ls,ir]=p.useState(null),[cs,Fa]=p.useState(!1),[ao,ds]=p.useState(!1),[nl,we]=p.useState(!1),[Ee,Re]=p.useState(null),[fe,Ce]=p.useState(!1),[De,ke]=p.useState(!1),[Se,qe]=p.useState(null),[Lt,Ut]=p.useState(!1),[ea,ma]=p.useState(32),[Cr,kr]=p.useState("hex"),[Hc,ch]=p.useState(!1),[al,km]=p.useState(""),[vE,Am]=p.useState(""),[dn,wn]=p.useState([]),[W6,X6]=p.useState([]),[Ba,or]=p.useState([]),[Ar,us]=p.useState([]),[hs,ro]=p.useState([]),[_m,Rm]=p.useState(!1),[ta,ei]=p.useState({path:"/my-plugin/*",pathType:"prefix",window:15*60*1e3,max:100}),[Rt,qc]=p.useState(null),yE=p.useRef(null),[wE,NE]=p.useState(!1),[SE,Gc]=p.useState(null),[ti,EE]=p.useState("server"),[jE,Om]=p.useState("client");p.useEffect(()=>(q?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[q]),p.useEffect(()=>(Er?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Er]),p.useEffect(()=>(Tr?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Tr]),p.useEffect(()=>(as?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[as]),p.useEffect(()=>(Er?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Er]),p.useEffect(()=>(Tr?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Tr]),p.useEffect(()=>(ao?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[ao]),p.useEffect(()=>(ct?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[ct]),p.useEffect(()=>(Hc?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Hc]);const Xe=(O,B,J,re)=>{i(le=>[...le,{id:re??`log-${Date.now()}-${Math.random()}`,type:O,message:B,timestamp:new Date,status:J}])},fs=p.useRef(new Set),Vc=p.useRef(new Set),rl=p.useRef(new Map),Yc=p.useRef(null),Dm=()=>xd.find(O=>!O.disabled)??xd[0],Cn=xd.find(O=>O.id===N)??Dm();p.useEffect(()=>{b(y?O=>{var B;return O||((B=Dm())==null?void 0:B.id)||""}:"")},[y,Dm]);const K6=O=>{b(O),O!=="custom"&&g(dw)},Z6=()=>{j(""),M(""),P(null),L("SHA-256"),G("hex"),S(!0)},Q6=async()=>{if(!E.trim()){V.error("Enter a password to hash");return}try{k(!0);const O=_?`${_}:${E}`:E,J=await Sfe(U,F).digest(O);P(J),V.success("Password hashed successfully")}catch(O){V.error("Failed to hash password"),console.error(O)}finally{k(!1)}},za=async O=>{try{await navigator.clipboard.writeText(O),V.success("Copied to clipboard")}catch{V.error("Failed to copy to clipboard")}},so=()=>{Yc.current&&!Yc.current.closed&&Yc.current.close(),Yc.current=null},ni=(O,B,J,re,le)=>{let he=rl.current.get(O);he||(he=new Map,rl.current.set(O,he));const et=he.get(J);if(et){i(qn=>qn.map(pt=>pt.id===et?{...pt,type:B,message:re,status:le,timestamp:new Date}:pt));return}const wt=`session-${O}-${J}-${Date.now()}`;he.set(J,wt),Xe(B,re,le,wt)},sl=(O,B,J=0)=>{fs.current.has(O)||fs.current.add(O),fetch(`/api/tools/oauth/status?testSessionId=${encodeURIComponent(O)}`).then(le=>le.json()).then(le=>{if(le.hasResult){fs.current.delete(O),Wc(le.result);return}if(J+1>=15){fs.current.delete(O),ni(O,"error","timeout","⌛ Timed out waiting for account creation. Check Better Auth logs.","failed"),so(),a(null),V.error("OAuth test timed out waiting for account creation");return}setTimeout(()=>sl(O,B,J+1),2e3)}).catch(le=>{J+1<15?setTimeout(()=>sl(O,B,J+1),2e3):(fs.current.delete(O),ni(O,"error","poll-error",`⚠️ Failed to check OAuth status: ${le}`,"failed"),so(),a(null),V.error("Failed to check OAuth status"))})},Wc=O=>{l(!0);const B=O.testSessionId;if(O.success){if(Vc.current.has(B)&&O.userInfo)return;if(ni(B,"success","waiting","✅ Verified with Better Auth.","completed"),O.userInfo){Vc.current.add(B);const J=[O.userInfo.name?`👤 ${O.userInfo.name}`:null,O.userInfo.email?`✉️ ${O.userInfo.email}`:null].filter(Boolean).join(" | "),re=J?`✅ ${O.provider} OAuth succeeded — ${J}`:`✅ ${O.provider} OAuth succeeded!`;ni(B,"success","completed",re,"completed"),V.success(`OAuth test for ${O.provider} passed!`),so(),a(null),rl.current.delete(B)}else ni(B,"progress","await-finalize","⌛ OAuth flow finished. Waiting for Better Auth to finalize account...","running"),fs.current.has(B)||(fs.current.add(B),sl(B,O.provider))}else{if(Vc.current.has(B))return;ni(B,"error","waiting","❌ Verification failed with Better Auth.","failed");const J=O.error?` — ${O.error}`:"";ni(B,"error","failed",`❌ ${O.provider} OAuth failed${J}`,"failed"),V.error(`OAuth test for ${O.provider} failed`),so(),a(null),rl.current.delete(B)}O.success||(Vc.current.add(B),rl.current.delete(B)),sessionStorage.removeItem("oauth_test_session"),sessionStorage.removeItem(`oauth_test_result_${B}`)};p.useEffect(()=>{const O=e.get("oauth_test_result");if(O)try{const B=JSON.parse(decodeURIComponent(O));l(!0),Wc(B),t({})}catch{}},[e,t,Wc]),p.useEffect(()=>{(async()=>{try{const J=await(await fetch("/api/tools/oauth/providers")).json();J.success&&J.providers&&d(J.providers.filter(re=>re.enabled))}catch{}})()},[]);const J6=async()=>{if(h.length===0){V.error("No OAuth providers configured"),Xe("error","❌ No OAuth providers found in configuration","failed"),Xe("info","💡 Please configure at least one OAuth provider in your Better Auth config","failed");return}u(!0)},eP=async O=>{u(!1),m(""),a("test-oauth"),l(!0),i([]),Xe("info",`🔍 Testing ${O} OAuth...`,"running");const B=new Date().toISOString();try{Xe("progress","📡 Contacting Better Auth...","running");const re=await(await fetch("/api/tools/oauth/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:O})})).json();if(re.success&&re.startUrl){rl.current.delete(re.testSessionId),ni(re.testSessionId,"progress","popup-open",`🌐 Opening ${re.provider} OAuth popup...`,"running");const le={testSessionId:re.testSessionId,provider:re.provider,providerId:O,startTime:B};Vc.current.delete(re.testSessionId),sessionStorage.setItem("oauth_test_session",JSON.stringify(le));const he=600,et=700,wt=(window.screen.width-he)/2,qn=(window.screen.height-et)/2,pt=window.open(re.startUrl,"oauth-test",`width=${he},height=${et},left=${wt},top=${qn},scrollbars=yes,resizable=yes`);if(!pt){Xe("error","❌ Failed to open OAuth window. Please allow popups for this site.","failed"),Xe("error","💡 Check your browser popup blocker settings","failed"),V.error("Failed to open OAuth window. Please allow popups."),a(null);return}Yc.current=pt;let Nt=!1;const ps=lr=>{if(lr.origin===window.location.origin){if(lr.data&&lr.data.type==="oauth_test_state"){if(lr.data.status==="redirect")fs.current.has(le.testSessionId)||sl(le.testSessionId,le.provider);else if(lr.data.status==="error"){Nt=!0;const io=sessionStorage.getItem("oauth_test_session");let Um=re.provider;if(io)try{Um=JSON.parse(io).provider||Um}catch{}Wc({success:!1,provider:Um,testSessionId:lr.data.testSessionId,error:lr.data.error||"Failed to start OAuth test"}),window.removeEventListener("message",ps),clearInterval(dh),clearTimeout(Lm),so()}return}if(lr.data&&lr.data.type==="oauth_test_result"){window.removeEventListener("message",ps),clearInterval(dh),clearTimeout(Lm),Nt=!0;const io=lr.data.result;Wc(io),fs.current.has(io.testSessionId)||sl(io.testSessionId,io.provider),so()}}};window.addEventListener("message",ps);const dh=setInterval(()=>{pt.closed&&(clearInterval(dh),clearTimeout(Lm),window.removeEventListener("message",ps),!sessionStorage.getItem(`oauth_test_result_${le.testSessionId}`)&&!Nt&&(Nt=!0,sl(le.testSessionId,le.provider)))},500),Lm=setTimeout(()=>{pt.closed||(clearInterval(dh),window.removeEventListener("message",ps),so(),Nt||(Nt=!0),Xe("error","❌ OAuth test timed out after 5 minutes","failed"),Xe("error","💡 Possible reasons:","failed"),Xe("error"," • Authentication took too long","failed"),Xe("error"," • Provider is not responding","failed"),Xe("error"," • Network connectivity issues","failed"),V.error("OAuth test timed out"),a(null))},5*60*1e3)}else Xe("error",`❌ Failed to initiate OAuth test: ${re.error||"Unknown error"}`,"failed"),re.details&&Xe("error",`💡 Details: ${JSON.stringify(re.details)}`,"failed"),re.cause&&Xe("error",`💡 Cause: ${re.cause}`,"failed"),V.error(re.error||"Failed to start OAuth test"),a(null)}catch(J){Xe("error",`❌ Network error: ${J}`,"failed"),V.error("Failed to start OAuth test"),a(null)}},tP=()=>{x(!0)},TE=async(O,B)=>{const J=xd.find(le=>le.id===O);if(!J){V.error("Unknown migration provider");return}if(J.disabled){V.info(`${J.name} migration is coming soon`);return}x(!1),a("run-migration"),l(!0),i([]);const re=le=>new Promise(he=>setTimeout(he,le));try{if(Xe("info",`🚀 Preparing ${J.name} migration...`,"running"),J.highlights)for(const et of J.highlights)await re(350),Xe("progress",et,"running");Xe("progress","📡 Sending migration payload to server...","running");const he=await(await fetch("/api/tools/migrations/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:J.id,script:J.custom?B:J.script})})).json();if(he.success)Xe("progress","🚀 Migration job acknowledged. Follow server logs for live progress.","running"),Xe("success",`✅ ${J.name} migration request accepted.`,"completed"),he.message&&Xe("info",he.message,"completed"),V.success(`${J.name} migration flow completed`);else throw new Error(he.error||"Migration request failed")}catch(le){Xe("error",`❌ Migration failed: ${le}`,"failed"),V.error("Migration failed")}finally{a(null)}},nP=async()=>{a("validate-config"),l(!0),i([]),z(null),C(!0),Xe("info","Validating Better Auth configuration...","running");try{const B=await(await fetch("/api/tools/validate-config",{method:"POST",headers:{"Content-Type":"application/json"}})).json();if(B.success!==void 0)z(B),Xe("info",`Found ${B.summary.total} validation checks`,"completed"),B.summary.errors>0&&Xe("error",`❌ ${B.summary.errors} error(s) found`,"failed"),B.summary.warnings>0&&Xe("progress",`⚠️ ${B.summary.warnings} warning(s) found`,"completed"),B.summary.passes>0&&Xe("success",`✅ ${B.summary.passes} check(s) passed`,"completed"),B.success?V.success("Configuration validation completed successfully"):V.error(`Configuration validation found ${B.summary.errors} error(s)`);else throw new Error(B.error||"Failed to validate configuration")}catch(O){Xe("error",`❌ Configuration validation failed: ${O}`,"failed"),V.error("Configuration validation failed")}finally{a(null)}},aP=async()=>{a("test-db"),l(!0),i([]),Xe("info","Testing database connection...","running");try{const B=await(await fetch("/api/database/test")).json();await new Promise(J=>setTimeout(J,1e3)),Xe("progress","Checking on database con!","running"),B.success?(Xe("success","✅ Database connection successful!","completed"),B.result&&Array.isArray(B.result)&&B.result.length>0&&(Xe("info","📄 Sample user record (first row):","completed"),Xe("info",JSON.stringify(B.result[0],null,2),"completed")),V.success("Database connection test successful")):(Xe("error",`❌ Database connection failed: ${B.error||"Unknown error"}`,"failed"),V.error("Database connection test failed"))}catch(O){Xe("error",`❌ Network error: ${O}`,"failed"),V.error("Failed to test database connection")}finally{a(null)}},rP=O=>{if(!O)return"N/A";const B=new Date(O);return Number.isNaN(B.getTime())?O:B.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})},sP=()=>{ne(!0)},iP=()=>{Fe(""),Ae(""),at(null),oe(null),Ke(!0)},oP=()=>{Tn("1"),nn([]),Dn(""),rr(null),it(!0)},lP=()=>{el(!0),Pn(""),rs(null),os(!1)},cP=async()=>{if(!Ys.trim()){V.error("Please enter a password to check");return}is(!0),rs(null);try{const B=await(await fetch("/api/tools/password-strength",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:Ys})})).json();B.success?(rs(B),V.success("Password strength checked")):V.error(B.error||"Failed to check password strength")}catch(O){const B=O instanceof Error?O.message:"Failed to check password strength";V.error(B)}finally{is(!1)}},dP=()=>{ds(!0),qe(null),ma(32),kr("hex")},uP=async()=>{Ut(!0),qe(null);try{const O=await fetch("/api/tools/generate-secret",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({length:ea,format:Cr})});if(!O.ok)throw new Error("Failed to generate secret");const B=await O.json();if(B.success)qe(B),V.success("Secret generated successfully");else throw new Error(B.message||"Failed to generate secret")}catch(O){V.error(O instanceof Error?O.message:"Failed to generate secret"),console.error(O)}finally{Ut(!1)}},hP=async()=>{if(!Se){V.error("Please generate a secret first");return}Ce(!0),Re(null);try{const B=await(await fetch("/api/tools/check-env-secret",{method:"POST",headers:{"Content-Type":"application/json"}})).json();if(B.success&&B.hasExisting){Re({hasExisting:!0,secret:B.existingSecret,path:B.path}),we(!0),Ce(!1);return}await CE("override")}catch(O){const B=O instanceof Error?O.message:"Failed to check secret";V.error(B),Ce(!1)}},CE=async O=>{if(Se){ke(!0),we(!1);try{const J=await(await fetch("/api/tools/write-env-secret",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:Se.secret,action:O})})).json();if(J.success)V.success(`Secret written to ${J.path}`),Re(null);else throw new Error(J.message||"Failed to write secret")}catch(B){const J=B instanceof Error?B.message:"Failed to write secret to .env";V.error(J)}finally{ke(!1),Ce(!1)}}},fP=async()=>{Ws(!0),m("google"),Jn(null),tl(!1);try{const B=await(await fetch("/api/config")).json();if(B.baseURL){const J=B.baseURL.replace(/^https?:\/\//,"");Xs(J),Qn(J)}else Xs("localhost:3000"),Qn("localhost:3000")}catch{Xs("localhost:3000"),Qn("localhost:3000")}},pP=async()=>{if(!f){V.error("Please select a provider");return}const O=fa.trim()||Pa;if(!O){V.error("Please enter an origin");return}const B=O.replace(/^https?:\/\//,"");Ks(!0),Jn(null),jr(null);try{const J=await fetch(`https://studio-backend-0.vercel.app/oauth/${f}?origin=${encodeURIComponent(B)}`);if(!J.ok)throw new Error(`Failed to fetch credentials: ${J.statusText}`);const re=await J.json();if(re.clientId&&re.clientSecret)Jn({clientId:re.clientId,clientSecret:re.clientSecret}),V.success("OAuth credentials fetched successfully");else throw new Error("Invalid response format")}catch(J){const re=J instanceof Error?J.message:"Failed to fetch OAuth credentials";V.error(re)}finally{Ks(!1)}},mP=async()=>{if(!f||!pa){V.error("Please fetch credentials first");return}Fa(!0),jr(null);try{const B=await(await fetch("/api/tools/check-env-credentials",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:f})})).json();if(B.success&&B.hasExisting){ir({hasExisting:!0,credentials:B.existingCredentials,path:B.path}),Js(!0),Fa(!1);return}await Im("override")}catch(O){const B=O instanceof Error?O.message:"Failed to check credentials";V.error(B),Fa(!1)}},Im=async O=>{if(!(!f||!pa)){no(!0),jr(null),Js(!1);try{const J=await(await fetch("/api/tools/write-env-credentials",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:f,clientId:pa.clientId,clientSecret:pa.clientSecret,action:O})})).json();if(J.success)jr({success:!0,message:J.message,path:J.path}),V.success(`Credentials written to ${J.path}`),ir(null);else throw new Error(J.message||"Failed to write credentials")}catch(B){const J=B instanceof Error?B.message:"Failed to write credentials to .env";jr({success:!1,message:J}),V.error(J)}finally{no(!1),Fa(!1)}}},gP=()=>{const O=Math.min(Math.max(parseInt(cn)||1,1),100),B=[];for(let J=0;J<O;J++)try{const re=crypto.randomUUID();B.push(re)}catch{V.error("Failed to generate UUID");return}nn(B),V.success(`Generated ${B.length} UUID(s)`)},bP=()=>{var qn,pt;const O=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,B=ns.trim();if(!B){rr(null);return}if(!O.test(B)){rr({isValid:!1});return}const re=B.split("-"),le=(qn=re[2])==null?void 0:qn[0],he=(pt=re[3])==null?void 0:pt[0];let et,wt;if(le){const Nt=parseInt(le,16);Nt>=1&&Nt<=5?et=`v${Nt}`:Nt===0&&(et="v1 (time-based)")}if(he){const Nt=parseInt(he,16);Nt>=8&&Nt<=11?wt="RFC 4122":Nt>=12&&Nt<=15?wt="Microsoft":Nt>=0&&Nt<=7&&(wt="Reserved")}rr({isValid:!0,version:et,variant:wt})},xP=()=>{pe("api_key"),Te(""),tt(""),ue("15"),xe(""),Q(`{
|
|
1131
|
+
}`),[Z,je]=p.useState(null),[Qe,st]=p.useState(!1),[ct,it]=p.useState(!1),[cn,Tn]=p.useState("1"),[yn,nn]=p.useState([]),[ns,Dn]=p.useState(""),[Hn,rr]=p.useState(null),[as,el]=p.useState(!1),[Ys,Pn]=p.useState(""),[It,rs]=p.useState(null),[ss,is]=p.useState(!1),[Sr,os]=p.useState(!1),[Er,Ws]=p.useState(!1),[fa,Qn]=p.useState(""),[Pa,Xs]=p.useState("localhost:3000"),[pa,Jn]=p.useState(null),[sr,Ks]=p.useState(!1),[Zs,tl]=p.useState(!1),[Qs,no]=p.useState(!1),[xt,jr]=p.useState(null),[Tr,Js]=p.useState(!1),[ls,ir]=p.useState(null),[cs,Fa]=p.useState(!1),[ao,ds]=p.useState(!1),[nl,we]=p.useState(!1),[Se,Re]=p.useState(null),[fe,Ce]=p.useState(!1),[De,ke]=p.useState(!1),[Ee,qe]=p.useState(null),[Lt,Ut]=p.useState(!1),[ea,ma]=p.useState(32),[Cr,kr]=p.useState("hex"),[Hc,ch]=p.useState(!1),[al,km]=p.useState(""),[vE,Am]=p.useState(""),[dn,wn]=p.useState([]),[W6,X6]=p.useState([]),[Ba,or]=p.useState([]),[Ar,us]=p.useState([]),[hs,ro]=p.useState([]),[_m,Rm]=p.useState(!1),[ta,ei]=p.useState({path:"/my-plugin/*",pathType:"prefix",window:15*60*1e3,max:100}),[Rt,qc]=p.useState(null),yE=p.useRef(null),[wE,NE]=p.useState(!1),[SE,Gc]=p.useState(null),[ti,EE]=p.useState("server"),[jE,Om]=p.useState("client");p.useEffect(()=>(q?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[q]),p.useEffect(()=>(Er?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Er]),p.useEffect(()=>(Tr?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Tr]),p.useEffect(()=>(as?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[as]),p.useEffect(()=>(Er?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Er]),p.useEffect(()=>(Tr?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Tr]),p.useEffect(()=>(ao?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[ao]),p.useEffect(()=>(ct?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[ct]),p.useEffect(()=>(Hc?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[Hc]);const Xe=(O,B,J,re)=>{i(le=>[...le,{id:re??`log-${Date.now()}-${Math.random()}`,type:O,message:B,timestamp:new Date,status:J}])},fs=p.useRef(new Set),Vc=p.useRef(new Set),rl=p.useRef(new Map),Yc=p.useRef(null),Dm=()=>xd.find(O=>!O.disabled)??xd[0],Cn=xd.find(O=>O.id===N)??Dm();p.useEffect(()=>{b(y?O=>{var B;return O||((B=Dm())==null?void 0:B.id)||""}:"")},[y,Dm]);const K6=O=>{b(O),O!=="custom"&&g(dw)},Z6=()=>{j(""),M(""),P(null),L("SHA-256"),G("hex"),S(!0)},Q6=async()=>{if(!E.trim()){V.error("Enter a password to hash");return}try{k(!0);const O=_?`${_}:${E}`:E,J=await Sfe(U,F).digest(O);P(J),V.success("Password hashed successfully")}catch(O){V.error("Failed to hash password"),console.error(O)}finally{k(!1)}},za=async O=>{try{await navigator.clipboard.writeText(O),V.success("Copied to clipboard")}catch{V.error("Failed to copy to clipboard")}},so=()=>{Yc.current&&!Yc.current.closed&&Yc.current.close(),Yc.current=null},ni=(O,B,J,re,le)=>{let he=rl.current.get(O);he||(he=new Map,rl.current.set(O,he));const et=he.get(J);if(et){i(qn=>qn.map(pt=>pt.id===et?{...pt,type:B,message:re,status:le,timestamp:new Date}:pt));return}const wt=`session-${O}-${J}-${Date.now()}`;he.set(J,wt),Xe(B,re,le,wt)},sl=(O,B,J=0)=>{fs.current.has(O)||fs.current.add(O),fetch(`/api/tools/oauth/status?testSessionId=${encodeURIComponent(O)}`).then(le=>le.json()).then(le=>{if(le.hasResult){fs.current.delete(O),Wc(le.result);return}if(J+1>=15){fs.current.delete(O),ni(O,"error","timeout","⌛ Timed out waiting for account creation. Check Better Auth logs.","failed"),so(),a(null),V.error("OAuth test timed out waiting for account creation");return}setTimeout(()=>sl(O,B,J+1),2e3)}).catch(le=>{J+1<15?setTimeout(()=>sl(O,B,J+1),2e3):(fs.current.delete(O),ni(O,"error","poll-error",`⚠️ Failed to check OAuth status: ${le}`,"failed"),so(),a(null),V.error("Failed to check OAuth status"))})},Wc=O=>{l(!0);const B=O.testSessionId;if(O.success){if(Vc.current.has(B)&&O.userInfo)return;if(ni(B,"success","waiting","✅ Verified with Better Auth.","completed"),O.userInfo){Vc.current.add(B);const J=[O.userInfo.name?`👤 ${O.userInfo.name}`:null,O.userInfo.email?`✉️ ${O.userInfo.email}`:null].filter(Boolean).join(" | "),re=J?`✅ ${O.provider} OAuth succeeded — ${J}`:`✅ ${O.provider} OAuth succeeded!`;ni(B,"success","completed",re,"completed"),V.success(`OAuth test for ${O.provider} passed!`),so(),a(null),rl.current.delete(B)}else ni(B,"progress","await-finalize","⌛ OAuth flow finished. Waiting for Better Auth to finalize account...","running"),fs.current.has(B)||(fs.current.add(B),sl(B,O.provider))}else{if(Vc.current.has(B))return;ni(B,"error","waiting","❌ Verification failed with Better Auth.","failed");const J=O.error?` — ${O.error}`:"";ni(B,"error","failed",`❌ ${O.provider} OAuth failed${J}`,"failed"),V.error(`OAuth test for ${O.provider} failed`),so(),a(null),rl.current.delete(B)}O.success||(Vc.current.add(B),rl.current.delete(B)),sessionStorage.removeItem("oauth_test_session"),sessionStorage.removeItem(`oauth_test_result_${B}`)};p.useEffect(()=>{const O=e.get("oauth_test_result");if(O)try{const B=JSON.parse(decodeURIComponent(O));l(!0),Wc(B),t({})}catch{}},[e,t,Wc]),p.useEffect(()=>{(async()=>{try{const J=await(await fetch("/api/tools/oauth/providers")).json();J.success&&J.providers&&d(J.providers.filter(re=>re.enabled))}catch{}})()},[]);const J6=async()=>{if(h.length===0){V.error("No OAuth providers configured"),Xe("error","❌ No OAuth providers found in configuration","failed"),Xe("info","💡 Please configure at least one OAuth provider in your Better Auth config","failed");return}u(!0)},eP=async O=>{u(!1),m(""),a("test-oauth"),l(!0),i([]),Xe("info",`🔍 Testing ${O} OAuth...`,"running");const B=new Date().toISOString();try{Xe("progress","📡 Contacting Better Auth...","running");const re=await(await fetch("/api/tools/oauth/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:O})})).json();if(re.success&&re.startUrl){rl.current.delete(re.testSessionId),ni(re.testSessionId,"progress","popup-open",`🌐 Opening ${re.provider} OAuth popup...`,"running");const le={testSessionId:re.testSessionId,provider:re.provider,providerId:O,startTime:B};Vc.current.delete(re.testSessionId),sessionStorage.setItem("oauth_test_session",JSON.stringify(le));const he=600,et=700,wt=(window.screen.width-he)/2,qn=(window.screen.height-et)/2,pt=window.open(re.startUrl,"oauth-test",`width=${he},height=${et},left=${wt},top=${qn},scrollbars=yes,resizable=yes`);if(!pt){Xe("error","❌ Failed to open OAuth window. Please allow popups for this site.","failed"),Xe("error","💡 Check your browser popup blocker settings","failed"),V.error("Failed to open OAuth window. Please allow popups."),a(null);return}Yc.current=pt;let Nt=!1;const ps=lr=>{if(lr.origin===window.location.origin){if(lr.data&&lr.data.type==="oauth_test_state"){if(lr.data.status==="redirect")fs.current.has(le.testSessionId)||sl(le.testSessionId,le.provider);else if(lr.data.status==="error"){Nt=!0;const io=sessionStorage.getItem("oauth_test_session");let Um=re.provider;if(io)try{Um=JSON.parse(io).provider||Um}catch{}Wc({success:!1,provider:Um,testSessionId:lr.data.testSessionId,error:lr.data.error||"Failed to start OAuth test"}),window.removeEventListener("message",ps),clearInterval(dh),clearTimeout(Lm),so()}return}if(lr.data&&lr.data.type==="oauth_test_result"){window.removeEventListener("message",ps),clearInterval(dh),clearTimeout(Lm),Nt=!0;const io=lr.data.result;Wc(io),fs.current.has(io.testSessionId)||sl(io.testSessionId,io.provider),so()}}};window.addEventListener("message",ps);const dh=setInterval(()=>{pt.closed&&(clearInterval(dh),clearTimeout(Lm),window.removeEventListener("message",ps),!sessionStorage.getItem(`oauth_test_result_${le.testSessionId}`)&&!Nt&&(Nt=!0,sl(le.testSessionId,le.provider)))},500),Lm=setTimeout(()=>{pt.closed||(clearInterval(dh),window.removeEventListener("message",ps),so(),Nt||(Nt=!0),Xe("error","❌ OAuth test timed out after 5 minutes","failed"),Xe("error","💡 Possible reasons:","failed"),Xe("error"," • Authentication took too long","failed"),Xe("error"," • Provider is not responding","failed"),Xe("error"," • Network connectivity issues","failed"),V.error("OAuth test timed out"),a(null))},5*60*1e3)}else Xe("error",`❌ Failed to initiate OAuth test: ${re.error||"Unknown error"}`,"failed"),re.details&&Xe("error",`💡 Details: ${JSON.stringify(re.details)}`,"failed"),re.cause&&Xe("error",`💡 Cause: ${re.cause}`,"failed"),V.error(re.error||"Failed to start OAuth test"),a(null)}catch(J){Xe("error",`❌ Network error: ${J}`,"failed"),V.error("Failed to start OAuth test"),a(null)}},tP=()=>{x(!0)},TE=async(O,B)=>{const J=xd.find(le=>le.id===O);if(!J){V.error("Unknown migration provider");return}if(J.disabled){V.info(`${J.name} migration is coming soon`);return}x(!1),a("run-migration"),l(!0),i([]);const re=le=>new Promise(he=>setTimeout(he,le));try{if(Xe("info",`🚀 Preparing ${J.name} migration...`,"running"),J.highlights)for(const et of J.highlights)await re(350),Xe("progress",et,"running");Xe("progress","📡 Sending migration payload to server...","running");const he=await(await fetch("/api/tools/migrations/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:J.id,script:J.custom?B:J.script})})).json();if(he.success)Xe("progress","🚀 Migration job acknowledged. Follow server logs for live progress.","running"),Xe("success",`✅ ${J.name} migration request accepted.`,"completed"),he.message&&Xe("info",he.message,"completed"),V.success(`${J.name} migration flow completed`);else throw new Error(he.error||"Migration request failed")}catch(le){Xe("error",`❌ Migration failed: ${le}`,"failed"),V.error("Migration failed")}finally{a(null)}},nP=async()=>{a("validate-config"),l(!0),i([]),z(null),C(!0),Xe("info","Validating Better Auth configuration...","running");try{const B=await(await fetch("/api/tools/validate-config",{method:"POST",headers:{"Content-Type":"application/json"}})).json();if(B.success!==void 0)z(B),Xe("info",`Found ${B.summary.total} validation checks`,"completed"),B.summary.errors>0&&Xe("error",`❌ ${B.summary.errors} error(s) found`,"failed"),B.summary.warnings>0&&Xe("progress",`⚠️ ${B.summary.warnings} warning(s) found`,"completed"),B.summary.passes>0&&Xe("success",`✅ ${B.summary.passes} check(s) passed`,"completed"),B.success?V.success("Configuration validation completed successfully"):V.error(`Configuration validation found ${B.summary.errors} error(s)`);else throw new Error(B.error||"Failed to validate configuration")}catch(O){Xe("error",`❌ Configuration validation failed: ${O}`,"failed"),V.error("Configuration validation failed")}finally{a(null)}},aP=async()=>{a("test-db"),l(!0),i([]),Xe("info","Testing database connection...","running");try{const B=await(await fetch("/api/database/test")).json();await new Promise(J=>setTimeout(J,1e3)),Xe("progress","Checking on database con!","running"),B.success?(Xe("success","✅ Database connection successful!","completed"),B.result&&Array.isArray(B.result)&&B.result.length>0&&(Xe("info","📄 Sample user record (first row):","completed"),Xe("info",JSON.stringify(B.result[0],null,2),"completed")),V.success("Database connection test successful")):(Xe("error",`❌ Database connection failed: ${B.error||"Unknown error"}`,"failed"),V.error("Database connection test failed"))}catch(O){Xe("error",`❌ Network error: ${O}`,"failed"),V.error("Failed to test database connection")}finally{a(null)}},rP=O=>{if(!O)return"N/A";const B=new Date(O);return Number.isNaN(B.getTime())?O:B.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})},sP=()=>{ne(!0)},iP=()=>{Fe(""),Ae(""),at(null),oe(null),Ke(!0)},oP=()=>{Tn("1"),nn([]),Dn(""),rr(null),it(!0)},lP=()=>{el(!0),Pn(""),rs(null),os(!1)},cP=async()=>{if(!Ys.trim()){V.error("Please enter a password to check");return}is(!0),rs(null);try{const B=await(await fetch("/api/tools/password-strength",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:Ys})})).json();B.success?(rs(B),V.success("Password strength checked")):V.error(B.error||"Failed to check password strength")}catch(O){const B=O instanceof Error?O.message:"Failed to check password strength";V.error(B)}finally{is(!1)}},dP=()=>{ds(!0),qe(null),ma(32),kr("hex")},uP=async()=>{Ut(!0),qe(null);try{const O=await fetch("/api/tools/generate-secret",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({length:ea,format:Cr})});if(!O.ok)throw new Error("Failed to generate secret");const B=await O.json();if(B.success)qe(B),V.success("Secret generated successfully");else throw new Error(B.message||"Failed to generate secret")}catch(O){V.error(O instanceof Error?O.message:"Failed to generate secret"),console.error(O)}finally{Ut(!1)}},hP=async()=>{if(!Ee){V.error("Please generate a secret first");return}Ce(!0),Re(null);try{const B=await(await fetch("/api/tools/check-env-secret",{method:"POST",headers:{"Content-Type":"application/json"}})).json();if(B.success&&B.hasExisting){Re({hasExisting:!0,secret:B.existingSecret,path:B.path}),we(!0),Ce(!1);return}await CE("override")}catch(O){const B=O instanceof Error?O.message:"Failed to check secret";V.error(B),Ce(!1)}},CE=async O=>{if(Ee){ke(!0),we(!1);try{const J=await(await fetch("/api/tools/write-env-secret",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:Ee.secret,action:O})})).json();if(J.success)V.success(`Secret written to ${J.path}`),Re(null);else throw new Error(J.message||"Failed to write secret")}catch(B){const J=B instanceof Error?B.message:"Failed to write secret to .env";V.error(J)}finally{ke(!1),Ce(!1)}}},fP=async()=>{Ws(!0),m("google"),Jn(null),tl(!1);try{const B=await(await fetch("/api/config")).json();if(B.baseURL){const J=B.baseURL.replace(/^https?:\/\//,"");Xs(J),Qn(J)}else Xs("localhost:3000"),Qn("localhost:3000")}catch{Xs("localhost:3000"),Qn("localhost:3000")}},pP=async()=>{if(!f){V.error("Please select a provider");return}const O=fa.trim()||Pa;if(!O){V.error("Please enter an origin");return}const B=O.replace(/^https?:\/\//,"");Ks(!0),Jn(null),jr(null);try{const J=await fetch(`https://studio-backend-0.vercel.app/oauth/${f}?origin=${encodeURIComponent(B)}`);if(!J.ok)throw new Error(`Failed to fetch credentials: ${J.statusText}`);const re=await J.json();if(re.clientId&&re.clientSecret)Jn({clientId:re.clientId,clientSecret:re.clientSecret}),V.success("OAuth credentials fetched successfully");else throw new Error("Invalid response format")}catch(J){const re=J instanceof Error?J.message:"Failed to fetch OAuth credentials";V.error(re)}finally{Ks(!1)}},mP=async()=>{if(!f||!pa){V.error("Please fetch credentials first");return}Fa(!0),jr(null);try{const B=await(await fetch("/api/tools/check-env-credentials",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:f})})).json();if(B.success&&B.hasExisting){ir({hasExisting:!0,credentials:B.existingCredentials,path:B.path}),Js(!0),Fa(!1);return}await Im("override")}catch(O){const B=O instanceof Error?O.message:"Failed to check credentials";V.error(B),Fa(!1)}},Im=async O=>{if(!(!f||!pa)){no(!0),jr(null),Js(!1);try{const J=await(await fetch("/api/tools/write-env-credentials",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:f,clientId:pa.clientId,clientSecret:pa.clientSecret,action:O})})).json();if(J.success)jr({success:!0,message:J.message,path:J.path}),V.success(`Credentials written to ${J.path}`),ir(null);else throw new Error(J.message||"Failed to write credentials")}catch(B){const J=B instanceof Error?B.message:"Failed to write credentials to .env";jr({success:!1,message:J}),V.error(J)}finally{no(!1),Fa(!1)}}},gP=()=>{const O=Math.min(Math.max(parseInt(cn)||1,1),100),B=[];for(let J=0;J<O;J++)try{const re=crypto.randomUUID();B.push(re)}catch{V.error("Failed to generate UUID");return}nn(B),V.success(`Generated ${B.length} UUID(s)`)},bP=()=>{var qn,pt;const O=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,B=ns.trim();if(!B){rr(null);return}if(!O.test(B)){rr({isValid:!1});return}const re=B.split("-"),le=(qn=re[2])==null?void 0:qn[0],he=(pt=re[3])==null?void 0:pt[0];let et,wt;if(le){const Nt=parseInt(le,16);Nt>=1&&Nt<=5?et=`v${Nt}`:Nt===0&&(et="v1 (time-based)")}if(he){const Nt=parseInt(he,16);Nt>=8&&Nt<=11?wt="RFC 4122":Nt>=12&&Nt<=15?wt="Microsoft":Nt>=0&&Nt<=7&&(wt="Reserved")}rr({isValid:!0,version:et,variant:wt})},xP=()=>{pe("api_key"),Te(""),tt(""),ue("15"),xe(""),Q(`{
|
|
1132
1132
|
|
|
1133
1133
|
}`),je(null),Ze(!0)},vP=async()=>{try{const B=await(await fetch("/api/database/schema")).json();if(B.success&&B.schema&&B.schema.tables){const J=B.schema.tables.map(re=>({name:re.name,displayName:re.displayName||re.name}));X6(J)}}catch{}},yP=()=>{km(""),Am(""),Om("react"),wn([]),or([]),us([]),Rm(!1),ei({path:"/my-plugin/*",pathType:"prefix",window:15*60*1e3,max:100}),qc(null),Gc(null),EE("server"),vP(),ch(!0)},wP=O=>{const B=[...Ba];B[O].expanded=!B[O].expanded,or(B)},NP=O=>{const B=[...Ar];B[O].expanded=!B[O].expanded,us(B)},SP=O=>{const B=[...hs];B[O].expanded=!B[O].expanded,ro(B)},EP=O=>{if(!Rt)return;const J={react:"better-auth/react",svelte:"better-auth/svelte",solid:"better-auth/solid",vue:"better-auth/vue"}[O]||"better-auth/react",re=Rt.name.charAt(0).toLowerCase()+Rt.name.slice(1),he={react:'process.env.NEXT_PUBLIC_BETTER_AUTH_URL || "http://localhost:3000"',svelte:'import.meta.env.PUBLIC_BETTER_AUTH_URL || "http://localhost:5173"',solid:'import.meta.env.PUBLIC_BETTER_AUTH_URL || "http://localhost:5173"',vue:'import.meta.env.PUBLIC_BETTER_AUTH_URL || "http://localhost:5173"'}[O]||'process.env.NEXT_PUBLIC_BETTER_AUTH_URL || "http://localhost:3000"',et=`import { createAuthClient } from "${J}";
|
|
1134
1134
|
import { ${re}Client } from "./plugin/${re}/client";
|
|
@@ -1142,4 +1142,4 @@ export const authClient = createAuthClient({
|
|
|
1142
1142
|
|
|
1143
1143
|
}`)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Reset"}),r.jsx($,{onClick:RP,disabled:Qe,className:"rounded-none",children:Qe?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Token"})]}),Z&&r.jsxs("div",{className:"space-y-4 border border-dashed border-white/15 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs uppercase font-mono text-gray-400",children:"Generated Token"}),r.jsx("p",{className:"text-white font-mono text-sm break-all mt-1",children:Z.token})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(Z.token),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"Type"}),r.jsx("p",{className:"text-white mt-1 capitalize",children:Z.type.replace("_"," ")})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"Expires"}),r.jsx("p",{className:"text-white mt-1",children:rP(Z.expiresAt)})]}),Z.url&&r.jsxs("div",{className:"col-span-1",children:[r.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"URL"}),r.jsx("p",{className:"text-white mt-1 break-all",children:Z.url})]})]}),Z.metadata&&r.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[r.jsx("p",{className:"text-xs uppercase font-mono text-gray-400 mb-2",children:"Metadata"}),r.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto",children:JSON.stringify(Z.metadata,null,2)})]})]})]})]})}),Hc&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60]",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-5xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(hi,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Plugin Generator"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>ch(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Plugin Name *"}),r.jsx(Ne,{value:al,onChange:O=>km(O.target.value),placeholder:"myPlugin",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Must to be filled"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Description (optional)"}),r.jsx(Ne,{value:vE,onChange:O=>Am(O.target.value),placeholder:"Plugin description",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Leave empty to use the default description"})]})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Tables (optional)"}),r.jsxs("div",{className:"flex space-x-2",children:[r.jsx($,{variant:"ghost",size:"sm",onClick:()=>wn([...dn,{name:"",isExtending:!1,fields:[{name:"",type:"string",required:!1,unique:!1}]}]),className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Add Table"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>wn([...dn,{name:"",isExtending:!0,extendedTableName:"",fields:[{name:"",type:"string",required:!1,unique:!1}]}]),className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Extend Table"})]})]}),dn.length===0?r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:"No tables added"}):r.jsx("div",{className:"space-y-2",children:dn.map((O,B)=>r.jsxs("div",{className:"border px-5 border-dashed border-white/15 p-3 relative",children:[r.jsxs("div",{className:"flex items-center space-x-2 relative",children:[O.isExtending?r.jsxs(r.Fragment,{children:[r.jsxs(hn,{value:O.extendedTableName||"",onValueChange:J=>{const re=[...dn];re[B].extendedTableName=J,re[B].name=J,wn(re)},children:[r.jsx(fn,{className:"bg-black sm:w-40 border border-dashed border-white/20 text-white text-xs rounded-none flex-1",children:r.jsx(Bn,{className:"sm:text-[11px] text-white/90 font-mono uppercase",placeholder:"Select table"})}),r.jsx(pn,{children:W6.map(J=>r.jsx(Le,{className:"sm:text-[11px] uppercase font-mono text-white/90 border-b border-dashed last:border-b-0",value:J.name,children:J.displayName},J.name))})]}),r.jsx("span",{className:"text-xs text-gray-400 font-mono uppercase whitespace-nowrap",children:"(Extending)"})]}):r.jsx(Ne,{value:O.name,onChange:J=>{const re=[...dn];re[B].name=J.target.value,wn(re)},placeholder:"Table name",className:"bg-black border border-dashed border-white/20 text-white text-xs rounded-none flex-1"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{wn(dn.filter((J,re)=>re!==B))},className:"text-red-400 hover:text-red-300 rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),O.fields.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute border border-dashed w-px border-white/30",style:{left:"7px",top:"31px",bottom:"12px"}}),r.jsx("div",{className:"absolute border border-dashed h-px w-[11px] border-white/30",style:{left:"9px",top:"31px",bottom:"12px"}}),r.jsx("div",{className:"mt-3 relative",children:r.jsxs("div",{className:"space-y-0 pl-6",children:[O.fields.map((J,re)=>r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute border border-dashed h-px border-white/30 top-1/2 -translate-y-1/2",style:{left:"-36px",width:"36px"}}),r.jsxs("div",{className:"flex items-center space-x-2 py-1",children:[r.jsx(Ne,{value:J.name,onChange:le=>{const he=[...dn];he[B].fields[re].name=le.target.value,wn(he)},placeholder:"Field name",className:"bg-black border border-dashed border-white/20 text-white text-xs rounded-none flex-1"}),r.jsxs(hn,{value:J.type,onValueChange:le=>{const he=[...dn];he[B].fields[re].type=le,wn(he)},children:[r.jsx(fn,{className:"sm:h-10 sm:w-56 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1",children:r.jsx(Bn,{className:"font-mono uppercase text-[10px] px-0 text-white/90"})}),r.jsxs(pn,{className:"font-mono uppercase text-[10px]",children:[r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"string",children:"string"}),r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"number",children:"number"}),r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"boolean",children:"boolean"}),r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"date",children:"date"})]})]}),J.required&&r.jsxs("div",{className:"flex items-center",children:[J.type==="string"&&r.jsx(Ne,{value:J.defaultValue||"",onChange:le=>{const he=[...dn];he[B].fields[re].defaultValue=le.target.value,wn(he)},placeholder:"Default value",className:"sm:h-10 sm:w-56 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1 font-mono uppercase text-[10px]"}),J.type==="boolean"&&r.jsxs(hn,{value:J.defaultValue||"",onValueChange:le=>{const he=[...dn];he[B].fields[re].defaultValue=le,wn(he)},children:[r.jsx(fn,{className:"sm:h-10 sm:w-56 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1",children:r.jsx(Bn,{className:"font-mono uppercase text-[10px] px-0 text-white/90",placeholder:"Default value"})}),r.jsxs(pn,{className:"font-mono uppercase text-[10px]",children:[r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"true",children:"true"}),r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"false",children:"false"})]})]}),J.type==="date"&&r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs(hn,{value:J.defaultValue==="now()"?"now()":J.defaultValue&&J.defaultValue!=="now()"?"custom":"",onValueChange:le=>{const he=[...dn];if(le==="now()")he[B].fields[re].defaultValue="now()";else if(le==="custom"){if(!he[B].fields[re].defaultValue||he[B].fields[re].defaultValue==="now()"){const et=new Date,wt=et.getFullYear(),qn=String(et.getMonth()+1).padStart(2,"0"),pt=String(et.getDate()).padStart(2,"0"),Nt=String(et.getHours()).padStart(2,"0"),ps=String(et.getMinutes()).padStart(2,"0");he[B].fields[re].defaultValue=`${wt}-${qn}-${pt}T${Nt}:${ps}`}}else he[B].fields[re].defaultValue=void 0;wn(he)},children:[r.jsx(fn,{className:"sm:h-10 sm:w-40 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1",children:r.jsx(Bn,{className:"font-mono uppercase text-[10px] px-0 text-white/90",placeholder:"Default"})}),r.jsxs(pn,{className:"font-mono uppercase text-[10px]",children:[r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"now()",children:"now()"}),r.jsx(Le,{className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",value:"custom",children:"Custom"})]})]}),J.defaultValue&&J.defaultValue!=="now()"&&r.jsx(Ne,{type:"datetime-local",value:J.defaultValue,onChange:le=>{const he=[...dn];he[B].fields[re].defaultValue=le.target.value,wn(he)},className:"sm:h-10 sm:w-40 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1 font-mono uppercase text-[10px]"})]}),J.type==="number"&&r.jsx(Ne,{type:"number",value:J.defaultValue||"",onChange:le=>{const he=[...dn];he[B].fields[re].defaultValue=le.target.value,wn(he)},placeholder:"Default value",className:"sm:h-10 sm:w-56 border px-0 border-dashed border-white/20 text-white/90 text-xs rounded-none py-1 font-mono uppercase text-[10px]"})]}),r.jsxs("div",{className:"h-8 flex items-end space-x-2",children:[r.jsx(wf,{id:`required-${B}-${re}`,checked:J.required,onCheckedChange:le=>{const he=[...dn];he[B].fields[re].required=le===!0,le===!1&&(he[B].fields[re].defaultValue=void 0),wn(he)}}),r.jsx(ce,{htmlFor:`required-${B}-${re}`,className:"text-xs text-gray-400 font-mono uppercase cursor-pointer",children:"Required"})]}),r.jsxs("div",{className:"flex h-8 items-end space-x-2",children:[r.jsx(wf,{id:`unique-${B}-${re}`,checked:J.unique,onCheckedChange:le=>{const he=[...dn];he[B].fields[re].unique=le===!0,wn(he)}}),r.jsx(ce,{htmlFor:`unique-${B}-${re}`,className:"text-xs text-gray-400 font-mono uppercase cursor-pointer",children:"Unique"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{const le=[...dn];le[B].fields=le[B].fields.filter((he,et)=>et!==re),wn(le)},className:"text-red-400 hover:text-red-300 rounded-none",children:r.jsx(dt,{className:"w-3 h-3"})})]})]},re)),r.jsxs("div",{className:"relative pt-2",children:[r.jsx("div",{className:"absolute border border-dashed h-px border-white/30",style:{left:"-35px",width:"36px",top:"25px"}}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{const J=[...dn];J[B].fields.push({name:"",type:"string",required:!1,unique:!1,defaultValue:void 0}),wn(J)},className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Add Field"})]})]})})]}),O.fields.length===0&&r.jsx("div",{className:"mt-3",children:r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{const J=[...dn];J[B].fields.push({name:"",type:"string",required:!1,unique:!1,defaultValue:void 0}),wn(J)},className:"text-xs text-gray-400 hover:text-white rounded-none",children:"+ Add Field"})})]},B))})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Uh,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Hooks"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>or([...Ba,{name:"",timing:"before",action:"sign-up",hookLogic:"const context = ctx;",expanded:!0}]),className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Add Hook"})]}),Ba.length===0?r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:"No hooks added"}):r.jsx("div",{className:"space-y-2",children:Ba.map((O,B)=>{const J=`${O.timing} ${O.action==="custom"?"custom":O.action}: ${O.name||`Hook ${B+1}`}`;return r.jsxs("div",{className:"border border-dashed border-white/10",children:[r.jsxs("button",{onClick:()=>wP(B),className:"w-full flex items-center justify-between p-3 hover:bg-white/5 transition-colors text-left",children:[r.jsx("span",{className:"text-xs font-mono text-white px-2 py-1 bg-black/40 border border-dashed border-white/20 rounded-none",children:J}),r.jsx(pd,{className:`w-4 h-4 text-white/60 transition-transform ${O.expanded?"rotate-90":""}`})]}),O.expanded&&r.jsxs("div",{className:"border-t border-dashed border-white/10 p-4 space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Hook Name"}),r.jsx(Ne,{value:O.name,onChange:re=>{const le=[...Ba];le[B].name=re.target.value,or(le)},placeholder:"e.g., Age Verification, TOS Check",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Timing"}),r.jsxs(XN,{value:O.timing,onValueChange:re=>{const le=[...Ba];le[B].timing=re,or(le)},className:"flex space-x-4",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nl,{value:"before",id:`hook-timing-before-${B}`}),r.jsx(ce,{htmlFor:`hook-timing-before-${B}`,className:"text-xs text-white font-mono cursor-pointer",children:"Before"})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nl,{value:"after",id:`hook-timing-after-${B}`}),r.jsx(ce,{htmlFor:`hook-timing-after-${B}`,className:"text-xs text-white font-mono cursor-pointer",children:"After"})]})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Action"}),r.jsxs(XN,{value:O.action,onValueChange:re=>{const le=[...Ba];le[B].action=re,or(le)},className:"flex space-x-4",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nl,{value:"sign-up",id:`hook-action-signup-${B}`}),r.jsx(ce,{htmlFor:`hook-action-signup-${B}`,className:"text-xs text-white font-mono cursor-pointer",children:"Sign-up"})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nl,{value:"sign-in",id:`hook-action-signin-${B}`}),r.jsx(ce,{htmlFor:`hook-action-signin-${B}`,className:"text-xs text-white font-mono cursor-pointer",children:"Sign-in"})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nl,{value:"custom",id:`hook-action-custom-${B}`}),r.jsx(ce,{htmlFor:`hook-action-custom-${B}`,className:"text-xs text-white font-mono cursor-pointer",children:"Custom"})]})]})]})]}),O.action==="custom"&&r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Custom Path"}),r.jsx(Ne,{value:O.customPath||"",onChange:re=>{const le=[...Ba];le[B].customPath=re.target.value,or(le)},placeholder:"/my-plugin/custom-endpoint",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Custom Matcher (optional)"}),r.jsx(Ne,{value:O.customMatcher||"",onChange:re=>{const le=[...Ba];le[B].customMatcher=re.target.value,or(le)},placeholder:"e.g., context.headers.get('x-custom') === 'value'",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Leave empty to use default path matching"})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[r.jsx(hi,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Hook Logic (TypeScript)"})]}),r.jsx("p",{className:"text-xs text-gray-400 mb-2 font-mono",children:"This is the TypeScript code that will be executed when the hook is triggered. This function has properties like ctx so you can access the request context, headers, body, etc. Here is a simple example of a hook logic:"}),r.jsx(lw,{value:O.hookLogic,onChange:re=>{const le=[...Ba];le[B].hookLogic=re,or(le)},language:"typescript",placeholder:"const context = ctx;",className:"w-full"})]}),r.jsxs($,{variant:"outline",onClick:()=>{or(Ba.filter((re,le)=>le!==B))},className:"w-full border border-dashed border-red-500/50 text-red-400 hover:bg-red-500/10 rounded-none",children:[r.jsx(dt,{className:"w-4 h-4 mr-2"}),"Remove Hook"]})]})]},B)})})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Mn,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Middleware"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>us([...Ar,{name:"",path:"/my-plugin/protected",pathType:"exact",middlewareLogic:"const context = ctx;",expanded:!0}]),className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Add Middleware"})]}),Ar.length===0?r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:"No middleware added"}):r.jsx("div",{className:"space-y-2",children:Ar.map((O,B)=>{const J=`${O.path}: ${O.name||`Middleware ${B+1}`}`;return r.jsxs("div",{className:"border border-dashed border-white/10",children:[r.jsxs("button",{onClick:()=>NP(B),className:"w-full flex items-center justify-between p-3 hover:bg-white/5 transition-colors text-left",children:[r.jsx("span",{className:"text-xs font-mono text-white px-2 py-1 bg-black/40 border border-dashed border-white/20 rounded-none",children:J}),r.jsx(pd,{className:`w-4 h-4 text-white/60 transition-transform ${O.expanded?"rotate-90":""}`})]}),O.expanded&&r.jsxs("div",{className:"border-t border-dashed border-white/10 p-4 space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Middleware Name"}),r.jsx(Ne,{value:O.name,onChange:re=>{const le=[...Ar];le[B].name=re.target.value,us(le)},placeholder:"e.g., Auth Check, Rate Limiter",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Path"}),r.jsx(Ne,{value:O.path,onChange:re=>{const le=[...Ar];le[B].path=re.target.value,us(le)},placeholder:"/my-plugin/protected",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Path Type"}),r.jsxs(hn,{value:O.pathType,onValueChange:re=>{const le=[...Ar];le[B].pathType=re,us(le)},children:[r.jsx(fn,{className:"bg-black border border-dashed border-white/20 text-white rounded-none",children:r.jsx(Bn,{})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"exact",children:"Exact Match"}),r.jsx(Le,{value:"prefix",children:"Prefix Match"}),r.jsx(Le,{value:"regex",children:"Regex Match"})]})]})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[r.jsx(hi,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Middleware Logic (TypeScript)"})]}),r.jsx("p",{className:"text-xs text-gray-400 mb-2 font-mono",children:"This is the TypeScript code that will be executed when the middleware is triggered. You can access the request context, headers, body, etc."}),r.jsx(lw,{value:O.middlewareLogic,onChange:re=>{const le=[...Ar];le[B].middlewareLogic=re,us(le)},language:"typescript",placeholder:"const context = ctx;",className:"w-full"})]}),r.jsxs($,{variant:"outline",onClick:()=>{us(Ar.filter((re,le)=>le!==B))},className:"w-full border border-dashed border-red-500/50 text-red-400 hover:bg-red-500/10 rounded-none",children:[r.jsx(dt,{className:"w-4 h-4 mr-2"}),"Remove Middleware"]})]})]},B)})})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Ql,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Endpoints"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{const O="/my-plugin/endpoint",B=Mm(O);ro([...hs,{name:B,path:O,method:"POST",handlerLogic:`// Endpoint handler logic here
|
|
1144
1144
|
return ctx.json({ success: true });`,expanded:!0}])},className:"text-xs uppercase font-mono text-gray-400 hover:text-white rounded-none",children:"+ Add Endpoint"})]}),hs.length===0?r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:"No endpoints added"}):r.jsx("div",{className:"space-y-2",children:hs.map((O,B)=>{const J=`${O.method} ${O.path}: ${O.name||Mm(O.path)||`Endpoint ${B+1}`}`;return r.jsxs("div",{className:"border border-dashed border-white/10",children:[r.jsxs("button",{onClick:()=>SP(B),className:"w-full flex items-center justify-between p-3 hover:bg-white/5 transition-colors text-left",children:[r.jsx("span",{className:"text-xs font-mono text-white px-2 py-1 bg-black/40 border border-dashed border-white/20 rounded-none",children:J}),r.jsx(pd,{className:`w-4 h-4 text-white/60 transition-transform ${O.expanded?"rotate-90":""}`})]}),O.expanded&&r.jsxs("div",{className:"border-t border-dashed border-white/10 p-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Path"}),r.jsx(Ne,{value:O.path,onChange:re=>{const le=re.target.value,he=Mm(le),et=[...hs];et[B].path=le,et[B].name=he,ro(et)},placeholder:"/sign-in/anonymous",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Endpoint Name (Auto-generated)"}),r.jsx(Ne,{value:O.name,readOnly:!0,className:"bg-black/50 border border-dashed border-white/10 text-white/70 rounded-none cursor-not-allowed"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Generated from path"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Method"}),r.jsxs(hn,{value:O.method,onValueChange:re=>{const le=[...hs];le[B].method=re,ro(le)},children:[r.jsx(fn,{className:"bg-black border border-dashed border-white/20 text-white rounded-none",children:r.jsx(Bn,{})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"GET",children:"GET"}),r.jsx(Le,{value:"POST",children:"POST"})]})]})]})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[r.jsx(hi,{className:"w-4 h-4 text-white"}),r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Handler Logic (TypeScript)"})]}),r.jsx("p",{className:"text-xs text-gray-400 mb-2 font-mono",children:"This is the TypeScript code that will be executed when the endpoint is called. You can access the context via ctx parameter."}),r.jsx(lw,{value:O.handlerLogic,onChange:re=>{const le=[...hs];le[B].handlerLogic=re,ro(le)},language:"typescript",placeholder:"// Endpoint handler logic here\\nreturn ctx.json({ success: true });",className:"w-full"})]}),r.jsxs($,{variant:"outline",onClick:()=>{ro(hs.filter((re,le)=>le!==B))},className:"w-full border border-dashed border-red-500/50 text-red-400 hover:bg-red-500/10 rounded-none",children:[r.jsx(dt,{className:"w-4 h-4 mr-2"}),"Remove Endpoint"]})]})]},B)})})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[r.jsx(wf,{id:"rate-limit",checked:_m,onCheckedChange:O=>Rm(O===!0)}),r.jsx(ce,{htmlFor:"rate-limit",className:"text-xs uppercase font-mono text-gray-400 cursor-pointer",children:"Enable Rate Limiting"})]}),_m&&r.jsxs("div",{className:"border border-dashed border-white/10 p-4 space-y-4 mt-3",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Path"}),r.jsx(Ne,{value:ta.path,onChange:O=>{ei({...ta,path:O.target.value})},placeholder:"/my-plugin/*",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Path Type"}),r.jsxs(hn,{value:ta.pathType,onValueChange:O=>{ei({...ta,pathType:O})},children:[r.jsx(fn,{className:"bg-black border border-dashed border-white/20 text-white rounded-none",children:r.jsx(Bn,{})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"exact",children:"Exact Match"}),r.jsx(Le,{value:"prefix",children:"Prefix Match"}),r.jsx(Le,{value:"regex",children:"Regex Match"})]})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Window (ms)"}),r.jsx(Ne,{type:"number",value:ta.window||"",onChange:O=>{const B=O.target.value;ei({...ta,window:B===""?0:parseInt(B,10)||0})},onBlur:O=>{(!O.target.value||parseInt(O.target.value,10)<=0)&&ei({...ta,window:15*60*1e3})},placeholder:"900000",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Time window in milliseconds (e.g., 900000 = 15 minutes)"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Max Requests"}),r.jsx(Ne,{type:"number",value:ta.max||"",onChange:O=>{const B=O.target.value;ei({...ta,max:B===""?0:parseInt(B,10)||0})},onBlur:O=>{(!O.target.value||parseInt(O.target.value,10)<=0)&&ei({...ta,max:100})},placeholder:"100",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Maximum requests per window"})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{km(""),Am(""),Om("react"),wn([]),or([]),us([]),ro([]),Rm(!1),ei({path:"/my-plugin/*",pathType:"prefix",window:15*60*1e3,max:100}),qc(null),Gc(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Reset"}),r.jsx($,{onClick:jP,disabled:wE||!al.trim(),className:"rounded-none",children:wE?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Plugin"})]}),SE&&r.jsx("div",{className:"border border-dashed border-red-500/30 bg-red-500/10 text-red-300 text-xs font-mono p-3 rounded-none",children:SE}),Rt&&r.jsxs("div",{ref:yE,className:"space-y-4 border border-dashed border-white/15 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("p",{className:"text-xs uppercase font-mono text-gray-400",children:"Generated Code"}),r.jsxs("div",{className:"flex items-center space-x-2",children:[ti==="clientSetup"&&r.jsxs("div",{className:"flex items-center space-x-2 mr-2",children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 whitespace-nowrap",children:"Framework:"}),r.jsxs(hn,{value:jE,onValueChange:O=>{Om(O),EP(O)},children:[r.jsx(fn,{className:"bg-black sm:w-56 border border-dashed border-white/20 text-white rounded-none w-[220px] h-10 text-xs font-mono uppercase px-4 py-2",children:r.jsx(Bn,{className:"font-mono uppercase text-xs text-white"})}),r.jsxs(pn,{className:"font-mono uppercase text-[10px] bg-black border border-dashed border-white/20",children:[r.jsxs(Le,{value:"react",className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",children:[" ","React"]}),r.jsxs(Le,{value:"svelte",className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",children:[" ","Svelte"]}),r.jsxs(Le,{value:"solid",className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",children:[" ","Solid"]}),r.jsxs(Le,{value:"vue",className:"sm:text-[11px] text-white/90 border-b border-dashed last:border-b-0",children:[" ","Vue"]})]})]})]}),r.jsxs($,{variant:"ghost",size:"sm",onClick:()=>{var et,wt,qn,pt,Nt;const O=Rt[ti],B=((Nt=[{id:"server",path:((et=Rt.filePaths)==null?void 0:et.server)||`plugin/${Rt.name}/index.ts`},{id:"client",path:((wt=Rt.filePaths)==null?void 0:wt.client)||`plugin/${Rt.name}/client/index.ts`},{id:"serverSetup",path:((qn=Rt.filePaths)==null?void 0:qn.serverSetup)||"auth.ts"},{id:"clientSetup",path:((pt=Rt.filePaths)==null?void 0:pt.clientSetup)||"auth-client.ts"}].find(ps=>ps.id===ti))==null?void 0:Nt.path)||`${Rt.name}-${ti}.ts`,J=new Blob([O],{type:"text/plain"}),re=window.URL.createObjectURL(J),le=document.createElement("a");le.href=re;const he=B.split("/").pop()||B;le.download=he,document.body.appendChild(le),le.click(),document.body.removeChild(le),window.URL.revokeObjectURL(re)},className:"text-gray-400 hover:text-white rounded-none",children:[r.jsx(Ul,{className:"w-4 h-4 mr-1"}),"Download"]})]})]}),r.jsx("div",{className:"flex space-x-2 border-b border-dashed border-white/10",children:[{id:"server",label:"Server Plugin",path:((kE=Rt.filePaths)==null?void 0:kE.server)||`plugin/${Rt.name}/index.ts`},{id:"client",label:"Client Plugin",path:((AE=Rt.filePaths)==null?void 0:AE.client)||`plugin/${Rt.name}/client/index.ts`},{id:"serverSetup",label:"Server Setup",path:((_E=Rt.filePaths)==null?void 0:_E.serverSetup)||"auth.ts"},{id:"clientSetup",label:"Client Setup",path:((RE=Rt.filePaths)==null?void 0:RE.clientSetup)||"auth-client.ts"}].map(O=>r.jsx("button",{onClick:()=>EE(O.id),className:`px-3 py-2 text-xs uppercase font-mono border-b-2 transition-colors ${ti===O.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white"}`,title:O.path,children:O.label},O.id))}),r.jsx("div",{className:"border border-dashed border-white/10",children:r.jsx(m6,{code:Rt[ti],language:"typescript",fileName:((LE=[{id:"server",path:((OE=Rt.filePaths)==null?void 0:OE.server)||`plugin/${Rt.name}/index.ts`},{id:"client",path:((DE=Rt.filePaths)==null?void 0:DE.client)||`plugin/${Rt.name}/client/index.ts`},{id:"serverSetup",path:((IE=Rt.filePaths)==null?void 0:IE.serverSetup)||"auth.ts"},{id:"clientSetup",path:((ME=Rt.filePaths)==null?void 0:ME.clientSetup)||"auth-client.ts"}].find(O=>O.id===ti))==null?void 0:LE.path)||`${Rt.name}-${ti}.ts`})})]})]})]})}),q&&I&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 overflow-hidden",onClick:O=>{O.target===O.currentTarget&&(C(!1),z(null))},children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",onClick:O=>O.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(wp,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Configuration Validator"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{C(!1),z(null)},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"mb-6 p-4 border border-dashed border-white/10",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-400 mb-3",children:"Summary"}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"text-left border-r border-dashed border-white/10 pr-4 last:border-r-0",children:[r.jsx("div",{className:"text-2xl font-mono text-white",children:I.summary.total}),r.jsx("div",{className:"text-xs text-gray-400 uppercase mt-1 font-mono",children:"Total Checks"})]}),r.jsxs("div",{className:"text-left border-r border-dashed border-white/10 pr-4 last:border-r-0",children:[r.jsx("div",{className:"text-2xl font-mono text-white",children:I.summary.passes}),r.jsx("div",{className:"text-xs text-gray-400 uppercase mt-1 font-mono",children:"Passed"})]}),r.jsxs("div",{className:"text-left border-r border-dashed border-white/10 pr-4 last:border-r-0",children:[r.jsx("div",{className:"text-2xl font-mono text-white",children:I.summary.errors}),r.jsx("div",{className:"text-xs text-gray-400 uppercase mt-1 font-mono",children:"Errors"})]}),r.jsxs("div",{className:"text-left",children:[r.jsx("div",{className:"text-2xl font-mono text-white",children:I.summary.warnings}),r.jsx("div",{className:"text-xs text-gray-400 uppercase mt-1 font-mono",children:"Warnings"})]})]})]}),r.jsx("div",{className:"space-y-4",children:Object.entries(I.results.reduce((O,B)=>(O[B.category]||(O[B.category]=[]),O[B.category].push(B),O),{})).map(([O,B])=>{if(O==="OAuth Providers"){const J=B.reduce((re,le)=>{const he=le.check.match(/^(.+?)\s*-\s*(.+)$/);if(he){const et=he[1],wt=he[2];re[et]||(re[et]=[]),re[et].push({...le,check:wt})}else re.General||(re.General=[]),re.General.push(le);return re},{});return r.jsxs("div",{className:"border border-dashed border-white/10 p-4",children:[r.jsxs("h4",{className:"text-white font-mono uppercase text-xs mb-4 text-left",children:[O,r.jsxs("span",{className:"text-gray-500 font-normal ml-2",children:["(",B.length," check",B.length!==1?"s":"",")"]})]}),r.jsx("div",{className:"space-y-2",children:Object.entries(J).map(([re,le])=>{const he=W.has(re),et=le.some(pt=>pt.severity==="error"),wt=le.some(pt=>pt.severity==="warning"),qn=le.every(pt=>pt.status==="pass");return r.jsxs("div",{className:"border border-dashed border-white/10",children:[r.jsxs("button",{onClick:()=>{Y(pt=>{const Nt=new Set(pt);return Nt.has(re)?Nt.delete(re):Nt.add(re),Nt})},className:"w-full flex items-center justify-between p-3 hover:bg-white/5 transition-colors text-left",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(pd,{className:`w-4 h-4 text-white/60 transition-transform ${he?"rotate-90":""}`}),r.jsx("span",{className:"text-white font-mono text-sm",children:re}),r.jsxs("span",{className:"text-xs text-gray-500 font-mono",children:["(",le.length," check",le.length!==1?"s":"",")"]})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[et&&r.jsx("span",{className:"text-xs text-white/60 font-mono",children:"Error"}),wt&&!et&&r.jsx("span",{className:"text-xs text-white/60 font-mono",children:"Warning"}),qn&&!et&&!wt&&r.jsx(Td,{className:"w-4 h-4 text-white/60"})]})]}),he&&r.jsx("div",{className:"border-t border-dashed border-white/10 space-y-2 p-2",children:le.map((pt,Nt)=>r.jsx("div",{className:`p-3 border-l border-dashed border-white/15 ${pt.status==="pass"?"bg-green-600/[8%]":"bg-red-600/[8%]"}`,children:r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx("div",{className:"mt-0.5",children:pt.severity==="error"?r.jsx(Ns,{className:"w-4 h-4 text-white/60"}):pt.severity==="warning"?r.jsx(sd,{className:"w-4 h-4 text-white/60"}):pt.status==="pass"?r.jsx(Td,{className:"w-4 h-4 text-white/60"}):r.jsx(Pl,{className:"w-4 h-4 text-white/40"})}),r.jsxs("div",{className:"flex-1 text-left",children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[r.jsx("span",{className:"text-white font-mono text-sm",children:pt.check}),r.jsx("span",{className:"text-xs px-2 py-0.5 border border-dashed border-white/20 text-white/60 font-mono",children:pt.status.toUpperCase()})]}),r.jsx("p",{className:"text-gray-300 text-sm",children:pt.message}),pt.suggestion&&r.jsxs("div",{className:"mt-2 p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("p",{className:"text-xs text-gray-400 uppercase mb-1 font-mono",children:"Suggestion"}),r.jsx("p",{className:"text-xs text-gray-300",children:pt.suggestion})]})]})]})},`${re}-${pt.check}-${Nt}`))})]},re)})})]},O)}return r.jsxs("div",{className:"border border-dashed border-white/10 p-4",children:[r.jsxs("h4",{className:"text-white font-mono uppercase text-xs mb-4 text-left",children:[O,r.jsxs("span",{className:"text-gray-500 font-normal ml-2",children:["(",B.length," check",B.length!==1?"s":"",")"]})]}),r.jsx("div",{className:"space-y-3",children:B.map((J,re)=>r.jsx("div",{className:`p-3 border-l border-dashed border-white/15 ${J.status==="pass"?"bg-green-600/[8%]":"bg-red-600/[8%]"}`,children:r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx("div",{className:"mt-0.5",children:J.severity==="error"?r.jsx(Ns,{className:"w-4 h-4 text-white/60"}):J.severity==="warning"?r.jsx(sd,{className:"w-4 h-4 text-white/60"}):J.status==="pass"?r.jsx(Td,{className:"w-4 h-4 text-white/60"}):r.jsx(Pl,{className:"w-4 h-4 text-white/40"})}),r.jsxs("div",{className:"flex-1 text-left",children:[r.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[r.jsx("span",{className:"text-white font-mono text-sm",children:J.check}),r.jsx("span",{className:"text-xs px-2 py-0.5 border border-dashed border-white/20 text-white/60 font-mono",children:J.status.toUpperCase()})]}),r.jsx("p",{className:"text-gray-300 text-sm",children:J.message}),J.suggestion&&r.jsxs("div",{className:"mt-2 p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("p",{className:"text-xs text-gray-400 uppercase mb-1 font-mono",children:"Suggestion"}),r.jsx("p",{className:"text-xs text-gray-300",children:J.suggestion})]})]})]})},`${J.category}-${J.check}-${re}`))})]},O)})}),r.jsx("div",{className:"mt-6 flex justify-end",children:r.jsx($,{variant:"outline",onClick:()=>{C(!1),z(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),ct&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",onClick:O=>{O.target===O.currentTarget&&it(!1)},children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",onClick:O=>O.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Uh,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"UUID Generator"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>it(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Generate UUIDs"}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Count (1-100)"}),r.jsx(Ne,{type:"number",value:cn,onChange:O=>{const B=O.target.value;if(B===""){Tn("");return}const J=parseInt(B);isNaN(J)||Tn(B)},onBlur:O=>{const B=O.target.value,J=parseInt(B);isNaN(J)||J<1?Tn("1"):J>100?Tn("100"):Tn(String(J))},min:"1",max:"100",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{Tn("1"),nn([])},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:gP,className:"rounded-none",children:"Generate UUIDs"})]})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Validate UUID"}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("div",{children:r.jsx(Ne,{value:ns,onChange:O=>{Dn(O.target.value)},onBlur:bP,placeholder:"Paste UUID to validate",className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs rounded-none"})}),r.jsx("div",{className:"flex items-end justify-end space-x-2",children:r.jsx($,{variant:"outline",onClick:()=>{Dn(""),rr(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"})})]}),Hn&&r.jsx("div",{className:`mt-2 border border-dashed p-3 rounded-none ${Hn.isValid?"border-white/10 bg-black/40":"border-red-500/30 bg-red-500/10"}`,children:r.jsxs("div",{className:"text-xs font-mono space-y-1",children:[r.jsx("div",{className:`${Hn.isValid?"text-green-400":"text-red-300"}`,children:Hn.isValid?"✓ Valid UUID":"✗ Invalid UUID"}),Hn.isValid&&Hn.version&&r.jsxs("div",{className:"text-gray-400",children:["Version: ",Hn.version]}),Hn.isValid&&Hn.variant&&r.jsxs("div",{className:"text-gray-400",children:["Variant: ",Hn.variant]})]})})]}),yn.length>0&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400",children:"Generated UUIDs"}),r.jsxs($,{variant:"ghost",size:"sm",onClick:()=>za(yn.join(`
|
|
1145
|
-
`)),className:"text-gray-400 hover:text-white rounded-none",children:[r.jsx(xa,{className:"w-4 h-4 mr-1"}),"Copy All"]})]}),r.jsx("div",{className:"border border-dashed border-white/10 p-3",children:r.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:yn.map((O,B)=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("span",{className:"text-white font-mono text-xs break-all",children:O}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(O),className:"text-gray-400 hover:text-white rounded-none ml-2",children:r.jsx(xa,{className:"w-3 h-3"})})]},B))})})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Version"}),r.jsx("p",{className:"text-white text-sm",children:"v4 (Random)"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"Cryptographically random"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Format"}),r.jsx("p",{className:"text-white text-sm",children:"8-4-4-4-12"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"36 characters"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Standard"}),r.jsx("p",{className:"text-white text-sm",children:"RFC 4122"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"Universally unique"})]})]})]})]})}),as&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Kl,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Password Strength Checker"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>el(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Password"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{type:Sr?"text":"password",value:Ys,onChange:O=>Pn(O.target.value),placeholder:"Enter password to check",className:"w-full bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>os(!Sr),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:Sr?r.jsx(pf,{className:"w-4 h-4"}):r.jsx(Ms,{className:"w-4 h-4"})})]})]}),r.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{Pn(""),rs(null),os(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:cP,disabled:ss||!Ys.trim(),className:"rounded-none",children:ss?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking..."]}):"Check Strength"})]}),It&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Strength"}),r.jsx("p",{className:`text-sm font-medium ${It.strength==="very-strong"?"text-green-400":It.strength==="strong"?"text-green-300":It.strength==="good"?"text-yellow-300":It.strength==="fair"?"text-orange-300":"text-red-300"}`,children:It.strength.split("-").map(O=>O.charAt(0).toUpperCase()+O.slice(1)).join(" ")}),r.jsx("div",{className:"w-full bg-black/40 h-2 rounded-none",children:r.jsx("div",{className:`h-full transition-all ${It.strength==="very-strong"?"bg-green-400 w-full":It.strength==="strong"?"bg-green-300 w-4/5":It.strength==="good"?"bg-yellow-300 w-3/5":It.strength==="fair"?"bg-orange-300 w-2/5":"bg-red-300 w-1/5"}`})})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Score"}),r.jsxs("p",{className:"text-white text-sm",children:[It.score," / 5"]}),r.jsx("p",{className:"text-gray-500 text-xs",children:It.score===5?"Excellent":It.score===4?"Very Good":It.score===3?"Good":It.score===2?"Fair":"Weak"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Config Match"}),r.jsx("p",{className:`text-sm ${It.meetsConfig?"text-green-400":"text-red-300"}`,children:It.meetsConfig?"✓ Meets Requirements":"✗ Fails Requirements"}),r.jsxs("p",{className:"text-gray-500 text-xs",children:[It.configRequirements.minLength," -"," ",It.configRequirements.maxLength," chars"]})]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-400 mb-3",children:"Checks"}),r.jsx("div",{className:"space-y-2",children:It.checks.map((O,B)=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("span",{className:"text-white font-mono text-xs",children:O.name}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("span",{className:`text-xs font-mono ${O.passed?"text-green-400":"text-red-300"}`,children:O.passed?"✓":"✗"}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:O.message})]})]},B))})]})]})]})]})}),Er&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(la,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"OAuth Credentials"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>Ws(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Select Provider"}),r.jsx("div",{className:"flex flex-wrap gap-3",children:["google","github"].map(O=>{const B=f===O;return r.jsx("button",{onClick:()=>m(O),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors ${B?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:O.charAt(0).toUpperCase()+O.slice(1)},O)})})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Origin"}),r.jsx(Ne,{value:fa,onChange:O=>Qn(O.target.value),placeholder:`http://${Pa}`,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs rounded-none"}),r.jsxs("p",{className:"text-[11px] text-gray-500 font-mono mt-1",children:["The default will be http://",Pa]})]}),r.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{Jn(null),Qn(Pa)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:pP,disabled:sr||!f||!fa.trim()&&!Pa,className:"rounded-none",children:sr?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Fetching..."]}):"Fetch Credentials"})]}),pa&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Client ID"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:pa.clientId,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(pa.clientId),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-4 h-4"})})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Client Secret"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{type:Zs?"text":"password",value:pa.clientSecret,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-20 rounded-none"}),r.jsxs("div",{className:"absolute right-0 top-0 h-full flex items-center",children:[r.jsx($,{variant:"ghost",size:"sm",onClick:()=>tl(!Zs),className:"px-2 text-gray-400 hover:text-white rounded-none",children:Zs?r.jsx(pf,{className:"w-4 h-4"}):r.jsx(Ms,{className:"w-4 h-4"})}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(pa.clientSecret),className:"px-2 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-4 h-4"})})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-dashed border-white/10",children:[r.jsx("div",{className:"flex-1",children:xt&&r.jsx("div",{className:"text-xs font-mono",children:xt.success?r.jsxs("span",{className:"text-green-400 uppercase",children:["✓ ",xt.message.toLowerCase(),r.jsxs("span",{className:"block normal-case text-gray-400",children:[r.jsx("span",{className:"text-gray-400 mr-1",children:">"})," ",xt.path]})]}):r.jsxs("span",{className:"text-red-300",children:["✗ ",xt.message]})})}),r.jsx($,{onClick:mP,disabled:Qs||cs,className:"rounded-none",children:cs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking..."]}):Qs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Uh,{className:"w-4 h-4 mr-2"}),"Write to .env"]})})]})]})]})]})}),ao&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(vo,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Secret Generator"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>ds(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Length (bytes)"}),r.jsx(Ne,{type:"number",value:ea===0?"":ea,onChange:O=>{const B=O.target.value;if(B===""){ma(0);return}const J=parseInt(B,10);isNaN(J)||ma(J)},onBlur:O=>{const B=parseInt(O.target.value,10);isNaN(B)||B<16?ma(32):B>128?ma(128):ma(B)},min:"16",max:"128",className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 font-mono mt-1",children:"Recommended: 32 bytes (256 bits)"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Format"}),r.jsx("div",{className:"flex gap-3",children:[{id:"hex",label:"Hex"},{id:"base64",label:"Base64"}].map(O=>r.jsx("button",{onClick:()=>kr(O.id),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors flex-1 ${Cr===O.id?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:O.label},O.id))})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{qe(null),ma(32),kr("hex")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:uP,disabled:Lt,className:"rounded-none",children:Lt?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Secret"})]}),Se&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Length"}),r.jsxs("p",{className:"text-white text-sm",children:[Se.length," bytes"]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Entropy"}),r.jsxs("p",{className:"text-white text-sm",children:[Se.entropy," bits"]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Format"}),r.jsx("p",{className:"text-white text-sm uppercase",children:Se.format})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Generated Secret"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:Se.secret,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(Se.secret),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-3 h-3"})})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Environment Variable Format"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:Se.envFormat,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(Se.envFormat),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-3 h-3"})})]}),r.jsxs("p",{className:"text-[11px] text-gray-500 font-mono mt-2",children:["Add this to your ",r.jsx("code",{className:"text-gray-400",children:".env"})," file. Keep it secret and never commit it to version control."]})]}),r.jsx("div",{className:"flex justify-end space-x-2 pt-2",children:r.jsx($,{variant:"outline",onClick:hP,disabled:fe||De,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:fe||De?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),De?"Writing...":"Checking..."]}):"Write to .env"})}),r.jsx("div",{className:"border border-dashed border-white/20 bg-black text-gray-300 text-xs font-mono p-3 rounded-none",children:r.jsxs("div",{className:"flex items-start space-x-2",children:[r.jsx(sd,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-400"}),r.jsxs("div",{children:[r.jsx("div",{className:"uppercase font-mono mb-2 text-gray-400 tracking-wider",children:"Security Best Practices"}),r.jsxs("ul",{className:"list-disc list-inside space-y-1 text-[11px] text-gray-300",children:[r.jsx("li",{children:"Use a minimum of 32 bytes (256 bits) for production"}),r.jsx("li",{children:"Store secrets in environment variables, never in code"}),r.jsx("li",{children:"Use different secrets for development and production"}),r.jsx("li",{children:"Rotate secrets periodically for enhanced security"})]})]})]})})]})]})]})}),Tr&&ls&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[70] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(sd,{className:"w-5 h-5 text-yellow-400"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Overwrite Existing Credentials?"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Js(!1),ir(null),Fa(!1)},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"border border-dashed border-white/20 p-4",children:[r.jsxs("p",{className:"text-sm border-b border-dashed border-white/20 pb-5 text-gray-300 font-mono mb-3",children:["The following"," ",r.jsx("span",{className:"text-white uppercase",children:(f==null?void 0:f.charAt(0).toUpperCase())+(f==null?void 0:f.slice(1))})," ","credentials already exist in"," ",r.jsx("span",{className:"text-gray-400 normal-case",children:ls.path}),":"]}),r.jsx("div",{className:"space-y-2 pt-2",children:Object.entries(ls.credentials).map(([O,B])=>r.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[r.jsx("span",{className:"text-gray-400 uppercase",children:O}),r.jsx("span",{className:"text-gray-500",children:B.length>20?`${B.substring(0,20)}...`:B})]},O))})]}),r.jsxs("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t border-dashed border-white/10",children:[r.jsx($,{variant:"outline",onClick:()=>{Js(!1),ir(null),Fa(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"No, Cancel"}),r.jsx($,{variant:"outline",onClick:()=>Im("append"),disabled:Qs,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Append"}),r.jsx($,{onClick:()=>Im("override"),disabled:Qs,className:"rounded-none",children:Qs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):"Yes, Overwrite"})]})]})]})}),nl&&Ee&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[70] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(sd,{className:"w-5 h-5 text-yellow-400"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Overwrite Existing Secret?"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{we(!1),Re(null),Ce(!1)},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"border border-dashed border-white/20 p-4",children:[r.jsxs("p",{className:"text-sm border-b border-dashed border-white/20 pb-5 text-gray-300 font-mono mb-3",children:[r.jsx("span",{className:"text-white uppercase",children:"BETTER_AUTH_SECRET"})," already exists in"," ",r.jsx("span",{className:"text-gray-400 normal-case",children:Ee.path}),":"]}),r.jsx("div",{className:"space-y-2 pt-2",children:r.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[r.jsx("span",{className:"text-gray-400 uppercase",children:"BETTER_AUTH_SECRET"}),r.jsx("span",{className:"text-gray-500",children:Ee.secret&&Ee.secret.length>20?`${Ee.secret.substring(0,20)}...`:Ee.secret||"***"})]})})]}),r.jsxs("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t border-dashed border-white/10",children:[r.jsx($,{variant:"outline",onClick:()=>{we(!1),Re(null),Ce(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"No, Cancel"}),r.jsx($,{onClick:()=>CE("override"),disabled:De,className:"rounded-none",children:De?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):"Yes, Overwrite"})]})]})]})})]})}function Jfe(){const{userId:e}=Q1(),t=yr(),[n,a]=p.useState(null),[s,i]=p.useState([]),[o,l]=p.useState([]),[c,u]=p.useState([]),[h,d]=p.useState([]),[f,m]=p.useState(!0),[y,x]=p.useState("details"),[N,b]=p.useState(!1),[v,g]=p.useState(!1),[w,S]=p.useState(!1),[E,j]=p.useState(!1),[_,M]=p.useState(!1),[U,L]=p.useState("random"),[F,G]=p.useState(!1),[A,P]=p.useState(!1),[R,k]=p.useState(!1),[T,D]=p.useState(""),[q,C]=p.useState(),[I,z]=p.useState(!1),[W,Y]=p.useState(""),[ae,ne]=p.useState([]),[X,ie]=p.useState(!1),[ve,se]=p.useState({}),ge=p.useRef({}),be=p.useCallback(async()=>{try{const pe=await(await fetch("/api/admin/status")).json();z(pe.enabled)}catch{z(!1)}},[]),Ue=p.useCallback(async K=>{try{const pe=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:K})});if(pe.ok){const ye=await pe.json();if(ye.success&&ye.location)return ye.location}return null}catch{return null}},[]),Be=p.useCallback(async K=>{const pe=K.filter(ze=>!ge.current[ze.id]);if(pe.length===0)return;const ye=await Promise.all(pe.map(async ze=>{const tt=await Ue(ze.ipAddress);return tt?{sessionId:ze.id,location:tt}:null})),Te={};ye.forEach(ze=>{ze&&(Te[ze.sessionId]=ze.location)}),Object.keys(Te).length>0&&(ge.current={...ge.current,...Te},se(ge.current))},[Ue]),$e=K=>{if(!K)return"🌍";const pe=K.toUpperCase().split("").map(ye=>127397+ye.charCodeAt(0));return String.fromCodePoint(...pe)},Ye=K=>K?K.replace(/[_-]/g," ").replace(/\b\w/g,pe=>pe.toUpperCase()):"Unknown Provider",bt=K=>{if(!K)return"Unknown";const pe=new Date(K);return Number.isNaN(pe.getTime())?"Unknown":pe.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},Ke=p.useCallback(async()=>{try{const K=await fetch(`/api/users/${e}`);if(K.ok){const pe=await K.json();a(pe.user)}else V.error("Failed to fetch user details"),t("/users")}catch{V.error("Failed to fetch user details"),t("/users")}finally{m(!1)}},[e,t]),de=p.useCallback(async()=>{try{const[K,pe,ye]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(K.ok){const Te=await K.json();i(Te.memberships||[])}if(pe.ok){const Te=await pe.json();l(Te.memberships||[])}if(ye.ok){const ze=(await ye.json()).sessions||[];u(ze),Be(ze)}}catch{}},[e,Be]),Fe=p.useCallback(async()=>{try{const K=await fetch(`/api/users/${e}/accounts`);if(K.ok){const pe=await K.json();d(pe.accounts||[])}}catch{}},[e]),Ie=async()=>{var Te,ze;if(!n)return;const K=(Te=document.getElementById("edit-name"))==null?void 0:Te.value,pe=(ze=document.getElementById("edit-email"))==null?void 0:ze.value;if(!K||!pe){V.error("Please fill in all fields");return}const ye=V.loading("Updating user...");try{const ee=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K,email:pe,role:W||null})})).json();ee.success?(a({...n,name:K,email:pe,role:W||void 0}),b(!1),Y(""),V.success("User updated successfully!",{id:ye})):V.error(`Error updating user: ${ee.error||"Unknown error"}`,{id:ye})}catch{V.error("Error updating user",{id:ye})}},Ae=async()=>{if(!n)return;const K=V.loading("Deleting user...");try{const ye=await(await fetch(`/api/users/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ye.success?(V.success("User deleted successfully!",{id:K}),t("/users")):V.error(`Error deleting user: ${ye.error||"Unknown error"}`,{id:K})}catch{V.error("Error deleting user",{id:K})}},We=async()=>{if(!n)return;if(!I){V.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use ban functionality.");return}const K=V.loading("Banning user...");try{const pe=await fetch("/api/admin/ban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,banReason:T||"No reason provided",banExpiresIn:q})}),ye=await pe.json();pe.ok?(V.success("User banned successfully!",{id:K}),g(!1),D(""),C(void 0),Ke()):pe.status===403?V.error("You do not have permission to ban users. Admin role required.",{id:K}):ye.adminPluginEnabled&&ye.instructions?V.error(`${ye.error}`,{id:K,duration:6e3,description:`Use: ${ye.instructions.example}`}):V.error(`Error banning user: ${ye.error||ye.message||"Unknown error"}`,{id:K})}catch{V.error("Error banning user",{id:K})}},at=async()=>{if(!n)return;if(!I){V.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use unban functionality.");return}const K=V.loading("Unbanning user...");try{const pe=await fetch("/api/admin/unban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})}),ye=await pe.json();pe.ok?(V.success("User unbanned successfully!",{id:K}),S(!1),Ke()):pe.status===403?V.error("You do not have permission to unban users. Admin role required.",{id:K}):ye.adminPluginEnabled&&ye.instructions?V.error(`${ye.error}`,{id:K,duration:6e3,description:`Use: ${ye.instructions.example}`}):V.error(`Error unbanning user: ${ye.error||ye.message||"Unknown error"}`,{id:K})}catch{V.error("Error unbanning user",{id:K})}},ft=async K=>{const pe=V.loading("Removing user from organization...");try{const Te=await(await fetch(`/api/organizations/members/${K}`,{method:"DELETE"})).json();Te.success?(i(ze=>ze.filter(tt=>tt.id!==K)),de(),V.success("User removed from organization!",{id:pe})):V.error(`Error removing user: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error removing user from organization",{id:pe})}},Yt=async K=>{const pe=V.loading("Removing user from team...");try{const Te=await(await fetch(`/api/teams/members/${K}`,{method:"DELETE"})).json();Te.success?(l(ze=>ze.filter(tt=>tt.id!==K)),de(),V.success("User removed from team!",{id:pe})):V.error(`Error removing user: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error removing user from team",{id:pe})}},Wt=async K=>{const pe=V.loading("Deleting session...");try{const Te=await(await fetch(`/api/sessions/${K}`,{method:"DELETE"})).json();Te.success?(u(ze=>ze.filter(tt=>tt.id!==K)),V.success("Session deleted successfully!",{id:pe})):V.error(`Error deleting session: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error deleting session",{id:pe})}},oe=async K=>{if(!e)return;const pe=V.loading("Unlinking account...");try{const ye=await fetch(`/api/users/${e}/accounts/${K}`,{method:"DELETE"}),Te=await ye.json();ye.ok&&Te.success?(d(ze=>ze.filter(tt=>tt.id!==K)),await Fe(),V.success("Account unlinked successfully",{id:pe})):V.error(Te.error||"Failed to unlink account",{id:pe})}catch{V.error("Failed to unlink account",{id:pe})}};p.useEffect(()=>{e&&(Ke(),de(),Fe(),be())},[e,be,Ke,de,Fe]);const _e=async(K=3)=>{if(e){ne([]),ie(!0),ne([{id:"start",type:"info",message:`Starting session seeding process for ${K} sessions...`,timestamp:new Date}]);try{const ye=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(ye.success){const Te=ye.results.map((tt,ee)=>tt.success?{id:`session-${ee}`,type:"progress",message:`Creating session ${ee+1}: ${tt.session.token.substring(0,20)}... from ${tt.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${ee}`,type:"error",message:`Failed to create session ${ee+1}: ${tt.error}`,timestamp:new Date});ne(tt=>[...tt,...Te]);const ze=ye.results.filter(tt=>tt.success).length;ne(tt=>[...tt,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${ze}/${K} sessions successfully`,timestamp:new Date}]),de()}else ne(Te=>[...Te,{id:"error",type:"error",message:`❌ Session seeding failed: ${ye.error||"Unknown error"}`,timestamp:new Date}])}catch(pe){ne(ye=>[...ye,{id:"error",type:"error",message:`❌ Network error: ${pe}`,timestamp:new Date}])}finally{ie(!1)}}},Ze=async(K=3,pe="random")=>{if(e){ne([]),ie(!0),ne([{id:"start",type:"info",message:`Starting account seeding process for ${K} accounts...`,timestamp:new Date}]);try{const Te=await(await fetch(`/api/users/${e}/seed-accounts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K,providerId:pe})})).json();if(Te.success){const ze=Te.results.map((ee,ue)=>{var Oe;return ee.success?{id:`account-${ue}`,type:"progress",message:`Creating account ${ue+1}: ${ee.account.providerId||ee.account.provider} (${((Oe=ee.account.accountId)==null?void 0:Oe.substring(0,20))||ee.account.id.substring(0,20)}...)`,timestamp:new Date,status:"completed"}:{id:`account-${ue}`,type:"error",message:`Failed to create account ${ue+1}: ${ee.error}`,timestamp:new Date}});ne(ee=>[...ee,...ze]);const tt=Te.results.filter(ee=>ee.success).length;ne(ee=>[...ee,{id:"complete",type:"success",message:`✅ Account seeding completed! Created ${tt}/${K} accounts successfully`,timestamp:new Date}]),Fe()}else ne(ze=>[...ze,{id:"error",type:"error",message:`❌ Account seeding failed: ${Te.error||"Unknown error"}`,timestamp:new Date}])}catch(ye){ne(Te=>[...Te,{id:"error",type:"error",message:`❌ Network error: ${ye}`,timestamp:new Date}])}finally{ie(!1)}}};return f?r.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:r.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):n?r.jsxs("div",{className:"space-y-6 p-6 bg-black w-full",children:[r.jsxs("div",{className:"w-full flex flex-col",children:[r.jsx("span",{className:"mb-4 ml-0 flex justify-start items-start text-left border-none text-white",children:r.jsxs("span",{className:"font-light",children:[r.jsxs("span",{onClick:()=>t("/users"),className:"uppercase cursor-pointer text-white/80 font-mono text-sm",children:["users /"," "]}),r.jsx("span",{className:"text-white font-mono text-sm",children:n.id})]})}),r.jsx("div",{className:"mb-8 mt-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[r.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:n.image?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsxs("h1",{className:"text-3xl font-light text-white inline-flex items-center",children:[n.name,r.jsx(on,{id:n.id,nonSliced:!0,variant:"subscript"}),n.role&&r.jsx("sup",{className:"ml-2 px-2 pt-2 pb-2 -mt-1 py-0.5 text-[10px] font-mono uppercase border border-dashed border-white/15 bg-white/5 text-white/80 rounded-none",children:n.role}),n.banned&&r.jsxs("sup",{className:"relative group inline-block ml-2 px-2 pt-2 pb-2 -mt-1 py-0.5 text-[10px] font-mono uppercase border border-dashed border-red-500/30 bg-red-500/10 text-red-400/80 rounded-none cursor-help",children:["Banned",n.banReason&&r.jsxs("span",{className:"absolute lowercase left-1/2 -translate-x-1/2 bottom-full mb-3 px-2 py-2 text-[10px] font-mono text-gray-300 bg-black border border-dashed border-white/20 rounded-none whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-150 pointer-events-none z-50",children:[r.jsx("span",{className:"text-gray-400 font-mono text-xs uppercase mr-1",children:"Banned Reason:"}),n.banReason,r.jsx("span",{className:"absolute left-1/2 -translate-x-1/2 top-full w-0 h-0 border-l-[4px] border-r-[4px] border-t-[4px] border-transparent border-t-white/20"})]})]})]}),r.jsx("p",{className:"text-gray-400 font-mono text-sm",children:n.email})]})]}),r.jsx("div",{className:"flex items-center space-x-2",children:r.jsxs("div",{className:"relative",children:[r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:K=>{K.stopPropagation(),k(!R)},children:r.jsx(l3,{className:"w-4 h-4"})}),R&&r.jsxs("div",{className:"absolute z-[999] right-0 top-full mt-1 w-48 bg-black border border-white/20 rounded-none shadow-lg",onClick:K=>K.stopPropagation(),children:[r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),b(!0),Y(n.role||"")},children:[r.jsx(Po,{className:"w-4 h-4"}),r.jsx("span",{children:"Edit User"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),G(!0)},children:[r.jsx(Mn,{className:"w-4 h-4"}),r.jsx("span",{children:"Update Password"})]}),I&&(n.banned?r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-green-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),S(!0)},children:[r.jsx(eb,{className:"w-4 h-4"}),r.jsx("span",{children:"Unban User"})]}):r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-yellow-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),g(!0)},children:[r.jsx(eb,{className:"w-4 h-4"}),r.jsx("span",{children:"Ban User"})]})),r.jsx("div",{className:"border-t border-white/10 my-1"}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),P(!0)},children:[r.jsx(Qu,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete User"})]})]})]})})]})}),r.jsxs("div",{className:"border border-dashed border-white/20 rounded-none",children:[r.jsx("div",{className:"border-b border-dashed border-white/20",children:r.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:md},{id:"organizations",name:"Organizations",icon:Ca,count:s.length},{id:"teams",name:"Teams",icon:Ot,count:o.length},{id:"accounts",name:"Accounts",icon:bo,count:h.length},{id:"sessions",name:"Sessions",icon:jN,count:c.length}].map(K=>r.jsxs("button",{onClick:()=>x(K.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${y===K.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[r.jsx(K.icon,{className:"w-4 h-4 text-white/90"}),r.jsxs("span",{className:"inline-flex items-start",children:[r.jsx("span",{className:"font-mono uppercase text-xs font-normal",children:K.name}),K.count!==void 0&&r.jsx("sup",{className:"text-xs text-gray-500 ml-1 inline-flex items-baseline",children:r.jsx(An,{value:K.count,className:"text-white/80 font-mono text-xs",prefix:r.jsx("span",{className:"mr-0.5 text-gray-500",children:"["}),suffix:r.jsx("span",{className:"ml-0.5 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]})]},K.id))})}),r.jsxs("div",{className:"p-6",children:[y==="details"&&r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[r.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"BASIC INFORMATION"}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(md,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Name"}),r.jsx("div",{className:"text-white font-sans text-sm",children:n.name})]})]}),r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(ys,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Email"}),r.jsx("div",{className:"text-white font-mono text-sm",children:n.email})]})]}),n.username&&r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(gae,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Username"}),r.jsx("div",{className:"text-white font-mono text-sm",children:n.username})]})]}),n.phoneNumber&&r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(mae,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Phone"}),r.jsx("div",{className:"text-white font-mono text-sm",children:"+251 91 234 5678"})]})]}),r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(cr,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Member Since"}),r.jsx("div",{className:"text-white font-mono text-sm",children:new Date(n.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})})]})]})]})]}),r.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[r.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"SECURITY"}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/10 rounded-none",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(ys,{className:"w-4 h-4 text-gray-400"}),r.jsx("div",{children:r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Email Verification"})})]}),r.jsx("div",{className:`px-2 rounded-none border border-dashed border-white/20 uppercase py-1 text-xs font-mono ${n.emailVerified?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:n.emailVerified?"Verified":"Unverified"})]}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/10 rounded-none",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(Rs,{className:"w-4 h-4 text-gray-400"}),r.jsx("div",{children:r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Two-Factor Authentication"})})]}),r.jsx("div",{className:`px-2 rounded-none border border-dashed border-white/20 uppercase py-1 text-xs font-mono ${n.twoFactorEnabled?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:n.twoFactorEnabled?"Enabled":"Disabled"})]})]})]})]}),y==="organizations"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between mb-4",children:r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Organizations",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:s.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Organizations this user belongs to"})]})}),s.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ca,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),r.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):r.jsx("div",{className:"grid gap-4",children:s.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:K.organization.image?r.jsx("img",{src:K.organization.image,alt:K.organization.name,className:"w-12 h-12 object-cover"}):r.jsx(Ca,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[K.organization.name,r.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white/80 font-mono text-xs",children:K.organization.slug}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1 flex items-center gap-2",children:[r.jsxs("span",{children:["in ",K.organization.slug]}),r.jsx("button",{onClick:pe=>{pe.stopPropagation(),t(`/organizations/${K.organization.id}`)},className:"text-white/60 hover:text-white transition-colors",title:"View organization details",children:r.jsx(vu,{className:"w-3.5 h-3.5"})})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>ft(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},K.id))})]}),y==="teams"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between mb-4",children:r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Teams",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:o.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Teams this user belongs to"})]})}),o.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ot,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),r.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):r.jsx("div",{className:"grid gap-4",children:o.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:r.jsx(Ot,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[K.team.name,r.jsx(on,{id:K.team.id,variant:"subscript",nonSliced:!!(K.team.organizationSlug||K.team.organizationName)})]}),r.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1 flex items-center gap-2",children:[r.jsxs("span",{children:["in"," ",K.team.organizationSlug||K.team.organizationName]}),r.jsx("button",{onClick:pe=>{pe.stopPropagation(),K.team.organizationId?t(`/organizations/${K.team.organizationId}/teams/${K.team.id}`):t(`/teams/${K.team.id}`)},className:"text-white/60 hover:text-white transition-colors",title:"View team details",children:r.jsx(vu,{className:"w-3.5 h-3.5"})})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>Yt(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},K.id))})]}),y==="accounts"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Linked Accounts",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:h.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Manage user OAuth account connections"})]}),r.jsxs($,{variant:"outline",onClick:()=>{ne([]),ie(!1),M(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[r.jsx(bo,{className:"w-4 h-4 mr-2"}),"Seed Accounts"]})]}),h.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(bo,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Linked Accounts"}),r.jsx("p",{className:"text-gray-400",children:"This user has not connected any accounts yet."})]}):r.jsx("div",{className:"grid gap-4",children:h.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:Y6(K.providerId)}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[Ye(K.providerId),r.jsx(on,{id:K.accountId,variant:"subscript",nonSliced:!!(K.email||n.email)})]}),r.jsx("p",{className:"text-gray-400 tracking-tight uppercase text-xs font-mono mt-1",children:`ID: ${K.id}`})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2 text-right",children:r.jsxs("div",{className:"flex items-center space-x-2 text-xs font-mono text-gray-400",children:[r.jsx("span",{children:"Linked:"}),r.jsx("span",{className:"text-white",children:bt(K.createdAt||K.updatedAt)})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>oe(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Unlink"]})})]},K.id))})]}),y==="sessions"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Sessions",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:c.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Manage user authentication sessions"})]}),r.jsxs($,{variant:"outline",onClick:()=>{ne([]),ie(!1),j(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[r.jsx(Rs,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(jN,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),r.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):r.jsx("div",{className:"grid gap-4",children:c.map(K=>{var pe,ye,Te,ze;return r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:r.jsx(NC,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:["Session ",K.id.substring(0,8),"...",r.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white/80 font-mono text-xs",children:K.ipAddress}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsxs("div",{className:"flex items-center space-x-2 mt-2",children:[r.jsx(pae,{className:"w-3.5 h-3.5 text-gray-400"}),r.jsxs("span",{className:"text-gray-400 uppercase font-mono text-xs",children:[((pe=ve[K.id])==null?void 0:pe.city)||"...",","," ",((ye=ve[K.id])==null?void 0:ye.country)||"..."]}),((Te=ve[K.id])==null?void 0:Te.countryCode)&&r.jsx("span",{className:"text-xs ml-1",children:$e((ze=ve[K.id])==null?void 0:ze.countryCode)})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Expires:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.expiresAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>Wt(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(eb,{className:"w-4 h-4 mr-1"}),"Revoke"]})})]},K.id)})})]})]})]})]}),N&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{b(!1),Y("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.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?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-medium",children:n==null?void 0:n.name}),r.jsx("p",{className:"text-gray-400 text-sm",children:n==null?void 0:n.email})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),r.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"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),r.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"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Role"}),r.jsxs(hn,{className:"bg-black text-white",value:W,onValueChange:Y,children:[r.jsx(fn,{className:"w-full border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{b(!1),Y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),v&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-red-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),r.jsxs("p",{className:"text-gray-400 mb-4",children:["Ban ",r.jsx("strong",{children:n.name})," from accessing the system."]}),r.jsxs("div",{className:"space-y-4 mb-6",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banReason",className:"text-white",children:"Ban Reason"}),r.jsx(Ne,{id:"banReason",value:T,onChange:K=>D(K.target.value),placeholder:"Enter reason for ban (optional)",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banExpires",className:"text-white",children:"Ban Duration (seconds)"}),r.jsx(Ne,{id:"banExpires",type:"number",value:q||"",onChange:K=>C(K.target.value?Number(K.target.value):void 0),placeholder:"Leave empty for permanent ban",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Examples: 3600 (1 hour), 86400 (1 day), 604800 (1 week)"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{g(!1),D(""),C(void 0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:We,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),w&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-green-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Unban User"}),r.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to unban ",r.jsx("strong",{children:n.name}),"? This will restore their access to the system."]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>S(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:at,className:"bg-green-400 text-white hover:bg-green-700 rounded-none",children:"Unban User"})]})]})}),A&&n&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>P(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n.image?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:n.name}),r.jsx("div",{className:"text-sm text-gray-400",children:n.email})]})]}),r.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>P(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ae,className:"bg-red-500 hover:bg-red-600 text-white border border-red-500 rounded-none",children:"Delete"})]})]})}),F&&n&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Update Password"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>G(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"new-password",className:"text-sm text-gray-400 font-light",children:"New Password"}),r.jsx(Ne,{id:"new-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>G(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:async()=>{var ye;const K=(ye=document.getElementById("new-password"))==null?void 0:ye.value;if(!K){V.error("Please enter a password");return}const pe=V.loading("Updating password...");try{const ze=await(await fetch(`/api/users/${e}/password`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:K})})).json();ze.success?(G(!1),document.getElementById("new-password").value="",V.success("Password updated successfully!",{id:pe})):V.error(`Error updating password: ${ze.error||"Unknown error"}`,{id:pe})}catch{V.error("Error updating password",{id:pe})}},className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),E&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:r.jsxs("div",{className:"overflow-x-hidden overflow-y-auto bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none max-h-[90vh]",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(NC,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Sessions"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),r.jsx(Ne,{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"})]}),r.jsx($,{onClick:()=>{var pe;const K=parseInt(((pe=document.getElementById("session-count"))==null?void 0:pe.value)||"3",10);_e(K)},disabled:X,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:X?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Rs,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})}),ae.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"Session Seeding Terminal",lines:ae,isRunning:X,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>j(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),_&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:r.jsxs("div",{className:"overflow-x-hidden overflow-y-auto bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none max-h-[90vh]",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(bo,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Accounts"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>M(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),r.jsx(Ne,{id:"account-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"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"account-provider",className:"text-sm text-gray-400 font-light",children:"Provider"}),r.jsxs(hn,{value:U,onValueChange:L,children:[r.jsx(fn,{className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select provider"})}),r.jsxs(pn,{className:"bg-black border border-dashed border-white/20",children:[r.jsx(Le,{value:"random",children:"Mix (Random)"}),r.jsx(Le,{value:"github",children:"GitHub"}),r.jsx(Le,{value:"google",children:"Google"}),r.jsx(Le,{value:"discord",children:"Discord"}),r.jsx(Le,{value:"facebook",children:"Facebook"}),r.jsx(Le,{value:"twitter",children:"Twitter"}),r.jsx(Le,{value:"linkedin",children:"LinkedIn"}),r.jsx(Le,{value:"apple",children:"Apple"}),r.jsx(Le,{value:"microsoft",children:"Microsoft"}),r.jsx(Le,{value:"gitlab",children:"GitLab"}),r.jsx(Le,{value:"bitbucket",children:"Bitbucket"}),r.jsx(Le,{value:"spotify",children:"Spotify"}),r.jsx(Le,{value:"twitch",children:"Twitch"}),r.jsx(Le,{value:"reddit",children:"Reddit"}),r.jsx(Le,{value:"slack",children:"Slack"}),r.jsx(Le,{value:"notion",children:"Notion"}),r.jsx(Le,{value:"tiktok",children:"TikTok"}),r.jsx(Le,{value:"zoom",children:"Zoom"})]})]})]})]}),r.jsx($,{onClick:()=>{var pe;const K=parseInt(((pe=document.getElementById("account-count"))==null?void 0:pe.value)||"3",10);Ze(K,U)},disabled:X,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:X?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(bo,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]}),ae.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"Account Seeding Terminal",lines:ae,isRunning:X,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>M(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):r.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:r.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function epe(){return r.jsx(YK,{children:r.jsxs(D$,{children:[r.jsx(zQ,{children:r.jsxs(j$,{children:[r.jsx(Vn,{path:"/",element:r.jsx(Pae,{})}),r.jsx(Vn,{path:"/users",element:r.jsx(IU,{})}),r.jsx(Vn,{path:"/users/:userId",element:r.jsx(Jfe,{})}),r.jsx(Vn,{path:"/organizations",element:r.jsx(DU,{})}),r.jsx(Vn,{path:"/organizations/:orgId",element:r.jsx(gfe,{})}),r.jsx(Vn,{path:"/teams",element:r.jsx(vfe,{})}),r.jsx(Vn,{path:"/teams/:teamId",element:r.jsx(s4,{})}),r.jsx(Vn,{path:"/organizations/:orgId/teams/:teamId",element:r.jsx(s4,{})}),r.jsx(Vn,{path:"/sessions",element:r.jsx(bfe,{})}),r.jsx(Vn,{path:"/database",element:r.jsx(zae,{})}),r.jsx(Vn,{path:"/database/demo",element:r.jsx(VK,{})}),r.jsx(Vn,{path:"/emails",element:r.jsx(pfe,{})}),r.jsx(Vn,{path:"/tools",element:r.jsx(Qfe,{})}),r.jsx(Vn,{path:"/settings",element:r.jsx(xfe,{})})]})}),r.jsx(d8,{className:"rounded-none border-dashed border-white/20",theme:"dark",position:"top-right",richColors:!0,toastOptions:{style:{border:"dashed 1px #ffffff20",borderRadius:"0"},className:"font-mono uppercase"},closeButton:!0})]})})}Dz.createRoot(document.getElementById("root")).render(r.jsx(te.StrictMode,{children:r.jsx(epe,{})}));
|
|
1145
|
+
`)),className:"text-gray-400 hover:text-white rounded-none",children:[r.jsx(xa,{className:"w-4 h-4 mr-1"}),"Copy All"]})]}),r.jsx("div",{className:"border border-dashed border-white/10 p-3",children:r.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:yn.map((O,B)=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("span",{className:"text-white font-mono text-xs break-all",children:O}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(O),className:"text-gray-400 hover:text-white rounded-none ml-2",children:r.jsx(xa,{className:"w-3 h-3"})})]},B))})})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Version"}),r.jsx("p",{className:"text-white text-sm",children:"v4 (Random)"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"Cryptographically random"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Format"}),r.jsx("p",{className:"text-white text-sm",children:"8-4-4-4-12"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"36 characters"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Standard"}),r.jsx("p",{className:"text-white text-sm",children:"RFC 4122"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"Universally unique"})]})]})]})]})}),as&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Kl,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Password Strength Checker"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>el(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Password"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{type:Sr?"text":"password",value:Ys,onChange:O=>Pn(O.target.value),placeholder:"Enter password to check",className:"w-full bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>os(!Sr),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:Sr?r.jsx(pf,{className:"w-4 h-4"}):r.jsx(Ms,{className:"w-4 h-4"})})]})]}),r.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{Pn(""),rs(null),os(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:cP,disabled:ss||!Ys.trim(),className:"rounded-none",children:ss?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking..."]}):"Check Strength"})]}),It&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Strength"}),r.jsx("p",{className:`text-sm font-medium ${It.strength==="very-strong"?"text-green-400":It.strength==="strong"?"text-green-300":It.strength==="good"?"text-yellow-300":It.strength==="fair"?"text-orange-300":"text-red-300"}`,children:It.strength.split("-").map(O=>O.charAt(0).toUpperCase()+O.slice(1)).join(" ")}),r.jsx("div",{className:"w-full bg-black/40 h-2 rounded-none",children:r.jsx("div",{className:`h-full transition-all ${It.strength==="very-strong"?"bg-green-400 w-full":It.strength==="strong"?"bg-green-300 w-4/5":It.strength==="good"?"bg-yellow-300 w-3/5":It.strength==="fair"?"bg-orange-300 w-2/5":"bg-red-300 w-1/5"}`})})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Score"}),r.jsxs("p",{className:"text-white text-sm",children:[It.score," / 5"]}),r.jsx("p",{className:"text-gray-500 text-xs",children:It.score===5?"Excellent":It.score===4?"Very Good":It.score===3?"Good":It.score===2?"Fair":"Weak"})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Config Match"}),r.jsx("p",{className:`text-sm ${It.meetsConfig?"text-green-400":"text-red-300"}`,children:It.meetsConfig?"✓ Meets Requirements":"✗ Fails Requirements"}),r.jsxs("p",{className:"text-gray-500 text-xs",children:[It.configRequirements.minLength," -"," ",It.configRequirements.maxLength," chars"]})]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-400 mb-3",children:"Checks"}),r.jsx("div",{className:"space-y-2",children:It.checks.map((O,B)=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-black/40 border border-dashed border-white/10",children:[r.jsx("span",{className:"text-white font-mono text-xs",children:O.name}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("span",{className:`text-xs font-mono ${O.passed?"text-green-400":"text-red-300"}`,children:O.passed?"✓":"✗"}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:O.message})]})]},B))})]})]})]})]})}),Er&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(la,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"OAuth Credentials"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>Ws(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Select Provider"}),r.jsx("div",{className:"flex flex-wrap gap-3",children:["google","github"].map(O=>{const B=f===O;return r.jsx("button",{onClick:()=>m(O),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors ${B?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:O.charAt(0).toUpperCase()+O.slice(1)},O)})})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Origin"}),r.jsx(Ne,{value:fa,onChange:O=>Qn(O.target.value),placeholder:`http://${Pa}`,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs rounded-none"}),r.jsxs("p",{className:"text-[11px] text-gray-500 font-mono mt-1",children:["The default will be http://",Pa]})]}),r.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{Jn(null),Qn(Pa)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:pP,disabled:sr||!f||!fa.trim()&&!Pa,className:"rounded-none",children:sr?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Fetching..."]}):"Fetch Credentials"})]}),pa&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Client ID"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:pa.clientId,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(pa.clientId),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-4 h-4"})})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Client Secret"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{type:Zs?"text":"password",value:pa.clientSecret,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-20 rounded-none"}),r.jsxs("div",{className:"absolute right-0 top-0 h-full flex items-center",children:[r.jsx($,{variant:"ghost",size:"sm",onClick:()=>tl(!Zs),className:"px-2 text-gray-400 hover:text-white rounded-none",children:Zs?r.jsx(pf,{className:"w-4 h-4"}):r.jsx(Ms,{className:"w-4 h-4"})}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(pa.clientSecret),className:"px-2 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-4 h-4"})})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-dashed border-white/10",children:[r.jsx("div",{className:"flex-1",children:xt&&r.jsx("div",{className:"text-xs font-mono",children:xt.success?r.jsxs("span",{className:"text-green-400 uppercase",children:["✓ ",xt.message.toLowerCase(),r.jsxs("span",{className:"block normal-case text-gray-400",children:[r.jsx("span",{className:"text-gray-400 mr-1",children:">"})," ",xt.path]})]}):r.jsxs("span",{className:"text-red-300",children:["✗ ",xt.message]})})}),r.jsx($,{onClick:mP,disabled:Qs||cs,className:"rounded-none",children:cs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking..."]}):Qs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Uh,{className:"w-4 h-4 mr-2"}),"Write to .env"]})})]})]})]})]})}),ao&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(vo,{className:"w-5 h-5 text-white"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Secret Generator"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>ds(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Length (bytes)"}),r.jsx(Ne,{type:"number",value:ea===0?"":ea,onChange:O=>{const B=O.target.value;if(B===""){ma(0);return}const J=parseInt(B,10);isNaN(J)||ma(J)},onBlur:O=>{const B=parseInt(O.target.value,10);isNaN(B)||B<16?ma(32):B>128?ma(128):ma(B)},min:"16",max:"128",className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs rounded-none"}),r.jsx("p",{className:"text-[11px] text-gray-500 font-mono mt-1",children:"Recommended: 32 bytes (256 bits)"})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Format"}),r.jsx("div",{className:"flex gap-3",children:[{id:"hex",label:"Hex"},{id:"base64",label:"Base64"}].map(O=>r.jsx("button",{onClick:()=>kr(O.id),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors flex-1 ${Cr===O.id?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:O.label},O.id))})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{qe(null),ma(32),kr("hex")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),r.jsx($,{onClick:uP,disabled:Lt,className:"rounded-none",children:Lt?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Secret"})]}),Ee&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Length"}),r.jsxs("p",{className:"text-white text-sm",children:[Ee.length," bytes"]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Entropy"}),r.jsxs("p",{className:"text-white text-sm",children:[Ee.entropy," bits"]})]}),r.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[r.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Format"}),r.jsx("p",{className:"text-white text-sm uppercase",children:Ee.format})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Generated Secret"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:Ee.secret,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(Ee.secret),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-3 h-3"})})]})]}),r.jsxs("div",{children:[r.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Environment Variable Format"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ne,{value:Ee.envFormat,readOnly:!0,className:"bg-black border border-dashed border-white/20 text-white font-mono text-xs pr-10 rounded-none"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>za(Ee.envFormat),className:"absolute right-0 top-0 h-full px-3 text-gray-400 hover:text-white rounded-none",children:r.jsx(xa,{className:"w-3 h-3"})})]}),r.jsxs("p",{className:"text-[11px] text-gray-500 font-mono mt-2",children:["Add this to your ",r.jsx("code",{className:"text-gray-400",children:".env"})," file. Keep it secret and never commit it to version control."]})]}),r.jsx("div",{className:"flex justify-end space-x-2 pt-2",children:r.jsx($,{variant:"outline",onClick:hP,disabled:fe||De,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:fe||De?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),De?"Writing...":"Checking..."]}):"Write to .env"})}),r.jsx("div",{className:"border border-dashed border-white/20 bg-black text-gray-300 text-xs font-mono p-3 rounded-none",children:r.jsxs("div",{className:"flex items-start space-x-2",children:[r.jsx(sd,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-400"}),r.jsxs("div",{children:[r.jsx("div",{className:"uppercase font-mono mb-2 text-gray-400 tracking-wider",children:"Security Best Practices"}),r.jsxs("ul",{className:"list-disc list-inside space-y-1 text-[11px] text-gray-300",children:[r.jsx("li",{children:"Use a minimum of 32 bytes (256 bits) for production"}),r.jsx("li",{children:"Store secrets in environment variables, never in code"}),r.jsx("li",{children:"Use different secrets for development and production"}),r.jsx("li",{children:"Rotate secrets periodically for enhanced security"})]})]})]})})]})]})]})}),Tr&&ls&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[70] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(sd,{className:"w-5 h-5 text-yellow-400"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Overwrite Existing Credentials?"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Js(!1),ir(null),Fa(!1)},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"border border-dashed border-white/20 p-4",children:[r.jsxs("p",{className:"text-sm border-b border-dashed border-white/20 pb-5 text-gray-300 font-mono mb-3",children:["The following"," ",r.jsx("span",{className:"text-white uppercase",children:(f==null?void 0:f.charAt(0).toUpperCase())+(f==null?void 0:f.slice(1))})," ","credentials already exist in"," ",r.jsx("span",{className:"text-gray-400 normal-case",children:ls.path}),":"]}),r.jsx("div",{className:"space-y-2 pt-2",children:Object.entries(ls.credentials).map(([O,B])=>r.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[r.jsx("span",{className:"text-gray-400 uppercase",children:O}),r.jsx("span",{className:"text-gray-500",children:B.length>20?`${B.substring(0,20)}...`:B})]},O))})]}),r.jsxs("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t border-dashed border-white/10",children:[r.jsx($,{variant:"outline",onClick:()=>{Js(!1),ir(null),Fa(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"No, Cancel"}),r.jsx($,{variant:"outline",onClick:()=>Im("append"),disabled:Qs,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Append"}),r.jsx($,{onClick:()=>Im("override"),disabled:Qs,className:"rounded-none",children:Qs?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):"Yes, Overwrite"})]})]})]})}),nl&&Se&&r.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[70] overflow-hidden",children:r.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(sd,{className:"w-5 h-5 text-yellow-400"}),r.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Overwrite Existing Secret?"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{we(!1),Re(null),Ce(!1)},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"border border-dashed border-white/20 p-4",children:[r.jsxs("p",{className:"text-sm border-b border-dashed border-white/20 pb-5 text-gray-300 font-mono mb-3",children:[r.jsx("span",{className:"text-white uppercase",children:"BETTER_AUTH_SECRET"})," already exists in"," ",r.jsx("span",{className:"text-gray-400 normal-case",children:Se.path}),":"]}),r.jsx("div",{className:"space-y-2 pt-2",children:r.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[r.jsx("span",{className:"text-gray-400 uppercase",children:"BETTER_AUTH_SECRET"}),r.jsx("span",{className:"text-gray-500",children:Se.secret&&Se.secret.length>20?`${Se.secret.substring(0,20)}...`:Se.secret||"***"})]})})]}),r.jsxs("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t border-dashed border-white/10",children:[r.jsx($,{variant:"outline",onClick:()=>{we(!1),Re(null),Ce(!1)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"No, Cancel"}),r.jsx($,{onClick:()=>CE("override"),disabled:De,className:"rounded-none",children:De?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-4 h-4 mr-2 animate-spin"}),"Writing..."]}):"Yes, Overwrite"})]})]})]})})]})}function Jfe(){const{userId:e}=Q1(),t=yr(),[n,a]=p.useState(null),[s,i]=p.useState([]),[o,l]=p.useState([]),[c,u]=p.useState([]),[h,d]=p.useState([]),[f,m]=p.useState(!0),[y,x]=p.useState("details"),[N,b]=p.useState(!1),[v,g]=p.useState(!1),[w,S]=p.useState(!1),[E,j]=p.useState(!1),[_,M]=p.useState(!1),[U,L]=p.useState("random"),[F,G]=p.useState(!1),[A,P]=p.useState(!1),[R,k]=p.useState(!1),[T,D]=p.useState(""),[q,C]=p.useState(),[I,z]=p.useState(!1),[W,Y]=p.useState(""),[ae,ne]=p.useState([]),[X,ie]=p.useState(!1),[ve,se]=p.useState({}),ge=p.useRef({}),be=p.useCallback(async()=>{try{const pe=await(await fetch("/api/admin/status")).json();z(pe.enabled)}catch{z(!1)}},[]),Ue=p.useCallback(async K=>{try{const pe=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:K})});if(pe.ok){const ye=await pe.json();if(ye.success&&ye.location)return ye.location}return null}catch{return null}},[]),Be=p.useCallback(async K=>{const pe=K.filter(ze=>!ge.current[ze.id]);if(pe.length===0)return;const ye=await Promise.all(pe.map(async ze=>{const tt=await Ue(ze.ipAddress);return tt?{sessionId:ze.id,location:tt}:null})),Te={};ye.forEach(ze=>{ze&&(Te[ze.sessionId]=ze.location)}),Object.keys(Te).length>0&&(ge.current={...ge.current,...Te},se(ge.current))},[Ue]),$e=K=>{if(!K)return"🌍";const pe=K.toUpperCase().split("").map(ye=>127397+ye.charCodeAt(0));return String.fromCodePoint(...pe)},Ye=K=>K?K.replace(/[_-]/g," ").replace(/\b\w/g,pe=>pe.toUpperCase()):"Unknown Provider",bt=K=>{if(!K)return"Unknown";const pe=new Date(K);return Number.isNaN(pe.getTime())?"Unknown":pe.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},Ke=p.useCallback(async()=>{try{const K=await fetch(`/api/users/${e}`);if(K.ok){const pe=await K.json();a(pe.user)}else V.error("Failed to fetch user details"),t("/users")}catch{V.error("Failed to fetch user details"),t("/users")}finally{m(!1)}},[e,t]),de=p.useCallback(async()=>{try{const[K,pe,ye]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(K.ok){const Te=await K.json();i(Te.memberships||[])}if(pe.ok){const Te=await pe.json();l(Te.memberships||[])}if(ye.ok){const ze=(await ye.json()).sessions||[];u(ze),Be(ze)}}catch{}},[e,Be]),Fe=p.useCallback(async()=>{try{const K=await fetch(`/api/users/${e}/accounts`);if(K.ok){const pe=await K.json();d(pe.accounts||[])}}catch{}},[e]),Ie=async()=>{var Te,ze;if(!n)return;const K=(Te=document.getElementById("edit-name"))==null?void 0:Te.value,pe=(ze=document.getElementById("edit-email"))==null?void 0:ze.value;if(!K||!pe){V.error("Please fill in all fields");return}const ye=V.loading("Updating user...");try{const ee=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K,email:pe,role:W||null})})).json();ee.success?(a({...n,name:K,email:pe,role:W||void 0}),b(!1),Y(""),V.success("User updated successfully!",{id:ye})):V.error(`Error updating user: ${ee.error||"Unknown error"}`,{id:ye})}catch{V.error("Error updating user",{id:ye})}},Ae=async()=>{if(!n)return;const K=V.loading("Deleting user...");try{const ye=await(await fetch(`/api/users/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ye.success?(V.success("User deleted successfully!",{id:K}),t("/users")):V.error(`Error deleting user: ${ye.error||"Unknown error"}`,{id:K})}catch{V.error("Error deleting user",{id:K})}},We=async()=>{if(!n)return;if(!I){V.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use ban functionality.");return}const K=V.loading("Banning user...");try{const pe=await fetch("/api/admin/ban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,banReason:T||"No reason provided",banExpiresIn:q})}),ye=await pe.json();pe.ok?(V.success("User banned successfully!",{id:K}),g(!1),D(""),C(void 0),Ke()):pe.status===403?V.error("You do not have permission to ban users. Admin role required.",{id:K}):ye.adminPluginEnabled&&ye.instructions?V.error(`${ye.error}`,{id:K,duration:6e3,description:`Use: ${ye.instructions.example}`}):V.error(`Error banning user: ${ye.error||ye.message||"Unknown error"}`,{id:K})}catch{V.error("Error banning user",{id:K})}},at=async()=>{if(!n)return;if(!I){V.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use unban functionality.");return}const K=V.loading("Unbanning user...");try{const pe=await fetch("/api/admin/unban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})}),ye=await pe.json();pe.ok?(V.success("User unbanned successfully!",{id:K}),S(!1),Ke()):pe.status===403?V.error("You do not have permission to unban users. Admin role required.",{id:K}):ye.adminPluginEnabled&&ye.instructions?V.error(`${ye.error}`,{id:K,duration:6e3,description:`Use: ${ye.instructions.example}`}):V.error(`Error unbanning user: ${ye.error||ye.message||"Unknown error"}`,{id:K})}catch{V.error("Error unbanning user",{id:K})}},ft=async K=>{const pe=V.loading("Removing user from organization...");try{const Te=await(await fetch(`/api/organizations/members/${K}`,{method:"DELETE"})).json();Te.success?(i(ze=>ze.filter(tt=>tt.id!==K)),de(),V.success("User removed from organization!",{id:pe})):V.error(`Error removing user: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error removing user from organization",{id:pe})}},Yt=async K=>{const pe=V.loading("Removing user from team...");try{const Te=await(await fetch(`/api/teams/members/${K}`,{method:"DELETE"})).json();Te.success?(l(ze=>ze.filter(tt=>tt.id!==K)),de(),V.success("User removed from team!",{id:pe})):V.error(`Error removing user: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error removing user from team",{id:pe})}},Wt=async K=>{const pe=V.loading("Deleting session...");try{const Te=await(await fetch(`/api/sessions/${K}`,{method:"DELETE"})).json();Te.success?(u(ze=>ze.filter(tt=>tt.id!==K)),V.success("Session deleted successfully!",{id:pe})):V.error(`Error deleting session: ${Te.error||"Unknown error"}`,{id:pe})}catch{V.error("Error deleting session",{id:pe})}},oe=async K=>{if(!e)return;const pe=V.loading("Unlinking account...");try{const ye=await fetch(`/api/users/${e}/accounts/${K}`,{method:"DELETE"}),Te=await ye.json();ye.ok&&Te.success?(d(ze=>ze.filter(tt=>tt.id!==K)),await Fe(),V.success("Account unlinked successfully",{id:pe})):V.error(Te.error||"Failed to unlink account",{id:pe})}catch{V.error("Failed to unlink account",{id:pe})}};p.useEffect(()=>{e&&(Ke(),de(),Fe(),be())},[e,be,Ke,de,Fe]);const _e=async(K=3)=>{if(e){ne([]),ie(!0),ne([{id:"start",type:"info",message:`Starting session seeding process for ${K} sessions...`,timestamp:new Date}]);try{const ye=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K})})).json();if(ye.success){const Te=ye.results.map((tt,ee)=>tt.success?{id:`session-${ee}`,type:"progress",message:`Creating session ${ee+1}: ${tt.session.token.substring(0,20)}... from ${tt.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${ee}`,type:"error",message:`Failed to create session ${ee+1}: ${tt.error}`,timestamp:new Date});ne(tt=>[...tt,...Te]);const ze=ye.results.filter(tt=>tt.success).length;ne(tt=>[...tt,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${ze}/${K} sessions successfully`,timestamp:new Date}]),de()}else ne(Te=>[...Te,{id:"error",type:"error",message:`❌ Session seeding failed: ${ye.error||"Unknown error"}`,timestamp:new Date}])}catch(pe){ne(ye=>[...ye,{id:"error",type:"error",message:`❌ Network error: ${pe}`,timestamp:new Date}])}finally{ie(!1)}}},Ze=async(K=3,pe="random")=>{if(e){ne([]),ie(!0),ne([{id:"start",type:"info",message:`Starting account seeding process for ${K} accounts...`,timestamp:new Date}]);try{const Te=await(await fetch(`/api/users/${e}/seed-accounts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:K,providerId:pe})})).json();if(Te.success){const ze=Te.results.map((ee,ue)=>{var Oe;return ee.success?{id:`account-${ue}`,type:"progress",message:`Creating account ${ue+1}: ${ee.account.providerId||ee.account.provider} (${((Oe=ee.account.accountId)==null?void 0:Oe.substring(0,20))||ee.account.id.substring(0,20)}...)`,timestamp:new Date,status:"completed"}:{id:`account-${ue}`,type:"error",message:`Failed to create account ${ue+1}: ${ee.error}`,timestamp:new Date}});ne(ee=>[...ee,...ze]);const tt=Te.results.filter(ee=>ee.success).length;ne(ee=>[...ee,{id:"complete",type:"success",message:`✅ Account seeding completed! Created ${tt}/${K} accounts successfully`,timestamp:new Date}]),Fe()}else ne(ze=>[...ze,{id:"error",type:"error",message:`❌ Account seeding failed: ${Te.error||"Unknown error"}`,timestamp:new Date}])}catch(ye){ne(Te=>[...Te,{id:"error",type:"error",message:`❌ Network error: ${ye}`,timestamp:new Date}])}finally{ie(!1)}}};return f?r.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:r.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):n?r.jsxs("div",{className:"space-y-6 p-6 bg-black w-full",children:[r.jsxs("div",{className:"w-full flex flex-col",children:[r.jsx("span",{className:"mb-4 ml-0 flex justify-start items-start text-left border-none text-white",children:r.jsxs("span",{className:"font-light",children:[r.jsxs("span",{onClick:()=>t("/users"),className:"uppercase cursor-pointer text-white/80 font-mono text-sm",children:["users /"," "]}),r.jsx("span",{className:"text-white font-mono text-sm",children:n.id})]})}),r.jsx("div",{className:"mb-8 mt-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[r.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:n.image?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsxs("h1",{className:"text-3xl font-light text-white inline-flex items-center",children:[n.name,r.jsx(on,{id:n.id,nonSliced:!0,variant:"subscript"}),n.role&&r.jsx("sup",{className:"ml-2 px-2 pt-2 pb-2 -mt-1 py-0.5 text-[10px] font-mono uppercase border border-dashed border-white/15 bg-white/5 text-white/80 rounded-none",children:n.role}),n.banned&&r.jsxs("sup",{className:"relative group inline-block ml-2 px-2 pt-2 pb-2 -mt-1 py-0.5 text-[10px] font-mono uppercase border border-dashed border-red-500/30 bg-red-500/10 text-red-400/80 rounded-none cursor-help",children:["Banned",n.banReason&&r.jsxs("span",{className:"absolute lowercase left-1/2 -translate-x-1/2 bottom-full mb-3 px-2 py-2 text-[10px] font-mono text-gray-300 bg-black border border-dashed border-white/20 rounded-none whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-150 pointer-events-none z-50",children:[r.jsx("span",{className:"text-gray-400 font-mono text-xs uppercase mr-1",children:"Banned Reason:"}),n.banReason,r.jsx("span",{className:"absolute left-1/2 -translate-x-1/2 top-full w-0 h-0 border-l-[4px] border-r-[4px] border-t-[4px] border-transparent border-t-white/20"})]})]})]}),r.jsx("p",{className:"text-gray-400 font-mono text-sm",children:n.email})]})]}),r.jsx("div",{className:"flex items-center space-x-2",children:r.jsxs("div",{className:"relative",children:[r.jsx($,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:K=>{K.stopPropagation(),k(!R)},children:r.jsx(l3,{className:"w-4 h-4"})}),R&&r.jsxs("div",{className:"absolute z-[999] right-0 top-full mt-1 w-48 bg-black border border-white/20 rounded-none shadow-lg",onClick:K=>K.stopPropagation(),children:[r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),b(!0),Y(n.role||"")},children:[r.jsx(Po,{className:"w-4 h-4"}),r.jsx("span",{children:"Edit User"})]}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),G(!0)},children:[r.jsx(Mn,{className:"w-4 h-4"}),r.jsx("span",{children:"Update Password"})]}),I&&(n.banned?r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-green-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),S(!0)},children:[r.jsx(eb,{className:"w-4 h-4"}),r.jsx("span",{children:"Unban User"})]}):r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-yellow-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),g(!0)},children:[r.jsx(eb,{className:"w-4 h-4"}),r.jsx("span",{children:"Ban User"})]})),r.jsx("div",{className:"border-t border-white/10 my-1"}),r.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-white/10 flex items-center space-x-2",onClick:K=>{K.stopPropagation(),k(!1),P(!0)},children:[r.jsx(Qu,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete User"})]})]})]})})]})}),r.jsxs("div",{className:"border border-dashed border-white/20 rounded-none",children:[r.jsx("div",{className:"border-b border-dashed border-white/20",children:r.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:md},{id:"organizations",name:"Organizations",icon:Ca,count:s.length},{id:"teams",name:"Teams",icon:Ot,count:o.length},{id:"accounts",name:"Accounts",icon:bo,count:h.length},{id:"sessions",name:"Sessions",icon:jN,count:c.length}].map(K=>r.jsxs("button",{onClick:()=>x(K.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${y===K.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[r.jsx(K.icon,{className:"w-4 h-4 text-white/90"}),r.jsxs("span",{className:"inline-flex items-start",children:[r.jsx("span",{className:"font-mono uppercase text-xs font-normal",children:K.name}),K.count!==void 0&&r.jsx("sup",{className:"text-xs text-gray-500 ml-1 inline-flex items-baseline",children:r.jsx(An,{value:K.count,className:"text-white/80 font-mono text-xs",prefix:r.jsx("span",{className:"mr-0.5 text-gray-500",children:"["}),suffix:r.jsx("span",{className:"ml-0.5 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]})]},K.id))})}),r.jsxs("div",{className:"p-6",children:[y==="details"&&r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[r.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"BASIC INFORMATION"}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(md,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Name"}),r.jsx("div",{className:"text-white font-sans text-sm",children:n.name})]})]}),r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(ys,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Email"}),r.jsx("div",{className:"text-white font-mono text-sm",children:n.email})]})]}),n.username&&r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(gae,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Username"}),r.jsx("div",{className:"text-white font-mono text-sm",children:n.username})]})]}),n.phoneNumber&&r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(mae,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Phone"}),r.jsx("div",{className:"text-white font-mono text-sm",children:"+251 91 234 5678"})]})]}),r.jsxs("div",{className:"flex items-start space-x-3",children:[r.jsx(cr,{className:"w-4 h-4 text-gray-400 mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Member Since"}),r.jsx("div",{className:"text-white font-mono text-sm",children:new Date(n.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})})]})]})]})]}),r.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[r.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"SECURITY"}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/10 rounded-none",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(ys,{className:"w-4 h-4 text-gray-400"}),r.jsx("div",{children:r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Email Verification"})})]}),r.jsx("div",{className:`px-2 rounded-none border border-dashed border-white/20 uppercase py-1 text-xs font-mono ${n.emailVerified?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:n.emailVerified?"Verified":"Unverified"})]}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/10 rounded-none",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx(Rs,{className:"w-4 h-4 text-gray-400"}),r.jsx("div",{children:r.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Two-Factor Authentication"})})]}),r.jsx("div",{className:`px-2 rounded-none border border-dashed border-white/20 uppercase py-1 text-xs font-mono ${n.twoFactorEnabled?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:n.twoFactorEnabled?"Enabled":"Disabled"})]})]})]})]}),y==="organizations"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between mb-4",children:r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Organizations",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:s.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Organizations this user belongs to"})]})}),s.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ca,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),r.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):r.jsx("div",{className:"grid gap-4",children:s.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:K.organization.image?r.jsx("img",{src:K.organization.image,alt:K.organization.name,className:"w-12 h-12 object-cover"}):r.jsx(Ca,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[K.organization.name,r.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white/80 font-mono text-xs",children:K.organization.slug}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1 flex items-center gap-2",children:[r.jsxs("span",{children:["in ",K.organization.slug]}),r.jsx("button",{onClick:pe=>{pe.stopPropagation(),t(`/organizations/${K.organization.id}`)},className:"text-white/60 hover:text-white transition-colors",title:"View organization details",children:r.jsx(vu,{className:"w-3.5 h-3.5"})})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>ft(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},K.id))})]}),y==="teams"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between mb-4",children:r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Teams",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:o.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Teams this user belongs to"})]})}),o.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ot,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),r.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):r.jsx("div",{className:"grid gap-4",children:o.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:r.jsx(Ot,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[K.team.name,r.jsx(on,{id:K.team.id,variant:"subscript",nonSliced:!!(K.team.organizationSlug||K.team.organizationName)})]}),r.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1 flex items-center gap-2",children:[r.jsxs("span",{children:["in"," ",K.team.organizationSlug||K.team.organizationName]}),r.jsx("button",{onClick:pe=>{pe.stopPropagation(),K.team.organizationId?t(`/organizations/${K.team.organizationId}/teams/${K.team.id}`):t(`/teams/${K.team.id}`)},className:"text-white/60 hover:text-white transition-colors",title:"View team details",children:r.jsx(vu,{className:"w-3.5 h-3.5"})})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>Yt(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},K.id))})]}),y==="accounts"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Linked Accounts",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:h.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Manage user OAuth account connections"})]}),r.jsxs($,{variant:"outline",onClick:()=>{ne([]),ie(!1),M(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[r.jsx(bo,{className:"w-4 h-4 mr-2"}),"Seed Accounts"]})]}),h.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(bo,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Linked Accounts"}),r.jsx("p",{className:"text-gray-400",children:"This user has not connected any accounts yet."})]}):r.jsx("div",{className:"grid gap-4",children:h.map(K=>r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:Y6(K.providerId)}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[Ye(K.providerId),r.jsx(on,{id:K.accountId,variant:"subscript",nonSliced:!!(K.email||n.email)})]}),r.jsx("p",{className:"text-gray-400 tracking-tight uppercase text-xs font-mono mt-1",children:`ID: ${K.id}`})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2 text-right",children:r.jsxs("div",{className:"flex items-center space-x-2 text-xs font-mono text-gray-400",children:[r.jsx("span",{children:"Linked:"}),r.jsx("span",{className:"text-white",children:bt(K.createdAt||K.updatedAt)})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>oe(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(Jg,{className:"w-4 h-4 mr-1"}),"Unlink"]})})]},K.id))})]}),y==="sessions"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg relative text-white font-light inline-flex items-start",children:["Sessions",r.jsxs("sup",{className:"text-xs text-gray-500 ml-1 mt-0",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white font-mono text-xs",children:c.length}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsx("p",{className:"text-gray-400 font-light font-mono text-xs uppercase mt-1",children:"Manage user authentication sessions"})]}),r.jsxs($,{variant:"outline",onClick:()=>{ne([]),ie(!1),j(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[r.jsx(Rs,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(jN,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),r.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):r.jsx("div",{className:"grid gap-4",children:c.map(K=>{var pe,ye,Te,ze;return r.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[r.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:r.jsx(NC,{className:"w-6 h-6 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:["Session ",K.id.substring(0,8),"...",r.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[r.jsx("span",{className:"mr-1",children:"["}),r.jsx("span",{className:"text-white/80 font-mono text-xs",children:K.ipAddress}),r.jsx("span",{className:"ml-1",children:"]"})]})]}),r.jsxs("div",{className:"flex items-center space-x-2 mt-2",children:[r.jsx(pae,{className:"w-3.5 h-3.5 text-gray-400"}),r.jsxs("span",{className:"text-gray-400 uppercase font-mono text-xs",children:[((pe=ve[K.id])==null?void 0:pe.city)||"...",","," ",((ye=ve[K.id])==null?void 0:ye.country)||"..."]}),((Te=ve[K.id])==null?void 0:Te.countryCode)&&r.jsx("span",{className:"text-xs ml-1",children:$e((ze=ve[K.id])==null?void 0:ze.countryCode)})]})]})]}),r.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Expires:"," "]}),r.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(K.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(K.expiresAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs($,{variant:"outline",size:"sm",onClick:()=>Wt(K.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[r.jsx(eb,{className:"w-4 h-4 mr-1"}),"Revoke"]})})]},K.id)})})]})]})]})]}),N&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>{b(!1),Y("")},className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.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?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h4",{className:"text-white font-medium",children:n==null?void 0:n.name}),r.jsx("p",{className:"text-gray-400 text-sm",children:n==null?void 0:n.email})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),r.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"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),r.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"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Role"}),r.jsxs(hn,{className:"bg-black text-white",value:W,onValueChange:Y,children:[r.jsx(fn,{className:"w-full border border-dashed border-white/20 bg-black text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select role"})}),r.jsxs(pn,{children:[r.jsx(Le,{value:"",children:"None"}),r.jsx(Le,{value:"admin",children:"Admin"}),r.jsx(Le,{value:"user",children:"User"})]})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>{b(!1),Y("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),v&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-red-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),r.jsxs("p",{className:"text-gray-400 mb-4",children:["Ban ",r.jsx("strong",{children:n.name})," from accessing the system."]}),r.jsxs("div",{className:"space-y-4 mb-6",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banReason",className:"text-white",children:"Ban Reason"}),r.jsx(Ne,{id:"banReason",value:T,onChange:K=>D(K.target.value),placeholder:"Enter reason for ban (optional)",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"banExpires",className:"text-white",children:"Ban Duration (seconds)"}),r.jsx(Ne,{id:"banExpires",type:"number",value:q||"",onChange:K=>C(K.target.value?Number(K.target.value):void 0),placeholder:"Leave empty for permanent ban",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Examples: 3600 (1 hour), 86400 (1 day), 604800 (1 week)"})]})]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>{g(!1),D(""),C(void 0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:We,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),w&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black border border-green-400/20 rounded-none p-6 w-full max-w-md",children:[r.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Unban User"}),r.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to unban ",r.jsx("strong",{children:n.name}),"? This will restore their access to the system."]}),r.jsxs("div",{className:"flex justify-end space-x-2",children:[r.jsx($,{variant:"outline",onClick:()=>S(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:at,className:"bg-green-400 text-white hover:bg-green-700 rounded-none",children:"Unban User"})]})]})}),A&&n&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>P(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n.image?r.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):r.jsx(md,{className:"w-8 h-8 text-white"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white font-light",children:n.name}),r.jsx("div",{className:"text-sm text-gray-400",children:n.email})]})]}),r.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>P(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:Ae,className:"bg-red-500 hover:bg-red-600 text-white border border-red-500 rounded-none",children:"Delete"})]})]})}),F&&n&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:r.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg text-white font-light",children:"Update Password"}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>G(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"new-password",className:"text-sm text-gray-400 font-light",children:"New Password"}),r.jsx(Ne,{id:"new-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),r.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[r.jsx($,{variant:"outline",onClick:()=>G(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),r.jsx($,{onClick:async()=>{var ye;const K=(ye=document.getElementById("new-password"))==null?void 0:ye.value;if(!K){V.error("Please enter a password");return}const pe=V.loading("Updating password...");try{const ze=await(await fetch(`/api/users/${e}/password`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:K})})).json();ze.success?(G(!1),document.getElementById("new-password").value="",V.success("Password updated successfully!",{id:pe})):V.error(`Error updating password: ${ze.error||"Unknown error"}`,{id:pe})}catch{V.error("Error updating password",{id:pe})}},className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),E&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:r.jsxs("div",{className:"overflow-x-hidden overflow-y-auto bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none max-h-[90vh]",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(NC,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Sessions"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx(ce,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),r.jsx(Ne,{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"})]}),r.jsx($,{onClick:()=>{var pe;const K=parseInt(((pe=document.getElementById("session-count"))==null?void 0:pe.value)||"3",10);_e(K)},disabled:X,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:X?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Rs,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})}),ae.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"Session Seeding Terminal",lines:ae,isRunning:X,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>j(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),_&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:r.jsxs("div",{className:"overflow-x-hidden overflow-y-auto bg-black/90 border border-white/10 p-6 w-full pt-4 max-w-2xl rounded-none max-h-[90vh]",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[r.jsx("span",{className:"text-white/50 mr-2",children:"["}),r.jsx(bo,{className:"inline mr-2 w-3 h-3 text-white"}),r.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Accounts"}),r.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),r.jsx($,{variant:"ghost",size:"sm",onClick:()=>M(!1),className:"text-gray-400 hover:text-white rounded-none",children:r.jsx(dt,{className:"w-4 h-4"})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),r.jsx(Ne,{id:"account-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"})]}),r.jsxs("div",{children:[r.jsx(ce,{htmlFor:"account-provider",className:"text-sm text-gray-400 font-light",children:"Provider"}),r.jsxs(hn,{value:U,onValueChange:L,children:[r.jsx(fn,{className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:r.jsx(Bn,{placeholder:"Select provider"})}),r.jsxs(pn,{className:"bg-black border border-dashed border-white/20",children:[r.jsx(Le,{value:"random",children:"Mix (Random)"}),r.jsx(Le,{value:"github",children:"GitHub"}),r.jsx(Le,{value:"google",children:"Google"}),r.jsx(Le,{value:"discord",children:"Discord"}),r.jsx(Le,{value:"facebook",children:"Facebook"}),r.jsx(Le,{value:"twitter",children:"Twitter"}),r.jsx(Le,{value:"linkedin",children:"LinkedIn"}),r.jsx(Le,{value:"apple",children:"Apple"}),r.jsx(Le,{value:"microsoft",children:"Microsoft"}),r.jsx(Le,{value:"gitlab",children:"GitLab"}),r.jsx(Le,{value:"bitbucket",children:"Bitbucket"}),r.jsx(Le,{value:"spotify",children:"Spotify"}),r.jsx(Le,{value:"twitch",children:"Twitch"}),r.jsx(Le,{value:"reddit",children:"Reddit"}),r.jsx(Le,{value:"slack",children:"Slack"}),r.jsx(Le,{value:"notion",children:"Notion"}),r.jsx(Le,{value:"tiktok",children:"TikTok"}),r.jsx(Le,{value:"zoom",children:"Zoom"})]})]})]})]}),r.jsx($,{onClick:()=>{var pe;const K=parseInt(((pe=document.getElementById("account-count"))==null?void 0:pe.value)||"3",10);Ze(K,U)},disabled:X,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:X?r.jsxs(r.Fragment,{children:[r.jsx(rn,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):r.jsxs(r.Fragment,{children:[r.jsx(bo,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]}),ae.length>0&&r.jsx("div",{className:"mt-6",children:r.jsx(Xi,{title:"Account Seeding Terminal",lines:ae,isRunning:X,className:"w-full",defaultCollapsed:!0})})]}),r.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),r.jsx("div",{className:"flex justify-end mt-6 pt-6",children:r.jsx($,{variant:"outline",onClick:()=>M(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):r.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:r.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function epe(){return r.jsx(YK,{children:r.jsxs(D$,{children:[r.jsx(zQ,{children:r.jsxs(j$,{children:[r.jsx(Vn,{path:"/",element:r.jsx(Pae,{})}),r.jsx(Vn,{path:"/users",element:r.jsx(IU,{})}),r.jsx(Vn,{path:"/users/:userId",element:r.jsx(Jfe,{})}),r.jsx(Vn,{path:"/organizations",element:r.jsx(DU,{})}),r.jsx(Vn,{path:"/organizations/:orgId",element:r.jsx(gfe,{})}),r.jsx(Vn,{path:"/teams",element:r.jsx(vfe,{})}),r.jsx(Vn,{path:"/teams/:teamId",element:r.jsx(s4,{})}),r.jsx(Vn,{path:"/organizations/:orgId/teams/:teamId",element:r.jsx(s4,{})}),r.jsx(Vn,{path:"/sessions",element:r.jsx(bfe,{})}),r.jsx(Vn,{path:"/database",element:r.jsx(zae,{})}),r.jsx(Vn,{path:"/database/demo",element:r.jsx(VK,{})}),r.jsx(Vn,{path:"/emails",element:r.jsx(pfe,{})}),r.jsx(Vn,{path:"/tools",element:r.jsx(Qfe,{})}),r.jsx(Vn,{path:"/settings",element:r.jsx(xfe,{})})]})}),r.jsx(d8,{className:"rounded-none border-dashed border-white/20",theme:"dark",position:"top-right",richColors:!0,toastOptions:{style:{border:"dashed 1px #ffffff20",borderRadius:"0"},className:"font-mono uppercase"},closeButton:!0})]})})}Dz.createRoot(document.getElementById("root")).render(r.jsx(te.StrictMode,{children:r.jsx(epe,{})}));
|