better-auth-studio 1.0.47-beta.1 → 1.0.47-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth-studio",
3
- "version": "1.0.47-beta.1",
3
+ "version": "1.0.47-beta.2",
4
4
  "description": "Studio for Better Auth",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -689,6 +689,6 @@ migrateFromClerk()
689
689
 
690
690
  }`),[q,ne]=m.useState(null),[ve,ue]=m.useState(!1),ae=(W,ce,de,Re)=>{i(Ze=>[...Ze,{id:Re??`log-${Date.now()}-${Math.random()}`,type:W,message:ce,timestamp:new Date,status:de}])},I=m.useRef(new Set),F=m.useRef(new Set),me=m.useRef(new Map),$e=m.useRef(null),Ke=()=>Wl.find(W=>!W.disabled)??Wl[0],ze=Wl.find(W=>W.id===w)??Ke();m.useEffect(()=>{g(y?W=>{var ce;return W||((ce=Ke())==null?void 0:ce.id)||""}:"")},[y,Ke]);const et=W=>{g(W),W!=="custom"&&p(nx)},Zt=()=>{S(""),A(""),R(null),U("SHA-256"),B("hex"),N(!0)},ns=async()=>{if(!C.trim()){L.error("Enter a password to hash");return}try{_(!0);const W=M?`${M}:${C}`:C,de=await cV(H,O).digest(W);R(de),L.success("Password hashed successfully")}catch(W){L.error("Failed to hash password"),console.error(W)}finally{_(!1)}},$t=async W=>{try{await navigator.clipboard.writeText(W),L.success("Copied to clipboard")}catch{L.error("Failed to copy to clipboard")}},Nt=()=>{$e.current&&!$e.current.closed&&$e.current.close(),$e.current=null},pn=(W,ce,de,Re,Ze)=>{let gt=me.current.get(W);gt||(gt=new Map,me.current.set(W,gt));const bn=gt.get(de);if(bn){i(Kr=>Kr.map(as=>as.id===bn?{...as,type:ce,message:Re,status:Ze,timestamp:new Date}:as));return}const Nn=`session-${W}-${de}-${Date.now()}`;gt.set(de,Nn),ae(ce,Re,Ze,Nn)},Ft=(W,ce,de=0)=>{I.current.has(W)||I.current.add(W),fetch(`/api/tools/oauth/status?testSessionId=${encodeURIComponent(W)}`).then(Ze=>Ze.json()).then(Ze=>{if(Ze.hasResult){I.current.delete(W),Bs(Ze.result);return}if(de+1>=15){I.current.delete(W),pn(W,"error","timeout","⌛ Timed out waiting for account creation. Check Better Auth logs.","failed"),Nt(),s(null),L.error("OAuth test timed out waiting for account creation");return}setTimeout(()=>Ft(W,ce,de+1),2e3)}).catch(Ze=>{de+1<15?setTimeout(()=>Ft(W,ce,de+1),2e3):(I.current.delete(W),pn(W,"error","poll-error",`⚠️ Failed to check OAuth status: ${Ze}`,"failed"),Nt(),s(null),L.error("Failed to check OAuth status"))})},Bs=W=>{l(!0);const ce=W.testSessionId;if(W.success){if(F.current.has(ce)&&W.userInfo)return;if(pn(ce,"success","waiting","✅ Verified with Better Auth.","completed"),W.userInfo){F.current.add(ce);const de=[W.userInfo.name?`👤 ${W.userInfo.name}`:null,W.userInfo.email?`✉️ ${W.userInfo.email}`:null].filter(Boolean).join(" | "),Re=de?`✅ ${W.provider} OAuth succeeded — ${de}`:`✅ ${W.provider} OAuth succeeded!`;pn(ce,"success","completed",Re,"completed"),L.success(`OAuth test for ${W.provider} passed!`),Nt(),s(null),me.current.delete(ce)}else pn(ce,"progress","await-finalize","⌛ OAuth flow finished. Waiting for Better Auth to finalize account...","running"),I.current.has(ce)||(I.current.add(ce),Ft(ce,W.provider))}else{if(F.current.has(ce))return;pn(ce,"error","waiting","❌ Verification failed with Better Auth.","failed");const de=W.error?` — ${W.error}`:"";pn(ce,"error","failed",`❌ ${W.provider} OAuth failed${de}`,"failed"),L.error(`OAuth test for ${W.provider} failed`),Nt(),s(null),me.current.delete(ce)}W.success||(F.current.add(ce),me.current.delete(ce)),sessionStorage.removeItem("oauth_test_session"),sessionStorage.removeItem(`oauth_test_result_${ce}`)};m.useEffect(()=>{const W=e.get("oauth_test_result");if(W)try{const ce=JSON.parse(decodeURIComponent(W));l(!0),Bs(ce),t({})}catch{}},[e,t,Bs]),m.useEffect(()=>{(async()=>{try{const de=await(await fetch("/api/tools/oauth/providers")).json();de.success&&de.providers&&d(de.providers.filter(Re=>Re.enabled))}catch{}})()},[]);const qr=async()=>{if(h.length===0){L.error("No OAuth providers configured"),ae("error","❌ No OAuth providers found in configuration","failed"),ae("info","💡 Please configure at least one OAuth provider in your Better Auth config","failed");return}u(!0)},Xr=async W=>{u(!1),x(""),s("test-oauth"),l(!0),i([]),ae("info",`🔍 Testing ${W} OAuth...`,"running");const ce=new Date().toISOString();try{ae("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:W})})).json();if(Re.success&&Re.startUrl){me.current.delete(Re.testSessionId),pn(Re.testSessionId,"progress","popup-open",`🌐 Opening ${Re.provider} OAuth popup...`,"running");const Ze={testSessionId:Re.testSessionId,provider:Re.provider,providerId:W,startTime:ce};F.current.delete(Re.testSessionId),sessionStorage.setItem("oauth_test_session",JSON.stringify(Ze));const gt=600,bn=700,Nn=(window.screen.width-gt)/2,Kr=(window.screen.height-bn)/2,as=window.open(Re.startUrl,"oauth-test",`width=${gt},height=${bn},left=${Nn},top=${Kr},scrollbars=yes,resizable=yes`);if(!as){ae("error","❌ Failed to open OAuth window. Please allow popups for this site.","failed"),ae("error","💡 Check your browser popup blocker settings","failed"),L.error("Failed to open OAuth window. Please allow popups."),s(null);return}$e.current=as;let Ns=!1;const ge=ie=>{if(ie.origin===window.location.origin){if(ie.data&&ie.data.type==="oauth_test_state"){if(ie.data.status==="redirect")I.current.has(Ze.testSessionId)||Ft(Ze.testSessionId,Ze.provider);else if(ie.data.status==="error"){Ns=!0;const Ne=sessionStorage.getItem("oauth_test_session");let De=Re.provider;if(Ne)try{De=JSON.parse(Ne).provider||De}catch{}Bs({success:!1,provider:De,testSessionId:ie.data.testSessionId,error:ie.data.error||"Failed to start OAuth test"}),window.removeEventListener("message",ge),clearInterval(ye),clearTimeout(je),Nt()}return}if(ie.data&&ie.data.type==="oauth_test_result"){window.removeEventListener("message",ge),clearInterval(ye),clearTimeout(je),Ns=!0;const Ne=ie.data.result;Bs(Ne),I.current.has(Ne.testSessionId)||Ft(Ne.testSessionId,Ne.provider),Nt()}}};window.addEventListener("message",ge);const ye=setInterval(()=>{as.closed&&(clearInterval(ye),clearTimeout(je),window.removeEventListener("message",ge),!sessionStorage.getItem(`oauth_test_result_${Ze.testSessionId}`)&&!Ns&&(Ns=!0,Ft(Ze.testSessionId,Ze.provider)))},500),je=setTimeout(()=>{as.closed||(clearInterval(ye),window.removeEventListener("message",ge),Nt(),Ns||(Ns=!0),ae("error","❌ OAuth test timed out after 5 minutes","failed"),ae("error","💡 Possible reasons:","failed"),ae("error"," • Authentication took too long","failed"),ae("error"," • Provider is not responding","failed"),ae("error"," • Network connectivity issues","failed"),L.error("OAuth test timed out"),s(null))},5*60*1e3)}else ae("error",`❌ Failed to initiate OAuth test: ${Re.error||"Unknown error"}`,"failed"),Re.details&&ae("error",`💡 Details: ${JSON.stringify(Re.details)}`,"failed"),Re.cause&&ae("error",`💡 Cause: ${Re.cause}`,"failed"),L.error(Re.error||"Failed to start OAuth test"),s(null)}catch(de){ae("error",`❌ Network error: ${de}`,"failed"),L.error("Failed to start OAuth test"),s(null)}},wl=()=>{b(!0)},Yi=async(W,ce)=>{const de=Wl.find(Ze=>Ze.id===W);if(!de){L.error("Unknown migration provider");return}if(de.disabled){L.info(`${de.name} migration is coming soon`);return}b(!1),s("run-migration"),l(!0),i([]);const Re=Ze=>new Promise(gt=>setTimeout(gt,Ze));try{if(ae("info",`🚀 Preparing ${de.name} migration...`,"running"),de.highlights)for(const bn of de.highlights)await Re(350),ae("progress",bn,"running");ae("progress","📡 Sending migration payload to server...","running");const gt=await(await fetch("/api/tools/migrations/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:de.id,script:de.custom?ce:de.script})})).json();if(gt.success)ae("progress","🚀 Migration job acknowledged. Follow server logs for live progress.","running"),ae("success",`✅ ${de.name} migration request accepted.`,"completed"),gt.message&&ae("info",gt.message,"completed"),L.success(`${de.name} migration flow completed`);else throw new Error(gt.error||"Migration request failed")}catch(Ze){ae("error",`❌ Migration failed: ${Ze}`,"failed"),L.error("Migration failed")}finally{s(null)}},pa=async()=>{s("validate-config"),l(!0),i([]),ae("info","Validating Better Auth configuration...","running");try{await new Promise(W=>setTimeout(W,500)),ae("progress","Checking database connection...","running"),await new Promise(W=>setTimeout(W,500)),ae("progress","Validating plugins configuration...","running"),await new Promise(W=>setTimeout(W,500)),ae("success","✅ Configuration is valid!","completed"),L.success("Configuration validated successfully")}catch(W){ae("error",`❌ Configuration validation failed: ${W}`,"failed"),L.error("Configuration validation failed")}finally{s(null)}},Gr=async()=>{s("test-db"),l(!0),i([]),ae("info","Testing database connection...","running");try{const ce=await(await fetch("/api/database/test")).json();await new Promise(de=>setTimeout(de,1e3)),ae("progress","Checking on database con!","running"),ce.success?(ae("success","✅ Database connection successful!","completed"),ce.result&&Array.isArray(ce.result)&&ce.result.length>0&&(ae("info","📄 Sample user record (first row):","completed"),ae("info",JSON.stringify(ce.result[0],null,2),"completed")),L.success("Database connection test successful")):(ae("error",`❌ Database connection failed: ${ce.error||"Unknown error"}`,"failed"),L.error("Database connection test failed"))}catch(W){ae("error",`❌ Network error: ${W}`,"failed"),L.error("Failed to test database connection")}finally{s(null)}},Fi=async()=>{s("generate-api-key"),l(!0),i([]),ae("info","Generating new API key...","running");try{const ce=await(await fetch("/api/tools/generate-api-key",{method:"POST",headers:{"Content-Type":"application/json"}})).json();ce.success&&ce.apiKey?(ae("success","✅ API key generated successfully!","completed"),ae("info",`API Key: ${ce.apiKey}`,"completed"),L.success("API key generated successfully")):(ae("error",`❌ Failed to generate API key: ${ce.error||"Unknown error"}`,"failed"),L.error("Failed to generate API key"))}catch(W){ae("error",`❌ Network error: ${W}`,"failed"),L.error("Failed to generate API key")}finally{s(null)}},Wa=W=>{if(!W)return"N/A";const ce=new Date(W);return Number.isNaN(ce.getTime())?W:ce.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})},qa=()=>{G(!0)},Xa=()=>{Me(""),He(""),Ve(null),Ge(null),xe(!0)},Zr=()=>{Ut("api_key"),te(""),Le(""),le("15"),pe(""),We(`{
691
691
 
692
- }`),ne(null),jt(!0)},Ii=async()=>{try{const ce=await(await fetch("/api/database/schema")).json();if(ce.success&&ce.schema&&ce.schema.tables){const de=ce.schema.tables.map(Re=>({name:Re.name,displayName:Re.displayName||Re.name}));V(de)}}catch{L.error("Failed to fetch available tables")}};m.useEffect(()=>{$&&(Ii(),Z(new Set))},[$]);const Vs=W=>{Z(ce=>{const de=new Set(ce);return de.has(W)?de.delete(W):de.add(W),de})},ss=()=>{Z(new Set(z.map(W=>W.name)))},Ys=()=>{Z(new Set)},Ga=async()=>{if(!Ce.trim()){L.error("Please paste a JWT to decode");return}vt(!0),Ge(null),Ve(null);try{const ce=await(await fetch("/api/tools/jwt/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:Ce.trim(),secret:Oe.trim()||void 0})})).json();if(ce.success)Ve(ce),L.success("JWT decoded successfully");else{const de=ce.error||"Failed to decode JWT";Ge(de),L.error(de)}}catch(W){const ce=W instanceof Error?W.message:"Failed to decode JWT";Ge(ce),L.error(ce)}finally{vt(!1)}},Wi=async()=>{const W=parseInt(Y,10);if(isNaN(W)||W<=0){L.error("Please provide a valid expiration (minutes)");return}let ce;if(it==="jwt"){const de=ke.trim();if(de.length>0&&de!=="{"&&de!=="}")try{ce=JSON.parse(de)}catch{L.error("Custom claims must be valid JSON");return}}ue(!0),ne(null);try{const Re=await(await fetch("/api/tools/token-generator",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:it,subject:Bt||void 0,audience:be||void 0,expiresInMinutes:W,customClaims:ce,secretOverride:he||void 0})})).json();if(Re.success)ne(Re),ae("success",`✅ Generated ${it.replace("_"," ")} token`,"completed"),L.success("Token generated successfully");else throw new Error(Re.error||"Failed to generate token")}catch(de){const Re=de instanceof Error?de.message:"Failed to generate token";ae("error",`❌ ${Re}`,"failed"),L.error(Re)}finally{ue(!1)}},jl=async()=>{if(X.size===0){L.error("Please select at least one table to export");return}const W=parseInt(K,10);if(isNaN(W)||W<=0){L.error("Please enter a valid limit (greater than 0)");return}if(W>1e4){L.error("Limit cannot exceed 10,000 rows per table");return}re(!0),s("export-data"),l(!0),i([]);try{ae("info",`📦 Starting export of ${X.size} table(s)...`,"running"),ae("progress",`Format: ${ee.toUpperCase()} | Limit: ${W} rows per table`,"running");const de=await(await fetch("/api/tools/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tables:Array.from(X),format:ee,limit:W})})).json();if(de.success){ae("success","✅ Export completed successfully!","completed"),de.rowCounts&&Object.entries(de.rowCounts).forEach(([bn,Nn])=>{ae("info",` • ${bn}: ${Nn} rows`,"completed")}),ae("info",`📥 Downloading ${de.filename}...`,"completed");const Re=new Blob([de.data],{type:de.contentType||(ee==="json"?"application/json":"text/csv")}),Ze=window.URL.createObjectURL(Re),gt=document.createElement("a");gt.href=Ze,gt.download=de.filename,document.body.appendChild(gt),gt.click(),document.body.removeChild(gt),window.URL.revokeObjectURL(Ze),L.success("Export downloaded successfully"),G(!1)}else throw new Error(de.error||"Export failed")}catch(ce){ae("error",`❌ Export failed: ${ce instanceof Error?ce.message:ce}`,"failed"),L.error("Export failed")}finally{re(!1),s(null)}},Fs=async()=>{s("health-check"),l(!0),i([]),ae("info","Running Better Auth health check...","running");try{ae("progress","Testing Better Auth endpoints...","running");const W=await fetch("/api/tools/health-check",{method:"POST"}),ce=await W.json();if(!W.ok)throw new Error(ce.error||ce.message||"Health check failed");ce.success?(ae("success","✅ Better Auth health check passed","completed"),L.success("Health check passed")):(ae("error","❌ Better Auth health check failed","failed"),ce.failedEndpoints&&ce.failedEndpoints.length>0&&ce.failedEndpoints.forEach(de=>{const Re=de.status?` (Status: ${de.status})`:"",Ze=de.error?` - ${de.error}`:"";ae("error",` • Endpoint ${de.endpoint}${Re}${Ze}`,"failed")}),L.error("Health check failed"))}catch(W){ae("error",`❌ Health check failed: ${W instanceof Error?W.message:W}`,"failed"),L.error("Health check failed")}finally{s(null)}},Is=new Set(["test-oauth","test-db","hash-password","health-check","export-data","jwt-decoder","token-generator"]),Qr=[{id:"test-oauth",name:"Test OAuth",description:"Test OAuth provider connections",icon:fs,action:qr,category:"oauth"},{id:"hash-password",name:"Hash Password",description:"Generate SHA hashes",icon:Ao,action:Zt,category:"utilities"},{id:"run-migration",name:"Run Migration",description:"Run database migrations",icon:Oa,action:wl,category:"database"},{id:"test-db",name:"Test Database",description:"Test database connection",icon:Oa,action:Gr,category:"database"},{id:"validate-config",name:"Validate Config",description:"Validate Better Auth configuration",icon:Tp,action:pa,category:"utilities"},{id:"generate-api-key",name:"Generate API Key",description:"Generate a new API key",icon:Ao,action:Fi,category:"utilities"},{id:"health-check",name:"Health Check",description:"Run system health check",icon:jy,action:Fs,category:"testing"},{id:"export-data",name:"Export Data",description:"Export database tables to JSON or CSV",icon:pc,action:qa,category:"database"},{id:"jwt-decoder",name:"JWT Decoder",description:"Inspect tokens and verify claims",icon:hn,action:Xa,category:"utilities"},{id:"token-generator",name:"Token Generator",description:"Mint short-lived test tokens",icon:bc,action:Zr,category:"utilities"}],Sl=[{id:"oauth",name:"OAuth",icon:fs},{id:"database",name:"Database",icon:Oa},{id:"testing",name:"Testing",icon:jy},{id:"utilities",name:"Utilities",icon:qS}].map(W=>({...W,tools:Qr.filter(ce=>ce.category===W.id)}));return a.jsxs("div",{className:"space-y-8 bg-black w-full min-h-screen",children:[a.jsxs("div",{className:"w-full flex flex-col",children:[a.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:a.jsxs("div",{className:"pb-8",children:[a.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Tools"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Utility tools for managing and testing your Better Auth setup"})]})}),a.jsxs("div",{className:"flex flex-col items-center space-y-8",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),o&&r.length>0&&a.jsxs("div",{className:"mb-6 p-6 gap-8",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 tracking-wider",children:"Tool Output"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsx(Br,{title:"Tool Execution Logs",lines:r,isRunning:n!==null,className:"w-full",defaultCollapsed:!1})]}),a.jsx("div",{className:"space-y-8 p-6 gap-8",children:Sl.map(W=>a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(W.icon,{className:"w-5 h-5 text-white"}),a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider",children:W.name})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:W.tools.map(ce=>{const de=ce.icon,Re=n===ce.id,Ze=Is.has(ce.id),gt=!Ze||n!==null&&n!==ce.id||Re;return a.jsxs("button",{onClick:()=>ce.action(),disabled:gt,className:`relative flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none transition-colors text-left group ${Ze?"hover:bg-black/50 disabled:opacity-50 disabled:cursor-not-allowed":"opacity-60 cursor-not-allowed"}`,children:[a.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:Re?a.jsx(vs,{className:"w-6 h-6 text-white animate-spin"}):a.jsx(de,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"text-white font-light mb-1",children:ce.name}),a.jsxs("p",{className:"text-xs uppercase font-mono flex items-center text-gray-400",children:[a.jsx(NB,{className:"w-4 h-4 mr-2"}),ce.description]})]}),!Ze&&a.jsx("span",{className:"absolute top-2 right-3 text-[10px] font-mono uppercase tracking-[0.2em] text-white/60",children:"Coming Soon"}),a.jsx(dr,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]},ce.id)})})]},W.id))})]}),j&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Ao,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Password Hasher"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Algorithm"}),a.jsxs("select",{value:H,onChange:W=>U(W.target.value),className:"mt-2 w-full bg-black border border-dashed border-white/20 text-white px-3 py-2 text-sm focus:outline-none",children:[a.jsx("option",{value:"SHA-256",children:"SHA-256"}),a.jsx("option",{value:"SHA-384",children:"SHA-384"}),a.jsx("option",{value:"SHA-512",children:"SHA-512"})]})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Encoding"}),a.jsxs("select",{value:O,onChange:W=>B(W.target.value),className:"mt-2 w-full bg-black border border-dashed border-white/20 text-white px-3 py-2 text-sm focus:outline-none",children:[a.jsx("option",{value:"hex",children:"Hex"}),a.jsx("option",{value:"base64",children:"Base64"}),a.jsx("option",{value:"base64url",children:"Base64 URL"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Salt (optional)"}),a.jsx(Be,{value:M,onChange:W=>A(W.target.value),placeholder:"e.g. project-specific-salt",className:"mt-2 bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsxs("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:["Salt is prepended (",a.jsx("span",{className:"text-white/80",children:"salt:password"}),")"]})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Password"}),a.jsxs("div",{className:"relative mt-2",children:[a.jsx(Be,{type:k?"text":"password",value:C,onChange:W=>S(W.target.value),placeholder:"Enter password",className:"bg-black border border-dashed border-white/20 text-white rounded-none pr-10"}),a.jsx("button",{type:"button",onClick:()=>D(W=>!W),className:"absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-white","aria-label":k?"Hide password":"Show password",children:k?a.jsx(D4,{className:"w-4 h-4"}):a.jsx(gl,{className:"w-4 h-4"})})]})]})]}),E&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Hash Result"}),a.jsxs("div",{className:"mt-2 flex items-center space-x-2",children:[a.jsx(Be,{value:E,readOnly:!0,className:"flex-1 bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsx(P,{variant:"outline",size:"icon",onClick:()=>E&&$t(E),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]})]})]}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-8 border-t border-dashed border-white/10 pt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>N(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"}),a.jsx(P,{onClick:ns,disabled:T,className:"rounded-none",children:T?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Hashing..."]}):"Hash Password"})]})]})}),c&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-8 w-full max-w-2xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(fs,{className:"w-6 h-6 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light",children:"Select OAuth Provider"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>{u(!1),x("")},className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"space-y-4",children:h.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(fs,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 mb-2 text-lg",children:"No OAuth providers configured"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Please configure OAuth providers in your Better Auth configuration"})]}):a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-4 uppercase font-mono",children:["Available Providers (",h.length,")"]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-96 overflow-y-auto",children:h.map(W=>a.jsxs("button",{onClick:()=>{x(W.id),setTimeout(()=>{Xr(W.id)},100)},className:`w-full flex items-center space-x-4 p-4 border rounded-none transition-all text-left group ${f===W.id?"border-white/50 bg-white/10":"border-dashed border-white/20 hover:bg-white/5 hover:border-white/30"}`,children:[a.jsx("div",{className:"flex-shrink-0",children:n5(W.id)}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-white uppercase font-mono font-light text-base",children:W.name||W.id})}),a.jsx(dr,{className:`w-5 h-5 transition-colors flex-shrink-0 ${f===W.id?"text-white":"text-gray-400 group-hover:text-white"}`})]},W.id))}),a.jsx("p",{className:"text-xs text-gray-500 mt-4 font-mono uppercase",children:"Click on a provider to start the OAuth test"})]})}),a.jsx("div",{className:"flex justify-end space-x-3 mt-8 pt-6 border-t border-dashed border-white/10",children:a.jsx(P,{variant:"outline",onClick:()=>{u(!1),x("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"})})]})}),y&&a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/95 border border-dashed border-white/20 p-8 w-full max-w-5xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Oa,{className:"w-6 h-6 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Select Migration"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>b(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[a.jsx("div",{className:"space-y-3",children:Wl.map(W=>{const ce=(ze==null?void 0:ze.id)===W.id;return a.jsxs("button",{onClick:()=>et(W.id),disabled:W.disabled,className:`w-full flex items-center space-x-3 p-4 border transition-colors rounded-none text-left ${W.disabled?"border-dashed border-white/10 bg-black/30 cursor-not-allowed opacity-60":ce?"border-white/60 bg-white/10":"border-dashed border-white/20 hover:bg-white/5 hover:border-white/40"}`,children:[a.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-white/10 flex items-center justify-center",children:W.logo?W.logo:a.jsx(vy,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white uppercase font-mono text-sm",children:W.name}),a.jsx("p",{className:"text-xs uppercase text-gray-400 font-mono mt-1 truncate",children:W.description})]}),W.disabled&&a.jsx("span",{className:"text-[10px] font-mono text-gray-400 uppercase",children:"Coming Soon"})]},W.id)})}),a.jsxs("div",{className:"md:col-span-2 space-y-4",children:[a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx("div",{className:"w-12 h-12 bg-white/10 flex items-center justify-center",children:ze.logo?ze.logo:a.jsx(vy,{className:"w-8 h-8 text-white"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-white -mb-2 text-lg font-light uppercase tracking-wider",children:ze.name}),a.jsx("p",{className:"text-sm mt-0 text-gray-400 uppercase font-mono leading-relaxed",children:ze.description}),a.jsx("div",{className:"flex items-center space-x-2",children:ze.docs&&a.jsx(P,{variant:"ghost",size:"sm",asChild:!0,className:"rounded-none border border-dashed",children:a.jsx("a",{href:ze.docs,target:"_blank",rel:"noreferrer",children:"View Docs"})})})]})]}),ze.highlights&&a.jsx("ul",{className:"space-y-2 text-xs text-gray-300 font-mono bg-black/40 border border-white/10 p-4",children:ze.highlights.map(W=>a.jsxs("li",{className:"flex items-start space-x-2",children:[a.jsx("span",{className:"text-white/60 mt-0.5",children:"•"}),a.jsx("span",{children:W})]},W))}),ze.disabled?a.jsxs("div",{className:"space-y-4 text-gray-400 font-mono text-xs",children:[a.jsx("p",{children:"This migration provider is coming soon."}),a.jsxs("p",{children:["Subscribe to updates at"," ",a.jsx("a",{href:"https://better-auth.com",target:"_blank",rel:"noreferrer",className:"text-white underline",children:"better-auth.com"}),"."]})]}):ze.custom?a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-xs uppercase font-mono text-gray-400",children:"Custom Migration Script"}),a.jsx("textarea",{value:v,onChange:W=>p(W.target.value),className:"w-full h-64 bg-black/70 border border-white/10 text-xs text-gray-200 font-mono p-3 rounded-none focus:outline-none focus:ring-0"}),a.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[a.jsx(P,{variant:"outline",size:"sm",className:"rounded-none",onClick:()=>p(nx),children:"Reset"}),a.jsxs(P,{variant:"ghost",size:"sm",className:"rounded-none text-gray-400 hover:text-white",onClick:()=>$t(v),children:[a.jsx(li,{className:"w-4 h-4"}),"Copy Script"]}),a.jsx(P,{className:"rounded-none",onClick:()=>Yi("custom",v),children:"Run Custom Script"})]})]}):a.jsxs("div",{className:"space-y-3",children:[ze.script&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs uppercase font-mono text-gray-400",children:[a.jsx("span",{children:"Migration Script Preview"}),a.jsxs(P,{variant:"ghost",size:"sm",className:"rounded-none text-gray-400 hover:text-white",onClick:()=>$t(ze.script),children:[a.jsx(li,{className:"w-4 h-4"}),"Copy Script"]})]}),a.jsx("pre",{className:"bg-black/70 border border-white/10 text-[11px] text-green-200 font-mono p-4 overflow-auto leading-relaxed h-64",children:a.jsx("code",{children:ze.script})})]}),a.jsx("div",{className:"flex items-center justify-end space-x-2",children:a.jsxs(P,{className:"rounded-none",onClick:()=>Yi(ze.id),children:["Run ",ze.name," Migration"]})})]})]})]})]})}),$&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-3xl max-h-[85vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(pc,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Export Data"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>G(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Export Format"}),a.jsxs("div",{className:"flex space-x-4",children:[a.jsx("button",{onClick:()=>J("json"),className:`px-4 py-2 border rounded-none transition-colors ${ee==="json"?"border-white/50 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/30"}`,children:"JSON"}),a.jsx("button",{onClick:()=>J("csv"),className:`px-4 py-2 border rounded-none transition-colors ${ee==="csv"?"border-white/50 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/30"}`,children:"CSV"})]})]}),a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"export-limit",className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Row Limit Per Table"}),a.jsx(Be,{id:"export-limit",type:"number",value:K,onChange:W=>se(W.target.value),min:"1",max:"10000",placeholder:"1000",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Maximum 10,000 rows per table (default: 1000)"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs(_e,{className:"text-xs uppercase font-mono text-gray-400",children:["Select Tables (",X.size," selected)"]}),a.jsxs("div",{className:"flex space-x-2",children:[a.jsx(P,{variant:"ghost",size:"sm",onClick:ss,className:"text-xs text-gray-400 hover:text-white rounded-none",children:"Select All"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:Ys,className:"text-xs text-gray-400 hover:text-white rounded-none",children:"Deselect All"})]})]}),a.jsx("div",{className:"border border-dashed border-white/20 rounded-none max-h-64 overflow-y-auto",children:z.length===0?a.jsx("div",{className:"p-4 text-center text-gray-400 text-sm",children:"Loading tables..."}):a.jsx("div",{className:"space-y-0",children:z.map(W=>{const ce=X.has(W.name);return a.jsx("button",{onClick:()=>Vs(W.name),className:`w-full text-left p-3 border-b border-dashed border-white/10 last:border-b-0 transition-colors ${ce?"bg-white/10 border-white/30":"hover:bg-white/5"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm font-mono",children:W.displayName}),a.jsxs("span",{className:"text-xs text-gray-400 ml-2 font-mono",children:["(",W.name,")"]})]}),ce&&a.jsx(SB,{className:"w-4 h-4 text-white"})]})},W.name)})})})]})]}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-8 border-t border-dashed border-white/10 pt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>G(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:jl,disabled:we||X.size===0,className:"rounded-none",children:we?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Exporting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(pc,{className:"w-4 h-4 mr-2"}),"Export"]})})]})]})}),fe&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60]",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(hn,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"JWT Decoder"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>xe(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"JWT Token"}),a.jsx("textarea",{value:Ce,onChange:W=>Me(W.target.value),placeholder:"Paste JWT here",className:"w-full min-h-[120px] bg-black border border-dashed border-white/20 text-white font-mono text-xs p-3 rounded-none focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"HMAC Secret (optional)"}),a.jsx(Be,{value:Oe,onChange:W=>He(W.target.value),placeholder:"Defaults to Better Auth secret if omitted",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>{Me(""),He(""),Ve(null),Ge(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),a.jsx(P,{onClick:Ga,disabled:wt,className:"rounded-none",children:wt?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Decoding..."]}):"Decode JWT"})]})]}),qe&&a.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:qe}),Ie&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Signature"}),a.jsx("p",{className:`text-sm ${Ie.verified?"text-green-400":"text-yellow-300"}`,children:Ie.verified?"Verified (HS256)":"Not verified"}),a.jsx("p",{className:"text-gray-400 break-all",children:Ie.signature||"None"})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Issued"}),a.jsx("p",{className:"text-white",children:Ie.issuedAtFormatted||"Unknown"}),a.jsx("p",{className:"text-gray-500",children:Ie.issuedAgo||""})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Expires"}),a.jsx("p",{className:`text-white ${Ie.expired?"text-red-300":""}`,children:Ie.expiresAtFormatted||"No expiry"}),a.jsx("p",{className:"text-gray-500",children:Ie.expiresIn||""})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs uppercase font-mono text-gray-400",children:"Header"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>$t(JSON.stringify(Ie.header,null,2)),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.header,null,2)})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs uppercase font-mono text-gray-400",children:"Payload"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>$t(JSON.stringify(Ie.payload,null,2)),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.payload,null,2)})]})]}),Ie.customClaims&&Object.keys(Ie.customClaims).length>0&&a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-400 mb-2",children:"Custom Claims"}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.customClaims,null,2)})]})]})]})]})}),Et&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(bc,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Token Generator"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>jt(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Token Type"}),a.jsx("div",{className:"flex flex-wrap gap-3",children:[{id:"api_key",label:"API Key"},{id:"jwt",label:"JWT"}].map(W=>a.jsx("button",{onClick:()=>Ut(W.id),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors ${it===W.id?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:W.label},W.id))})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject / User ID (optional)"}),a.jsx(Be,{value:Bt,onChange:W=>te(W.target.value),placeholder:"User identifier or email",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Audience (optional)"}),a.jsx(Be,{value:be,onChange:W=>Le(W.target.value),placeholder:"Audience / app id",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Expires In (minutes)"}),a.jsx(Be,{type:"number",value:Y,onChange:W=>le(W.target.value),min:"1",max:"1440",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),it==="jwt"&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Override Secret (optional)"}),a.jsx(Be,{value:he,onChange:W=>pe(W.target.value),placeholder:"Defaults to Better Auth secret",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]})]}),it==="jwt"&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Custom Claims (JSON)"}),a.jsx("textarea",{value:ke,onChange:W=>We(W.target.value),placeholder:'{"role":"admin"}',className:"w-full min-h-[120px] bg-black border border-dashed border-white/20 text-white font-mono text-xs p-3 rounded-none focus:outline-none"}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Leave empty to include only default claims (iss, sub, aud, exp, iat, jti)."})]}),a.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>{ne(null),te(""),Le(""),We(`{
692
+ }`),ne(null),jt(!0)},Ii=async()=>{try{const ce=await(await fetch("/api/database/schema")).json();if(ce.success&&ce.schema&&ce.schema.tables){const de=ce.schema.tables.map(Re=>({name:Re.name,displayName:Re.displayName||Re.name}));V(de)}}catch{L.error("Failed to fetch available tables")}};m.useEffect(()=>{$&&(Ii(),Z(new Set))},[$]);const Vs=W=>{Z(ce=>{const de=new Set(ce);return de.has(W)?de.delete(W):de.add(W),de})},ss=()=>{Z(new Set(z.map(W=>W.name)))},Ys=()=>{Z(new Set)},Ga=async()=>{if(!Ce.trim()){L.error("Please paste a JWT to decode");return}vt(!0),Ge(null),Ve(null);try{const ce=await(await fetch("/api/tools/jwt/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:Ce.trim(),secret:Oe.trim()||void 0})})).json();if(ce.success)Ve(ce),L.success("JWT decoded successfully");else{const de=ce.error||"Failed to decode JWT";Ge(de),L.error(de)}}catch(W){const ce=W instanceof Error?W.message:"Failed to decode JWT";Ge(ce),L.error(ce)}finally{vt(!1)}},Wi=async()=>{const W=parseInt(Y,10);if(isNaN(W)||W<=0){L.error("Please provide a valid expiration (minutes)");return}let ce;if(it==="jwt"){const de=ke.trim();if(de.length>0&&de!=="{"&&de!=="}")try{ce=JSON.parse(de)}catch{L.error("Custom claims must be valid JSON");return}}ue(!0),ne(null);try{const Re=await(await fetch("/api/tools/token-generator",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:it,subject:Bt||void 0,audience:be||void 0,expiresInMinutes:W,customClaims:ce,secretOverride:he||void 0})})).json();if(Re.success)ne(Re),ae("success",`✅ Generated ${it.replace("_"," ")} token`,"completed"),L.success("Token generated successfully");else throw new Error(Re.error||"Failed to generate token")}catch(de){const Re=de instanceof Error?de.message:"Failed to generate token";ae("error",`❌ ${Re}`,"failed"),L.error(Re)}finally{ue(!1)}},jl=async()=>{if(X.size===0){L.error("Please select at least one table to export");return}const W=parseInt(K,10);if(isNaN(W)||W<=0){L.error("Please enter a valid limit (greater than 0)");return}if(W>1e4){L.error("Limit cannot exceed 10,000 rows per table");return}re(!0),s("export-data"),l(!0),i([]);try{ae("info",`📦 Starting export of ${X.size} table(s)...`,"running"),ae("progress",`Format: ${ee.toUpperCase()} | Limit: ${W} rows per table`,"running");const de=await(await fetch("/api/tools/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tables:Array.from(X),format:ee,limit:W})})).json();if(de.success){ae("success","✅ Export completed successfully!","completed"),de.rowCounts&&Object.entries(de.rowCounts).forEach(([bn,Nn])=>{ae("info",` • ${bn}: ${Nn} rows`,"completed")}),ae("info",`Downloading ${de.filename}...`,"completed");const Re=new Blob([de.data],{type:de.contentType||(ee==="json"?"application/json":"text/csv")}),Ze=window.URL.createObjectURL(Re),gt=document.createElement("a");gt.href=Ze,gt.download=de.filename,document.body.appendChild(gt),gt.click(),document.body.removeChild(gt),window.URL.revokeObjectURL(Ze),L.success("Export downloaded successfully"),G(!1)}else throw new Error(de.error||"Export failed")}catch(ce){ae("error",`❌ Export failed: ${ce instanceof Error?ce.message:ce}`,"failed"),L.error("Export failed")}finally{re(!1),s(null)}},Fs=async()=>{s("health-check"),l(!0),i([]),ae("info","Running Better Auth health check...","running");try{ae("progress","Testing Better Auth endpoints...","running");const W=await fetch("/api/tools/health-check",{method:"POST"}),ce=await W.json();if(!W.ok)throw new Error(ce.error||ce.message||"Health check failed");ce.success?(ae("success","✅ Better Auth health check passed","completed"),L.success("Health check passed")):(ae("error","❌ Better Auth health check failed","failed"),ce.failedEndpoints&&ce.failedEndpoints.length>0&&ce.failedEndpoints.forEach(de=>{const Re=de.status?` (Status: ${de.status})`:"",Ze=de.error?` - ${de.error}`:"";ae("error",` • Endpoint ${de.endpoint}${Re}${Ze}`,"failed")}),L.error("Health check failed"))}catch(W){ae("error",`❌ Health check failed: ${W instanceof Error?W.message:W}`,"failed"),L.error("Health check failed")}finally{s(null)}},Is=new Set(["test-oauth","test-db","hash-password","health-check","export-data","jwt-decoder","token-generator"]),Qr=[{id:"test-oauth",name:"Test OAuth",description:"Test OAuth provider connections",icon:fs,action:qr,category:"oauth"},{id:"hash-password",name:"Hash Password",description:"Generate SHA hashes",icon:Ao,action:Zt,category:"utilities"},{id:"run-migration",name:"Run Migration",description:"Run database migrations",icon:Oa,action:wl,category:"database"},{id:"test-db",name:"Test Database",description:"Test database connection",icon:Oa,action:Gr,category:"database"},{id:"validate-config",name:"Validate Config",description:"Validate Better Auth configuration",icon:Tp,action:pa,category:"utilities"},{id:"generate-api-key",name:"Generate API Key",description:"Generate a new API key",icon:Ao,action:Fi,category:"utilities"},{id:"health-check",name:"Health Check",description:"Run system health check",icon:jy,action:Fs,category:"testing"},{id:"export-data",name:"Export Data",description:"Export database tables to JSON or CSV",icon:pc,action:qa,category:"database"},{id:"jwt-decoder",name:"JWT Decoder",description:"Inspect tokens and verify claims",icon:hn,action:Xa,category:"utilities"},{id:"token-generator",name:"Token Generator",description:"Mint short-lived test tokens",icon:bc,action:Zr,category:"utilities"}],Sl=[{id:"oauth",name:"OAuth",icon:fs},{id:"database",name:"Database",icon:Oa},{id:"testing",name:"Testing",icon:jy},{id:"utilities",name:"Utilities",icon:qS}].map(W=>({...W,tools:Qr.filter(ce=>ce.category===W.id)}));return a.jsxs("div",{className:"space-y-8 bg-black w-full min-h-screen",children:[a.jsxs("div",{className:"w-full flex flex-col",children:[a.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:a.jsxs("div",{className:"pb-8",children:[a.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Tools"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Utility tools for managing and testing your Better Auth setup"})]})}),a.jsxs("div",{className:"flex flex-col items-center space-y-8",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),o&&r.length>0&&a.jsxs("div",{className:"mb-6 p-6 gap-8",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 tracking-wider",children:"Tool Output"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsx(Br,{title:"Tool Execution Logs",lines:r,isRunning:n!==null,className:"w-full",defaultCollapsed:!1})]}),a.jsx("div",{className:"space-y-8 p-6 gap-8",children:Sl.map(W=>a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(W.icon,{className:"w-5 h-5 text-white"}),a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider",children:W.name})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:W.tools.map(ce=>{const de=ce.icon,Re=n===ce.id,Ze=Is.has(ce.id),gt=!Ze||n!==null&&n!==ce.id||Re;return a.jsxs("button",{onClick:()=>ce.action(),disabled:gt,className:`relative flex items-center space-x-4 p-4 bg-black/30 border border-dashed border-white/20 rounded-none transition-colors text-left group ${Ze?"hover:bg-black/50 disabled:opacity-50 disabled:cursor-not-allowed":"opacity-60 cursor-not-allowed"}`,children:[a.jsx("div",{className:"p-2 bg-white/10 rounded-none group-hover:bg-white/20 transition-colors",children:Re?a.jsx(vs,{className:"w-6 h-6 text-white animate-spin"}):a.jsx(de,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"text-white font-light mb-1",children:ce.name}),a.jsxs("p",{className:"text-xs uppercase font-mono flex items-center text-gray-400",children:[a.jsx(NB,{className:"w-4 h-4 mr-2"}),ce.description]})]}),!Ze&&a.jsx("span",{className:"absolute top-2 right-3 text-[10px] font-mono uppercase tracking-[0.2em] text-white/60",children:"Coming Soon"}),a.jsx(dr,{className:"w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]},ce.id)})})]},W.id))})]}),j&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Ao,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Password Hasher"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Algorithm"}),a.jsxs("select",{value:H,onChange:W=>U(W.target.value),className:"mt-2 w-full bg-black border border-dashed border-white/20 text-white px-3 py-2 text-sm focus:outline-none",children:[a.jsx("option",{value:"SHA-256",children:"SHA-256"}),a.jsx("option",{value:"SHA-384",children:"SHA-384"}),a.jsx("option",{value:"SHA-512",children:"SHA-512"})]})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Encoding"}),a.jsxs("select",{value:O,onChange:W=>B(W.target.value),className:"mt-2 w-full bg-black border border-dashed border-white/20 text-white px-3 py-2 text-sm focus:outline-none",children:[a.jsx("option",{value:"hex",children:"Hex"}),a.jsx("option",{value:"base64",children:"Base64"}),a.jsx("option",{value:"base64url",children:"Base64 URL"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Salt (optional)"}),a.jsx(Be,{value:M,onChange:W=>A(W.target.value),placeholder:"e.g. project-specific-salt",className:"mt-2 bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsxs("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:["Salt is prepended (",a.jsx("span",{className:"text-white/80",children:"salt:password"}),")"]})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Password"}),a.jsxs("div",{className:"relative mt-2",children:[a.jsx(Be,{type:k?"text":"password",value:C,onChange:W=>S(W.target.value),placeholder:"Enter password",className:"bg-black border border-dashed border-white/20 text-white rounded-none pr-10"}),a.jsx("button",{type:"button",onClick:()=>D(W=>!W),className:"absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-white","aria-label":k?"Hide password":"Show password",children:k?a.jsx(D4,{className:"w-4 h-4"}):a.jsx(gl,{className:"w-4 h-4"})})]})]})]}),E&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400",children:"Hash Result"}),a.jsxs("div",{className:"mt-2 flex items-center space-x-2",children:[a.jsx(Be,{value:E,readOnly:!0,className:"flex-1 bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsx(P,{variant:"outline",size:"icon",onClick:()=>E&&$t(E),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]})]})]}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-8 border-t border-dashed border-white/10 pt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>N(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"}),a.jsx(P,{onClick:ns,disabled:T,className:"rounded-none",children:T?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Hashing..."]}):"Hash Password"})]})]})}),c&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-8 w-full max-w-2xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(fs,{className:"w-6 h-6 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light",children:"Select OAuth Provider"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>{u(!1),x("")},className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"space-y-4",children:h.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(fs,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 mb-2 text-lg",children:"No OAuth providers configured"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Please configure OAuth providers in your Better Auth configuration"})]}):a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-4 uppercase font-mono",children:["Available Providers (",h.length,")"]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-96 overflow-y-auto",children:h.map(W=>a.jsxs("button",{onClick:()=>{x(W.id),setTimeout(()=>{Xr(W.id)},100)},className:`w-full flex items-center space-x-4 p-4 border rounded-none transition-all text-left group ${f===W.id?"border-white/50 bg-white/10":"border-dashed border-white/20 hover:bg-white/5 hover:border-white/30"}`,children:[a.jsx("div",{className:"flex-shrink-0",children:n5(W.id)}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-white uppercase font-mono font-light text-base",children:W.name||W.id})}),a.jsx(dr,{className:`w-5 h-5 transition-colors flex-shrink-0 ${f===W.id?"text-white":"text-gray-400 group-hover:text-white"}`})]},W.id))}),a.jsx("p",{className:"text-xs text-gray-500 mt-4 font-mono uppercase",children:"Click on a provider to start the OAuth test"})]})}),a.jsx("div",{className:"flex justify-end space-x-3 mt-8 pt-6 border-t border-dashed border-white/10",children:a.jsx(P,{variant:"outline",onClick:()=>{u(!1),x("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"})})]})}),y&&a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/95 border border-dashed border-white/20 p-8 w-full max-w-5xl rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Oa,{className:"w-6 h-6 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Select Migration"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>b(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[a.jsx("div",{className:"space-y-3",children:Wl.map(W=>{const ce=(ze==null?void 0:ze.id)===W.id;return a.jsxs("button",{onClick:()=>et(W.id),disabled:W.disabled,className:`w-full flex items-center space-x-3 p-4 border transition-colors rounded-none text-left ${W.disabled?"border-dashed border-white/10 bg-black/30 cursor-not-allowed opacity-60":ce?"border-white/60 bg-white/10":"border-dashed border-white/20 hover:bg-white/5 hover:border-white/40"}`,children:[a.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-white/10 flex items-center justify-center",children:W.logo?W.logo:a.jsx(vy,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white uppercase font-mono text-sm",children:W.name}),a.jsx("p",{className:"text-xs uppercase text-gray-400 font-mono mt-1 truncate",children:W.description})]}),W.disabled&&a.jsx("span",{className:"text-[10px] font-mono text-gray-400 uppercase",children:"Coming Soon"})]},W.id)})}),a.jsxs("div",{className:"md:col-span-2 space-y-4",children:[a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx("div",{className:"w-12 h-12 bg-white/10 flex items-center justify-center",children:ze.logo?ze.logo:a.jsx(vy,{className:"w-8 h-8 text-white"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-white -mb-2 text-lg font-light uppercase tracking-wider",children:ze.name}),a.jsx("p",{className:"text-sm mt-0 text-gray-400 uppercase font-mono leading-relaxed",children:ze.description}),a.jsx("div",{className:"flex items-center space-x-2",children:ze.docs&&a.jsx(P,{variant:"ghost",size:"sm",asChild:!0,className:"rounded-none border border-dashed",children:a.jsx("a",{href:ze.docs,target:"_blank",rel:"noreferrer",children:"View Docs"})})})]})]}),ze.highlights&&a.jsx("ul",{className:"space-y-2 text-xs text-gray-300 font-mono bg-black/40 border border-white/10 p-4",children:ze.highlights.map(W=>a.jsxs("li",{className:"flex items-start space-x-2",children:[a.jsx("span",{className:"text-white/60 mt-0.5",children:"•"}),a.jsx("span",{children:W})]},W))}),ze.disabled?a.jsxs("div",{className:"space-y-4 text-gray-400 font-mono text-xs",children:[a.jsx("p",{children:"This migration provider is coming soon."}),a.jsxs("p",{children:["Subscribe to updates at"," ",a.jsx("a",{href:"https://better-auth.com",target:"_blank",rel:"noreferrer",className:"text-white underline",children:"better-auth.com"}),"."]})]}):ze.custom?a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-xs uppercase font-mono text-gray-400",children:"Custom Migration Script"}),a.jsx("textarea",{value:v,onChange:W=>p(W.target.value),className:"w-full h-64 bg-black/70 border border-white/10 text-xs text-gray-200 font-mono p-3 rounded-none focus:outline-none focus:ring-0"}),a.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[a.jsx(P,{variant:"outline",size:"sm",className:"rounded-none",onClick:()=>p(nx),children:"Reset"}),a.jsxs(P,{variant:"ghost",size:"sm",className:"rounded-none text-gray-400 hover:text-white",onClick:()=>$t(v),children:[a.jsx(li,{className:"w-4 h-4"}),"Copy Script"]}),a.jsx(P,{className:"rounded-none",onClick:()=>Yi("custom",v),children:"Run Custom Script"})]})]}):a.jsxs("div",{className:"space-y-3",children:[ze.script&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs uppercase font-mono text-gray-400",children:[a.jsx("span",{children:"Migration Script Preview"}),a.jsxs(P,{variant:"ghost",size:"sm",className:"rounded-none text-gray-400 hover:text-white",onClick:()=>$t(ze.script),children:[a.jsx(li,{className:"w-4 h-4"}),"Copy Script"]})]}),a.jsx("pre",{className:"bg-black/70 border border-white/10 text-[11px] text-green-200 font-mono p-4 overflow-auto leading-relaxed h-64",children:a.jsx("code",{children:ze.script})})]}),a.jsx("div",{className:"flex items-center justify-end space-x-2",children:a.jsxs(P,{className:"rounded-none",onClick:()=>Yi(ze.id),children:["Run ",ze.name," Migration"]})})]})]})]})]})}),$&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black border border-dashed border-white/20 rounded-none p-6 w-full max-w-3xl max-h-[85vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(pc,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Export Data"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>G(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Export Format"}),a.jsxs("div",{className:"flex space-x-4",children:[a.jsx("button",{onClick:()=>J("json"),className:`px-4 py-2 border rounded-none transition-colors ${ee==="json"?"border-white/50 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/30"}`,children:"JSON"}),a.jsx("button",{onClick:()=>J("csv"),className:`px-4 py-2 border rounded-none transition-colors ${ee==="csv"?"border-white/50 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/30"}`,children:"CSV"})]})]}),a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"export-limit",className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Row Limit Per Table"}),a.jsx(Be,{id:"export-limit",type:"number",value:K,onChange:W=>se(W.target.value),min:"1",max:"10000",placeholder:"1000",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Maximum 10,000 rows per table (default: 1000)"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs(_e,{className:"text-xs uppercase font-mono text-gray-400",children:["Select Tables (",X.size," selected)"]}),a.jsxs("div",{className:"flex space-x-2",children:[a.jsx(P,{variant:"ghost",size:"sm",onClick:ss,className:"text-xs text-gray-400 hover:text-white rounded-none",children:"Select All"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:Ys,className:"text-xs text-gray-400 hover:text-white rounded-none",children:"Deselect All"})]})]}),a.jsx("div",{className:"border border-dashed border-white/20 rounded-none max-h-64 overflow-y-auto",children:z.length===0?a.jsx("div",{className:"p-4 text-center text-gray-400 text-sm",children:"Loading tables..."}):a.jsx("div",{className:"space-y-0",children:z.map(W=>{const ce=X.has(W.name);return a.jsx("button",{onClick:()=>Vs(W.name),className:`w-full text-left p-3 border-b border-dashed border-white/10 last:border-b-0 transition-colors ${ce?"bg-white/10 border-white/30":"hover:bg-white/5"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm font-mono",children:W.displayName}),a.jsxs("span",{className:"text-xs text-gray-400 ml-2 font-mono",children:["(",W.name,")"]})]}),ce&&a.jsx(SB,{className:"w-4 h-4 text-white"})]})},W.name)})})})]})]}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-8 border-t border-dashed border-white/10 pt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>G(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:jl,disabled:we||X.size===0,className:"rounded-none",children:we?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Exporting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(pc,{className:"w-4 h-4 mr-2"}),"Export"]})})]})]})}),fe&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[60]",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(hn,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"JWT Decoder"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>xe(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"JWT Token"}),a.jsx("textarea",{value:Ce,onChange:W=>Me(W.target.value),placeholder:"Paste JWT here",className:"w-full min-h-[120px] bg-black border border-dashed border-white/20 text-white font-mono text-xs p-3 rounded-none focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"HMAC Secret (optional)"}),a.jsx(Be,{value:Oe,onChange:W=>He(W.target.value),placeholder:"Defaults to Better Auth secret if omitted",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{className:"flex items-end justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>{Me(""),He(""),Ve(null),Ge(null)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Clear"}),a.jsx(P,{onClick:Ga,disabled:wt,className:"rounded-none",children:wt?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Decoding..."]}):"Decode JWT"})]})]}),qe&&a.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:qe}),Ie&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Signature"}),a.jsx("p",{className:`text-sm ${Ie.verified?"text-green-400":"text-yellow-300"}`,children:Ie.verified?"Verified (HS256)":"Not verified"}),a.jsx("p",{className:"text-gray-400 break-all",children:Ie.signature||"None"})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Issued"}),a.jsx("p",{className:"text-white",children:Ie.issuedAtFormatted||"Unknown"}),a.jsx("p",{className:"text-gray-500",children:Ie.issuedAgo||""})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3 space-y-2",children:[a.jsx("div",{className:"text-gray-400 uppercase tracking-wider",children:"Expires"}),a.jsx("p",{className:`text-white ${Ie.expired?"text-red-300":""}`,children:Ie.expiresAtFormatted||"No expiry"}),a.jsx("p",{className:"text-gray-500",children:Ie.expiresIn||""})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs uppercase font-mono text-gray-400",children:"Header"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>$t(JSON.stringify(Ie.header,null,2)),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.header,null,2)})]}),a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs uppercase font-mono text-gray-400",children:"Payload"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>$t(JSON.stringify(Ie.payload,null,2)),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.payload,null,2)})]})]}),Ie.customClaims&&Object.keys(Ie.customClaims).length>0&&a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-400 mb-2",children:"Custom Claims"}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto max-h-64",children:JSON.stringify(Ie.customClaims,null,2)})]})]})]})]})}),Et&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(bc,{className:"w-5 h-5 text-white"}),a.jsx("h3",{className:"text-xl text-white font-light uppercase tracking-wider",children:"Token Generator"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>jt(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Token Type"}),a.jsx("div",{className:"flex flex-wrap gap-3",children:[{id:"api_key",label:"API Key"},{id:"jwt",label:"JWT"}].map(W=>a.jsx("button",{onClick:()=>Ut(W.id),className:`px-4 py-2 border rounded-none text-sm uppercase font-mono transition-colors ${it===W.id?"border-white/60 bg-white/10 text-white":"border-dashed border-white/20 text-gray-400 hover:border-white/40"}`,children:W.label},W.id))})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject / User ID (optional)"}),a.jsx(Be,{value:Bt,onChange:W=>te(W.target.value),placeholder:"User identifier or email",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Audience (optional)"}),a.jsx(Be,{value:be,onChange:W=>Le(W.target.value),placeholder:"Audience / app id",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Expires In (minutes)"}),a.jsx(Be,{type:"number",value:Y,onChange:W=>le(W.target.value),min:"1",max:"1440",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),it==="jwt"&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Override Secret (optional)"}),a.jsx(Be,{value:he,onChange:W=>pe(W.target.value),placeholder:"Defaults to Better Auth secret",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]})]}),it==="jwt"&&a.jsxs("div",{children:[a.jsx(_e,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Custom Claims (JSON)"}),a.jsx("textarea",{value:ke,onChange:W=>We(W.target.value),placeholder:'{"role":"admin"}',className:"w-full min-h-[120px] bg-black border border-dashed border-white/20 text-white font-mono text-xs p-3 rounded-none focus:outline-none"}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1 font-mono",children:"Leave empty to include only default claims (iss, sub, aud, exp, iat, jti)."})]}),a.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>{ne(null),te(""),Le(""),We(`{
693
693
 
694
694
  }`)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Reset"}),a.jsx(P,{onClick:Wi,disabled:ve,className:"rounded-none",children:ve?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Token"})]}),q&&a.jsxs("div",{className:"space-y-4 border border-dashed border-white/15 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs uppercase font-mono text-gray-400",children:"Generated Token"}),a.jsx("p",{className:"text-white font-mono text-sm break-all mt-1",children:q.token})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>$t(q.token),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(li,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"Type"}),a.jsx("p",{className:"text-white mt-1 capitalize",children:q.type.replace("_"," ")})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"Expires"}),a.jsx("p",{className:"text-white mt-1",children:Wa(q.expiresAt)})]}),q.url&&a.jsxs("div",{className:"col-span-1",children:[a.jsx("p",{className:"text-gray-400 uppercase tracking-wider",children:"URL"}),a.jsx("p",{className:"text-white mt-1 break-all",children:q.url})]})]}),q.metadata&&a.jsxs("div",{className:"border border-dashed border-white/10 p-3",children:[a.jsx("p",{className:"text-xs uppercase font-mono text-gray-400 mb-2",children:"Metadata"}),a.jsx("pre",{className:"text-[11px] text-gray-100 font-mono bg-black/40 p-3 overflow-x-auto",children:JSON.stringify(q.metadata,null,2)})]})]})]})]})})]})}function uV(){const{userId:e}=Lg(),t=Ls(),[n,s]=m.useState(null),[r,i]=m.useState([]),[o,l]=m.useState([]),[c,u]=m.useState([]),[h,d]=m.useState([]),[f,x]=m.useState(!0),[y,b]=m.useState("details"),[w,g]=m.useState(!1),[v,p]=m.useState(!1),[j,N]=m.useState(!1),[C,S]=m.useState(!1),[M,A]=m.useState(!1),[H,U]=m.useState("random"),[O,B]=m.useState(!1),[E,R]=m.useState(!1),[T,_]=m.useState(!1),[k,D]=m.useState(""),[$,G]=m.useState(),[z,V]=m.useState(!1),[X,Z]=m.useState(""),[ee,J]=m.useState([]),[K,se]=m.useState(!1),[we,re]=m.useState({}),fe=m.useRef({}),xe=m.useCallback(async()=>{try{const le=await(await fetch("/api/admin/status")).json();V(le.enabled)}catch{V(!1)}},[]),Ce=m.useCallback(async Y=>{try{const le=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:Y})});if(le.ok){const he=await le.json();if(he.success&&he.location)return he.location}return null}catch{return null}},[]),Me=m.useCallback(async Y=>{const le=Y.filter(ke=>!fe.current[ke.id]);if(le.length===0)return;const he=await Promise.all(le.map(async ke=>{const We=await Ce(ke.ipAddress);return We?{sessionId:ke.id,location:We}:null})),pe={};he.forEach(ke=>{ke&&(pe[ke.sessionId]=ke.location)}),Object.keys(pe).length>0&&(fe.current={...fe.current,...pe},re(fe.current))},[Ce]),Oe=Y=>{if(!Y)return"🌍";const le=Y.toUpperCase().split("").map(he=>127397+he.charCodeAt(0));return String.fromCodePoint(...le)},He=Y=>Y?Y.replace(/[_-]/g," ").replace(/\b\w/g,le=>le.toUpperCase()):"Unknown Provider",Ie=Y=>{if(!Y)return"Unknown";const le=new Date(Y);return Number.isNaN(le.getTime())?"Unknown":le.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},Ve=m.useCallback(async()=>{try{const Y=await fetch(`/api/users/${e}`);if(Y.ok){const le=await Y.json();s(le.user)}else L.error("Failed to fetch user details"),t("/users")}catch{L.error("Failed to fetch user details"),t("/users")}finally{x(!1)}},[e,t]),wt=m.useCallback(async()=>{try{const[Y,le,he]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(Y.ok){const pe=await Y.json();i(pe.memberships||[])}if(le.ok){const pe=await le.json();l(pe.memberships||[])}if(he.ok){const ke=(await he.json()).sessions||[];u(ke),Me(ke)}}catch{}},[e,Me]),vt=m.useCallback(async()=>{try{const Y=await fetch(`/api/users/${e}/accounts`);if(Y.ok){const le=await Y.json();d(le.accounts||[])}}catch{}},[e]),qe=async()=>{var pe,ke;if(!n)return;const Y=(pe=document.getElementById("edit-name"))==null?void 0:pe.value,le=(ke=document.getElementById("edit-email"))==null?void 0:ke.value;if(!Y||!le){L.error("Please fill in all fields");return}const he=L.loading("Updating user...");try{const q=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Y,email:le,role:X||null})})).json();q.success?(s({...n,name:Y,email:le,role:X||void 0}),g(!1),Z(""),L.success("User updated successfully!",{id:he})):L.error(`Error updating user: ${q.error||"Unknown error"}`,{id:he})}catch{L.error("Error updating user",{id:he})}},Ge=async()=>{if(!n)return;const Y=L.loading("Deleting user...");try{const he=await(await fetch(`/api/users/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();he.success?(L.success("User deleted successfully!",{id:Y}),t("/users")):L.error(`Error deleting user: ${he.error||"Unknown error"}`,{id:Y})}catch{L.error("Error deleting user",{id:Y})}},Et=async()=>{if(!n)return;if(!z){L.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use ban functionality.");return}const Y=L.loading("Banning user...");try{const le=await fetch("/api/admin/ban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,banReason:k||"No reason provided",banExpiresIn:$})}),he=await le.json();le.ok?(L.success("User banned successfully!",{id:Y}),p(!1),D(""),G(void 0),Ve()):le.status===403?L.error("You do not have permission to ban users. Admin role required.",{id:Y}):he.adminPluginEnabled&&he.instructions?L.error(`${he.error}`,{id:Y,duration:6e3,description:`Use: ${he.instructions.example}`}):L.error(`Error banning user: ${he.error||he.message||"Unknown error"}`,{id:Y})}catch{L.error("Error banning user",{id:Y})}},jt=async()=>{if(!n)return;if(!z){L.error("Admin plugin is not enabled. Please enable the admin plugin in your Better Auth configuration to use unban functionality.");return}const Y=L.loading("Unbanning user...");try{const le=await fetch("/api/admin/unban-user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})}),he=await le.json();le.ok?(L.success("User unbanned successfully!",{id:Y}),N(!1),Ve()):le.status===403?L.error("You do not have permission to unban users. Admin role required.",{id:Y}):he.adminPluginEnabled&&he.instructions?L.error(`${he.error}`,{id:Y,duration:6e3,description:`Use: ${he.instructions.example}`}):L.error(`Error unbanning user: ${he.error||he.message||"Unknown error"}`,{id:Y})}catch{L.error("Error unbanning user",{id:Y})}},it=async Y=>{const le=L.loading("Removing user from organization...");try{const pe=await(await fetch(`/api/organizations/members/${Y}`,{method:"DELETE"})).json();pe.success?(i(ke=>ke.filter(We=>We.id!==Y)),wt(),L.success("User removed from organization!",{id:le})):L.error(`Error removing user: ${pe.error||"Unknown error"}`,{id:le})}catch{L.error("Error removing user from organization",{id:le})}},Ut=async Y=>{const le=L.loading("Removing user from team...");try{const pe=await(await fetch(`/api/teams/members/${Y}`,{method:"DELETE"})).json();pe.success?(l(ke=>ke.filter(We=>We.id!==Y)),wt(),L.success("User removed from team!",{id:le})):L.error(`Error removing user: ${pe.error||"Unknown error"}`,{id:le})}catch{L.error("Error removing user from team",{id:le})}},Bt=async Y=>{const le=L.loading("Deleting session...");try{const pe=await(await fetch(`/api/sessions/${Y}`,{method:"DELETE"})).json();pe.success?(u(ke=>ke.filter(We=>We.id!==Y)),L.success("Session deleted successfully!",{id:le})):L.error(`Error deleting session: ${pe.error||"Unknown error"}`,{id:le})}catch{L.error("Error deleting session",{id:le})}},te=async Y=>{if(!e)return;const le=L.loading("Unlinking account...");try{const he=await fetch(`/api/users/${e}/accounts/${Y}`,{method:"DELETE"}),pe=await he.json();he.ok&&pe.success?(d(ke=>ke.filter(We=>We.id!==Y)),await vt(),L.success("Account unlinked successfully",{id:le})):L.error(pe.error||"Failed to unlink account",{id:le})}catch{L.error("Failed to unlink account",{id:le})}};m.useEffect(()=>{e&&(Ve(),wt(),vt(),xe())},[e,xe,Ve,wt,vt]);const be=async(Y=3)=>{if(e){J([]),se(!0),J([{id:"start",type:"info",message:`Starting session seeding process for ${Y} sessions...`,timestamp:new Date}]);try{const he=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:Y})})).json();if(he.success){const pe=he.results.map((We,q)=>We.success?{id:`session-${q}`,type:"progress",message:`Creating session ${q+1}: ${We.session.token.substring(0,20)}... from ${We.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${q}`,type:"error",message:`Failed to create session ${q+1}: ${We.error}`,timestamp:new Date});J(We=>[...We,...pe]);const ke=he.results.filter(We=>We.success).length;J(We=>[...We,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${ke}/${Y} sessions successfully`,timestamp:new Date}]),wt()}else J(pe=>[...pe,{id:"error",type:"error",message:`❌ Session seeding failed: ${he.error||"Unknown error"}`,timestamp:new Date}])}catch(le){J(he=>[...he,{id:"error",type:"error",message:`❌ Network error: ${le}`,timestamp:new Date}])}finally{se(!1)}}},Le=async(Y=3,le="random")=>{if(e){J([]),se(!0),J([{id:"start",type:"info",message:`Starting account seeding process for ${Y} accounts...`,timestamp:new Date}]);try{const pe=await(await fetch(`/api/users/${e}/seed-accounts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:Y,providerId:le})})).json();if(pe.success){const ke=pe.results.map((q,ne)=>{var ve;return q.success?{id:`account-${ne}`,type:"progress",message:`Creating account ${ne+1}: ${q.account.providerId||q.account.provider} (${((ve=q.account.accountId)==null?void 0:ve.substring(0,20))||q.account.id.substring(0,20)}...)`,timestamp:new Date,status:"completed"}:{id:`account-${ne}`,type:"error",message:`Failed to create account ${ne+1}: ${q.error}`,timestamp:new Date}});J(q=>[...q,...ke]);const We=pe.results.filter(q=>q.success).length;J(q=>[...q,{id:"complete",type:"success",message:`✅ Account seeding completed! Created ${We}/${Y} accounts successfully`,timestamp:new Date}]),vt()}else J(ke=>[...ke,{id:"error",type:"error",message:`❌ Account seeding failed: ${pe.error||"Unknown error"}`,timestamp:new Date}])}catch(he){J(pe=>[...pe,{id:"error",type:"error",message:`❌ Network error: ${he}`,timestamp:new Date}])}finally{se(!1)}}};return f?a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):n?a.jsxs("div",{className:"space-y-6 p-6 bg-black w-full",children:[a.jsxs("div",{className:"w-full flex flex-col",children:[a.jsx("span",{className:"mb-4 ml-0 flex justify-start items-start text-left border-none text-white",children:a.jsxs("span",{className:"font-light",children:[a.jsxs("span",{onClick:()=>t("/users"),className:"uppercase cursor-pointer text-white/80 font-mono text-sm",children:["users /"," "]}),a.jsx("span",{className:"text-white font-mono text-sm",children:n.id})]})}),a.jsx("div",{className:"mb-8 mt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center space-x-4",children:[a.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:n.image?a.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):a.jsx(Fl,{className:"w-8 h-8 text-white"})}),a.jsxs("div",{children:[a.jsxs("h1",{className:"text-3xl font-light text-white inline-flex items-center",children:[n.name,a.jsx(_n,{id:n.id,variant:"subscript"}),n.role&&a.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&&a.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-red-500/30 bg-red-500/10 text-red-400/80 rounded-none",children:"Banned"})]}),a.jsx("p",{className:"text-gray-400 font-mono text-sm",children:n.email})]})]}),a.jsx("div",{className:"flex items-center space-x-2",children:a.jsxs("div",{className:"relative",children:[a.jsx(P,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Y=>{Y.stopPropagation(),_(!T)},children:a.jsx(_4,{className:"w-4 h-4"})}),T&&a.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:Y=>Y.stopPropagation(),children:[a.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:Y=>{Y.stopPropagation(),_(!1),g(!0),Z(n.role||"")},children:[a.jsx(Di,{className:"w-4 h-4"}),a.jsx("span",{children:"Edit User"})]}),a.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:Y=>{Y.stopPropagation(),_(!1),B(!0)},children:[a.jsx(hn,{className:"w-4 h-4"}),a.jsx("span",{children:"Update Password"})]}),z&&(n.banned?a.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:Y=>{Y.stopPropagation(),_(!1),N(!0)},children:[a.jsx(ex,{className:"w-4 h-4"}),a.jsx("span",{children:"Unban User"})]}):a.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:Y=>{Y.stopPropagation(),_(!1),p(!0)},children:[a.jsx(ex,{className:"w-4 h-4"}),a.jsx("span",{children:"Ban User"})]})),a.jsx("div",{className:"border-t border-white/10 my-1"}),a.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:Y=>{Y.stopPropagation(),_(!1),R(!0)},children:[a.jsx(yf,{className:"w-4 h-4"}),a.jsx("span",{children:"Delete User"})]})]})]})})]})}),a.jsxs("div",{className:"border border-dashed border-white/20 rounded-none",children:[a.jsx("div",{className:"border-b border-dashed border-white/10",children:a.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:Fl},{id:"organizations",name:"Organizations",icon:Fn,count:r.length},{id:"teams",name:"Teams",icon:pt,count:o.length},{id:"accounts",name:"Accounts",icon:ci,count:h.length},{id:"sessions",name:"Sessions",icon:b0,count:c.length}].map(Y=>a.jsxs("button",{onClick:()=>b(Y.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${y===Y.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[a.jsx(Y.icon,{className:"w-4 h-4 text-white/90"}),a.jsxs("span",{className:"inline-flex items-start",children:[a.jsx("span",{className:"",children:Y.name}),Y.count!==void 0&&a.jsx("sup",{className:"text-xs text-gray-500 ml-1 inline-flex items-baseline",children:a.jsx(_s,{value:Y.count,className:"text-white/80 font-mono text-xs",prefix:a.jsx("span",{className:"mr-0.5 text-gray-500",children:"["}),suffix:a.jsx("span",{className:"ml-0.5 text-gray-500",children:"]"}),format:{notation:"standard",maximumFractionDigits:0}})})]})]},Y.id))})}),a.jsxs("div",{className:"p-6",children:[y==="details"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[a.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"BASIC INFORMATION"}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx(Fl,{className:"w-4 h-4 text-gray-400 mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Name"}),a.jsx("div",{className:"text-white font-sans text-sm",children:n.name})]})]}),a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx(Na,{className:"w-4 h-4 text-gray-400 mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Email"}),a.jsx("div",{className:"text-white font-mono text-sm",children:n.email})]})]}),n.username&&a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx(TB,{className:"w-4 h-4 text-gray-400 mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Username"}),a.jsx("div",{className:"text-white font-mono text-sm",children:n.username})]})]}),n.phoneNumber&&a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx(MB,{className:"w-4 h-4 text-gray-400 mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Phone"}),a.jsx("div",{className:"text-white font-mono text-sm",children:"+251 91 234 5678"})]})]}),a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx(Ss,{className:"w-4 h-4 text-gray-400 mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500 mb-1",children:"Member Since"}),a.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"})})]})]})]})]}),a.jsxs("div",{className:"overflow-x-hidden bg-white/[3%] border border-white/10 p-6 rounded-none",children:[a.jsx("h3",{className:"text-sm uppercase font-mono text-gray-400 mb-4 tracking-wider",children:"SECURITY"}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed my-4"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/5 rounded-none",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Na,{className:"w-4 h-4 text-gray-400"}),a.jsx("div",{children:a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Email Verification"})})]}),a.jsx("div",{className:`px-2 rounded-none 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"})]}),a.jsxs("div",{className:"flex items-center justify-between p-3 bg-black/30 border border-white/5 rounded-none",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Oa,{className:"w-4 h-4 text-gray-400"}),a.jsx("div",{children:a.jsx("div",{className:"text-xs uppercase font-mono text-gray-500",children:"Two-Factor Authentication"})})]}),a.jsx("div",{className:`px-2 rounded-none 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"&&a.jsx("div",{className:"space-y-4",children:r.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Fn,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),a.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):a.jsx("div",{className:"grid gap-4",children:r.map(Y=>a.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[a.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:Y.organization.image?a.jsx("img",{src:Y.organization.image,alt:Y.organization.name,className:"w-12 h-12 object-cover"}):a.jsx(Fn,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[Y.organization.name,a.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[a.jsx("span",{className:"mr-1",children:"["}),a.jsx("span",{className:"text-white/80 font-mono text-xs",children:Y.organization.slug}),a.jsx("span",{className:"ml-1",children:"]"})]})]}),a.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1",children:["in ",Y.organization.slug]})]})]}),a.jsx("div",{className:"flex flex-col items-end space-y-2",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),a.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(Y.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(Y.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),a.jsx("div",{className:"flex items-center justify-end",children:a.jsxs(P,{variant:"outline",size:"sm",onClick:()=>it(Y.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[a.jsx(Jm,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},Y.id))})}),y==="teams"&&a.jsx("div",{className:"space-y-4",children:o.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(pt,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),a.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):a.jsx("div",{className:"grid gap-4",children:o.map(Y=>a.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[a.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:a.jsx(pt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[Y.team.name,a.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[a.jsx("span",{className:"mr-1",children:"["}),a.jsx("span",{className:"text-white/80 font-mono text-xs",children:Y.team.organizationSlug||Y.team.organizationName}),a.jsx("span",{className:"ml-1",children:"]"})]})]}),a.jsxs("p",{className:"text-gray-400 text-sm font-sans mt-1",children:["in"," ",Y.team.organizationSlug||Y.team.organizationName]})]})]}),a.jsx("div",{className:"flex flex-col items-end space-y-2",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Joined:"," "]}),a.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(Y.joinedAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(Y.joinedAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),a.jsx("div",{className:"flex items-center justify-end",children:a.jsxs(P,{variant:"outline",size:"sm",onClick:()=>Ut(Y.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[a.jsx(Jm,{className:"w-4 h-4 mr-1"}),"Remove"]})})]},Y.id))})}),y==="accounts"&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-medium text-white",children:"Linked Accounts"}),a.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user OAuth account connections"})]}),a.jsxs(P,{variant:"outline",onClick:()=>{J([]),se(!1),A(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(ci,{className:"w-4 h-4 mr-2"}),"Seed Accounts"]})]}),h.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(ci,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Linked Accounts"}),a.jsx("p",{className:"text-gray-400",children:"This user has not connected any accounts yet."})]}):a.jsx("div",{className:"grid gap-4",children:h.map(Y=>a.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[a.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:n5(Y.providerId)}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:[He(Y.providerId),a.jsx(_n,{id:Y.accountId,variant:"subscript",nonSliced:!!(Y.email||n.email)})]}),a.jsx("p",{className:"text-gray-400 tracking-tight uppercase text-xs font-mono mt-1",children:`ID: ${Y.id}`})]})]}),a.jsx("div",{className:"flex flex-col items-end space-y-2 text-right",children:a.jsxs("div",{className:"flex items-center space-x-2 text-xs font-mono text-gray-400",children:[a.jsx("span",{children:"Linked:"}),a.jsx("span",{className:"text-white",children:Ie(Y.createdAt||Y.updatedAt)})]})})]}),a.jsx("div",{className:"flex items-center justify-end",children:a.jsxs(P,{variant:"outline",size:"sm",onClick:()=>te(Y.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[a.jsx(Jm,{className:"w-4 h-4 mr-1"}),"Unlink"]})})]},Y.id))})]}),y==="sessions"&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-medium text-white",children:"Sessions"}),a.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user authentication sessions"})]}),a.jsxs(P,{variant:"outline",onClick:()=>{J([]),se(!1),S(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(b0,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),a.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):a.jsx("div",{className:"grid gap-4",children:c.map(Y=>{var le,he,pe,ke;return a.jsxs("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[a.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:a.jsx(pw,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h3",{className:"text-white font-light inline-flex items-start",children:["Session ",Y.id.substring(0,8),"...",a.jsxs("sup",{className:"text-xs text-gray-500 ml-2 mt-0.5",children:[a.jsx("span",{className:"mr-1",children:"["}),a.jsx("span",{className:"text-white/80 font-mono text-xs",children:Y.ipAddress}),a.jsx("span",{className:"ml-1",children:"]"})]})]}),a.jsxs("div",{className:"flex items-center space-x-2 mt-2",children:[a.jsx(EB,{className:"w-3.5 h-3.5 text-gray-400"}),a.jsxs("span",{className:"text-gray-400 uppercase font-mono text-xs",children:[((le=we[Y.id])==null?void 0:le.city)||"...",","," ",((he=we[Y.id])==null?void 0:he.country)||"..."]}),((pe=we[Y.id])==null?void 0:pe.countryCode)&&a.jsx("span",{className:"text-xs ml-1",children:Oe((ke=we[Y.id])==null?void 0:ke.countryCode)})]})]})]}),a.jsx("div",{className:"flex flex-col items-end space-y-2",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("span",{className:"text-gray-500 font-mono text-xs uppercase",children:["Expires:"," "]}),a.jsxs("span",{className:"text-white font-mono text-xs",children:[new Date(Y.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),","," ",new Date(Y.expiresAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})]})]})})]}),a.jsx("div",{className:"flex items-center justify-end",children:a.jsxs(P,{variant:"outline",size:"sm",onClick:()=>Bt(Y.id),className:"border border-dashed border-red-400/20 text-red-400 hover:bg-red-400/10 rounded-none",children:[a.jsx(ex,{className:"w-4 h-4 mr-1"}),"Revoke"]})})]},Y.id)})})]})]})]})]}),w&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>{g(!1),Z("")},className:"text-gray-400 hover:text-white rounded-none",children:"×"})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.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?a.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):a.jsx(Fl,{className:"w-8 h-8 text-white"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"text-white font-medium",children:n==null?void 0:n.name}),a.jsx("p",{className:"text-gray-400 text-sm",children:n==null?void 0:n.email})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Role"}),a.jsxs(ms,{className:"bg-black text-white",value:X,onValueChange:Z,children:[a.jsx(xs,{className:"w-full border border-dashed border-white/20 bg-black text-white rounded-none",children:a.jsx(Ar,{placeholder:"Select role"})}),a.jsxs(gs,{children:[a.jsx(Fe,{value:"",children:"None"}),a.jsx(Fe,{value:"admin",children:"Admin"}),a.jsx(Fe,{value:"user",children:"User"})]})]})]})]}),a.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>{g(!1),Z("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:qe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),v&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black border border-red-400/20 rounded-none p-6 w-full max-w-md",children:[a.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),a.jsxs("p",{className:"text-gray-400 mb-4",children:["Ban ",a.jsx("strong",{children:n.name})," from accessing the system."]}),a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"banReason",className:"text-white",children:"Ban Reason"}),a.jsx(Be,{id:"banReason",value:k,onChange:Y=>D(Y.target.value),placeholder:"Enter reason for ban (optional)",className:"bg-black border border-dashed border-white/20 text-white rounded-none"})]}),a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"banExpires",className:"text-white",children:"Ban Duration (seconds)"}),a.jsx(Be,{id:"banExpires",type:"number",value:$||"",onChange:Y=>G(Y.target.value?Number(Y.target.value):void 0),placeholder:"Leave empty for permanent ban",className:"bg-black border border-dashed border-white/20 text-white rounded-none"}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Examples: 3600 (1 hour), 86400 (1 day), 604800 (1 week)"})]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>{p(!1),D(""),G(void 0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:Et,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),j&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black border border-green-400/20 rounded-none p-6 w-full max-w-md",children:[a.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Unban User"}),a.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to unban ",a.jsx("strong",{children:n.name}),"? This will restore their access to the system."]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(P,{variant:"outline",onClick:()=>N(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:jt,className:"bg-green-400 text-white hover:bg-green-700 rounded-none",children:"Unban User"})]})]})}),E&&n&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>R(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n.image?a.jsx("img",{src:n.image,alt:n.name,className:"w-16 h-16 object-cover"}):a.jsx(Fl,{className:"w-8 h-8 text-white"})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-light",children:n.name}),a.jsx("div",{className:"text-sm text-gray-400",children:n.email})]})]}),a.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>R(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:Ge,className:"bg-red-500 hover:bg-red-600 text-white border border-red-500 rounded-none",children:"Delete"})]})]})}),O&&n&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-lg text-white font-light",children:"Update Password"}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>B(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"new-password",className:"text-sm text-gray-400 font-light",children:"New Password"}),a.jsx(Be,{id:"new-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),a.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[a.jsx(P,{variant:"outline",onClick:()=>B(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),a.jsx(P,{onClick:async()=>{var he;const Y=(he=document.getElementById("new-password"))==null?void 0:he.value;if(!Y){L.error("Please enter a password");return}const le=L.loading("Updating password...");try{const ke=await(await fetch(`/api/users/${e}/password`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:Y})})).json();ke.success?(B(!1),document.getElementById("new-password").value="",L.success("Password updated successfully!",{id:le})):L.error(`Error updating password: ${ke.error||"Unknown error"}`,{id:le})}catch{L.error("Error updating password",{id:le})}},className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),C&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[a.jsx("span",{className:"text-white/50 mr-2",children:"["}),a.jsx(pw,{className:"inline mr-2 w-3 h-3 text-white"}),a.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Sessions"}),a.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>S(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(_e,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),a.jsx(Be,{id:"session-count",type:"number",min:"1",max:"50",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),a.jsx(P,{onClick:()=>{var le;const Y=parseInt(((le=document.getElementById("session-count"))==null?void 0:le.value)||"3",10);be(Y)},disabled:K,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:K?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Oa,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})}),ee.length>0&&a.jsx("div",{className:"mt-6",children:a.jsx(Br,{title:"Session Seeding Terminal",lines:ee,isRunning:K,className:"w-full",defaultCollapsed:!0})})]}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),a.jsx("div",{className:"flex justify-end mt-6 pt-6",children:a.jsx(P,{variant:"outline",onClick:()=>S(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),M&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 overflow-hidden",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("h3",{className:"text-sm text-white flex items-center justify-center font-light uppercase",children:[a.jsx("span",{className:"text-white/50 mr-2",children:"["}),a.jsx(ci,{className:"inline mr-2 w-3 h-3 text-white"}),a.jsx("span",{className:"font-mono text-white/70 uppercase",children:"Seed Accounts"}),a.jsx("span",{className:"text-white/50 ml-2",children:"]"})]}),a.jsx(P,{variant:"ghost",size:"sm",onClick:()=>A(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(zt,{className:"w-4 h-4"})})]}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed -mt-4 mb-4"}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),a.jsx(Be,{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"})]}),a.jsxs("div",{children:[a.jsx(_e,{htmlFor:"account-provider",className:"text-sm text-gray-400 font-light",children:"Provider"}),a.jsxs(ms,{value:H,onValueChange:U,children:[a.jsx(xs,{className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:a.jsx(Ar,{placeholder:"Select provider"})}),a.jsxs(gs,{className:"bg-black border border-dashed border-white/20",children:[a.jsx(Fe,{value:"random",children:"Mix (Random)"}),a.jsx(Fe,{value:"github",children:"GitHub"}),a.jsx(Fe,{value:"google",children:"Google"}),a.jsx(Fe,{value:"discord",children:"Discord"}),a.jsx(Fe,{value:"facebook",children:"Facebook"}),a.jsx(Fe,{value:"twitter",children:"Twitter"}),a.jsx(Fe,{value:"linkedin",children:"LinkedIn"}),a.jsx(Fe,{value:"apple",children:"Apple"}),a.jsx(Fe,{value:"microsoft",children:"Microsoft"}),a.jsx(Fe,{value:"gitlab",children:"GitLab"}),a.jsx(Fe,{value:"bitbucket",children:"Bitbucket"}),a.jsx(Fe,{value:"spotify",children:"Spotify"}),a.jsx(Fe,{value:"twitch",children:"Twitch"}),a.jsx(Fe,{value:"reddit",children:"Reddit"}),a.jsx(Fe,{value:"slack",children:"Slack"}),a.jsx(Fe,{value:"notion",children:"Notion"}),a.jsx(Fe,{value:"tiktok",children:"TikTok"}),a.jsx(Fe,{value:"zoom",children:"Zoom"})]})]})]})]}),a.jsx(P,{onClick:()=>{var le;const Y=parseInt(((le=document.getElementById("account-count"))==null?void 0:le.value)||"3",10);Le(Y,H)},disabled:K,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:K?a.jsxs(a.Fragment,{children:[a.jsx(vs,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ci,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]}),ee.length>0&&a.jsx("div",{className:"mt-6",children:a.jsx(Br,{title:"Account Seeding Terminal",lines:ee,isRunning:K,className:"w-full",defaultCollapsed:!0})})]}),a.jsx("hr",{className:"border-white/10 -mx-10 border-dashed mt-10"}),a.jsx("div",{className:"flex justify-end mt-6 pt-6",children:a.jsx(P,{variant:"outline",onClick:()=>A(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function hV(){return a.jsx(cR,{children:a.jsxs(tE,{children:[a.jsx(t$,{children:a.jsxs(qk,{children:[a.jsx(Cn,{path:"/",element:a.jsx(QB,{})}),a.jsx(Cn,{path:"/users",element:a.jsx(t5,{})}),a.jsx(Cn,{path:"/users/:userId",element:a.jsx(uV,{})}),a.jsx(Cn,{path:"/organizations",element:a.jsx(e5,{})}),a.jsx(Cn,{path:"/organizations/:orgId",element:a.jsx(nV,{})}),a.jsx(Cn,{path:"/teams",element:a.jsx(rV,{})}),a.jsx(Cn,{path:"/teams/:teamId",element:a.jsx(Mw,{})}),a.jsx(Cn,{path:"/organizations/:orgId/teams/:teamId",element:a.jsx(Mw,{})}),a.jsx(Cn,{path:"/sessions",element:a.jsx(sV,{})}),a.jsx(Cn,{path:"/database",element:a.jsx(eV,{})}),a.jsx(Cn,{path:"/database/demo",element:a.jsx(lR,{})}),a.jsx(Cn,{path:"/tools",element:a.jsx(dV,{})}),a.jsx(Cn,{path:"/settings",element:a.jsx(aV,{})})]})}),a.jsx(AE,{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})]})})}tk.createRoot(document.getElementById("root")).render(a.jsx(Q.StrictMode,{children:a.jsx(hV,{})}));
package/public/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Better Auth Studio</title>
8
- <script type="module" crossorigin src="/assets/main-tXNuCij7.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-CkD7P57H.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/main-B0A1h6za.css">
10
10
  </head>
11
11
  <body>